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