Changes in uspace/srv/net/netif/dp8390/dp8390.c [1e2e0c1e:aadf01e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/netif/dp8390/dp8390.c
r1e2e0c1e raadf01e 67 67 * @returns EINVAL 68 68 */ 69 int queue_packet( dpeth_t * dep, packet_t packet);69 int queue_packet(dpeth_t * dep, packet_t packet); 70 70 71 71 /** Reads a memory block byte by byte. … … 74 74 * @param[in] size The memory block size in bytes. 75 75 */ 76 static void outsb( port_t port, void * buf, size_t size);76 static void outsb(port_t port, void * buf, size_t size); 77 77 78 78 /** Reads a memory block word by word. … … 81 81 * @param[in] size The memory block size in bytes. 82 82 */ 83 static void outsw( port_t port, void * buf, size_t size);83 static void outsw(port_t port, void * buf, size_t size); 84 84 85 85 //static u16_t eth_ign_proto; … … 98 98 //{ 99 99 /* I/O port, IRQ, Buffer address, Env. var. */ 100 /* { 101 { 102 { 100 /* { 0x280, 3, 0xD0000, "DPETH0" }, 101 { 0x300, 5, 0xC8000, "DPETH1" }, 102 { 0x380, 10, 0xD8000, "DPETH2" }, 103 103 }; 104 104 */ … … 126 126 127 127 //#if ENABLE_PCI 128 //_PROTOTYPE( 128 //_PROTOTYPE(static void pci_conf, (void) ); 129 129 //#endif 130 //_PROTOTYPE( 130 //_PROTOTYPE(static void do_vwrite, (message *mp, int from_int, 131 131 // int vectored) ); 132 //_PROTOTYPE( 133 //_PROTOTYPE( 134 //_PROTOTYPE( 135 //_PROTOTYPE( 136 //_PROTOTYPE( 137 //_PROTOTYPE( 138 //_PROTOTYPE( 139 //_PROTOTYPE( 140 //_PROTOTYPE( 141 _PROTOTYPE( 142 //_PROTOTYPE( 143 _PROTOTYPE( 144 _PROTOTYPE( 145 //_PROTOTYPE( 146 _PROTOTYPE( 147 _PROTOTYPE( 148 //_PROTOTYPE( 149 _PROTOTYPE( 132 //_PROTOTYPE(static void do_vwrite_s, (message *mp, int from_int) ); 133 //_PROTOTYPE(static void do_vread, (message *mp, int vectored) ); 134 //_PROTOTYPE(static void do_vread_s, (message *mp) ); 135 //_PROTOTYPE(static void do_init, (message *mp) ); 136 //_PROTOTYPE(static void do_int, (dpeth_t *dep) ); 137 //_PROTOTYPE(static void do_getstat, (message *mp) ); 138 //_PROTOTYPE(static void do_getstat_s, (message *mp) ); 139 //_PROTOTYPE(static void do_getname, (message *mp) ); 140 //_PROTOTYPE(static void do_stop, (message *mp) ); 141 _PROTOTYPE(static void dp_init, (dpeth_t *dep) ); 142 //_PROTOTYPE(static void dp_confaddr, (dpeth_t *dep) ); 143 _PROTOTYPE(static void dp_reinit, (dpeth_t *dep) ); 144 _PROTOTYPE(static void dp_reset, (dpeth_t *dep) ); 145 //_PROTOTYPE(static void dp_check_ints, (dpeth_t *dep) ); 146 _PROTOTYPE(static void dp_recv, (dpeth_t *dep) ); 147 _PROTOTYPE(static void dp_send, (dpeth_t *dep) ); 148 //_PROTOTYPE(static void dp8390_stop, (void) ); 149 _PROTOTYPE(static void dp_getblock, (dpeth_t *dep, int page, 150 150 size_t offset, size_t size, void *dst) ); 151 _PROTOTYPE( 151 _PROTOTYPE(static void dp_pio8_getblock, (dpeth_t *dep, int page, 152 152 size_t offset, size_t size, void *dst) ); 153 _PROTOTYPE( 153 _PROTOTYPE(static void dp_pio16_getblock, (dpeth_t *dep, int page, 154 154 size_t offset, size_t size, void *dst) ); 155 _PROTOTYPE( 156 int length) 157 //_PROTOTYPE( 155 _PROTOTYPE(static int dp_pkt2user, (dpeth_t *dep, int page, 156 int length) ); 157 //_PROTOTYPE(static int dp_pkt2user_s, (dpeth_t *dep, int page, 158 158 // int length) ); 159 _PROTOTYPE( 160 vir_bytes offset, int nic_addr, vir_bytes count) 161 //_PROTOTYPE( 159 _PROTOTYPE(static void dp_user2nic, (dpeth_t *dep, iovec_dat_t *iovp, 160 vir_bytes offset, int nic_addr, vir_bytes count) ); 161 //_PROTOTYPE(static void dp_user2nic_s, (dpeth_t *dep, iovec_dat_s_t *iovp, 162 162 // vir_bytes offset, int nic_addr, vir_bytes count) ); 163 _PROTOTYPE( 163 _PROTOTYPE(static void dp_pio8_user2nic, (dpeth_t *dep, 164 164 iovec_dat_t *iovp, vir_bytes offset, 165 int nic_addr, vir_bytes count) 166 //_PROTOTYPE( 165 int nic_addr, vir_bytes count) ); 166 //_PROTOTYPE(static void dp_pio8_user2nic_s, (dpeth_t *dep, 167 167 // iovec_dat_s_t *iovp, vir_bytes offset, 168 168 // int nic_addr, vir_bytes count) ); 169 _PROTOTYPE( 169 _PROTOTYPE(static void dp_pio16_user2nic, (dpeth_t *dep, 170 170 iovec_dat_t *iovp, vir_bytes offset, 171 int nic_addr, vir_bytes count) 172 //_PROTOTYPE( 171 int nic_addr, vir_bytes count) ); 172 //_PROTOTYPE(static void dp_pio16_user2nic_s, (dpeth_t *dep, 173 173 // iovec_dat_s_t *iovp, vir_bytes offset, 174 174 // int nic_addr, vir_bytes count) ); 175 _PROTOTYPE( 175 _PROTOTYPE(static void dp_nic2user, (dpeth_t *dep, int nic_addr, 176 176 iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); 177 //_PROTOTYPE( 177 //_PROTOTYPE(static void dp_nic2user_s, (dpeth_t *dep, int nic_addr, 178 178 // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); 179 _PROTOTYPE( 179 _PROTOTYPE(static void dp_pio8_nic2user, (dpeth_t *dep, int nic_addr, 180 180 iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); 181 //_PROTOTYPE( 181 //_PROTOTYPE(static void dp_pio8_nic2user_s, (dpeth_t *dep, int nic_addr, 182 182 // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); 183 _PROTOTYPE( 183 _PROTOTYPE(static void dp_pio16_nic2user, (dpeth_t *dep, int nic_addr, 184 184 iovec_dat_t *iovp, vir_bytes offset, vir_bytes count) ); 185 //_PROTOTYPE( 185 //_PROTOTYPE(static void dp_pio16_nic2user_s, (dpeth_t *dep, int nic_addr, 186 186 // iovec_dat_s_t *iovp, vir_bytes offset, vir_bytes count) ); 187 _PROTOTYPE( 188 //_PROTOTYPE( 189 _PROTOTYPE( 190 //_PROTOTYPE( 191 _PROTOTYPE( 192 //_PROTOTYPE( 193 //_PROTOTYPE( 194 _PROTOTYPE( 195 //_PROTOTYPE( 196 _PROTOTYPE( 187 _PROTOTYPE(static void dp_next_iovec, (iovec_dat_t *iovp) ); 188 //_PROTOTYPE(static void dp_next_iovec_s, (iovec_dat_s_t *iovp) ); 189 _PROTOTYPE(static void conf_hw, (dpeth_t *dep) ); 190 //_PROTOTYPE(static void update_conf, (dpeth_t *dep, dp_conf_t *dcp) ); 191 _PROTOTYPE(static void map_hw_buffer, (dpeth_t *dep) ); 192 //_PROTOTYPE(static int calc_iovec_size, (iovec_dat_t *iovp) ); 193 //_PROTOTYPE(static int calc_iovec_size_s, (iovec_dat_s_t *iovp) ); 194 _PROTOTYPE(static void reply, (dpeth_t *dep, int err, int may_block) ); 195 //_PROTOTYPE(static void mess_reply, (message *req, message *reply) ); 196 _PROTOTYPE(static void get_userdata, (int user_proc, 197 197 vir_bytes user_addr, vir_bytes count, void *loc_addr) ); 198 //_PROTOTYPE( 198 //_PROTOTYPE(static void get_userdata_s, (int user_proc, 199 199 // cp_grant_id_t grant, vir_bytes offset, vir_bytes count, 200 200 // void *loc_addr) ); 201 //_PROTOTYPE( 201 //_PROTOTYPE(static void put_userdata, (int user_proc, 202 202 // vir_bytes user_addr, vir_bytes count, void *loc_addr) ); 203 //_PROTOTYPE( 203 //_PROTOTYPE(static void put_userdata_s, (int user_proc, 204 204 // cp_grant_id_t grant, size_t count, void *loc_addr) ); 205 _PROTOTYPE( 206 _PROTOTYPE( 207 //_PROTOTYPE( 205 _PROTOTYPE(static void insb, (port_t port, void *buf, size_t size) ); 206 _PROTOTYPE(static void insw, (port_t port, void *buf, size_t size) ); 207 //_PROTOTYPE(static void do_vir_insb, (port_t port, int proc, 208 208 // vir_bytes buf, size_t size) ); 209 //_PROTOTYPE( 209 //_PROTOTYPE(static void do_vir_insw, (port_t port, int proc, 210 210 // vir_bytes buf, size_t size) ); 211 //_PROTOTYPE( 211 //_PROTOTYPE(static void do_vir_outsb, (port_t port, int proc, 212 212 // vir_bytes buf, size_t size) ); 213 //_PROTOTYPE( 213 //_PROTOTYPE(static void do_vir_outsw, (port_t port, int proc, 214 214 // vir_bytes buf, size_t size) ); 215 215 216 int do_probe( dpeth_t * dep){216 int do_probe(dpeth_t * dep){ 217 217 /* This is the default, try to (re)locate the device. */ 218 218 conf_hw(dep); … … 230 230 * dp8390_dump * 231 231 *===========================================================================*/ 232 void dp8390_dump( dpeth_t * dep)232 void dp8390_dump(dpeth_t * dep) 233 233 { 234 234 // dpeth_t *dep; … … 282 282 * do_init * 283 283 *===========================================================================*/ 284 int do_init( dpeth_t * dep, int mode){284 int do_init(dpeth_t * dep, int mode){ 285 285 if (dep->de_mode == DEM_DISABLED) 286 286 { … … 303 303 } 304 304 assert(dep->de_mode == DEM_ENABLED); 305 assert(dep->de_flags & 305 assert(dep->de_flags &DEF_ENABLED); 306 306 307 307 dep->de_flags &= ~(DEF_PROMISC | DEF_MULTI | DEF_BROAD); 308 308 309 if (mode & 309 if (mode &DL_PROMISC_REQ) 310 310 dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD; 311 if (mode & 311 if (mode &DL_MULTI_REQ) 312 312 dep->de_flags |= DEF_MULTI; 313 if (mode & 313 if (mode &DL_BROAD_REQ) 314 314 dep->de_flags |= DEF_BROAD; 315 315 … … 329 329 * do_stop * 330 330 *===========================================================================*/ 331 void do_stop( dpeth_t * dep){332 if(( dep->de_mode != DEM_SINK ) && ( dep->de_mode == DEM_ENABLED ) && ( dep->de_flags & DEF_ENABLED)){333 outb_reg0( dep, DP_CR, CR_STP | CR_DM_ABORT);334 ( dep->de_stopf )( dep);331 void do_stop(dpeth_t * dep){ 332 if((dep->de_mode != DEM_SINK) && (dep->de_mode == DEM_ENABLED) && (dep->de_flags &DEF_ENABLED)){ 333 outb_reg0(dep, DP_CR, CR_STP | CR_DM_ABORT); 334 (dep->de_stopf)(dep); 335 335 336 336 dep->de_flags = DEF_EMPTY; … … 338 338 } 339 339 340 int queue_packet( dpeth_t * dep, packet_t packet){341 packet_t 342 343 if( dep->packet_count >= MAX_PACKETS){344 netif_pq_release( packet_get_id( packet));340 int queue_packet(dpeth_t * dep, packet_t packet){ 341 packet_t tmp; 342 343 if(dep->packet_count >= MAX_PACKETS){ 344 netif_pq_release(packet_get_id(packet)); 345 345 return ELIMIT; 346 346 } 347 347 348 348 tmp = dep->packet_queue; 349 while( pq_next( tmp)){350 tmp = pq_next( tmp);351 } 352 if( pq_add( & tmp, packet, 0, 0 ) != EOK){349 while(pq_next(tmp)){ 350 tmp = pq_next(tmp); 351 } 352 if(pq_add(&tmp, packet, 0, 0) != EOK){ 353 353 return EINVAL; 354 354 } 355 if( ! dep->packet_count){355 if(! dep->packet_count){ 356 356 dep->packet_queue = packet; 357 357 } … … 363 363 * based on do_vwrite * 364 364 *===========================================================================*/ 365 int do_pwrite( dpeth_t * dep, packet_t packet, int from_int)365 int do_pwrite(dpeth_t * dep, packet_t packet, int from_int) 366 366 { 367 367 // int port, count, size; … … 386 386 } 387 387 assert(dep->de_mode == DEM_ENABLED); 388 assert(dep->de_flags & 389 if( dep->packet_queue && ( ! from_int)){390 // if (dep->de_flags & 388 assert(dep->de_flags &DEF_ENABLED); 389 if(dep->packet_queue && (! from_int)){ 390 // if (dep->de_flags &DEF_SEND_AVAIL){ 391 391 // panic("", "dp8390: send already in progress", NO_NUM); 392 return queue_packet( dep, packet);392 return queue_packet(dep, packet); 393 393 } 394 394 … … 402 402 // reply(dep, OK, FALSE); 403 403 // return; 404 // return queue_packet( dep, packet);404 // return queue_packet(dep, packet); 405 405 // } 406 // assert(!(dep->de_flags & 406 // assert(!(dep->de_flags &DEF_PACK_SEND)); 407 407 408 408 /* if (vectored) … … 419 419 } 420 420 else 421 { 421 { 422 422 dep->de_write_iovec.iod_iovec[0].iov_addr = 423 423 (vir_bytes) mp->DL_ADDR; … … 430 430 } 431 431 */ 432 size = packet_get_data_length( packet);433 dep->de_write_iovec.iod_iovec[0].iov_addr = ( vir_bytes ) packet_get_data( packet);432 size = packet_get_data_length(packet); 433 dep->de_write_iovec.iod_iovec[0].iov_addr = (vir_bytes) packet_get_data(packet); 434 434 dep->de_write_iovec.iod_iovec[0].iov_size = size; 435 435 dep->de_write_iovec.iod_iovec_s = 1; … … 449 449 outb_reg0(dep, DP_TPSR, dep->de_sendq[sendq_head].sq_sendpage); 450 450 outb_reg0(dep, DP_TBCR1, size >> 8); 451 outb_reg0(dep, DP_TBCR0, size & 451 outb_reg0(dep, DP_TBCR0, size &0xff); 452 452 outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA);/* there it goes.. */ 453 453 } … … 470 470 471 471 assert(dep->de_mode == DEM_ENABLED); 472 assert(dep->de_flags & 472 assert(dep->de_flags &DEF_ENABLED); 473 473 return EOK; 474 474 } … … 516 516 /* Step 4: */ 517 517 dp_rcr_reg = 0; 518 if (dep->de_flags & 518 if (dep->de_flags &DEF_PROMISC) 519 519 dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM; 520 if (dep->de_flags & 520 if (dep->de_flags &DEF_BROAD) 521 521 dp_rcr_reg |= RCR_AB; 522 if (dep->de_flags & 522 if (dep->de_flags &DEF_MULTI) 523 523 dp_rcr_reg |= RCR_AM; 524 524 outb_reg0(dep, DP_RCR, dp_rcr_reg); … … 621 621 622 622 dp_rcr_reg = 0; 623 if (dep->de_flags & 623 if (dep->de_flags &DEF_PROMISC) 624 624 dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM; 625 if (dep->de_flags & 625 if (dep->de_flags &DEF_BROAD) 626 626 dp_rcr_reg |= RCR_AB; 627 if (dep->de_flags & 627 if (dep->de_flags &DEF_MULTI) 628 628 dp_rcr_reg |= RCR_AM; 629 629 outb_reg0(dep, DP_RCR, dp_rcr_reg); … … 642 642 outb_reg0(dep, DP_RBCR0, 0); 643 643 outb_reg0(dep, DP_RBCR1, 0); 644 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) & 644 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) &ISR_RST) == 0); i++) 645 645 ; /* Do nothing */ 646 646 outb_reg0(dep, DP_TCR, TCR_1EXTERNAL|TCR_OFST); … … 649 649 650 650 /* Acknowledge the ISR_RDC (remote dma) interrupt. */ 651 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) & 651 for (i= 0; i < 0x1000 && ((inb_reg0(dep, DP_ISR) &ISR_RDC) == 0); i++) 652 652 ; /* Do nothing */ 653 outb_reg0(dep, DP_ISR, inb_reg0(dep, DP_ISR) & 653 outb_reg0(dep, DP_ISR, inb_reg0(dep, DP_ISR) &~ISR_RDC); 654 654 655 655 /* Reset the transmit ring. If we were transmitting a packet, we … … 674 674 int size, sendq_tail; 675 675 676 if (!(dep->de_flags & 676 if (!(dep->de_flags &DEF_ENABLED)) 677 677 panic("", "dp8390: got premature interrupt", NO_NUM); 678 678 … … 683 683 break; 684 684 outb_reg0(dep, DP_ISR, isr); 685 if (isr & 686 { 687 if (isr & 685 if (isr &(ISR_PTX|ISR_TXE)) 686 { 687 if (isr &ISR_TXE) 688 688 { 689 689 #if DEBUG 690 { printf("%s: got send Error\n", dep->de_name);}690 {printf("%s: got send Error\n", dep->de_name);} 691 691 #endif 692 692 dep->de_stat.ets_sendErr++; … … 696 696 tsr = inb_reg0(dep, DP_TSR); 697 697 698 if (tsr & 698 if (tsr &TSR_PTX) dep->de_stat.ets_packetT++; 699 699 #if 0 /* Reserved in later manuals, should be ignored */ 700 if (!(tsr & 700 if (!(tsr &TSR_DFR)) 701 701 { 702 702 /* In most (all?) implementations of … … 707 707 } 708 708 #endif 709 if (tsr & 710 if (tsr & 711 if (tsr & 712 if (tsr & 709 if (tsr &TSR_COL) dep->de_stat.ets_collision++; 710 if (tsr &TSR_ABT) dep->de_stat.ets_transAb++; 711 if (tsr &TSR_CRS) dep->de_stat.ets_carrSense++; 712 if (tsr &TSR_FU 713 713 && ++dep->de_stat.ets_fifoUnder <= 10) 714 714 { … … 716 716 dep->de_name); 717 717 } 718 if (tsr & 718 if (tsr &TSR_CDH 719 719 && ++dep->de_stat.ets_CDheartbeat <= 10) 720 720 { … … 722 722 dep->de_name); 723 723 } 724 if (tsr & 724 if (tsr &TSR_OWC) dep->de_stat.ets_OWC++; 725 725 } 726 726 sendq_tail= dep->de_sendq_tail; … … 747 747 dep->de_sendq[sendq_tail].sq_sendpage); 748 748 outb_reg0(dep, DP_TBCR1, size >> 8); 749 outb_reg0(dep, DP_TBCR0, size & 749 outb_reg0(dep, DP_TBCR0, size &0xff); 750 750 outb_reg0(dep, DP_CR, CR_TXP | CR_EXTRA); 751 751 } 752 // if (dep->de_flags & 752 // if (dep->de_flags &DEF_SEND_AVAIL) 753 753 dp_send(dep); 754 754 } 755 755 756 if (isr & 756 if (isr &ISR_PRX) 757 757 { 758 758 /* Only call dp_recv if there is a read request */ 759 // if (dep->de_flags) & 759 // if (dep->de_flags) &DEF_READING) 760 760 dp_recv(dep); 761 761 } 762 762 763 if (isr & 764 if (isr & 763 if (isr &ISR_RXE) dep->de_stat.ets_recvErr++; 764 if (isr &ISR_CNT) 765 765 { 766 766 dep->de_stat.ets_CRCerr += inb_reg0(dep, DP_CNTR0); … … 768 768 dep->de_stat.ets_missedP += inb_reg0(dep, DP_CNTR2); 769 769 } 770 if (isr & 770 if (isr &ISR_OVW) 771 771 { 772 772 dep->de_stat.ets_OVW++; 773 773 #if 0 774 { 775 "%s: got overwrite warning\n", dep->de_name); 774 {printW(); printf( 775 "%s: got overwrite warning\n", dep->de_name);} 776 776 #endif 777 /* if (dep->de_flags & 777 /* if (dep->de_flags &DEF_READING) 778 778 { 779 779 printf( … … 782 782 } 783 783 */ } 784 if (isr & 784 if (isr &ISR_RDC) 785 785 { 786 786 /* Nothing to do */ 787 787 } 788 if (isr & 788 if (isr &ISR_RST) 789 789 { 790 790 /* this means we got an interrupt but the ethernet … … 794 794 */ 795 795 #if 0 796 { 797 "%s: NIC stopped\n", dep->de_name); 796 {printW(); printf( 797 "%s: NIC stopped\n", dep->de_name);} 798 798 #endif 799 799 dep->de_flags |= DEF_STOPPED; … … 802 802 isr = inb_reg0(dep, DP_ISR); 803 803 } 804 // if ((dep->de_flags & 804 // if ((dep->de_flags &(DEF_READING|DEF_STOPPED)) == 805 805 // (DEF_READING|DEF_STOPPED)) 806 if ((dep->de_flags & DEF_STOPPED) == DEF_STOPPED)806 if ((dep->de_flags &DEF_STOPPED) == DEF_STOPPED) 807 807 { 808 808 /* The chip is stopped, and all arrived packets are … … 874 874 dep->de_stat.ets_packetR++; 875 875 } 876 */ else if (header.dr_status & 876 */ else if (header.dr_status &RSR_FO) 877 877 { 878 878 /* This is very serious, so we issue a warning and … … 883 883 next = curr; 884 884 } 885 else if ((header.dr_status & RSR_PRX) &&886 (dep->de_flags & 885 else if ((header.dr_status &RSR_PRX) && 886 (dep->de_flags &DEF_ENABLED)) 887 887 { 888 888 // if (dep->de_safecopy_read) … … 914 914 packet_t packet; 915 915 916 // if (!(dep->de_flags & 916 // if (!(dep->de_flags &DEF_SEND_AVAIL)) 917 917 // return; 918 918 919 if( dep->packet_queue){919 if(dep->packet_queue){ 920 920 packet = dep->packet_queue; 921 dep->packet_queue = pq_detach( packet);922 do_pwrite( dep, packet, TRUE);923 netif_pq_release( packet_get_id( packet));921 dep->packet_queue = pq_detach(packet); 922 do_pwrite(dep, packet, TRUE); 923 netif_pq_release(packet_get_id(packet)); 924 924 -- dep->packet_count; 925 925 } 926 // if( ! dep->packet_queue){926 // if(! dep->packet_queue){ 927 927 // dep->de_flags &= ~DEF_SEND_AVAIL; 928 928 // } … … 967 967 { 968 968 offset = page * DP_PAGESIZE + offset; 969 outb_reg0(dep, DP_RBCR0, size & 969 outb_reg0(dep, DP_RBCR0, size &0xFF); 970 970 outb_reg0(dep, DP_RBCR1, size >> 8); 971 outb_reg0(dep, DP_RSAR0, offset & 971 outb_reg0(dep, DP_RSAR0, offset &0xFF); 972 972 outb_reg0(dep, DP_RSAR1, offset >> 8); 973 973 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 987 987 { 988 988 offset = page * DP_PAGESIZE + offset; 989 outb_reg0(dep, DP_RBCR0, size & 989 outb_reg0(dep, DP_RBCR0, size &0xFF); 990 990 outb_reg0(dep, DP_RBCR1, size >> 8); 991 outb_reg0(dep, DP_RSAR0, offset & 991 outb_reg0(dep, DP_RSAR0, offset &0xFF); 992 992 outb_reg0(dep, DP_RSAR1, offset >> 8); 993 993 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); 994 994 995 assert (!(size & 995 assert (!(size &1)); 996 996 insw(dep->de_data_port, dst, size); 997 997 } … … 1005 1005 { 1006 1006 int last, count; 1007 packet_t 1008 1009 // if (!(dep->de_flags & 1007 packet_t packet; 1008 1009 // if (!(dep->de_flags &DEF_READING)) 1010 1010 // return EGENERIC; 1011 1011 1012 packet = netif_packet_get_1( length ); 1013 if( ! packet ) return ENOMEM; 1014 dep->de_read_iovec.iod_iovec[0].iov_addr = ( vir_bytes ) packet_suffix( packet, length ); 1012 packet = netif_packet_get_1(length); 1013 if(! packet){ 1014 return ENOMEM; 1015 } 1016 dep->de_read_iovec.iod_iovec[0].iov_addr = (vir_bytes) packet_suffix(packet, length); 1015 1017 dep->de_read_iovec.iod_iovec[0].iov_size = length; 1016 1018 dep->de_read_iovec.iod_iovec_s = 1; … … 1028 1030 sizeof(dp_rcvhdr_t), &dep->de_tmp_iovec, 0, count); 1029 1031 (dep->de_nic2userf)(dep, dep->de_startpage * DP_PAGESIZE, 1030 1032 &dep->de_read_iovec, count, length - count); 1031 1033 } 1032 1034 else … … 1040 1042 // dep->de_flags &= ~DEF_READING; 1041 1043 1042 if( dep->received_count >= MAX_PACKETS){1043 netif_pq_release( packet_get_id( packet));1044 if(dep->received_count >= MAX_PACKETS){ 1045 netif_pq_release(packet_get_id(packet)); 1044 1046 return ELIMIT; 1045 1047 }else{ 1046 if( pq_add( & dep->received_queue, packet, 0, 0 ) == EOK){1048 if(pq_add(&dep->received_queue, packet, 0, 0) == EOK){ 1047 1049 ++ dep->received_count; 1048 1050 }else{ 1049 netif_pq_release( packet_get_id( packet));1051 netif_pq_release(packet_get_id(packet)); 1050 1052 } 1051 1053 } … … 1119 1121 outb_reg0(dep, DP_ISR, ISR_RDC); 1120 1122 1121 outb_reg0(dep, DP_RBCR0, count & 1123 outb_reg0(dep, DP_RBCR0, count &0xFF); 1122 1124 outb_reg0(dep, DP_RBCR1, count >> 8); 1123 outb_reg0(dep, DP_RSAR0, nic_addr & 1125 outb_reg0(dep, DP_RSAR0, nic_addr &0xFF); 1124 1126 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1125 1127 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); … … 1154 1156 for (i= 0; i<100; i++) 1155 1157 { 1156 if (inb_reg0(dep, DP_ISR) & 1158 if (inb_reg0(dep, DP_ISR) &ISR_RDC) 1157 1159 break; 1158 1160 } … … 1181 1183 int odd_byte; 1182 1184 1183 ecount= (count+1) & 1185 ecount= (count+1) &~1; 1184 1186 odd_byte= 0; 1185 1187 1186 1188 outb_reg0(dep, DP_ISR, ISR_RDC); 1187 outb_reg0(dep, DP_RBCR0, ecount & 1189 outb_reg0(dep, DP_RBCR0, ecount &0xFF); 1188 1190 outb_reg0(dep, DP_RBCR1, ecount >> 8); 1189 outb_reg0(dep, DP_RSAR0, nic_addr & 1191 outb_reg0(dep, DP_RSAR0, nic_addr &0xFF); 1190 1192 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1191 1193 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); … … 1234 1236 continue; 1235 1237 } 1236 ecount= bytes & 1238 ecount= bytes &~1; 1237 1239 if (ecount != 0) 1238 1240 { … … 1271 1273 for (i= 0; i<100; i++) 1272 1274 { 1273 if (inb_reg0(dep, DP_ISR) & 1275 if (inb_reg0(dep, DP_ISR) &ISR_RDC) 1274 1276 break; 1275 1277 } … … 1343 1345 vir_bytes bytes; 1344 1346 1345 outb_reg0(dep, DP_RBCR0, count & 1347 outb_reg0(dep, DP_RBCR0, count &0xFF); 1346 1348 outb_reg0(dep, DP_RBCR1, count >> 8); 1347 outb_reg0(dep, DP_RSAR0, nic_addr & 1349 outb_reg0(dep, DP_RSAR0, nic_addr &0xFF); 1348 1350 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1349 1351 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 1395 1397 int odd_byte; 1396 1398 1397 ecount= (count+1) & 1399 ecount= (count+1) &~1; 1398 1400 odd_byte= 0; 1399 1401 1400 outb_reg0(dep, DP_RBCR0, ecount & 1402 outb_reg0(dep, DP_RBCR0, ecount &0xFF); 1401 1403 outb_reg0(dep, DP_RBCR1, ecount >> 8); 1402 outb_reg0(dep, DP_RSAR0, nic_addr & 1404 outb_reg0(dep, DP_RSAR0, nic_addr &0xFF); 1403 1405 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1404 1406 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 1445 1447 continue; 1446 1448 } 1447 ecount= bytes & 1449 ecount= bytes &~1; 1448 1450 if (ecount != 0) 1449 1451 { … … 1502 1504 dpeth_t *dep; 1503 1505 { 1504 // static eth_stat_t empty_stat = {0, 0, 0, 0, 0, 0 /* ,... */ 1506 // static eth_stat_t empty_stat = {0, 0, 0, 0, 0, 0 /* ,... */}; 1505 1507 1506 1508 // int ifnr; … … 1551 1553 return; 1552 1554 }else{ 1553 printf( "map_hw_buffer: no buffer!\n");1555 printf("map_hw_buffer: no buffer!\n"); 1554 1556 } 1555 1557 … … 1584 1586 1585 1587 status = 0; 1586 if (dep->de_flags & 1588 if (dep->de_flags &DEF_PACK_SEND) 1587 1589 status |= DL_PACK_SEND; 1588 if (dep->de_flags & 1590 if (dep->de_flags &DEF_PACK_RECV) 1589 1591 status |= DL_PACK_RECV; 1590 1592 … … 1633 1635 size_t i; 1634 1636 1635 for( i = 0; i < size; ++ i){1636 *(( uint8_t * ) buf + i ) = inb( port);1637 for(i = 0; i < size; ++ i){ 1638 *((uint8_t *) buf + i) = inb(port); 1637 1639 } 1638 1640 } … … 1642 1644 size_t i; 1643 1645 1644 for( i = 0; i * 2 < size; ++ i){1645 *(( uint16_t * ) buf + i ) = inw( port);1646 for(i = 0; i * 2 < size; ++ i){ 1647 *((uint16_t *) buf + i) = inw(port); 1646 1648 } 1647 1649 } … … 1651 1653 size_t i; 1652 1654 1653 for( i = 0; i < size; ++ i){1654 outb( port, *(( uint8_t * ) buf + i));1655 for(i = 0; i < size; ++ i){ 1656 outb(port, *((uint8_t *) buf + i)); 1655 1657 } 1656 1658 } … … 1660 1662 size_t i; 1661 1663 1662 for( i = 0; i * 2 < size; ++ i){1663 outw( port, *(( uint16_t * ) buf + i));1664 for(i = 0; i * 2 < size; ++ i){ 1665 outw(port, *((uint16_t *) buf + i)); 1664 1666 } 1665 1667 }
Note:
See TracChangeset
for help on using the changeset viewer.