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