1/* Config Manager 2 * provides access to device configurations 3 * 4 * Copyright 2002-2004, Marcus Overhagen, marcus@overhagen.de. 5 * Distributed under the terms of the MIT License. 6 */ 7 8 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> 16 17 18static pci_module_info *gPCI = NULL; 19 20#define B_CONFIG_MANAGER_FOR_BUS_MODULE_NAME "bus_managers/config_manager/bus/v1" 21 22#define FUNCTION(x, y...) dprintf("%s" x, __FUNCTION__, y) 23#define TRACE(x) dprintf x 24 25 26// Driver module API 27 28 29static status_t 30driver_get_next_device_info(bus_type bus, uint64 *cookie, struct device_info *info, uint32 size) 31{ 32 FUNCTION("(bus = %d, cookie = %" B_PRId64 ")\n", bus, *cookie); 33 return B_ENTRY_NOT_FOUND; 34} 35 36 37static status_t 38driver_get_device_info_for(uint64 id, struct device_info *info, uint32 size) 39{ 40 FUNCTION("(id = %" B_PRId64 ")\n", id); 41 return B_ENTRY_NOT_FOUND; 42} 43 44 45static status_t 46driver_get_size_of_current_configuration_for(uint64 id) 47{ 48 FUNCTION("(id = %" B_PRId64 ")\n", id); 49 return B_ENTRY_NOT_FOUND; 50} 51 52 53static status_t 54driver_get_current_configuration_for(uint64 id, struct device_configuration *current, uint32 size) 55{ 56 FUNCTION("(id = %" B_PRId64 ", current = %p, size = %" B_PRIu32 ")\n", id, 57 current, size); 58 return B_ENTRY_NOT_FOUND; 59} 60 61 62static status_t 63driver_get_size_of_possible_configurations_for(uint64 id) 64{ 65 FUNCTION("(id = %" B_PRId64 ")\n", id); 66 return B_ENTRY_NOT_FOUND; 67} 68 69 70static status_t 71driver_get_possible_configurations_for(uint64 id, struct possible_device_configurations *possible, uint32 size) 72{ 73 FUNCTION("(id = %" B_PRId64 ", possible = %p, size = %" B_PRIu32 ")\n", id, 74 possible, size); 75 return B_ENTRY_NOT_FOUND; 76} 77 78 79static status_t 80driver_count_resource_descriptors_of_type(const struct device_configuration *config, resource_type type) 81{ 82 FUNCTION("(config = %p, type = %d)\n", config, type); 83 return B_ENTRY_NOT_FOUND; 84} 85 86 87static status_t 88driver_get_nth_resource_descriptor_of_type(const struct device_configuration *config, uint32 num, 89 resource_type type, resource_descriptor *descr, uint32 size) 90{ 91 FUNCTION("(config = %p, num = %" B_PRId32 ")\n", config, num); 92 return B_ENTRY_NOT_FOUND; 93} 94 95 96static int32 97driver_std_ops(int32 op, ...) 98{ 99 switch (op) { 100 case B_MODULE_INIT: 101 TRACE(("config_manager: driver module: init\n")); 102 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; 108 } 109 break; 110 case B_MODULE_UNINIT: 111 TRACE(("config_manager: driver module: uninit\n")); 112 break; 113 default: 114 return EINVAL; 115 } 116 return B_OK; 117} 118 119 120// #pragma mark - 121// Bus module API 122 123 124static int32 125bus_std_ops(int32 op, ...) 126{ 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; 136 } 137 return B_OK; 138} 139 140 141struct config_manager_for_driver_module_info gDriverModuleInfo = { 142 { 143 B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME, 144 B_KEEP_LOADED, 145 driver_std_ops 146 }, 147 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, 154 155 &driver_count_resource_descriptors_of_type, 156 &driver_get_nth_resource_descriptor_of_type, 157}; 158 159struct module_info gBusModuleInfo = { 160 //{ 161 B_CONFIG_MANAGER_FOR_BUS_MODULE_NAME, 162 B_KEEP_LOADED, 163 bus_std_ops 164 //}, 165 166 // ToDo: find out what's in here! 167}; 168 169module_info *modules[] = { 170 (module_info *)&gDriverModuleInfo, 171 (module_info *)&gBusModuleInfo, 172 NULL 173}; 174