Changes in uspace/drv/nic/e1k/e1k.c [7de1988c:f2c19b0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
r7de1988c rf2c19b0 59 59 #define E1000_DEFAULT_INTERRUPT_INTERVAL_USEC 250 60 60 61 /* Must be power of 8 */ 62 #define E1000_RX_FRAME_COUNT 12863 #define E1000_TX_FRAME_COUNT 12861 /* Must be power of 8 */ //TODO power or multiple? previous value was 128 62 #define E1000_RX_FRAME_COUNT 8 63 #define E1000_TX_FRAME_COUNT 8 64 64 65 65 #define E1000_RECEIVE_ADDRESS 16 … … 129 129 130 130 /** Physical tx ring address */ 131 uintptr_ttx_ring_phys;131 void *tx_ring_phys; 132 132 /** Virtual tx ring address */ 133 133 void *tx_ring_virt; 134 134 135 135 /** Ring of TX frames, physical address */ 136 uintptr_t*tx_frame_phys;136 void **tx_frame_phys; 137 137 /** Ring of TX frames, virtual address */ 138 138 void **tx_frame_virt; 139 139 140 140 /** Physical rx ring address */ 141 uintptr_trx_ring_phys;141 void *rx_ring_phys; 142 142 /** Virtual rx ring address */ 143 143 void *rx_ring_virt; 144 144 145 145 /** Ring of RX frames, physical address */ 146 uintptr_t*rx_frame_phys;146 void **rx_frame_phys; 147 147 /** Ring of RX frames, virtual address */ 148 148 void **rx_frame_virt; … … 1377 1377 int rc = dmamem_map_anonymous( 1378 1378 E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t), 1379 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0,1380 &e1000->rx_ring_ phys, &e1000->rx_ring_virt);1379 AS_AREA_READ | AS_AREA_WRITE, 0, &e1000->rx_ring_phys, 1380 &e1000->rx_ring_virt); 1381 1381 if (rc != EOK) 1382 1382 return rc; … … 1387 1387 (uint32_t) PTR_TO_U64(e1000->rx_ring_phys)); 1388 1388 1389 e1000->rx_frame_phys = (uintptr_t *)1390 calloc(E1000_RX_FRAME_COUNT, sizeof( uintptr_t));1389 e1000->rx_frame_phys = 1390 calloc(E1000_RX_FRAME_COUNT, sizeof(void *)); 1391 1391 e1000->rx_frame_virt = 1392 1392 calloc(E1000_RX_FRAME_COUNT, sizeof(void *)); 1393 if ( (e1000->rx_frame_phys == NULL) || (e1000->rx_frame_virt == NULL)) {1393 if (e1000->rx_frame_phys == NULL || e1000->rx_frame_virt == NULL) { 1394 1394 rc = ENOMEM; 1395 1395 goto error; … … 1397 1397 1398 1398 size_t i; 1399 uintptr_t frame_phys;1400 1399 void *frame_virt; 1400 void *frame_phys; 1401 1401 1402 1402 for (i = 0; i < E1000_RX_FRAME_COUNT; i++) { 1403 rc = dmamem_map_anonymous( E1000_MAX_SEND_FRAME_SIZE,1404 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0,1405 &frame_phys, &frame_virt);1403 rc = dmamem_map_anonymous( 1404 E1000_MAX_SEND_FRAME_SIZE, AS_AREA_READ | AS_AREA_WRITE, 1405 0, &frame_phys, &frame_virt); 1406 1406 if (rc != EOK) 1407 1407 goto error; 1408 1408 1409 e1000->rx_frame_virt[i] = frame_virt; 1409 1410 e1000->rx_frame_phys[i] = frame_phys; 1410 e1000->rx_frame_virt[i] = frame_virt;1411 1411 } 1412 1412 … … 1424 1424 if (e1000->rx_frame_virt[i] != NULL) { 1425 1425 dmamem_unmap_anonymous(e1000->rx_frame_virt[i]); 1426 e1000->rx_frame_phys[i] = 0;1427 1426 e1000->rx_frame_virt[i] = NULL; 1427 e1000->rx_frame_phys[i] = NULL; 1428 1428 } 1429 1429 } … … 1436 1436 if (e1000->rx_frame_virt != NULL) { 1437 1437 free(e1000->rx_frame_virt); 1438 e1000->rx_frame_ virt= NULL;1438 e1000->rx_frame_phys = NULL; 1439 1439 } 1440 1440 … … 1454 1454 for (unsigned int offset = 0; offset < E1000_RX_FRAME_COUNT; offset++) { 1455 1455 dmamem_unmap_anonymous(e1000->rx_frame_virt[offset]); 1456 e1000->rx_frame_phys[offset] = 0;1457 1456 e1000->rx_frame_virt[offset] = NULL; 1457 e1000->rx_frame_phys[offset] = NULL; 1458 1458 } 1459 1459 1460 1460 free(e1000->rx_frame_virt); 1461 1461 free(e1000->rx_frame_phys); 1462 e1000->rx_frame_virt = NULL; 1462 1463 e1000->rx_frame_phys = NULL; 1463 e1000->rx_frame_virt = NULL;1464 1465 1464 dmamem_unmap_anonymous(e1000->rx_ring_virt); 1466 1465 } … … 1570 1569 fibril_mutex_lock(&e1000->tx_lock); 1571 1570 1572 e1000->tx_ring_phys = 0;1571 e1000->tx_ring_phys = NULL; 1573 1572 e1000->tx_ring_virt = NULL; 1574 1575 1573 e1000->tx_frame_phys = NULL; 1576 1574 e1000->tx_frame_virt = NULL; … … 1578 1576 int rc = dmamem_map_anonymous( 1579 1577 E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t), 1580 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0,1581 &e1000->tx_ring_ phys, &e1000->tx_ring_virt);1578 AS_AREA_READ | AS_AREA_WRITE, 0, &e1000->tx_ring_phys, 1579 &e1000->tx_ring_virt); 1582 1580 if (rc != EOK) 1583 1581 goto error; … … 1586 1584 E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t)); 1587 1585 1588 e1000->tx_frame_phys = (uintptr_t *) 1589 calloc(E1000_TX_FRAME_COUNT, sizeof(uintptr_t)); 1590 e1000->tx_frame_virt = 1591 calloc(E1000_TX_FRAME_COUNT, sizeof(void *)); 1592 1593 if ((e1000->tx_frame_phys == NULL) || (e1000->tx_frame_virt == NULL)) { 1586 e1000->tx_frame_phys = calloc(E1000_TX_FRAME_COUNT, sizeof(void *)); 1587 e1000->tx_frame_virt = calloc(E1000_TX_FRAME_COUNT, sizeof(void *)); 1588 1589 if (e1000->tx_frame_phys == NULL || e1000->tx_frame_virt == NULL) { 1594 1590 rc = ENOMEM; 1595 1591 goto error; … … 1597 1593 1598 1594 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1599 rc = dmamem_map_anonymous( E1000_MAX_SEND_FRAME_SIZE,1600 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE,1595 rc = dmamem_map_anonymous( 1596 E1000_MAX_SEND_FRAME_SIZE, AS_AREA_READ | AS_AREA_WRITE, 1601 1597 0, &e1000->tx_frame_phys[i], &e1000->tx_frame_virt[i]); 1602 1598 if (rc != EOK) … … 1620 1616 } 1621 1617 1622 if ( (e1000->tx_frame_phys != NULL) && (e1000->tx_frame_virt != NULL)) {1618 if (e1000->tx_frame_phys != NULL && e1000->tx_frame_virt != NULL) { 1623 1619 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1624 1620 if (e1000->tx_frame_virt[i] != NULL) { 1625 1621 dmamem_unmap_anonymous(e1000->tx_frame_virt[i]); 1626 e1000->tx_frame_phys[i] = 0;1627 1622 e1000->tx_frame_virt[i] = NULL; 1623 e1000->tx_frame_phys[i] = NULL; 1628 1624 } 1629 1625 } … … 1637 1633 if (e1000->tx_frame_virt != NULL) { 1638 1634 free(e1000->tx_frame_virt); 1639 e1000->tx_frame_ virt= NULL;1635 e1000->tx_frame_phys = NULL; 1640 1636 } 1641 1637 … … 1654 1650 for (i = 0; i < E1000_TX_FRAME_COUNT; i++) { 1655 1651 dmamem_unmap_anonymous(e1000->tx_frame_virt[i]); 1656 e1000->tx_frame_phys[i] = 0;1657 1652 e1000->tx_frame_virt[i] = NULL; 1653 e1000->tx_frame_phys[i] = NULL; 1658 1654 } 1659 1655 … … 1665 1661 if (e1000->tx_frame_virt != NULL) { 1666 1662 free(e1000->tx_frame_virt); 1667 e1000->tx_frame_ virt= NULL;1663 e1000->tx_frame_phys = NULL; 1668 1664 } 1669 1665 … … 1941 1937 e1000->irq = hw_resources->irqs.irqs[0]; 1942 1938 e1000->reg_base_phys = 1943 MEMADDR_TO_PTR( RNGABS(hw_resources->mem_ranges.ranges[0]));1939 MEMADDR_TO_PTR(hw_resources->mem_ranges.ranges[0].address); 1944 1940 1945 1941 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.