Changeset 8e7c9fe in mainline for uspace/drv/nic/e1k/e1k.c
- Timestamp:
- 2014-09-12T03:45:25Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
r3eb0c85 r8e7c9fe 33 33 */ 34 34 35 /* XXX Fix this */36 #define _DDF_DATA_IMPLANT37 38 35 #include <assert.h> 39 36 #include <stdio.h> … … 42 39 #include <align.h> 43 40 #include <byteorder.h> 44 #include <sysinfo.h> 45 #include <ipc/irc.h> 46 #include <ipc/ns.h> 41 #include <irc.h> 42 #include <as.h> 47 43 #include <ddi.h> 48 #include <as.h>49 44 #include <ddf/log.h> 50 45 #include <ddf/interrupt.h> … … 76 71 /** ddf_fun_t * -> nic_driver_data_t* cast */ 77 72 #define NIC_DATA_FUN(fun) \ 78 ((nic_t *) ddf_ fun_data_get(fun))73 ((nic_t *) ddf_dev_data_get(ddf_fun_get_dev(fun))) 79 74 80 75 /** ddf_dev_t * -> nic_driver_data_t* cast */ … … 1234 1229 /** Handle device interrupt 1235 1230 * 1236 * @param dev E1000 device1237 1231 * @param iid IPC call id 1238 1232 * @param icall IPC call structure 1239 * 1240 */ 1241 static void e1000_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid, 1242 ipc_call_t *icall) 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) 1243 1238 { 1244 1239 uint32_t icr = (uint32_t) IPC_GET_ARG2(*icall); … … 1375 1370 fibril_mutex_lock(&e1000->rx_lock); 1376 1371 1372 e1000->rx_ring_virt = AS_AREA_ANY; 1377 1373 int rc = dmamem_map_anonymous( 1378 1374 E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t), … … 1396 1392 } 1397 1393 1398 size_t i; 1399 uintptr_t frame_phys; 1400 void *frame_virt; 1401 1402 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) { 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 1403 1398 rc = dmamem_map_anonymous(E1000_MAX_SEND_FRAME_SIZE, 1404 1399 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, … … 1412 1407 1413 1408 /* Write descriptor */ 1414 for ( i = 0; i < E1000_RX_FRAME_COUNT; i++)1409 for (size_t i = 0; i < E1000_RX_FRAME_COUNT; i++) 1415 1410 e1000_fill_new_rx_descriptor(nic, i); 1416 1411 … … 1421 1416 1422 1417 error: 1423 for ( i = 0; i < E1000_RX_FRAME_COUNT; i++) {1418 for (size_t i = 0; i < E1000_RX_FRAME_COUNT; i++) { 1424 1419 if (e1000->rx_frame_virt[i] != NULL) { 1425 1420 dmamem_unmap_anonymous(e1000->rx_frame_virt[i]); … … 1571 1566 1572 1567 e1000->tx_ring_phys = 0; 1573 e1000->tx_ring_virt = NULL;1568 e1000->tx_ring_virt = AS_AREA_ANY; 1574 1569 1575 1570 e1000->tx_frame_phys = NULL; … … 1597 1592 1598 1593 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1594 e1000->tx_frame_virt[i] = AS_AREA_ANY; 1599 1595 rc = dmamem_map_anonymous(E1000_MAX_SEND_FRAME_SIZE, 1600 1596 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, … … 1757 1753 e1000_enable_interrupts(e1000); 1758 1754 1759 nic_enable_interrupt(nic, e1000->irq); 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 } 1760 1763 1761 1764 e1000_clear_rx_ring(e1000); … … 1795 1798 e1000_disable_rx(e1000); 1796 1799 1797 nic_disable_interrupt(nic,e1000->irq);1800 irc_disable_interrupt(e1000->irq); 1798 1801 e1000_disable_interrupts(e1000); 1799 1802 … … 2147 2150 nic_set_ddf_fun(nic, fun); 2148 2151 ddf_fun_set_ops(fun, &e1000_dev_ops); 2149 ddf_fun_data_implant(fun, nic);2150 2152 2151 2153 rc = e1000_register_int_handler(nic); 2152 2154 if (rc != EOK) 2153 2155 goto err_fun_create; 2154 2155 rc = nic_connect_to_services(nic);2156 if (rc != EOK)2157 goto err_irq;2158 2156 2159 2157 rc = e1000_initialize_rx_structure(nic); … … 2378 2376 int main(void) 2379 2377 { 2380 int rc = nic_driver_init(NAME); 2381 if (rc != EOK) 2382 return rc; 2378 printf("%s: HelenOS E1000 network adapter driver\n", NAME); 2379 2380 if (nic_driver_init(NAME) != EOK) 2381 return 1; 2383 2382 2384 2383 nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops, … … 2386 2385 2387 2386 ddf_log_init(NAME); 2388 ddf_msg(LVL_NOTE, "HelenOS E1000 driver started");2389 2387 return ddf_driver_main(&e1000_driver); 2390 2388 }
Note:
See TracChangeset
for help on using the changeset viewer.