xref: /haiku/src/add-ons/kernel/bus_managers/pci/pci_module.cpp (revision 97901ec593ec4dd50ac115c1c35a6d72f6e489a5)
1 /*
2  * Copyright 2005-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Copyright 2003, Marcus Overhagen. All rights reserved.
4  *
5  * Distributed under the terms of the MIT License.
6  */
7 
8 
9 #include <PCI.h>
10 
11 #include "pci_private.h"
12 #include "pci_info.h"
13 #include "pci.h"
14 
15 
16 device_manager_info *gDeviceManager;
17 extern struct pci_arch_module gPCIArchModule;
18 
19 static int32
20 pci_old_module_std_ops(int32 op, ...)
21 {
22 	switch (op) {
23 		case B_MODULE_INIT:
24 		{
25 			status_t status;
26 
27 			TRACE(("PCI: pci_module_init\n"));
28 
29 			status = pci_init();
30 			if (status < B_OK)
31 				return status;
32 
33 			pci_print_info();
34 
35 			return B_OK;
36 		}
37 
38 		case B_MODULE_UNINIT:
39 			TRACE(("PCI: pci_module_uninit\n"));
40 			pci_uninit();
41 			return B_OK;
42 	}
43 
44 	return B_BAD_VALUE;
45 }
46 
47 
48 static struct pci_module_info sOldPCIModule = {
49 	{
50 		{
51 			B_PCI_MODULE_NAME,
52 			B_KEEP_LOADED,
53 			pci_old_module_std_ops
54 		},
55 		NULL
56 	},
57 	&pci_read_io_8,
58 	&pci_write_io_8,
59 	&pci_read_io_16,
60 	&pci_write_io_16,
61 	&pci_read_io_32,
62 	&pci_write_io_32,
63 	&pci_get_nth_pci_info,
64 	&pci_read_config,
65 	&pci_write_config,
66 	&pci_ram_address,
67 	&pci_find_capability,
68 	&pci_reserve_device,
69 	&pci_unreserve_device
70 };
71 
72 module_dependency module_dependencies[] = {
73 	{B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&gDeviceManager},
74 	{}
75 };
76 
77 driver_module_info gPCILegacyDriverModule = {
78 	{
79 		PCI_LEGACY_DRIVER_MODULE_NAME,
80 		0,
81 		NULL,
82 	},
83 	NULL
84 };
85 
86 module_info *modules[] = {
87 	(module_info *)&sOldPCIModule,
88 	(module_info *)&gPCIRootModule,
89 	(module_info *)&gPCIDeviceModule,
90 	(module_info *)&gPCILegacyDriverModule,
91 #ifdef __INTEL__
92 	// add platforms when they provide an arch specific module
93 	(module_info *)&gPCIArchModule,
94 #endif
95 	NULL
96 };
97