1 /* 2 * Copyright 2022, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "X86PCIController.h" 8 9 10 device_manager_info* gDeviceManager; 11 12 13 pci_controller_module_info gPciControllerDriver = { 14 .info = { 15 .info = { 16 .name = PCI_X86_DRIVER_MODULE_NAME, 17 }, 18 .supports_device = X86PCIController::SupportsDevice, 19 .register_device = X86PCIController::RegisterDevice, 20 .init_driver = [](device_node* node, void** driverCookie) { 21 return X86PCIController::InitDriver(node, *(X86PCIController**)driverCookie); 22 }, 23 .uninit_driver = [](void* driverCookie) { 24 return static_cast<X86PCIController*>(driverCookie)->UninitDriver(); 25 }, 26 }, 27 .read_pci_config = [](void* cookie, 28 uint8 bus, uint8 device, uint8 function, 29 uint16 offset, uint8 size, uint32* value) { 30 return static_cast<X86PCIController*>(cookie) 31 ->ReadConfig(bus, device, function, offset, size, *value); 32 }, 33 .write_pci_config = [](void* cookie, 34 uint8 bus, uint8 device, uint8 function, 35 uint16 offset, uint8 size, uint32 value) { 36 return static_cast<X86PCIController*>(cookie) 37 ->WriteConfig(bus, device, function, offset, size, value); 38 }, 39 .get_max_bus_devices = [](void* cookie, int32* count) { 40 return static_cast<X86PCIController*>(cookie)->GetMaxBusDevices(*count); 41 }, 42 .read_pci_irq = [](void* cookie, 43 uint8 bus, uint8 device, uint8 function, 44 uint8 pin, uint8 *irq) { 45 return static_cast<X86PCIController*>(cookie)->ReadIrq(bus, device, function, pin, *irq); 46 }, 47 .write_pci_irq = [](void* cookie, 48 uint8 bus, uint8 device, uint8 function, 49 uint8 pin, uint8 irq) { 50 return static_cast<X86PCIController*>(cookie)->WriteIrq(bus, device, function, pin, irq); 51 }, 52 .get_range = [](void *cookie, uint32 index, pci_resource_range* range) { 53 return static_cast<X86PCIController*>(cookie)->GetRange(index, range); 54 }, 55 .finalize = [](void *cookie) { 56 return static_cast<X86PCIController*>(cookie)->Finalize(); 57 } 58 }; 59 60 61 _EXPORT module_dependency module_dependencies[] = { 62 { B_DEVICE_MANAGER_MODULE_NAME, (module_info**)&gDeviceManager }, 63 {} 64 }; 65 66 _EXPORT module_info *modules[] = { 67 (module_info *)&gPciControllerDriver, 68 NULL 69 }; 70