Rev 6682 | Rev 6713 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6682 | Rev 6711 | ||
---|---|---|---|
Line 142... | Line 142... | ||
142 | EE_93C56_READ_CMD = (6 shl 8) ; 110b + 8bit address |
142 | EE_93C56_READ_CMD = (6 shl 8) ; 110b + 8bit address |
143 | EE_93C46_CMD_LENGTH = 9 ; start bit + cmd + 6bit address |
143 | EE_93C46_CMD_LENGTH = 9 ; start bit + cmd + 6bit address |
144 | EE_93C56_CMD_LENGTH = 11 ; start bit + cmd + 8bit ddress |
144 | EE_93C56_CMD_LENGTH = 11 ; start bit + cmd + 8bit ddress |
Line 145... | Line 145... | ||
145 | 145 | ||
146 | ; See chapter "5.7 Transmit Configuration Register" of RTL8139D(L).pdf |
146 | ; See chapter "5.7 Transmit Configuration Register" of RTL8139D(L).pdf |
- | 147 | VER_RTL8139 = 1000000b |
|
147 | VER_RTL8139 = 1100000b |
148 | VER_RTL8139_K = 1100000b |
148 | VER_RTL8139A = 1110000b |
149 | VER_RTL8139A = 1110000b |
149 | VER_RTL8139AG = 1110100b |
150 | VER_RTL8139A_G = 1110010b |
150 | VER_RTL8139B = 1111000b |
151 | VER_RTL8139B = 1111000b |
151 | VER_RTL8130 = VER_RTL8139B |
152 | VER_RTL8130 = 1111100b |
152 | VER_RTL8139C = 1110100b |
153 | VER_RTL8139C = 1110100b |
153 | VER_RTL8100 = 1111010b |
154 | VER_RTL8100 = 1111010b |
154 | VER_RTL8100B = 1110101b |
- | |
155 | VER_RTL8139D = VER_RTL8100B |
- | |
156 | VER_RTL8139CP = 1110110b |
155 | VER_RTL8100_8139D = 1110101b |
Line -... | Line 156... | ||
- | 156 | VER_RTL8101 = 1110111b |
|
157 | VER_RTL8101 = 1110111b |
157 | |
- | 158 | IDX_UNKNOWN = 0 |
|
158 | 159 | IDX_RTL8139 = 1 |
|
159 | IDX_RTL8139 = 0 |
160 | IDX_RTL8139_K = 2 |
160 | IDX_RTL8139A = 1 |
161 | IDX_RTL8139A = 3 |
161 | IDX_RTL8139B = 2 |
162 | IDX_RTL8139A_G = 4 |
162 | IDX_RTL8139C = 3 |
163 | IDX_RTL8139B = 5 |
163 | IDX_RTL8100 = 4 |
164 | IDX_RTL8130 = 6 |
- | 165 | IDX_RTL8139C = 7 |
|
164 | IDX_RTL8139D = 5 |
166 | IDX_RTL8100 = 8 |
- | 167 | IDX_RTL8100_8139D = 9 |
|
- | 168 | IDX_RTL8101 = 10 |
|
Line 165... | Line 169... | ||
165 | IDX_RTL8139D = 6 |
169 | |
166 | IDX_RTL8101 = 7 |
170 | HW_VERSIONS = 10 |
167 | 171 | ||
168 | ISR_SERR = 1 shl 15 |
172 | ISR_SERR = 1 shl 15 |
Line 325... | Line 329... | ||
325 | ; We've found the io address, find IRQ now |
329 | ; We've found the io address, find IRQ now |
Line 326... | Line 330... | ||
326 | 330 | ||
327 | invoke PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.interrupt_line |
331 | invoke PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.interrupt_line |
Line 328... | Line 332... | ||
328 | mov [ebx + device.irq_line], al |
332 | mov [ebx + device.irq_line], al |
329 | 333 | ||
Line 330... | Line 334... | ||
330 | DEBUGF 1, "Hooking into device, dev:%x, bus:%x, irq:%x, I/O addr:%x\n",\ |
334 | DEBUGF 1, "Hooking into device, devfn:%x, bus:%x, irq:%x, I/O addr:%x\n",\ |
Line 331... | Line 335... | ||
331 | [ebx + device.pci_dev]:1,[ebx + device.pci_bus]:1,[ebx + device.irq_line]:1,[ebx + device.io_addr]:4 |
335 | [ebx + device.pci_dev]:2,[ebx + device.pci_bus]:2,[ebx + device.irq_line]:2,[ebx + device.io_addr]:4 |
332 | 336 | ||
Line 375... | Line 379... | ||
375 | mov eax, [devices] |
379 | mov eax, [devices] |
376 | mov dword[device_list-4+4*eax], 0 |
380 | mov dword[device_list-4+4*eax], 0 |
377 | dec [devices] |
381 | dec [devices] |
Line 378... | Line 382... | ||
378 | 382 | ||
379 | .err: |
383 | .err: |
380 | DEBUGF 2, "Error, removing all data !\n" |
384 | DEBUGF 2, "Fatal error occured, aborting\n" |
381 | invoke KernelFree, [ebx + device.rx_buffer] |
385 | invoke KernelFree, [ebx + device.rx_buffer] |
Line 382... | Line 386... | ||
382 | invoke KernelFree, ebx |
386 | invoke KernelFree, ebx |
383 | 387 | ||
Line 419... | Line 423... | ||
419 | probe: |
423 | probe: |
420 | DEBUGF 1, "Probing\n" |
424 | DEBUGF 1, "Probing\n" |
Line 421... | Line 425... | ||
421 | 425 | ||
422 | ; Make the device a bus master |
426 | ; Make the device a bus master |
423 | invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command |
427 | invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command |
424 | or al, PCI_CMD_MASTER |
428 | or al, PCI_CMD_MASTER or PCI_CMD_PIO |
Line 425... | Line 429... | ||
425 | invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax |
429 | invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax |
426 | 430 | ||
- | 431 | ; wake up old chips |
|
- | 432 | set_io [ebx + device.io_addr], 0 |
|
- | 433 | set_io [ebx + device.io_addr], REG_HLTCLK |
|
- | 434 | mov al, 'R' ; run the clock |
|
- | 435 | out dx, al |
|
427 | ; get chip version |
436 | |
428 | set_io [ebx + device.io_addr], 0 |
437 | ; get chip version |
- | 438 | set_io [ebx + device.io_addr], REG_TXCONFIG |
|
429 | set_io [ebx + device.io_addr], REG_TXCONFIG + 2 |
439 | in eax, dx |
430 | in ax, dx |
440 | shr eax, 16 |
431 | shr ah, 2 |
441 | shr ah, 2 |
- | 442 | shr ax, 6 |
|
Line 432... | Line 443... | ||
432 | shr ax, 6 |
443 | and al, 0x7f |
433 | and al, 01111111b |
444 | DEBUGF 1, "Chip version: %x\n", eax:2 |
434 | 445 | ||
435 | ; now find it in our array |
446 | ; now find it in our array |
436 | mov ecx, HW_VER_ARRAY_SIZE-1 |
447 | mov ecx, HW_VERSIONS |
437 | .chip_ver_loop: |
448 | @@: |
438 | cmp al, [hw_ver_array + ecx] |
449 | cmp al, [hw_ver_array + ecx] |
439 | je .chip_ver_found |
450 | je @f |
440 | dec ecx |
- | |
441 | jns .chip_ver_loop |
- | |
442 | .unknown: |
- | |
443 | mov ecx, 8 |
- | |
444 | .chip_ver_found: |
- | |
445 | cmp ecx, 8 |
451 | dec ecx |
446 | ja .unknown |
- | |
447 | 452 | jnz @r |
|
448 | mov [ebx + device.hw_ver_id], cl |
453 | @@: |
449 | - | ||
450 | mov ecx, [crosslist+ecx*4] |
454 | mov [ebx + device.hw_ver_id], cl |
Line 451... | Line -... | ||
451 | mov [ebx + device.name], ecx |
- | |
452 | - | ||
453 | DEBUGF 1, "Chip version: %s\n", ecx |
- | |
454 | - | ||
455 | ; wake up the chip |
- | |
456 | set_io [ebx + device.io_addr], 0 |
- | |
457 | set_io [ebx + device.io_addr], REG_HLTCLK |
- | |
458 | mov al, 'R' ; run the clock |
- | |
459 | out dx, al |
- | |
460 | - | ||
461 | ; unlock config and BMCR registers |
- | |
462 | set_io [ebx + device.io_addr], REG_9346CR |
- | |
463 | mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0) |
- | |
464 | out dx, al |
- | |
465 | 455 | mov ecx, [hw_ver_names+ecx*4] |
|
466 | ; enable power management |
456 | mov [ebx + device.name], ecx |
- | 457 | DEBUGF 1, "Chip version: %s\n", ecx |
|
467 | set_io [ebx + device.io_addr], REG_CONFIG1 |
458 | |
- | 459 | cmp [ebx + device.hw_ver_id], IDX_RTL8139B |
|
- | 460 | jae .new_chip |
|
- | 461 | ||
- | 462 | ; wake up older chips |
|
468 | in al, dx |
463 | .old_chip: |
469 | cmp [ebx + device.hw_ver_id], IDX_RTL8139B |
464 | DEBUGF 1, "Wake up chip old style\n" |
470 | jae .new_chip |
465 | set_io [ebx + device.io_addr], REG_CONFIG1 |
Line 471... | Line 466... | ||
471 | ; wake up older chips |
466 | in al, dx |
472 | and al, not ((1 shl BIT_SLEEP) or (1 shl BIT_PWRDWN)) |
467 | and al, not ((1 shl BIT_SLEEP) or (1 shl BIT_PWRDWN)) |
473 | out dx, al |
468 | out dx, al |
474 | jmp .finish_wake_up |
469 | jmp .done |
475 | 470 | ||
- | 471 | ; set LWAKE pin to active high (default value). |
|
- | 472 | ; it is for Wake-On-LAN functionality of some motherboards. |
|
- | 473 | ; this signal is used to inform the motherboard to execute a wake-up process. |
|
- | 474 | ; only at newer chips. |
|
- | 475 | .new_chip: |
|
- | 476 | DEBUGF 1, "Wake up chip new style\n" |
|
- | 477 | ; unlock config and BMCR registers |
|
- | 478 | set_io [ebx + device.io_addr], 0 |
|
- | 479 | set_io [ebx + device.io_addr], REG_9346CR |
|
- | 480 | mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0) |
|
476 | ; set LWAKE pin to active high (default value). |
481 | out dx, al |
477 | ; it is for Wake-On-LAN functionality of some motherboards. |
482 | |
478 | ; this signal is used to inform the motherboard to execute a wake-up process. |
483 | ; |
Line -... | Line 484... | ||
- | 484 | set_io [ebx + device.io_addr], REG_CONFIG1 |
|
479 | ; only at newer chips. |
485 | in al, dx |
480 | .new_chip: |
486 | or al, (1 shl BIT_PMEn) |
481 | or al, (1 shl BIT_PMEn) |
487 | and al, not (1 shl BIT_LWACT) |
482 | and al, not (1 shl BIT_LWACT) |
488 | out dx, al |
Line 483... | Line 489... | ||
483 | out dx, al |
489 | |
484 | - | ||
485 | set_io [ebx + device.io_addr], REG_CONFIG4 |
490 | ; |
486 | in al, dx |
- | |
487 | and al, not (1 shl BIT_LWPTN) |
491 | set_io [ebx + device.io_addr], REG_CONFIG4 |
488 | out dx, al |
492 | in al, dx |
489 | - | ||
Line -... | Line 493... | ||
- | 493 | and al, not (1 shl BIT_LWPTN) |
|
- | 494 | out dx, al |
|
490 | ; lock config and BMCR registers |
495 | |
491 | .finish_wake_up: |
- | |
492 | xor al, al |
496 | ; lock config and BMCR registers |
Line 493... | Line 497... | ||
493 | set_io [ebx + device.io_addr], 0 |
497 | xor al, al |
494 | set_io [ebx + device.io_addr], REG_9346CR |
498 | set_io [ebx + device.io_addr], REG_9346CR |
Line 514... | Line 518... | ||
514 | set_io [ebx + device.io_addr], 0 |
518 | set_io [ebx + device.io_addr], 0 |
515 | set_io [ebx + device.io_addr], REG_COMMAND |
519 | set_io [ebx + device.io_addr], REG_COMMAND |
516 | mov al, 1 shl BIT_RST |
520 | mov al, 1 shl BIT_RST |
517 | out dx, al |
521 | out dx, al |
518 | mov cx, 1000 ; wait no longer for the reset |
522 | mov cx, 1000 ; wait no longer for the reset |
519 | .wait_for_reset: |
523 | @@: |
520 | in al, dx |
524 | in al, dx |
521 | test al, 1 shl BIT_RST |
525 | test al, 1 shl BIT_RST |
522 | jz .reset_completed ; RST remains 1 during reset |
526 | jz @f ; RST remains 1 during reset |
523 | dec cx |
527 | dec cx |
524 | jns .wait_for_reset |
528 | jnz @r |
525 | DEBUGF 2, "Reset timeout!\n" |
529 | DEBUGF 2, "Reset timeout!\n" |
526 | or eax, -1 |
530 | or eax, -1 |
527 | ret |
531 | ret |
528 | .reset_completed: |
532 | @@: |
Line 529... | Line 533... | ||
529 | 533 | ||
530 | ; Read MAC address |
534 | ; Read MAC address |
Line 531... | Line 535... | ||
531 | call read_mac |
535 | call read_mac |
Line 618... | Line 622... | ||
618 | out dx, ax |
622 | out dx, ax |
Line 619... | Line 623... | ||
619 | 623 | ||
620 | ; Set the mtu, kernel will be able to send now |
624 | ; Set the mtu, kernel will be able to send now |
Line -... | Line 625... | ||
- | 625 | mov [ebx + device.mtu], 1514 |
|
621 | mov [ebx + device.mtu], 1514 |
626 | |
Line 622... | Line 627... | ||
622 | 627 | ; Detect current link status |
|
623 | call link |
628 | call link |
624 | 629 | ||
Line 1120... | Line 1125... | ||
1120 | 1125 | ||
Line 1121... | Line 1126... | ||
1121 | include '../peimport.inc' |
1126 | include '../peimport.inc' |
Line -... | Line 1127... | ||
- | 1127 | ||
1122 | 1128 | my_service db 'RTL8139',0 ; max 16 chars include zero |
|
1123 | my_service db 'RTL8139',0 ; max 16 chars include zero |
1129 | |
1124 | 1130 | sz_unknown db 'Unknown RTL8139 clone', 0 |
|
1125 | device_1 db 'Realtek 8139',0 |
1131 | sz_RTL8139 db 'Realtek 8139',0 |
1126 | device_2 db 'Realtek 8139A',0 |
1132 | sz_RTL8139_K db 'Realtek 8139 rev K',0 |
1127 | device_3 db 'Realtek 8139B',0 |
1133 | sz_RTL8139A db 'Realtek 8139A',0 |
1128 | device_4 db 'Realtek 8139C',0 |
1134 | sz_RTL8139A_G db 'Realtek 8139A rev G',0 |
1129 | device_5 db 'Realtek 8100',0 |
1135 | sz_RTL8139B db 'Realtek 8139B',0 |
- | 1136 | sz_RTL8130 db 'Realtek 8130',0 |
|
1130 | device_6 db 'Realtek 8139D',0 |
1137 | sz_RTL8139C db 'Realtek 8139C',0 |
1131 | device_7 db 'Realtek 8139CP',0 |
1138 | sz_RTL8100 db 'Realtek 8100',0 |
1132 | device_8 db 'Realtek 8101',0 |
1139 | sz_RTL8100_8139D db 'Realtek 8100B / 8139D',0 |
- | 1140 | sz_RTL8101 db 'Realtek 8101',0 |
|
1133 | device_unknown db 'Unknown RTL8139 clone', 0 |
1141 | |
1134 | 1142 | hw_ver_names: |
|
1135 | crosslist: |
1143 | dd sz_unknown |
1136 | dd device_1 |
1144 | dd sz_RTL8139 |
1137 | dd device_2 |
1145 | dd sz_RTL8139_K |
1138 | dd device_3 |
1146 | dd sz_RTL8139A |
1139 | dd device_4 |
1147 | dd sz_RTL8139A_G |
1140 | dd device_5 |
1148 | dd sz_RTL8139B |
- | 1149 | dd sz_RTL8130 |
|
1141 | dd device_6 |
1150 | dd sz_RTL8139C |
Line 1142... | Line 1151... | ||
1142 | dd device_7 |
1151 | dd sz_RTL8100 |
- | 1152 | dd sz_RTL8100_8139D |
|
1143 | dd device_8 |
1153 | dd sz_RTL8101 |
- | 1154 | ||
1144 | dd device_unknown |
1155 | hw_ver_array: ; This array is used by the probe routine to find out wich version of the RTL8139 we are working with |
- | 1156 | db 0 |
|
1145 | 1157 | db VER_RTL8139 |
|
- | 1158 | db VER_RTL8139_K |
|
1146 | hw_ver_array: ; This array is used by the probe routine to find out wich version of the RTL8139 we are working with |
1159 | db VER_RTL8139A |
1147 | db VER_RTL8139 |
1160 | db VER_RTL8139A_G |
1148 | db VER_RTL8139A |
1161 | db VER_RTL8139B |
1149 | db VER_RTL8139B |
- | |
1150 | db VER_RTL8139C |
1162 | db VER_RTL8130 |
1151 | db VER_RTL8100 |
- | |
1152 | db VER_RTL8139D |
- | |
1153 | db VER_RTL8139CP |
- | |
Line 1154... | Line 1163... | ||
1154 | db VER_RTL8101 |
1163 | db VER_RTL8139C |
Line 1155... | Line 1164... | ||
1155 | db 0 |
1164 | db VER_RTL8100 |
1156 | 1165 | db VER_RTL8100_8139D |