Changes in uspace/srv/net/netif/dp8390/dp8390.c [aadf01e:1e2e0c1e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/netif/dp8390/dp8390.c
raadf01e r1e2e0c1e 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 /* { 0x280, 3, 0xD0000, "DPETH0" },101 { 0x300, 5, 0xC8000, "DPETH1" },102 { 0x380, 10, 0xD8000, "DPETH2" },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( static void pci_conf, (void) );128 //_PROTOTYPE( static void pci_conf, (void) ); 129 129 //#endif 130 //_PROTOTYPE( static void do_vwrite, (message *mp, int from_int,130 //_PROTOTYPE( static void do_vwrite, (message *mp, int from_int, 131 131 // int vectored) ); 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,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( static void dp_pio8_getblock, (dpeth_t *dep, int page,151 _PROTOTYPE( static void dp_pio8_getblock, (dpeth_t *dep, int page, 152 152 size_t offset, size_t size, void *dst) ); 153 _PROTOTYPE( static void dp_pio16_getblock, (dpeth_t *dep, int page,153 _PROTOTYPE( static void dp_pio16_getblock, (dpeth_t *dep, int page, 154 154 size_t offset, size_t size, void *dst) ); 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,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( 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,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( static void dp_pio8_user2nic, (dpeth_t *dep,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( static void dp_pio8_user2nic_s, (dpeth_t *dep,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( static void dp_pio16_user2nic, (dpeth_t *dep,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( static void dp_pio16_user2nic_s, (dpeth_t *dep,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( static void dp_nic2user, (dpeth_t *dep, int nic_addr,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( static void dp_nic2user_s, (dpeth_t *dep, int nic_addr,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( static void dp_pio8_nic2user, (dpeth_t *dep, int nic_addr,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( static void dp_pio8_nic2user_s, (dpeth_t *dep, int nic_addr,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( static void dp_pio16_nic2user, (dpeth_t *dep, int nic_addr,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( static void dp_pio16_nic2user_s, (dpeth_t *dep, int nic_addr,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( 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,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( static void get_userdata_s, (int user_proc,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( static void put_userdata, (int user_proc,201 //_PROTOTYPE( static void put_userdata, (int user_proc, 202 202 // vir_bytes user_addr, vir_bytes count, void *loc_addr) ); 203 //_PROTOTYPE( static void put_userdata_s, (int user_proc,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( 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,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( static void do_vir_insw, (port_t port, int proc,209 //_PROTOTYPE( static void do_vir_insw, (port_t port, int proc, 210 210 // vir_bytes buf, size_t size) ); 211 //_PROTOTYPE( static void do_vir_outsb, (port_t port, int proc,211 //_PROTOTYPE( static void do_vir_outsb, (port_t port, int proc, 212 212 // vir_bytes buf, size_t size) ); 213 //_PROTOTYPE( static void do_vir_outsw, (port_t port, int proc,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 & DEF_ENABLED);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 & DL_PROMISC_REQ)309 if (mode & DL_PROMISC_REQ) 310 310 dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD; 311 if (mode & DL_MULTI_REQ)311 if (mode & DL_MULTI_REQ) 312 312 dep->de_flags |= DEF_MULTI; 313 if (mode & DL_BROAD_REQ)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 & DEF_ENABLED);389 if( dep->packet_queue && (! from_int)){390 // if (dep->de_flags & DEF_SEND_AVAIL){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 & DEF_PACK_SEND));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 & 0xff);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 & DEF_ENABLED);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 & DEF_PROMISC)518 if (dep->de_flags & DEF_PROMISC) 519 519 dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM; 520 if (dep->de_flags & DEF_BROAD)520 if (dep->de_flags & DEF_BROAD) 521 521 dp_rcr_reg |= RCR_AB; 522 if (dep->de_flags & DEF_MULTI)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 & DEF_PROMISC)623 if (dep->de_flags & DEF_PROMISC) 624 624 dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM; 625 if (dep->de_flags & DEF_BROAD)625 if (dep->de_flags & DEF_BROAD) 626 626 dp_rcr_reg |= RCR_AB; 627 if (dep->de_flags & DEF_MULTI)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) & ISR_RST) == 0); i++)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) & ISR_RDC) == 0); i++)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) & ~ISR_RDC);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 & DEF_ENABLED))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 & (ISR_PTX|ISR_TXE))686 { 687 if (isr & ISR_TXE)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 & TSR_PTX) dep->de_stat.ets_packetT++;698 if (tsr & TSR_PTX) dep->de_stat.ets_packetT++; 699 699 #if 0 /* Reserved in later manuals, should be ignored */ 700 if (!(tsr & TSR_DFR))700 if (!(tsr & TSR_DFR)) 701 701 { 702 702 /* In most (all?) implementations of … … 707 707 } 708 708 #endif 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_FU709 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 & TSR_CDH718 if (tsr & TSR_CDH 719 719 && ++dep->de_stat.ets_CDheartbeat <= 10) 720 720 { … … 722 722 dep->de_name); 723 723 } 724 if (tsr & TSR_OWC) dep->de_stat.ets_OWC++;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 & 0xff);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 & DEF_SEND_AVAIL)752 // if (dep->de_flags & DEF_SEND_AVAIL) 753 753 dp_send(dep); 754 754 } 755 755 756 if (isr & ISR_PRX)756 if (isr & ISR_PRX) 757 757 { 758 758 /* Only call dp_recv if there is a read request */ 759 // if (dep->de_flags) & DEF_READING)759 // if (dep->de_flags) & DEF_READING) 760 760 dp_recv(dep); 761 761 } 762 762 763 if (isr & ISR_RXE) dep->de_stat.ets_recvErr++;764 if (isr & ISR_CNT)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 & ISR_OVW)770 if (isr & ISR_OVW) 771 771 { 772 772 dep->de_stat.ets_OVW++; 773 773 #if 0 774 { printW(); printf(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 & DEF_READING)777 /* if (dep->de_flags & DEF_READING) 778 778 { 779 779 printf( … … 782 782 } 783 783 */ } 784 if (isr & ISR_RDC)784 if (isr & ISR_RDC) 785 785 { 786 786 /* Nothing to do */ 787 787 } 788 if (isr & ISR_RST)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 { printW(); printf(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 & (DEF_READING|DEF_STOPPED)) ==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 & RSR_FO)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 & DEF_ENABLED))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 & DEF_SEND_AVAIL))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 & 0xFF);969 outb_reg0(dep, DP_RBCR0, size & 0xFF); 970 970 outb_reg0(dep, DP_RBCR1, size >> 8); 971 outb_reg0(dep, DP_RSAR0, offset & 0xFF);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 & 0xFF);989 outb_reg0(dep, DP_RBCR0, size & 0xFF); 990 990 outb_reg0(dep, DP_RBCR1, size >> 8); 991 outb_reg0(dep, DP_RSAR0, offset & 0xFF);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 & 1));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 & DEF_READING))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){ 1014 return ENOMEM; 1015 } 1016 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 ) return ENOMEM; 1014 dep->de_read_iovec.iod_iovec[0].iov_addr = ( vir_bytes ) packet_suffix( packet, length ); 1017 1015 dep->de_read_iovec.iod_iovec[0].iov_size = length; 1018 1016 dep->de_read_iovec.iod_iovec_s = 1; … … 1030 1028 sizeof(dp_rcvhdr_t), &dep->de_tmp_iovec, 0, count); 1031 1029 (dep->de_nic2userf)(dep, dep->de_startpage * DP_PAGESIZE, 1032 &dep->de_read_iovec, count, length - count);1030 &dep->de_read_iovec, count, length - count); 1033 1031 } 1034 1032 else … … 1042 1040 // dep->de_flags &= ~DEF_READING; 1043 1041 1044 if( dep->received_count >= MAX_PACKETS){1045 netif_pq_release( packet_get_id(packet));1042 if( dep->received_count >= MAX_PACKETS ){ 1043 netif_pq_release( packet_get_id( packet )); 1046 1044 return ELIMIT; 1047 1045 }else{ 1048 if( pq_add(&dep->received_queue, packet, 0, 0) == EOK){1046 if( pq_add( & dep->received_queue, packet, 0, 0 ) == EOK ){ 1049 1047 ++ dep->received_count; 1050 1048 }else{ 1051 netif_pq_release( packet_get_id(packet));1049 netif_pq_release( packet_get_id( packet )); 1052 1050 } 1053 1051 } … … 1121 1119 outb_reg0(dep, DP_ISR, ISR_RDC); 1122 1120 1123 outb_reg0(dep, DP_RBCR0, count & 0xFF);1121 outb_reg0(dep, DP_RBCR0, count & 0xFF); 1124 1122 outb_reg0(dep, DP_RBCR1, count >> 8); 1125 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF);1123 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF); 1126 1124 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1127 1125 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); … … 1156 1154 for (i= 0; i<100; i++) 1157 1155 { 1158 if (inb_reg0(dep, DP_ISR) & ISR_RDC)1156 if (inb_reg0(dep, DP_ISR) & ISR_RDC) 1159 1157 break; 1160 1158 } … … 1183 1181 int odd_byte; 1184 1182 1185 ecount= (count+1) & ~1;1183 ecount= (count+1) & ~1; 1186 1184 odd_byte= 0; 1187 1185 1188 1186 outb_reg0(dep, DP_ISR, ISR_RDC); 1189 outb_reg0(dep, DP_RBCR0, ecount & 0xFF);1187 outb_reg0(dep, DP_RBCR0, ecount & 0xFF); 1190 1188 outb_reg0(dep, DP_RBCR1, ecount >> 8); 1191 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF);1189 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF); 1192 1190 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1193 1191 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); … … 1236 1234 continue; 1237 1235 } 1238 ecount= bytes & ~1;1236 ecount= bytes & ~1; 1239 1237 if (ecount != 0) 1240 1238 { … … 1273 1271 for (i= 0; i<100; i++) 1274 1272 { 1275 if (inb_reg0(dep, DP_ISR) & ISR_RDC)1273 if (inb_reg0(dep, DP_ISR) & ISR_RDC) 1276 1274 break; 1277 1275 } … … 1345 1343 vir_bytes bytes; 1346 1344 1347 outb_reg0(dep, DP_RBCR0, count & 0xFF);1345 outb_reg0(dep, DP_RBCR0, count & 0xFF); 1348 1346 outb_reg0(dep, DP_RBCR1, count >> 8); 1349 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF);1347 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF); 1350 1348 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1351 1349 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 1397 1395 int odd_byte; 1398 1396 1399 ecount= (count+1) & ~1;1397 ecount= (count+1) & ~1; 1400 1398 odd_byte= 0; 1401 1399 1402 outb_reg0(dep, DP_RBCR0, ecount & 0xFF);1400 outb_reg0(dep, DP_RBCR0, ecount & 0xFF); 1403 1401 outb_reg0(dep, DP_RBCR1, ecount >> 8); 1404 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF);1402 outb_reg0(dep, DP_RSAR0, nic_addr & 0xFF); 1405 1403 outb_reg0(dep, DP_RSAR1, nic_addr >> 8); 1406 1404 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); … … 1447 1445 continue; 1448 1446 } 1449 ecount= bytes & ~1;1447 ecount= bytes & ~1; 1450 1448 if (ecount != 0) 1451 1449 { … … 1504 1502 dpeth_t *dep; 1505 1503 { 1506 // static eth_stat_t empty_stat = {0, 0, 0, 0, 0, 0 /* ,... */ };1504 // static eth_stat_t empty_stat = {0, 0, 0, 0, 0, 0 /* ,... */ }; 1507 1505 1508 1506 // int ifnr; … … 1553 1551 return; 1554 1552 }else{ 1555 printf( "map_hw_buffer: no buffer!\n");1553 printf( "map_hw_buffer: no buffer!\n" ); 1556 1554 } 1557 1555 … … 1586 1584 1587 1585 status = 0; 1588 if (dep->de_flags & DEF_PACK_SEND)1586 if (dep->de_flags & DEF_PACK_SEND) 1589 1587 status |= DL_PACK_SEND; 1590 if (dep->de_flags & DEF_PACK_RECV)1588 if (dep->de_flags & DEF_PACK_RECV) 1591 1589 status |= DL_PACK_RECV; 1592 1590 … … 1635 1633 size_t i; 1636 1634 1637 for( i = 0; i < size; ++ i){1638 *(( uint8_t *) buf + i) = inb(port);1635 for( i = 0; i < size; ++ i ){ 1636 *(( uint8_t * ) buf + i ) = inb( port ); 1639 1637 } 1640 1638 } … … 1644 1642 size_t i; 1645 1643 1646 for( i = 0; i * 2 < size; ++ i){1647 *(( uint16_t *) buf + i) = inw(port);1644 for( i = 0; i * 2 < size; ++ i ){ 1645 *(( uint16_t * ) buf + i ) = inw( port ); 1648 1646 } 1649 1647 } … … 1653 1651 size_t i; 1654 1652 1655 for( i = 0; i < size; ++ i){1656 outb( port, *((uint8_t *) buf + i));1653 for( i = 0; i < size; ++ i ){ 1654 outb( port, *(( uint8_t * ) buf + i )); 1657 1655 } 1658 1656 } … … 1662 1660 size_t i; 1663 1661 1664 for( i = 0; i * 2 < size; ++ i){1665 outw( port, *((uint16_t *) buf + i));1662 for( i = 0; i * 2 < size; ++ i ){ 1663 outw( port, *(( uint16_t * ) buf + i )); 1666 1664 } 1667 1665 }
Note:
See TracChangeset
for help on using the changeset viewer.