xref: /haiku/src/add-ons/kernel/bus_managers/pci/pci_module.cpp (revision 52f7c9389475e19fc21487b38064b4390eeb6fea)
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 	&pci_update_interrupt_line,
71 	&pci_find_extended_capability,
72 	&pci_get_powerstate,
73 	&pci_set_powerstate
74 };
75 
76 module_dependency module_dependencies[] = {
77 	{B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&gDeviceManager},
78 	{}
79 };
80 
81 driver_module_info gPCILegacyDriverModule = {
82 	{
83 		PCI_LEGACY_DRIVER_MODULE_NAME,
84 		0,
85 		NULL,
86 	},
87 	NULL
88 };
89 
90 module_info *modules[] = {
91 	(module_info *)&sOldPCIModule,
92 	(module_info *)&gPCIRootModule,
93 	(module_info *)&gPCIDeviceModule,
94 	(module_info *)&gPCILegacyDriverModule,
95 #if defined(__i386__) || defined(__x86_64__)
96 	// add platforms when they provide an arch specific module
97 	(module_info *)&gPCIArchModule,
98 #endif
99 	NULL
100 };
101