Changeset 66b628a in mainline
- 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
- Location:
- uspace/srv/hw/netif/dp8390
- Files:
-
- 6 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; -
uspace/srv/hw/netif/dp8390/dp8390.h
re3fe7df r66b628a 89 89 90 90 /** Page 1, read/write */ 91 #define DP_PAR0 0x1 /* Physical Address Register 0*/92 #define DP_PAR1 0x2 /* Physical Address Register 1*/93 #define DP_PAR2 0x3 /* Physical Address Register 2*/94 #define DP_PAR3 0x4 /* Physical Address Register 3*/95 #define DP_PAR4 0x5 /* Physical Address Register 4*/96 #define DP_PAR5 0x6 /* Physical Address Register 5*/97 #define DP_CURR 0x7 /* Current Page Register*/98 #define DP_MAR0 0x8 /* Multicast Address Register 0*/99 #define DP_MAR1 0x9 /* Multicast Address Register 1*/100 #define DP_MAR2 0xA /* Multicast Address Register 2*/101 #define DP_MAR3 0xB /* Multicast Address Register 3*/102 #define DP_MAR4 0xC /* Multicast Address Register 4*/103 #define DP_MAR5 0xD /* Multicast Address Register 5*/104 #define DP_MAR6 0xE /* Multicast Address Register 6*/105 #define DP_MAR7 0xF /* Multicast Address Register 7*/91 #define DP_PAR0 0x01 /**< Physical Address Register 0 */ 92 #define DP_PAR1 0x02 /**< Physical Address Register 1 */ 93 #define DP_PAR2 0x03 /**< Physical Address Register 2 */ 94 #define DP_PAR3 0x04 /**< Physical Address Register 3 */ 95 #define DP_PAR4 0x05 /**< Physical Address Register 4 */ 96 #define DP_PAR5 0x06 /**< Physical Address Register 5 */ 97 #define DP_CURR 0x07 /**< Current Page Register */ 98 #define DP_MAR0 0x08 /**< Multicast Address Register 0 */ 99 #define DP_MAR1 0x09 /**< Multicast Address Register 1 */ 100 #define DP_MAR2 0x0a /**< Multicast Address Register 2 */ 101 #define DP_MAR3 0x0b /**< Multicast Address Register 3 */ 102 #define DP_MAR4 0x0c /**< Multicast Address Register 4 */ 103 #define DP_MAR5 0x0d /**< Multicast Address Register 5 */ 104 #define DP_MAR6 0x0e /**< Multicast Address Register 6 */ 105 #define DP_MAR7 0x0f /**< Multicast Address Register 7 */ 106 106 107 107 /* Bits in dp_cr */ … … 271 271 dp_initf_t de_initf; 272 272 dp_stopf_t de_stopf; 273 char de_name[sizeof("dp8390#n")];274 273 275 274 /* … … 300 299 301 300 /* Fields for internal use by the dp8390 driver. */ 302 int de_flags;303 int de_mode;304 301 eth_stat_t de_stat; 305 302 dp_user2nicf_t de_user2nicf; … … 308 305 309 306 /* Driver flags */ 307 bool up; 308 bool enabled; 309 bool stopped; 310 310 bool sending; 311 311 bool send_avail; 312 312 } dpeth_t; 313 313 314 #define DEF_PROMISC 0x040315 #define DEF_MULTI 0x080316 #define DEF_BROAD 0x100317 #define DEF_ENABLED 0x200318 #define DEF_STOPPED 0x400319 320 #define DEM_DISABLED 0x0321 #define DEM_ENABLED 0x2322 323 314 #endif 324 315 -
uspace/srv/hw/netif/dp8390/dp8390_drv.h
re3fe7df r66b628a 40 40 #include "dp8390.h" 41 41 42 /** Initializes and/or starts the network interface. 43 * @param[in,out] dep The network interface structure. 44 * @param[in] mode The state mode. 45 * @returns EOK on success. 46 * @returns EXDEV if the network interface is disabled. 47 */ 48 int do_init(dpeth_t *dep, int mode); 42 int do_init(dpeth_t *dep); 49 43 50 44 /** Stops the network interface. -
uspace/srv/hw/netif/dp8390/dp8390_module.c
re3fe7df r66b628a 130 130 fibril_rwlock_write_unlock(&netif_globals.lock); 131 131 132 if ((dep != NULL) && (dep-> de_mode == DEM_ENABLED)) {133 assert(dep-> de_flags & DEF_ENABLED);132 if ((dep != NULL) && (dep->up)) { 133 assert(dep->enabled); 134 134 dp_check_ints(nil_phone, device_id, dep, IRQ_GET_ISR(*call)); 135 135 } … … 233 233 device->state = NETIF_STOPPED; 234 234 dep->de_irq = irq; 235 dep-> de_mode = DEM_DISABLED;235 dep->up = false; 236 236 237 237 //TODO address? … … 306 306 return rc; 307 307 308 rc = do_init(dep , DL_BROAD_REQ);308 rc = do_init(dep); 309 309 if (rc != EOK) { 310 310 ipc_unregister_irq(dep->de_irq, device->device_id); -
uspace/srv/hw/netif/dp8390/dp8390_port.h
re3fe7df r66b628a 78 78 #define outw(port, value) pio_write_16((ioport16_t *) (port), (value)) 79 79 80 /* Bits in 'DL_MODE' field of DL requests. */81 #define DL_NOMODE 0x082 #define DL_PROMISC_REQ 0x283 #define DL_MULTI_REQ 0x484 #define DL_BROAD_REQ 0x885 86 80 /** Type definition of a port. 87 81 */ -
uspace/srv/hw/netif/dp8390/ne2000.c
re3fe7df r66b628a 206 206 dep->de_stoppage = dep->de_offset_page + dep->de_ramsize / DP_PAGESIZE; 207 207 208 printf(" %s:Novell NE%d000 ethernet card at I/O address "208 printf("Novell NE%d000 ethernet card at I/O address " 209 209 "%#lx, memory size %#lx, irq %d\n", 210 dep->de_ name, dep->de_16bit ? 2 : 1,211 dep->de_ base_port, dep->de_ramsize, dep->de_irq);210 dep->de_16bit ? 2 : 1, dep->de_base_port, dep->de_ramsize, 211 dep->de_irq); 212 212 } 213 213 … … 235 235 236 236 if (i == N) { 237 printf(" %s: NE1000 remote DMA test failed\n", dep->de_name);237 printf("NE1000 remote DMA test failed\n"); 238 238 return 0; 239 239 } … … 274 274 275 275 if (i == N) { 276 printf(" %s: NE2000 remote DMA test failed\n", dep->de_name);276 printf("NE2000 remote DMA test failed\n"); 277 277 return 0; 278 278 }
Note:
See TracChangeset
for help on using the changeset viewer.