Changeset 7300c37 in mainline for uspace/srv/hw/netif/dp8390/dp8390.c
- Timestamp:
- 2011-01-11T01:33:13Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8136102
- Parents:
- 4fc2b3b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/dp8390.c
r4fc2b3b r7300c37 54 54 #include <errno.h> 55 55 #include <libarch/ddi.h> 56 #include <netif_skel.h>57 56 #include <net/packet.h> 58 #include <nil_interface.h>59 57 #include <packet_client.h> 60 58 #include "dp8390.h" … … 344 342 345 343 /* Step 10: */ 346 pio_write_8(ne2k->port + DP_CR, CR_ DM_ABORT | CR_STA);344 pio_write_8(ne2k->port + DP_CR, CR_PS_P0 | CR_DM_ABORT | CR_STA); 347 345 348 346 /* Step 11: */ … … 449 447 } 450 448 451 static void ne2k_receive_frame(ne2k_t *ne2k, uint8_t page, size_t length, 452 int nil_phone, device_id_t device_id) 453 { 454 packet_t *packet = netif_packet_get_1(length); 455 if (!packet) 456 return; 457 458 void *buf = packet_suffix(packet, length); 449 static frame_t *ne2k_receive_frame(ne2k_t *ne2k, uint8_t page, size_t length) 450 { 451 frame_t *frame = (frame_t *) malloc(sizeof(frame_t)); 452 if (frame == NULL) 453 return NULL; 454 455 link_initialize(&frame->link); 456 457 frame->packet = netif_packet_get_1(length); 458 if (frame->packet == NULL) { 459 free(frame); 460 return NULL; 461 } 462 463 void *buf = packet_suffix(frame->packet, length); 459 464 bzero(buf, length); 460 465 uint8_t last = page + length / DP_PAGE; … … 473 478 474 479 ne2k->stats.receive_packets++; 475 nil_received_msg(nil_phone, device_id, packet, SERVICE_NONE); 476 } 477 478 static void ne2k_receive(ne2k_t *ne2k, int nil_phone, device_id_t device_id) 479 { 480 return frame; 481 } 482 483 static link_t *ne2k_receive(ne2k_t *ne2k) 484 { 485 /* 486 * Allocate memory for the list of received frames. 487 * If the allocation fails here we still receive the 488 * frames from the network, but they will be lost. 489 */ 490 link_t *frames = (link_t *) malloc(sizeof(link_t)); 491 if (frames != NULL) 492 list_initialize(frames); 493 480 494 while (true) { 481 495 uint8_t boundary = pio_read_8(ne2k->port + DP_BNRY) + 1; … … 526 540 ne2k->overruns++; 527 541 next = current; 528 } else if ((header.status & RSR_PRX) && (ne2k->up)) 529 ne2k_receive_frame(ne2k, boundary, length, nil_phone, device_id); 542 } else if ((header.status & RSR_PRX) && (ne2k->up)) { 543 frame_t *frame = ne2k_receive_frame(ne2k, boundary, length); 544 if ((frame != NULL) && (frames != NULL)) 545 list_append(&frame->link, frames); 546 } 530 547 531 548 /* … … 542 559 pio_write_8(ne2k->port + DP_BNRY, next); 543 560 } 544 } 545 546 void ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, int nil_phone, device_id_t device_id) 547 { 561 562 return frames; 563 } 564 565 link_t *ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, uint8_t tsr) 566 { 567 /* List of received frames */ 568 link_t *frames = NULL; 569 548 570 if (isr & (ISR_PTX | ISR_TXE)) { 549 571 if (isr & ISR_TXE) 550 572 ne2k->stats.send_errors++; 551 573 else { 552 uint8_t tsr = pio_read_8(ne2k->port + DP_TSR);553 554 574 if (tsr & TSR_PTX) 555 575 ne2k->stats.send_packets++; … … 598 618 } 599 619 600 if (isr & ISR_PRX)601 ne2k_receive(ne2k, nil_phone, device_id);602 603 620 if (isr & ISR_RXE) 604 621 ne2k->stats.receive_errors++; … … 613 630 } 614 631 632 if (isr & ISR_PRX) 633 frames = ne2k_receive(ne2k); 634 615 635 if (isr & ISR_RST) { 616 636 /* … … 624 644 pio_write_8(ne2k->port + DP_IMR, 625 645 IMR_PRXE | IMR_PTXE | IMR_RXEE | IMR_TXEE | IMR_OVWE | IMR_CNTE); 646 647 return frames; 626 648 } 627 649
Note:
See TracChangeset
for help on using the changeset viewer.