Changeset 0764cc8a in mainline for uspace/drv/nic/rtl8169/driver.c
- Timestamp:
- 2014-05-26T20:52:46Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 59b3095
- Parents:
- f1ac202
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8169/driver.c
rf1ac202 r0764cc8a 87 87 static rtl8169_t *rtl8169_create_dev_data(ddf_dev_t *dev); 88 88 89 static int rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode, 90 const nic_address_t *, size_t); 91 static int rtl8169_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode, 92 const nic_address_t *addr, size_t addr_count); 93 static int rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode); 94 95 89 96 /** Network interface options for RTL8169 card driver */ 90 97 static nic_iface_t rtl8169_nic_iface = { … … 221 228 } 222 229 230 static int rtl8169_allocate_buffers(rtl8169_t *rtl8169) 231 { 232 int rc; 233 234 ddf_msg(LVL_DEBUG, "Allocating DMA buffer rings"); 235 236 /* Allocate TX ring */ 237 rc = dmamem_map_anonymous(TX_RING_SIZE, DMAMEM_4GiB, 238 AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->tx_ring_phys, 239 &rtl8169->tx_ring_virt); 240 241 if (rc != EOK) 242 return rc; 243 244 /* Allocate RX ring */ 245 rc = dmamem_map_anonymous(RX_RING_SIZE, DMAMEM_4GiB, 246 AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->rx_ring_phys, 247 &rtl8169->rx_ring_virt); 248 249 if (rc != EOK) 250 return rc; 251 252 /* Allocate TX buffers */ 253 rc = dmamem_map_anonymous(TX_BUFFERS_SIZE, DMAMEM_4GiB, 254 AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->tx_buff_phys, 255 &rtl8169->tx_buff_virt); 256 257 if (rc != EOK) 258 return rc; 259 260 /* Allocate RX buffers */ 261 rc = dmamem_map_anonymous(RX_BUFFERS_SIZE, DMAMEM_4GiB, 262 AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->rx_buff_phys, 263 &rtl8169->rx_buff_virt); 264 265 if (rc != EOK) 266 return rc; 267 } 268 223 269 static rtl8169_t *rtl8169_create_dev_data(ddf_dev_t *dev) 224 270 { … … 244 290 rtl8169_on_activated, NULL, rtl8169_on_stopped); 245 291 nic_set_filtering_change_handlers(nic_data, 246 NULL, NULL, NULL, NULL, NULL); 292 rtl8169_unicast_set, rtl8169_multicast_set, rtl8169_broadcast_set, 293 NULL, NULL); 247 294 248 295 fibril_mutex_initialize(&rtl8169->rx_lock); … … 255 302 return rtl8169; 256 303 } 257 258 304 259 305 static int rtl8169_dev_initialize(ddf_dev_t *dev) … … 344 390 ddf_msg(LVL_DEBUG, "Interrupt handler installed"); 345 391 346 rtl8169_reset(rtl8169);347 pio_write_16(rtl8169->regs + IMR, 0xffff);348 349 392 uint8_t cr_value = pio_read_8(rtl8169->regs + CR); 350 393 pio_write_8(rtl8169->regs + CR, cr_value | CR_TE | CR_RE); … … 377 420 goto err_fun_bind; 378 421 } 379 422 380 423 ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.", 381 424 ddf_dev_get_name(dev)); … … 474 517 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 475 518 519 /* Reset card */ 520 pio_write_8(rtl8169->regs + CONFIG0, 0); 521 rtl8169_reset(rtl8169); 522 523 /* Enable TX and RX */ 524 uint8_t cr = pio_read_8(rtl8169->regs + CR); 525 cr |= CR_TE | CR_RE; 526 pio_write_8(rtl8169->regs + CR, cr); 527 476 528 pio_write_16(rtl8169->regs + IMR, 0xffff); 529 nic_enable_interrupt(nic_data, rtl8169->irq); 477 530 478 531 return EOK; … … 481 534 static int rtl8169_on_stopped(nic_t *nic_data) 482 535 { 536 ddf_msg(LVL_NOTE, "Stopping device"); 483 537 return EOK; 484 538 } … … 522 576 523 577 } 578 579 static int rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode, 580 const nic_address_t *addr, size_t addr_count) 581 { 582 return EOK; 583 } 584 585 static int rtl8169_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode, 586 const nic_address_t *addr, size_t addr_count) 587 { 588 return EOK; 589 } 590 591 static int rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode) 592 { 593 return EOK; 594 } 595 596 524 597 525 598 static void rtl8169_irq_handler(ddf_dev_t *dev, ipc_callid_t iid,
Note:
See TracChangeset
for help on using the changeset viewer.