Changeset 506a805 in mainline
- Timestamp:
- 2011-01-06T14:57:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2a6e4ac2
- Parents:
- d3c9b60
- Location:
- uspace/srv/hw/netif/dp8390
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hw/netif/dp8390/dp8390.c
rd3c9b60 r506a805 338 338 (*dep->de_initf)(dep); 339 339 340 if (debug) { 341 printf("%s: Ethernet address ", dep->de_name); 342 for (i = 0; i < 6; i++) 343 printf("%x%c", dep->de_address.ea_addr[i], i < 5 ? ':' : '\n'); 344 } 340 printf("%s: Ethernet address ", dep->de_name); 341 for (i = 0; i < 6; i++) 342 printf("%x%c", dep->de_address.ea_addr[i], i < 5 ? ':' : '\n'); 345 343 346 344 /* … … 516 514 if (isr &ISR_TXE) 517 515 { 518 #if DEBUG519 {printf("%s: got send Error\n", dep->de_name);}520 #endif521 516 dep->de_stat.ets_sendErr++; 522 517 } … … 558 553 { 559 554 /* Software bug? */ 560 assert( !debug);555 assert(false); 561 556 562 557 /* Or hardware bug? */ -
uspace/srv/hw/netif/dp8390/dp8390.h
rd3c9b60 r506a805 351 351 #define DEM_ENABLED 0x2 352 352 353 #define debug 1354 355 353 #endif 356 354 -
uspace/srv/hw/netif/dp8390/ne2000.c
rd3c9b60 r506a805 16 16 #include "ne2000.h" 17 17 18 /** Number of bytes to transfer. 19 */ 20 #define N 100 21 22 /** Sleeps for the defined millicesonds. 23 * @param[in] millis The number of milliseconds to sleep. 24 */ 25 #define milli_delay(millis) usleep((millis) * 1000) 18 /** Number of bytes to transfer */ 19 #define N 100 26 20 27 21 /** Type definition of the testing function. … … 29 23 _PROTOTYPE(typedef int (*testf_t), (dpeth_t *dep, int pos, u8_t *pat) ); 30 24 31 /** First data pattern. 32 */ 33 u8_t pat0[]= {0x00, 0x00, 0x00, 0x00}; 34 35 /** Second data pattern. 36 */ 37 u8_t pat1[]= {0xFF, 0xFF, 0xFF, 0xFF}; 38 39 /** Third data pattern. 40 */ 41 u8_t pat2[]= {0xA5, 0x5A, 0x69, 0x96}; 42 43 /** Fourth data pattern. 44 */ 45 u8_t pat3[]= {0x96, 0x69, 0x5A, 0xA5}; 25 /** Data patterns */ 26 u8_t pat0[]= {0x00, 0x00, 0x00, 0x00}; 27 u8_t pat1[]= {0xFF, 0xFF, 0xFF, 0xFF}; 28 u8_t pat2[]= {0xA5, 0x5A, 0x69, 0x96}; 29 u8_t pat3[]= {0x96, 0x69, 0x5A, 0xA5}; 46 30 47 31 /** Tests 8 bit NE2000 network interface. … … 92 76 /* Reset the ethernet card */ 93 77 byte= inb_ne(dep, NE_RESET); 94 milli_delay(2);78 usleep(2000); 95 79 outb_ne(dep, NE_RESET, byte); 96 milli_delay(2);80 usleep(2000); 97 81 98 82 /* Reset the dp8390 */ … … 193 177 dep->de_irq &= ~DEI_DEFAULT; 194 178 195 if (!debug) 196 { 197 printf("%s: NE%d000 at %#lx:%d\n", 198 dep->de_name, dep->de_16bit ? 2 : 1, 199 dep->de_base_port, dep->de_irq); 200 } 201 else 202 { 203 printf("%s: Novell NE%d000 ethernet card at I/O address " 204 "%#lx, memory size %#lx, irq %d\n", 205 dep->de_name, dep->de_16bit ? 2 : 1, 206 dep->de_base_port, dep->de_ramsize, dep->de_irq); 207 } 208 } 209 210 /*===========================================================================* 211 * test_8 * 212 *===========================================================================*/ 213 static int test_8(dep, pos, pat) 214 dpeth_t *dep; 215 int pos; 216 u8_t *pat; 179 printf("%s: Novell NE%d000 ethernet card at I/O address " 180 "%#lx, memory size %#lx, irq %d\n", 181 dep->de_name, dep->de_16bit ? 2 : 1, 182 dep->de_base_port, dep->de_ramsize, dep->de_irq); 183 } 184 185 static int test_8(dpeth_t *dep, int pos, u8_t *pat) 217 186 { 218 187 u8_t buf[4]; 219 188 int i; 220 int r; 221 222 outb_reg0(dep, DP_ISR, 0xFF); 223 189 190 outb_reg0(dep, DP_ISR, 0xff); 191 224 192 /* Setup a transfer to put the pattern. */ 225 193 outb_reg0(dep, DP_RBCR0, 4); 226 194 outb_reg0(dep, DP_RBCR1, 0); 227 outb_reg0(dep, DP_RSAR0, pos & 0xFF);195 outb_reg0(dep, DP_RSAR0, pos & 0xff); 228 196 outb_reg0(dep, DP_RSAR1, pos >> 8); 229 197 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); 230 231 for (i = 0; i<4; i++)198 199 for (i = 0; i < 4; i++) 232 200 outb_ne(dep, NE_DATA, pat[i]); 233 234 for (i= 0; i<N; i++) 235 { 201 202 for (i = 0; i < N; i++) { 203 if (inb_reg0(dep, DP_ISR) & ISR_RDC) 204 break; 205 } 206 207 if (i == N) { 208 printf("%s: NE1000 remote DMA test failed\n", dep->de_name); 209 return 0; 210 } 211 212 outb_reg0(dep, DP_RBCR0, 4); 213 outb_reg0(dep, DP_RBCR1, 0); 214 outb_reg0(dep, DP_RSAR0, pos & 0xff); 215 outb_reg0(dep, DP_RSAR1, pos >> 8); 216 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); 217 218 for (i = 0; i < 4; i++) 219 buf[i] = inb_ne(dep, NE_DATA); 220 221 return (memcmp(buf, pat, 4) == 0); 222 } 223 224 static int test_16(dpeth_t *dep, int pos, u8_t *pat) 225 { 226 u8_t buf[4]; 227 int i; 228 229 outb_reg0(dep, DP_ISR, 0xff); 230 231 /* Setup a transfer to put the pattern. */ 232 outb_reg0(dep, DP_RBCR0, 4); 233 outb_reg0(dep, DP_RBCR1, 0); 234 outb_reg0(dep, DP_RSAR0, pos & 0xff); 235 outb_reg0(dep, DP_RSAR1, pos >> 8); 236 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); 237 238 for (i = 0; i < 4; i += 2) 239 outw_ne(dep, NE_DATA, *(u16_t *)(pat + i)); 240 241 for (i = 0; i < N; i++) { 236 242 if (inb_reg0(dep, DP_ISR) &ISR_RDC) 237 243 break; 238 244 } 239 if (i == N) 240 { 241 if (debug) 242 { 243 printf("%s: NE1000 remote DMA test failed\n", 244 dep->de_name); 245 } 245 246 if (i == N) { 247 printf("%s: NE2000 remote DMA test failed\n", dep->de_name); 246 248 return 0; 247 249 } 248 249 outb_reg0(dep, DP_RBCR0, 4); 250 outb_reg0(dep, DP_RBCR1, 0); 251 outb_reg0(dep, DP_RSAR0, pos & 0xFF);250 251 outb_reg0(dep, DP_RBCR0, 4); 252 outb_reg0(dep, DP_RBCR1, 0); 253 outb_reg0(dep, DP_RSAR0, pos & 0xff); 252 254 outb_reg0(dep, DP_RSAR1, pos >> 8); 253 255 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); 254 255 for (i= 0; i<4; i++) 256 buf[i]= inb_ne(dep, NE_DATA); 257 258 r= (memcmp(buf, pat, 4) == 0); 259 return r; 260 } 261 262 /*===========================================================================* 263 * test_16 * 264 *===========================================================================*/ 265 static int test_16(dep, pos, pat) 266 dpeth_t *dep; 267 int pos; 268 u8_t *pat; 269 { 270 u8_t buf[4]; 271 int i; 272 int r; 273 274 outb_reg0(dep, DP_ISR, 0xFF); 275 276 /* Setup a transfer to put the pattern. */ 277 outb_reg0(dep, DP_RBCR0, 4); 278 outb_reg0(dep, DP_RBCR1, 0); 279 outb_reg0(dep, DP_RSAR0, pos &0xFF); 280 outb_reg0(dep, DP_RSAR1, pos >> 8); 281 outb_reg0(dep, DP_CR, CR_DM_RW | CR_PS_P0 | CR_STA); 282 283 for (i= 0; i<4; i += 2) 284 { 285 outw_ne(dep, NE_DATA, *(u16_t *)(pat+i)); 286 } 287 288 for (i= 0; i<N; i++) 289 { 290 if (inb_reg0(dep, DP_ISR) &ISR_RDC) 291 break; 292 } 293 if (i == N) 294 { 295 if (debug) 296 { 297 printf("%s: NE2000 remote DMA test failed\n", 298 dep->de_name); 299 } 300 return 0; 301 } 302 303 outb_reg0(dep, DP_RBCR0, 4); 304 outb_reg0(dep, DP_RBCR1, 0); 305 outb_reg0(dep, DP_RSAR0, pos &0xFF); 306 outb_reg0(dep, DP_RSAR1, pos >> 8); 307 outb_reg0(dep, DP_CR, CR_DM_RR | CR_PS_P0 | CR_STA); 308 309 for (i= 0; i<4; i += 2) 310 { 311 *(u16_t *)(buf+i)= inw_ne(dep, NE_DATA); 312 } 313 314 r= (memcmp(buf, pat, 4) == 0); 315 return r; 316 } 317 318 /*===========================================================================* 319 * ne_stop * 320 *===========================================================================*/ 321 static void ne_stop(dep) 322 dpeth_t *dep; 323 { 324 int byte; 325 256 257 for (i = 0; i < 4; i += 2) 258 *(u16_t *)(buf + i) = inw_ne(dep, NE_DATA); 259 260 return (memcmp(buf, pat, 4) == 0); 261 } 262 263 static void ne_stop(dpeth_t *dep) 264 { 326 265 /* Reset the ethernet card */ 327 byte= inb_ne(dep, NE_RESET);328 milli_delay(2);266 int byte = inb_ne(dep, NE_RESET); 267 usleep(2000); 329 268 outb_ne(dep, NE_RESET, byte); 330 269 } -
uspace/srv/hw/netif/dp8390/ne2000.h
rd3c9b60 r506a805 16 16 /** DP8390 register offset. 17 17 */ 18 #define NE_DP8390 18 #define NE_DP8390 0x00 19 19 20 20 /** Data register. 21 21 */ 22 #define NE_DATA 22 #define NE_DATA 0x10 23 23 24 24 /** Reset register. 25 25 */ 26 #define NE_RESET 0x1F26 #define NE_RESET 0x1f 27 27 28 28 /** NE1000 data start. 29 29 */ 30 #define NE1000_START 30 #define NE1000_START 0x2000 31 31 32 32 /** NE1000 data size. 33 33 */ 34 #define NE1000_SIZE 34 #define NE1000_SIZE 0x2000 35 35 36 36 /** NE2000 data start. 37 37 */ 38 #define NE2000_START 38 #define NE2000_START 0x4000 39 39 40 40 /** NE2000 data size. 41 41 */ 42 #define NE2000_SIZE 42 #define NE2000_SIZE 0x4000 43 43 44 44 /** Reads 1 byte register. … … 47 47 * @returns The read value. 48 48 */ 49 #define inb_ne(dep, reg) (inb(dep->de_base_port+reg))49 #define inb_ne(dep, reg) (inb(dep->de_base_port + reg)) 50 50 51 51 /** Writes 1 byte register. … … 54 54 * @param[in] data The value to be written. 55 55 */ 56 #define outb_ne(dep, reg, data) (outb(dep->de_base_port+reg, data))56 #define outb_ne(dep, reg, data) (outb(dep->de_base_port + reg, data)) 57 57 58 58 /** Reads 1 word (2 bytes) register. … … 61 61 * @returns The read value. 62 62 */ 63 #define inw_ne(dep, reg) 63 #define inw_ne(dep, reg) (inw(dep->de_base_port+reg)) 64 64 65 65 /** Writes 1 word (2 bytes) register. … … 68 68 * @param[in] data The value to be written. 69 69 */ 70 #define outw_ne(dep, reg, data) 70 #define outw_ne(dep, reg, data) (outw(dep->de_base_port+reg, data)) 71 71 72 #endif /* __NET_NETIF_NE2000_H__ */72 #endif 73 73 74 74 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.