To avoid circular dependencies and Rust lifetime/drop-check issues between fake::Kernel and fake::SyscallDriver, the design uses a DriverShareRef pattern.
Instead of drivers holding a direct reference to the fake::Kernel, they receive a DriverShareRef. This handle provides access to ShareData (which contains common data like the upcall queue) without requiring lifetime parameters. This allows the unit test case to own both the kernel and the drivers directly.
DriverShareRef is provided to drivers via a registration method on the SyscallDriver trait.
struct DriverShareRef {
driver_num: u32,
share_data: Rc<ShareData>,
}
trait SyscallDriver {
/* ... */
fn register(&self, share_ref: DriverShareRef);
}