Changeset 7300c37 in mainline
- 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
- Location:
- uspace/srv/hw/netif/dp8390
- Files:
-
- 3 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 -
uspace/srv/hw/netif/dp8390/dp8390.h
r4fc2b3b r7300c37 50 50 51 51 #include <fibril_synch.h> 52 #include <adt/list.h> 52 53 #include <net/packet.h> 54 #include <netif_skel.h> 53 55 54 56 /** Module name */ … … 230 232 } ne2k_t; 231 233 234 typedef struct { 235 link_t link; 236 packet_t *packet; 237 } frame_t; 238 232 239 extern int ne2k_probe(ne2k_t *, void *, int); 233 240 extern int ne2k_up(ne2k_t *); 234 241 extern void ne2k_down(ne2k_t *); 235 242 extern void ne2k_send(ne2k_t *, packet_t *); 236 extern void ne2k_interrupt(ne2k_t *, uint8_t isr, int, device_id_t);243 extern link_t *ne2k_interrupt(ne2k_t *, uint8_t, uint8_t); 237 244 238 245 #endif -
uspace/srv/hw/netif/dp8390/ne2000.c
r4fc2b3b r7300c37 68 68 #define IRQ_GET_ISR(call) ((int) IPC_GET_ARG2(call)) 69 69 70 /** Return the TSR from the interrupt call. 71 * 72 * @param[in] call The interrupt call. 73 * 74 */ 75 #define IRQ_GET_TSR(call) ((int) IPC_GET_ARG3(call)) 76 70 77 static int irc_service = 0; 71 78 static int irc_phone = -1; … … 92 99 /* Predicate for accepting the interrupt */ 93 100 .cmd = CMD_PREDICATE, 94 .value = 3,101 .value = 4, 95 102 .srcarg = 3 96 103 }, … … 111 118 }, 112 119 { 120 /* Read Transmit Status Register */ 121 .cmd = CMD_PIO_READ_8, 122 .addr = NULL, 123 .dstarg = 3 124 }, 125 { 113 126 .cmd = CMD_ACCEPT 114 127 } … … 125 138 /** Handle the interrupt notification. 126 139 * 127 * This is the interrupt notification function. 140 * This is the interrupt notification function. It is quarantied 141 * that there is only a single instance of this notification 142 * function running at one time until the return from the 143 * ne2k_interrupt() function (where the interrupts are unmasked 144 * again). 128 145 * 129 146 * @param[in] iid Interrupt notification identifier. … … 148 165 fibril_rwlock_read_unlock(&netif_globals.lock); 149 166 150 if (ne2k != NULL) 151 ne2k_interrupt(ne2k, IRQ_GET_ISR(*call), nil_phone, device_id); 167 if (ne2k != NULL) { 168 link_t *frames = 169 ne2k_interrupt(ne2k, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call)); 170 171 if (frames != NULL) { 172 while (!list_empty(frames)) { 173 frame_t *frame = 174 list_get_instance(frames->next, frame_t, link); 175 176 list_remove(&frame->link); 177 nil_received_msg(nil_phone, device_id, frame->packet, 178 SERVICE_NONE); 179 free(frame); 180 } 181 182 free(frames); 183 } 184 } 152 185 } 153 186
Note:
See TracChangeset
for help on using the changeset viewer.