Changes in uspace/drv/nic/ne2k/ne2k.c [9571230:e86b8f0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/ne2k/ne2k.c
r9571230 re86b8f0 64 64 #define NE2K(device) ((ne2k_t *) nic_get_specific(DRIVER_DATA(device))) 65 65 66 static irq_pio_range_t ne2k_ranges_prototype[] = {67 {68 .base = 0,69 .size = NE2K_IO_SIZE,70 }71 };72 73 66 /** NE2000 kernel interrupt command sequence. 74 67 * … … 129 122 130 123 if (ne2k->code.cmdcount == 0) { 131 irq_pio_range_t *ne2k_ranges; 132 irq_cmd_t *ne2k_cmds; 133 134 ne2k_ranges = malloc(sizeof(ne2k_ranges_prototype)); 135 if (!ne2k_ranges) 136 return ENOMEM; 137 memcpy(ne2k_ranges, ne2k_ranges_prototype, 138 sizeof(ne2k_ranges_prototype)); 139 ne2k_ranges[0].base = (uintptr_t) ne2k->base_port; 140 141 ne2k_cmds = malloc(sizeof(ne2k_cmds_prototype)); 142 if (!ne2k_cmds) { 143 free(ne2k_ranges); 124 irq_cmd_t *ne2k_cmds = malloc(sizeof(ne2k_cmds_prototype)); 125 if (ne2k_cmds == NULL) { 144 126 return ENOMEM; 145 127 } 146 memcpy(ne2k_cmds, ne2k_cmds_prototype, 147 sizeof(ne2k_cmds_prototype)); 148 ne2k_cmds[0].addr = ne2k->base_port + DP_ISR; 149 ne2k_cmds[3].addr = ne2k->base_port + DP_IMR; 128 memcpy(ne2k_cmds, ne2k_cmds_prototype, sizeof (ne2k_cmds_prototype)); 129 ne2k_cmds[0].addr = ne2k->port + DP_ISR; 130 ne2k_cmds[3].addr = ne2k->port + DP_IMR; 150 131 ne2k_cmds[4].addr = ne2k_cmds[0].addr; 151 ne2k_cmds[5].addr = ne2k->base_port + DP_TSR; 152 153 ne2k->code.rangecount = sizeof(ne2k_ranges_prototype) / 154 sizeof(irq_pio_range_t); 155 ne2k->code.ranges = ne2k_ranges; 156 157 ne2k->code.cmdcount = sizeof(ne2k_cmds_prototype) / 158 sizeof(irq_cmd_t); 132 ne2k_cmds[5].addr = ne2k->port + DP_TSR; 133 134 ne2k->code.cmdcount = sizeof(ne2k_cmds_prototype) / sizeof(irq_cmd_t); 159 135 ne2k->code.cmds = ne2k_cmds; 160 136 } … … 172 148 ne2k_t *ne2k = NE2K(dev); 173 149 if (ne2k) { 174 free(ne2k->code.ranges);175 150 free(ne2k->code.cmds); 176 151 } … … 286 261 /* Note: some frame with previous physical address may slip to NIL here 287 262 * (for a moment the filtering is not exact), but ethernet should be OK with 288 * that. Some packetmay also be lost, but this is not a problem.263 * that. Some frames may also be lost, but this is not a problem. 289 264 */ 290 265 ne2k_set_physical_address((ne2k_t *) nic_get_specific(nic_data), address); … … 363 338 static int ne2k_dev_add(ddf_dev_t *dev) 364 339 { 340 ddf_fun_t *fun; 341 365 342 /* Allocate driver data for the device. */ 366 343 nic_t *nic_data = nic_create_and_bind(dev); … … 396 373 } 397 374 398 rc = nic_ register_as_ddf_fun(nic_data, &ne2k_dev_ops);375 rc = nic_connect_to_services(nic_data); 399 376 if (rc != EOK) { 400 377 ne2k_dev_cleanup(dev); … … 402 379 } 403 380 404 rc = nic_connect_to_services(nic_data);405 if ( rc != EOK) {381 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); 382 if (fun == NULL) { 406 383 ne2k_dev_cleanup(dev); 384 return ENOMEM; 385 } 386 nic_set_ddf_fun(nic_data, fun); 387 fun->ops = &ne2k_dev_ops; 388 fun->driver_data = nic_data; 389 390 rc = ddf_fun_bind(fun); 391 if (rc != EOK) { 392 ddf_fun_destroy(fun); 393 ne2k_dev_cleanup(dev); 394 return rc; 395 } 396 397 rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 398 if (rc != EOK) { 399 ddf_fun_unbind(fun); 400 ddf_fun_destroy(fun); 407 401 return rc; 408 402 }
Note:
See TracChangeset
for help on using the changeset viewer.