Changeset 89ce401a in mainline
- Timestamp:
- 2010-04-08T10:20:29Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2480e19
- Parents:
- 5e598e0
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/include/ipc/dev_iface.h
r5e598e0 r89ce401a 32 32 #include <ipc/ipc.h> 33 33 #include <malloc.h> 34 #include <unistd.h> 34 35 35 36 #define DEV_IFACE_FIRST IPC_FIRST_USER_METHOD … … 88 89 static inline void clean_hw_resource_list(hw_resource_list_t *hw_res) 89 90 { 90 free(hw_res->resources); 91 hw_res->resources = 0; 91 if(NULL != hw_res->resources) { 92 free(hw_res->resources); 93 hw_res->resources = NULL; 94 } 92 95 hw_res->count = 0; 93 96 } -
uspace/srv/drivers/pciintel/pci.c
r5e598e0 r89ce401a 150 150 } 151 151 152 void create_pci_match_ids(device_t *dev) 153 { 154 pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data; 155 match_id_t *match_id = NULL; 156 match_id = create_match_id(); 157 if (NULL != match_id) { 158 asprintf(&match_id->id, "pci/ven=%04x,dev=%04x", dev_data->vendor_id, dev_data->device_id); 159 match_id->score = 90; 160 add_match_id(&dev->match_ids, match_id); 161 } 162 // TODO add more ids (with subsys ids, using class id etc.) 163 } 164 165 152 166 void pci_bus_scan(device_t *parent, int bus_num) 153 167 { … … 181 195 header_type = header_type & 0x7F; // clear the multifunction bit 182 196 183 // TODO initialize device - name, match ids, interfaces 184 // TODO register device 197 // TODO initialize device - interfaces, hw resources 198 199 create_pci_dev_name(dev); 200 printf(NAME ": adding new device name %s.\n", dev->name); 201 202 create_pci_match_ids(dev); 203 204 if (!child_device_register(dev, parent)) { 205 clean_match_ids(&dev->match_ids); 206 free((char *)dev->name); 207 dev->name = NULL; 208 continue; 209 } 185 210 186 211 if (header_type == PCI_HEADER_TYPE_BRIDGE || header_type == PCI_HEADER_TYPE_CARDBUS ) { … … 219 244 if (dev->parent_phone <= 0) { 220 245 printf(NAME ": pci_add_device failed to connect to the parent's driver.\n"); 221 free(bus_data);246 delete_pci_bus_data(bus_data); 222 247 return false; 223 248 } … … 227 252 if (!get_hw_resources(dev->parent_phone, &hw_resources)) { 228 253 printf(NAME ": pci_add_device failed to get hw resources for the device.\n"); 229 free(bus_data);254 delete_pci_bus_data(bus_data); 230 255 ipc_hangup(dev->parent_phone); 231 256 return false; … … 243 268 if (pio_enable(bus_data->conf_io_addr, 8, &bus_data->conf_addr_port)) { 244 269 printf(NAME ": failed to enable configuration ports.\n"); 245 free(bus_data);270 delete_pci_bus_data(bus_data); 246 271 ipc_hangup(dev->parent_phone); 247 272 clean_hw_resource_list(&hw_resources); … … 252 277 dev->driver_data = bus_data; 253 278 254 // TODO scan the bus 279 // enumerate child devices 280 printf(NAME ": scanning the bus\n"); 255 281 pci_bus_scan(dev, 0); 256 282 -
uspace/srv/drivers/pciintel/pci.h
r5e598e0 r89ce401a 74 74 } 75 75 76 static inline void create_pci_dev_name(device_t *dev) 77 { 78 pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data; 79 char *name = NULL; 80 asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev, dev_data->fn); 81 dev->name = name; 82 } 83 84 void create_pci_match_ids(device_t *dev); 85 76 86 uint8_t pci_conf_read_8(device_t *dev, int reg); 77 87 uint16_t pci_conf_read_16(device_t *dev, int reg);
Note:
See TracChangeset
for help on using the changeset viewer.