1 use alloc::sync::Arc; 2 use system_error::SystemError; 3 4 use self::{pt_device::TestDevice, pt_driver::TestDriver}; 5 6 use super::{ 7 dev_id::PciDeviceID, 8 device::pci_device_manager, 9 driver::{pci_driver_manager, PciDriver}, 10 }; 11 12 pub mod pt_device; 13 pub mod pt_driver; 14 15 static mut TEST_DRIVER: Option<Arc<TestDriver>> = None; 16 static mut TEST_DEVICE: Option<Arc<TestDevice>> = None; pt_init() -> Result<(), SystemError>17pub fn pt_init() -> Result<(), SystemError> { 18 let tdev = Arc::new(TestDevice::new()); 19 let mut drv = TestDriver::new(); 20 drv.add_dynid(PciDeviceID::dummpy())?; 21 let tdrv = Arc::new(drv); 22 23 let _ = pci_device_manager().device_add(tdev.clone()); 24 let _ = pci_driver_manager().register(tdrv.clone()); 25 unsafe { 26 TEST_DEVICE = Some(tdev); 27 TEST_DRIVER = Some(tdrv); 28 } 29 Ok(()) 30 } 31