Changeset 66b628a in mainline for uspace/srv/hw/netif/dp8390/dp8390.c
- Timestamp:
- 2011-01-06T23:23:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7922dea
- Parents:
- e3fe7df
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/dp8390.c
re3fe7df r66b628a 102 102 /* This is the default, try to (re)locate the device. */ 103 103 conf_hw(dep); 104 if ( dep->de_mode == DEM_DISABLED)104 if (!dep->up) 105 105 /* Probe failed, or the device is configured off. */ 106 106 return EXDEV; 107 107 108 if (dep-> de_mode == DEM_ENABLED)108 if (dep->up) 109 109 dp_init(dep); 110 110 … … 112 112 } 113 113 114 int do_init(dpeth_t *dep, int mode) 115 { 116 if (dep->de_mode == DEM_DISABLED) 114 /** Initialize and/or start the network interface. 115 * 116 * @param[in,out] dep The network interface structure. 117 * 118 * @return EOK on success. 119 * @return EXDEV if the network interface is disabled. 120 * 121 */ 122 int do_init(dpeth_t *dep) 123 { 124 if (!dep->up) 117 125 /* FIXME: Perhaps call do_probe()? */ 118 126 return EXDEV; 119 127 120 assert(dep->de_mode == DEM_ENABLED); 121 assert(dep->de_flags & DEF_ENABLED); 122 123 dep->de_flags &= ~(DEF_PROMISC | DEF_MULTI | DEF_BROAD); 124 125 if (mode &DL_PROMISC_REQ) 126 dep->de_flags |= DEF_PROMISC | DEF_MULTI | DEF_BROAD; 127 128 if (mode &DL_MULTI_REQ) 129 dep->de_flags |= DEF_MULTI; 130 131 if (mode &DL_BROAD_REQ) 132 dep->de_flags |= DEF_BROAD; 128 assert(dep->up); 129 assert(dep->enabled); 133 130 134 131 dp_reinit(dep); … … 138 135 void do_stop(dpeth_t *dep) 139 136 { 140 if ((dep->de_mode == DEM_ENABLED) 141 && (dep->de_flags & DEF_ENABLED)) { 137 if ((dep->up) && (dep->enabled)) { 142 138 outb_reg0(dep, DP_CR, CR_STP | CR_DM_ABORT); 143 139 (dep->de_stopf)(dep); 140 dep->enabled = false; 141 dep->stopped = false; 144 142 dep->sending = false; 145 143 dep->send_avail = false; … … 152 150 int sendq_head; 153 151 154 assert(dep-> de_mode == DEM_ENABLED);155 assert(dep-> de_flags & DEF_ENABLED);152 assert(dep->up); 153 assert(dep->enabled); 156 154 157 155 if (dep->send_avail) { … … 213 211 214 212 /* General initialization */ 213 dep->enabled = false; 214 dep->stopped = false; 215 215 dep->sending = false; 216 216 dep->send_avail = false; 217 217 (*dep->de_initf)(dep); 218 218 219 printf(" %s: Ethernet address ", dep->de_name);219 printf("Ethernet address "); 220 220 for (i = 0; i < 6; i++) 221 221 printf("%x%c", dep->de_address.ea_addr[i], i < 5 ? ':' : '\n'); … … 241 241 242 242 /* Step 4: */ 243 dp_rcr_reg = 0; 244 245 if (dep->de_flags & DEF_PROMISC) 246 dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM; 247 248 if (dep->de_flags & DEF_BROAD) 249 dp_rcr_reg |= RCR_AB; 250 251 if (dep->de_flags & DEF_MULTI) 252 dp_rcr_reg |= RCR_AM; 243 dp_rcr_reg = RCR_AB; /* Enable broadcasts */ 253 244 254 245 outb_reg0(dep, DP_RCR, dp_rcr_reg); … … 301 292 302 293 /* Finish the initialization. */ 303 dep-> de_flags |= DEF_ENABLED;294 dep->enabled = true; 304 295 for (i = 0; i < dep->de_sendq_nr; i++) 305 296 dep->de_sendq[i].sq_filled= 0; … … 325 316 outb_reg0(dep, DP_CR, CR_PS_P0 | CR_EXTRA); 326 317 327 dp_rcr_reg = 0; 328 329 if (dep->de_flags & DEF_PROMISC) 330 dp_rcr_reg |= RCR_AB | RCR_PRO | RCR_AM; 331 332 if (dep->de_flags & DEF_BROAD) 333 dp_rcr_reg |= RCR_AB; 334 335 if (dep->de_flags & DEF_MULTI) 336 dp_rcr_reg |= RCR_AM; 318 /* Enable broadcasts */ 319 dp_rcr_reg = RCR_AB; 337 320 338 321 outb_reg0(dep, DP_RCR, dp_rcr_reg); … … 373 356 374 357 dep->send_avail = false; 375 dep-> de_flags &= ~DEF_STOPPED;358 dep->stopped = false; 376 359 } 377 360 … … 389 372 int tsr; 390 373 int size, sendq_tail; 391 392 if (!(dep->de_flags & DEF_ENABLED))393 fprintf(stderr, "dp8390: got premature interrupt\n");394 374 395 375 for (; (isr & 0x7f) != 0; isr = isr_acknowledge(dep)) { … … 413 393 414 394 if ((tsr & TSR_FU) && (++dep->de_stat.ets_fifoUnder <= 10)) 415 printf(" %s: fifo underrun\n", dep->de_name);395 printf("FIFO underrun\n"); 416 396 417 397 if ((tsr & TSR_CDH) && (++dep->de_stat.ets_CDheartbeat <= 10)) 418 printf(" %s: CD heart beat failure\n", dep->de_name);398 printf("CD heart beat failure\n"); 419 399 420 400 if (tsr & TSR_OWC) … … 425 405 426 406 if (!(dep->de_sendq[sendq_tail].sq_filled)) { 427 /* Or hardware bug? */ 428 printf("%s: transmit interrupt, but not sending\n", dep->de_name); 407 printf("PTX interrupt, but no frame to send\n"); 429 408 continue; 430 409 } … … 470 449 if (isr & ISR_RST) { 471 450 /* 472 * This means we got an interrupt but the ethernet 473 * chip is shutdown. We set the flag DEF_STOPPED,451 * This means we got an interrupt but the ethernet 452 * chip is shutdown. We set the flag 'stopped' 474 453 * and continue processing arrived packets. When the 475 454 * receive buffer is empty, we reset the dp8390. 476 455 */ 477 dep-> de_flags |= DEF_STOPPED;456 dep->stopped = true; 478 457 break; 479 458 } 480 459 } 481 460 482 if ( (dep->de_flags & DEF_STOPPED) == DEF_STOPPED) {461 if (dep->stopped) { 483 462 /* 484 * The chip is stopped, and all arrived packets485 * are delivered.463 * The chip is stopped, and all arrived 464 * frames are delivered. 486 465 */ 487 466 dp_reset(dep); … … 518 497 next = header.dr_next; 519 498 if ((length < ETH_MIN_PACK_SIZE) || (length > ETH_MAX_PACK_SIZE_TAGGED)) { 520 printf(" %s: packet with strange length arrived: %d\n", dep->de_name, (int)length);499 printf("Packet with strange length arrived: %zu\n", length); 521 500 next= curr; 522 501 } else if ((next < dep->de_startpage) || (next >= dep->de_stoppage)) { 523 printf(" %s: strange next page\n", dep->de_name);502 printf("Strange next page\n"); 524 503 next= curr; 525 504 } else if (header.dr_status & RSR_FO) { … … 528 507 * reset the buffers 529 508 */ 530 printf(" %s: fifo overrun, resetting receive buffer\n", dep->de_name);509 printf("FIFO overrun, resetting receive buffer\n"); 531 510 dep->de_stat.ets_fifoOver++; 532 511 next = curr; 533 } else if ((header.dr_status & RSR_PRX) && (dep-> de_flags & DEF_ENABLED)) {512 } else if ((header.dr_status & RSR_PRX) && (dep->enabled)) { 534 513 r = dp_pkt2user(nil_phone, device_id, dep, pageno, length); 535 514 if (r != EOK) … … 710 689 { 711 690 if (!ne_probe(dep)) { 712 printf("%s: No ethernet card found at %#lx\n", 713 dep->de_name, dep->de_base_port); 714 dep->de_mode= DEM_DISABLED; 691 printf("No ethernet card found at %#lx\n", dep->de_base_port); 692 dep->up = false; 715 693 return; 716 694 } 717 695 718 dep->de_mode = DEM_ENABLED; 696 dep->up = true; 697 dep->enabled = false; 698 dep->stopped = false; 719 699 dep->sending = false; 720 700 dep->send_avail = false;
Note:
See TracChangeset
for help on using the changeset viewer.