Changes in uspace/drv/nic/e1k/e1k.c [8820544:99e8fb7b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
r8820544 r99e8fb7b 33 33 */ 34 34 35 /* XXX Fix this */ 36 #define _DDF_DATA_IMPLANT 37 35 38 #include <assert.h> 36 39 #include <stdio.h> … … 39 42 #include <align.h> 40 43 #include <byteorder.h> 41 #include <irc.h> 44 #include <sysinfo.h> 45 #include <ipc/irc.h> 46 #include <ipc/ns.h> 47 #include <ddi.h> 42 48 #include <as.h> 43 #include <ddi.h>44 49 #include <ddf/log.h> 45 50 #include <ddf/interrupt.h> … … 71 76 /** ddf_fun_t * -> nic_driver_data_t* cast */ 72 77 #define NIC_DATA_FUN(fun) \ 73 ((nic_t *) ddf_ dev_data_get(ddf_fun_get_dev(fun)))78 ((nic_t *) ddf_fun_data_get(fun)) 74 79 75 80 /** ddf_dev_t * -> nic_driver_data_t* cast */ … … 1229 1234 /** Handle device interrupt 1230 1235 * 1236 * @param dev E1000 device 1231 1237 * @param iid IPC call id 1232 1238 * @param icall IPC call structure 1233 * @param dev E1000 device 1234 * 1235 */ 1236 static void e1000_interrupt_handler(ipc_callid_t iid, ipc_call_t *icall, 1237 ddf_dev_t *dev) 1239 * 1240 */ 1241 static void e1000_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid, 1242 ipc_call_t *icall) 1238 1243 { 1239 1244 uint32_t icr = (uint32_t) IPC_GET_ARG2(*icall); … … 1370 1375 fibril_mutex_lock(&e1000->rx_lock); 1371 1376 1372 e1000->rx_ring_virt = AS_AREA_ANY;1373 1377 int rc = dmamem_map_anonymous( 1374 1378 E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t), … … 1392 1396 } 1393 1397 1394 for (size_t i = 0; i < E1000_RX_FRAME_COUNT; i++) { 1395 uintptr_t frame_phys; 1396 void *frame_virt = AS_AREA_ANY; 1397 1398 size_t i; 1399 uintptr_t frame_phys; 1400 void *frame_virt; 1401 1402 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) { 1398 1403 rc = dmamem_map_anonymous(E1000_MAX_SEND_FRAME_SIZE, 1399 1404 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, … … 1407 1412 1408 1413 /* Write descriptor */ 1409 for ( size_ti = 0; i < E1000_RX_FRAME_COUNT; i++)1414 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) 1410 1415 e1000_fill_new_rx_descriptor(nic, i); 1411 1416 … … 1416 1421 1417 1422 error: 1418 for ( size_ti = 0; i < E1000_RX_FRAME_COUNT; i++) {1423 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) { 1419 1424 if (e1000->rx_frame_virt[i] != NULL) { 1420 1425 dmamem_unmap_anonymous(e1000->rx_frame_virt[i]); … … 1566 1571 1567 1572 e1000->tx_ring_phys = 0; 1568 e1000->tx_ring_virt = AS_AREA_ANY;1573 e1000->tx_ring_virt = NULL; 1569 1574 1570 1575 e1000->tx_frame_phys = NULL; … … 1592 1597 1593 1598 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1594 e1000->tx_frame_virt[i] = AS_AREA_ANY;1595 1599 rc = dmamem_map_anonymous(E1000_MAX_SEND_FRAME_SIZE, 1596 1600 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, … … 1753 1757 e1000_enable_interrupts(e1000); 1754 1758 1755 int rc = irc_enable_interrupt(e1000->irq); 1756 if (rc != EOK) { 1757 e1000_disable_interrupts(e1000); 1758 fibril_mutex_unlock(&e1000->ctrl_lock); 1759 fibril_mutex_unlock(&e1000->tx_lock); 1760 fibril_mutex_unlock(&e1000->rx_lock); 1761 return rc; 1762 } 1759 nic_enable_interrupt(nic, e1000->irq); 1763 1760 1764 1761 e1000_clear_rx_ring(e1000); … … 1798 1795 e1000_disable_rx(e1000); 1799 1796 1800 irc_disable_interrupt(e1000->irq);1797 nic_disable_interrupt(nic, e1000->irq); 1801 1798 e1000_disable_interrupts(e1000); 1802 1799 … … 2150 2147 nic_set_ddf_fun(nic, fun); 2151 2148 ddf_fun_set_ops(fun, &e1000_dev_ops); 2149 ddf_fun_data_implant(fun, nic); 2152 2150 2153 2151 rc = e1000_register_int_handler(nic); 2154 2152 if (rc != EOK) 2155 2153 goto err_fun_create; 2154 2155 rc = nic_connect_to_services(nic); 2156 if (rc != EOK) 2157 goto err_irq; 2156 2158 2157 2159 rc = e1000_initialize_rx_structure(nic); … … 2376 2378 int main(void) 2377 2379 { 2378 printf("%s: HelenOS E1000 network adapter driver\n", NAME); 2379 2380 if (nic_driver_init(NAME) != EOK) 2381 return 1; 2380 int rc = nic_driver_init(NAME); 2381 if (rc != EOK) 2382 return rc; 2382 2383 2383 2384 nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops, … … 2385 2386 2386 2387 ddf_log_init(NAME); 2388 ddf_msg(LVL_NOTE, "HelenOS E1000 driver started"); 2387 2389 return ddf_driver_main(&e1000_driver); 2388 2390 }
Note:
See TracChangeset
for help on using the changeset viewer.