Changes in uspace/drv/nic/ne2k/ne2k.c [9d58539:80099c19] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/ne2k/ne2k.c
r9d58539 r80099c19 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 framesmay also be lost, but this is not a problem.263 * that. Some packet 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); … … 361 336 } 362 337 363 static int ne2k_dev_add(ddf_dev_t *dev) 364 { 365 ddf_fun_t *fun; 366 338 static int ne2k_add_device(ddf_dev_t *dev) 339 { 367 340 /* Allocate driver data for the device. */ 368 341 nic_t *nic_data = nic_create_and_bind(dev); … … 370 343 return ENOMEM; 371 344 372 nic_set_ send_frame_handler(nic_data, ne2k_send);345 nic_set_write_packet_handler(nic_data, ne2k_send); 373 346 nic_set_state_change_handlers(nic_data, 374 347 ne2k_on_activating, NULL, ne2k_on_stopping); … … 398 371 } 399 372 373 rc = nic_register_as_ddf_fun(nic_data, &ne2k_dev_ops); 374 if (rc != EOK) { 375 ne2k_dev_cleanup(dev); 376 return rc; 377 } 378 400 379 rc = nic_connect_to_services(nic_data); 401 380 if (rc != EOK) { … … 404 383 } 405 384 406 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0");407 if (fun == NULL) {408 ne2k_dev_cleanup(dev);409 return ENOMEM;410 }411 nic_set_ddf_fun(nic_data, fun);412 fun->ops = &ne2k_dev_ops;413 fun->driver_data = nic_data;414 415 rc = ddf_fun_bind(fun);416 if (rc != EOK) {417 ddf_fun_destroy(fun);418 ne2k_dev_cleanup(dev);419 return rc;420 }421 422 rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);423 if (rc != EOK) {424 ddf_fun_unbind(fun);425 ddf_fun_destroy(fun);426 return rc;427 }428 429 385 return EOK; 430 386 } … … 435 391 436 392 static driver_ops_t ne2k_driver_ops = { 437 . dev_add = ne2k_dev_add393 .add_device = ne2k_add_device 438 394 }; 439 395
Note:
See TracChangeset
for help on using the changeset viewer.