BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / config_manager / config_manager.c
blobccb7a66261e03cd4b78e29a92f819a0bdaebe415
1 /* Config Manager
2 * provides access to device configurations
4 * Copyright 2002-2004, Marcus Overhagen, marcus@overhagen.de.
5 * Distributed under the terms of the MIT License.
6 */
9 #include <config_manager.h>
10 #include <PCI.h>
11 #include <ISA.h>
12 #include <bus_manager.h>
13 #include <string.h>
14 #include <heap.h>
15 #include <KernelExport.h>
18 static pci_module_info *gPCI = NULL;
20 #define B_CONFIG_MANAGER_FOR_BUS_MODULE_NAME "bus_managers/config_manager/bus/v1"
22 #define FUNCTION(x, y...) dprintf("%s" x, __FUNCTION__, y)
23 #define TRACE(x) dprintf x
26 // Driver module API
29 static status_t
30 driver_get_next_device_info(bus_type bus, uint64 *cookie, struct device_info *info, uint32 size)
32 FUNCTION("(bus = %d, cookie = %" B_PRId64 ")\n", bus, *cookie);
33 return B_ENTRY_NOT_FOUND;
37 static status_t
38 driver_get_device_info_for(uint64 id, struct device_info *info, uint32 size)
40 FUNCTION("(id = %" B_PRId64 ")\n", id);
41 return B_ENTRY_NOT_FOUND;
45 static status_t
46 driver_get_size_of_current_configuration_for(uint64 id)
48 FUNCTION("(id = %" B_PRId64 ")\n", id);
49 return B_ENTRY_NOT_FOUND;
53 static status_t
54 driver_get_current_configuration_for(uint64 id, struct device_configuration *current, uint32 size)
56 FUNCTION("(id = %" B_PRId64 ", current = %p, size = %" B_PRIu32 ")\n", id,
57 current, size);
58 return B_ENTRY_NOT_FOUND;
62 static status_t
63 driver_get_size_of_possible_configurations_for(uint64 id)
65 FUNCTION("(id = %" B_PRId64 ")\n", id);
66 return B_ENTRY_NOT_FOUND;
70 static status_t
71 driver_get_possible_configurations_for(uint64 id, struct possible_device_configurations *possible, uint32 size)
73 FUNCTION("(id = %" B_PRId64 ", possible = %p, size = %" B_PRIu32 ")\n", id,
74 possible, size);
75 return B_ENTRY_NOT_FOUND;
79 static status_t
80 driver_count_resource_descriptors_of_type(const struct device_configuration *config, resource_type type)
82 FUNCTION("(config = %p, type = %d)\n", config, type);
83 return B_ENTRY_NOT_FOUND;
87 static status_t
88 driver_get_nth_resource_descriptor_of_type(const struct device_configuration *config, uint32 num,
89 resource_type type, resource_descriptor *descr, uint32 size)
91 FUNCTION("(config = %p, num = %" B_PRId32 ")\n", config, num);
92 return B_ENTRY_NOT_FOUND;
96 static int32
97 driver_std_ops(int32 op, ...)
99 switch (op) {
100 case B_MODULE_INIT:
101 TRACE(("config_manager: driver module: init\n"));
103 // ToDo: should not do this! Instead, iterate through all busses/config_manager/
104 // modules and get them
105 if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI) != 0) {
106 TRACE(("config_manager: failed to load PCI module\n"));
107 return -1;
109 break;
110 case B_MODULE_UNINIT:
111 TRACE(("config_manager: driver module: uninit\n"));
112 break;
113 default:
114 return EINVAL;
116 return B_OK;
120 // #pragma mark -
121 // Bus module API
124 static int32
125 bus_std_ops(int32 op, ...)
127 switch(op) {
128 case B_MODULE_INIT:
129 TRACE(("config_manager: bus module: init\n"));
130 break;
131 case B_MODULE_UNINIT:
132 TRACE(("config_manager: bus module: uninit\n"));
133 break;
134 default:
135 return EINVAL;
137 return B_OK;
141 struct config_manager_for_driver_module_info gDriverModuleInfo = {
143 B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME,
144 B_KEEP_LOADED,
145 driver_std_ops
148 &driver_get_next_device_info,
149 &driver_get_device_info_for,
150 &driver_get_size_of_current_configuration_for,
151 &driver_get_current_configuration_for,
152 &driver_get_size_of_possible_configurations_for,
153 &driver_get_possible_configurations_for,
155 &driver_count_resource_descriptors_of_type,
156 &driver_get_nth_resource_descriptor_of_type,
159 struct module_info gBusModuleInfo = {
161 B_CONFIG_MANAGER_FOR_BUS_MODULE_NAME,
162 B_KEEP_LOADED,
163 bus_std_ops
164 //},
166 // ToDo: find out what's in here!
169 module_info *modules[] = {
170 (module_info *)&gDriverModuleInfo,
171 (module_info *)&gBusModuleInfo,
172 NULL