Rev 1889 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1889 | Rev 1893 | ||
---|---|---|---|
Line 22... | Line 22... | ||
22 | 22 | ||
Line 23... | Line 23... | ||
23 | MAX_DEVICES equ 16 |
23 | MAX_DEVICES equ 16 |
24 | 24 | ||
25 | DEBUG equ 1 |
25 | DEBUG equ 1 |
Line -... | Line 26... | ||
- | 26 | __DEBUG__ equ 1 |
|
- | 27 | __DEBUG_LEVEL__ equ 2 |
|
- | 28 | ||
- | 29 | W_MAX_TIMEOUT equ 0x0FFF ; max time out delay time |
|
26 | __DEBUG__ equ 1 |
30 | |
27 | __DEBUG_LEVEL__ equ 1 |
31 | TX_TIMEOUT equ 6000 ; Time before concluding the transmitter is hung, in ms |
Line -... | Line 32... | ||
- | 32 | ||
- | 33 | TX_RING_SIZE equ 4 ; RING sizes must be a power of 2 |
|
- | 34 | RX_RING_SIZE equ 4 |
|
- | 35 | ||
- | 36 | RX_BUF_LEN_IDX equ 3 ; 0==8K, 1==16K, 2==32K, 3==64K |
|
- | 37 | ||
- | 38 | ; Threshold is bytes transferred to chip before transmission starts. |
|
- | 39 | ||
- | 40 | TX_FIFO_THRESH equ 256 ; In bytes, rounded down to 32 byte units. |
|
- | 41 | ||
- | 42 | ; The following settings are log_2(bytes)-4: 0 == 16 bytes .. 6==1024. |
|
- | 43 | ||
- | 44 | RX_FIFO_THRESH equ 4 ; Rx buffer level before first PCI xfer. |
|
Line 28... | Line 45... | ||
28 | 45 | RX_DMA_BURST equ 4 ; Maximum PCI burst, '4' is 256 bytes |
|
29 | TX_RING_SIZE equ 4 |
46 | TX_DMA_BURST equ 4 |
30 | RX_RING_SIZE equ 4 |
47 | |
31 | 48 | ||
Line 32... | Line 49... | ||
32 | 49 | ||
33 | include 'proc32.inc' |
50 | include 'proc32.inc' |
34 | include 'imports.inc' |
51 | include 'imports.inc' |
Line -... | Line 52... | ||
- | 52 | include 'fdo.inc' |
|
Line 35... | Line -... | ||
35 | include 'fdo.inc' |
- | |
36 | include 'netdrv.inc' |
- | |
37 | - | ||
38 | public START |
- | |
39 | public service_proc |
- | |
40 | public version |
- | |
41 | - | ||
42 | - | ||
43 | ; ethernet address length |
- | |
44 | ETH_ALEN equ 6 |
- | |
45 | ETH_HLEN equ (2 * ETH_ALEN + 2) |
- | |
46 | ETH_ZLEN equ 60 ; 60 + 4bytes auto payload for mininmum 64bytes frame length |
- | |
47 | - | ||
48 | ; system timer frequency |
- | |
49 | HZ equ 1000 |
- | |
50 | - | ||
51 | ; max time out delay time |
- | |
52 | W_MAX_TIMEOUT equ 0x0FFF |
- | |
53 | - | ||
54 | ;; Size of the in-memory receive ring. |
- | |
55 | RX_BUF_LEN_IDX equ 3 ;; 0==8K, 1==16K, 2==32K, 3==64K |
- | |
56 | RX_BUF_LEN equ (8192 << RX_BUF_LEN_IDX) |
- | |
57 | - | ||
58 | ;; PCI Tuning Parameters |
- | |
59 | ; Threshold is bytes transferred to chip before transmission starts. |
- | |
60 | TX_FIFO_THRESH equ 256 ;; In bytes, rounded down to 32 byte units. |
53 | include 'netdrv.inc' |
61 | 54 | ||
62 | ;; The following settings are log_2(bytes)-4: 0 == 16 bytes .. 6==1024. |
55 | public START |
63 | RX_FIFO_THRESH equ 4 ;; Rx buffer level before first PCI xfer. |
56 | public service_proc |
Line 64... | Line -... | ||
64 | RX_DMA_BURST equ 4 ;; Maximum PCI burst, '4' is 256 bytes |
- | |
65 | TX_DMA_BURST equ 4 |
- | |
66 | - | ||
67 | ;; Operational parameters that usually are not changed. |
- | |
68 | PHY1_ADDR equ 1 ;For MAC1 |
- | |
69 | PHY2_ADDR equ 3 ;For MAC2 |
- | |
70 | PHY_MODE equ 0x3100 ;PHY CHIP Register 0 |
57 | public version |
71 | PHY_CAP equ 0x01E1 ;PHY CHIP Register 4 |
58 | |
72 | 59 | ; Operational parameters that usually are not changed. |
|
73 | ;; Time in jiffies before concluding the transmitter is hung. |
60 | |
74 | TX_TIMEOUT equ ((6000*HZ)/1000) |
61 | PHY1_ADDR equ 1 ;For MAC1 |
Line 137... | Line 124... | ||
137 | MID_3H equ 0x84 ;MID3 High |
124 | MID_3H equ 0x84 ;MID3 High |
138 | PHY_CC equ 0x88 ;PHY status change configuration register |
125 | PHY_CC equ 0x88 ;PHY status change configuration register |
139 | PHY_ST equ 0x8A ;PHY status register |
126 | PHY_ST equ 0x8A ;PHY status register |
140 | MAC_SM equ 0xAC ;MAC status machine |
127 | MAC_SM equ 0xAC ;MAC status machine |
141 | MAC_ID equ 0xBE ;Identifier register |
128 | MAC_ID equ 0xBE ;Identifier register |
142 | ;?[ |
129 | |
143 | ;TX_DCNT equ 0x80 ;TX descriptor count |
- | |
144 | ;RX_DCNT equ 0x80 ;RX descriptor count |
- | |
145 | MAX_BUF_SIZE equ 0x600 ;1536 |
130 | MAX_BUF_SIZE equ 0x600 ;1536 |
Line 146... | Line 131... | ||
146 | 131 | ||
147 | MBCR_DEFAULT equ 0x012A ;MAC Bus Control Register |
132 | MBCR_DEFAULT equ 0x012A ;MAC Bus Control Register |
Line 167... | Line 152... | ||
167 | 152 | ||
168 | RX_INTS equ RX_FIFO_FULL or RX_NO_DESC or RX_FINISH |
153 | RX_INTS equ RX_FIFO_FULL or RX_NO_DESC or RX_FINISH |
169 | TX_INTS equ TX_FINISH |
154 | TX_INTS equ TX_FINISH |
Line -... | Line 155... | ||
- | 155 | INT_MASK equ RX_INTS or TX_INTS |
|
- | 156 | ||
- | 157 | RX_BUF_LEN equ (8192 << RX_BUF_LEN_IDX) ; Size of the in-memory receive ring. |
|
- | 158 | ||
- | 159 | IO_SIZE equ 256 ; RDC MAC I/O Size |
|
Line 170... | Line 160... | ||
170 | INT_MASK equ RX_INTS or TX_INTS |
160 | MAX_MAC equ 2 ; MAX RDC MAC |
171 | 161 | ||
172 | 162 | ||
173 | virtual at 0 |
163 | virtual at 0 |
Line 331... | Line 321... | ||
331 | 321 | ||
Line 332... | Line 322... | ||
332 | ; We've found the io address, find IRQ now |
322 | ; We've found the io address, find IRQ now |
Line 333... | Line 323... | ||
333 | 323 | ||
334 | find_irq [device.pci_bus], [device.pci_dev], [device.irq_line] |
324 | find_irq [device.pci_bus], [device.pci_dev], [device.irq_line] |
Line 335... | Line 325... | ||
335 | 325 | ||
336 | DEBUGF 2,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
326 | DEBUGF 1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
Line 357... | Line 347... | ||
357 | ret |
347 | ret |
Line 358... | Line 348... | ||
358 | 348 | ||
Line 359... | Line 349... | ||
359 | ; If the device was already loaded, find the device number and return it in eax |
349 | ; If the device was already loaded, find the device number and return it in eax |
360 | 350 | ||
361 | .find_devicenum: |
351 | .find_devicenum: |
362 | DEBUGF 2,"Trying to find device number of already registered device\n" |
352 | DEBUGF 1,"Trying to find device number of already registered device\n" |
363 | call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
353 | call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
364 | ; into a device number in edi |
354 | ; into a device number in edi |
365 | mov eax, edi ; Application wants it in eax instead |
355 | mov eax, edi ; Application wants it in eax instead |
Line 366... | Line 356... | ||
366 | DEBUGF 2,"Kernel says: %u\n", eax |
356 | DEBUGF 1,"Kernel says: %u\n", eax |
Line 367... | Line 357... | ||
367 | ret |
357 | ret |
Line 390... | Line 380... | ||
390 | ;; Actual Hardware dependent code starts here ;; |
380 | ;; Actual Hardware dependent code starts here ;; |
391 | ;; ;; |
381 | ;; ;; |
392 | ;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;; |
382 | ;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;; |
Line 393... | Line 383... | ||
393 | 383 | ||
394 | 384 | ||
395 | macro r6040_mdio_write reg, val { |
385 | macro mdio_write reg, val { |
Line 396... | Line 386... | ||
396 | stdcall r6040_phy_read, [io_addr], [r6040_private.phy_addr], reg |
386 | stdcall phy_read, [device.io_addr], [device.phy_addr], reg |
397 | } |
387 | } |
398 | 388 | ||
Line 399... | Line 389... | ||
399 | macro r6040_mdio_write reg, val { |
389 | macro mdio_write reg, val { |
400 | stdcall r6040_phy_write, [io_addr], [r6040_private.phy_addr], reg, val |
390 | stdcall phy_write, [device.io_addr], [devce.phy_addr], reg, val |
Line 445... | Line 435... | ||
445 | ; Some bootloaders/BIOSes do not initialize MAC address, warn about that |
435 | ; Some bootloaders/BIOSes do not initialize MAC address, warn about that |
446 | and eax, 0xFF |
436 | and eax, 0xFF |
447 | or eax, dword [device.mac] |
437 | or eax, dword [device.mac] |
448 | test eax, eax |
438 | test eax, eax |
449 | jnz @f |
439 | jnz @f |
450 | DEBUGF 1, "MAC address not initialized\n" ;, generating random" |
440 | DEBUGF 2, "ERROR: MAC address not initialized!\n" |
451 | - | ||
452 | ;Asper: Add here generate function call! |
- | |
453 | ; Temporary workaround: init by constant adress |
- | |
Line 454... | Line -... | ||
454 | - | ||
455 | mov dword [device.mac], 0x00006000 |
- | |
456 | mov word [device.mac+4], 0x0001 |
441 | |
457 | @@: |
- | |
458 | 442 | @@: |
|
459 | ; Init RDC private data |
443 | ; Init RDC private data |
460 | mov [device.mcr0], 0x1002 |
444 | mov [device.mcr0], 0x1002 |
461 | ;mov [private.phy_addr], 1 ; Asper: Only one network card is supported now. |
445 | ;mov [private.phy_addr], 1 ; Asper: Only one network card is supported now. |
Line 462... | Line 446... | ||
462 | mov [device.switch_sig], 0 |
446 | mov [device.switch_sig], 0 |
463 | 447 | ||
464 | ; Check the vendor ID on the PHY, if 0xFFFF assume none attached |
448 | ; Check the vendor ID on the PHY, if 0xFFFF assume none attached |
465 | stdcall phy_read, 1, 2 |
449 | stdcall phy_read, 1, 2 |
466 | cmp ax, 0xFFFF |
450 | cmp ax, 0xFFFF |
467 | jne @f |
451 | jne @f |
468 | DEBUGF 1, "Failed to detect an attached PHY\n" ;, generating random" |
452 | DEBUGF 2, "Failed to detect an attached PHY\n" ;, generating random" |
469 | mov eax, -1 |
453 | mov eax, -1 |
Line 470... | Line 454... | ||
470 | ret |
454 | ret |
Line 490... | Line 474... | ||
490 | ; PHY Mode Check |
474 | ; PHY Mode Check |
491 | movzx eax, [device.phy_addr] |
475 | movzx eax, [device.phy_addr] |
492 | stdcall phy_write, eax, 4, PHY_CAP |
476 | stdcall phy_write, eax, 4, PHY_CAP |
493 | stdcall phy_write, eax, 0, PHY_MODE |
477 | stdcall phy_write, eax, 0, PHY_MODE |
Line 494... | Line 478... | ||
494 | 478 | ||
495 | ; if PHY_MODE = 0x3100 |
479 | if PHY_MODE = 0x3100 |
496 | call phy_mode_chk |
480 | call phy_mode_chk |
497 | mov [device.phy_mode], ax |
481 | mov [device.phy_mode], ax |
498 | jmp .phy_readen |
482 | jmp .phy_readen |
Line 499... | Line 483... | ||
499 | ; end if |
483 | end if |
500 | 484 | ||
501 | ; if not (PHY_MODE and 0x0100) |
485 | if not (PHY_MODE and 0x0100) |
- | 486 | mov [device.phy_mode], 0 |
|
502 | mov [device.phy_mode], 0 |
487 | end if |
Line 503... | Line 488... | ||
503 | ; end if |
488 | |
504 | .phy_readen: |
489 | .phy_readen: |
505 | 490 | ||
Line 525... | Line 510... | ||
525 | 510 | ||
526 | 511 | ||
Line 527... | Line 512... | ||
527 | align 4 |
512 | align 4 |
Line 528... | Line 513... | ||
528 | reset: |
513 | reset: |
529 | 514 | ||
530 | DEBUGF 1,"Resetting R6040\n" |
515 | DEBUGF 2,"Resetting R6040\n" |
531 | 516 | ||
Line 537... | Line 522... | ||
537 | 522 | ||
Line 538... | Line 523... | ||
538 | 523 | ||
539 | ; attach int handler |
524 | ; attach int handler |
540 | 525 | ||
541 | movzx eax, [device.irq_line] |
526 | movzx eax, [device.irq_line] |
542 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
527 | DEBUGF 2,"Attaching int handler to irq %x\n", eax:1 |
543 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
528 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
544 | test eax, eax |
529 | test eax, eax |
545 | jnz @f |
530 | jnz @f |
546 | DEBUGF 1,"\nCould not attach int handler!\n" |
531 | DEBUGF 2,"\nCould not attach int handler!\n" |
Line 649... | Line 634... | ||
649 | GetRealAddr |
634 | GetRealAddr |
650 | mov ecx, TX_RING_SIZE |
635 | mov ecx, TX_RING_SIZE |
Line 651... | Line 636... | ||
651 | 636 | ||
652 | .next_desc: |
637 | .next_desc: |
653 | mov [esi + x_head.ndesc], eax |
638 | mov [esi + x_head.ndesc], eax |
654 | mov [edi + x_head.skb_ptr], 0 |
639 | mov [esi + x_head.skb_ptr], 0 |
Line 655... | Line 640... | ||
655 | mov [esi + x_head.status], DSC_OWNER_MAC |
640 | mov [esi + x_head.status], DSC_OWNER_MAC |
656 | 641 | ||
Line 662... | Line 647... | ||
662 | 647 | ||
663 | lea eax, [device.tx_ring] |
648 | lea eax, [device.tx_ring] |
664 | GetRealAddr |
649 | GetRealAddr |
Line 665... | Line -... | ||
665 | mov [device.tx_ring + x_head.sizeof*(TX_RING_SIZE - 1) + x_head.ndesc], eax |
- | |
666 | - | ||
667 | DEBUGF 1,"ok\n" |
650 | mov [device.tx_ring + x_head.sizeof*(TX_RING_SIZE - 1) + x_head.ndesc], eax |
Line 668... | Line 651... | ||
668 | 651 | ||
Line 680... | Line 663... | ||
680 | GetRealAddr |
663 | GetRealAddr |
681 | mov edx, eax |
664 | mov edx, eax |
682 | mov ecx, RX_RING_SIZE |
665 | mov ecx, RX_RING_SIZE |
Line 683... | Line 666... | ||
683 | 666 | ||
684 | .next_desc: |
- | |
685 | DEBUGF 1,"esi=0x%x, edx=0x%x, ", esi, edx |
667 | .next_desc: |
Line 686... | Line 668... | ||
686 | mov [esi + x_head.ndesc], edx |
668 | mov [esi + x_head.ndesc], edx |
687 | 669 | ||
688 | push esi ecx |
670 | push esi ecx |
Line 689... | Line -... | ||
689 | stdcall KernelAlloc, dword 2000 |
- | |
690 | pop ecx esi |
671 | stdcall KernelAlloc, MAX_BUF_SIZE |
691 | 672 | pop ecx esi |
|
692 | DEBUGF 1,"eax=0x%x, ", eax |
- | |
693 | mov [esi + x_head.skb_ptr], eax |
673 | |
694 | GetRealAddr |
674 | mov [esi + x_head.skb_ptr], eax |
Line 695... | Line 675... | ||
695 | DEBUGF 1,"eax=0x%x\n", eax |
675 | GetRealAddr |
696 | mov [esi + x_head.buf], eax |
676 | mov [esi + x_head.buf], eax |
Line 706... | Line 686... | ||
706 | 686 | ||
707 | lea eax, [device.rx_ring] |
687 | lea eax, [device.rx_ring] |
708 | GetRealAddr |
688 | GetRealAddr |
Line 709... | Line -... | ||
709 | mov [device.rx_ring + x_head.sizeof*(RX_RING_SIZE - 1) + x_head.ndesc], eax |
- | |
710 | - | ||
711 | DEBUGF 1,"ok\n" |
689 | mov [device.rx_ring + x_head.sizeof*(RX_RING_SIZE - 1) + x_head.ndesc], eax |
Line 712... | Line 690... | ||
712 | 690 | ||
Line 723... | Line 701... | ||
723 | movzx eax, [device.phy_addr] |
701 | movzx eax, [device.phy_addr] |
724 | stdcall phy_read, eax, 1 |
702 | stdcall phy_read, eax, 1 |
725 | test eax, 0x4 |
703 | test eax, 0x4 |
726 | jz .ret_0x8000 |
704 | jz .ret_0x8000 |
Line 727... | Line -... | ||
727 | - | ||
728 | ; jnz @f |
- | |
729 | ; mov eax, 0x8000 ; Link Failed, full duplex |
- | |
730 | ; @@: |
- | |
731 | 705 | ||
732 | ; PHY Chip Auto-Negotiation Status |
706 | ; PHY Chip Auto-Negotiation Status |
733 | movzx eax, [device.phy_addr] |
707 | movzx eax, [device.phy_addr] |
734 | stdcall phy_read, eax, 1 |
708 | stdcall phy_read, eax, 1 |
735 | test eax, 0x0020 |
709 | test eax, 0x0020 |
Line 772... | Line 746... | ||
772 | ;; pointer to device structure in ebx ;; |
746 | ;; pointer to device structure in ebx ;; |
773 | ;; ;; |
747 | ;; ;; |
774 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
748 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
775 | align 4 |
749 | align 4 |
776 | transmit: |
750 | transmit: |
777 | DEBUGF 1,"\nTransmitting packet, buffer:%x, size:%u\n", [esp+4], [esp+8] |
751 | DEBUGF 2,"\nTransmitting packet, buffer:%x, size:%u\n", [esp+4], [esp+8] |
778 | mov eax, [esp+4] |
752 | mov eax, [esp+4] |
779 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
753 | DEBUGF 2,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
780 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
754 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
781 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
755 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
782 | [eax+13]:2,[eax+12]:2 |
756 | [eax+13]:2,[eax+12]:2 |
Line 783... | Line 757... | ||
783 | 757 | ||
Line 789... | Line 763... | ||
789 | movzx edi, [device.cur_tx] |
763 | movzx edi, [device.cur_tx] |
790 | shl edi, 5 |
764 | shl edi, 5 |
791 | add edi, ebx |
765 | add edi, ebx |
792 | add edi, device.tx_ring - ebx |
766 | add edi, device.tx_ring - ebx |
Line 793... | Line 767... | ||
793 | 767 | ||
Line 794... | Line 768... | ||
794 | DEBUGF 1,"R6040: TX buffer status: 0x%x\n", [edi + x_head.status]:4 |
768 | DEBUGF 2,"TX buffer status: 0x%x\n", [edi + x_head.status]:4 |
795 | 769 | ||
Line 796... | Line 770... | ||
796 | test [edi + x_head.status], 0x8000 ; check if buffer is available |
770 | test [edi + x_head.status], DSC_OWNER_MAC ; check if buffer is available |
Line -... | Line 771... | ||
- | 771 | jnz .wait_to_send |
|
- | 772 | ||
797 | jnz .wait_to_send |
773 | .do_send: |
798 | 774 | ||
799 | .do_send: |
775 | DEBUGF 2,"Sending now\n" |
800 | 776 | ||
801 | mov eax, [esp+4] |
777 | mov eax, [esp+4] |
802 | mov [edi + x_head.skb_ptr], eax |
778 | mov [edi + x_head.skb_ptr], eax |
803 | GetRealAddr |
779 | GetRealAddr |
Line 804... | Line 780... | ||
804 | mov [edi + x_head.buf], eax |
780 | mov [edi + x_head.buf], eax |
805 | mov ecx, [esp+8] |
781 | mov ecx, [esp+8] |
806 | mov [edi + x_head.len], cx |
782 | mov [edi + x_head.len], cx |
807 | mov [edi + x_head.status], 0x8000 |
783 | mov [edi + x_head.status], DSC_OWNER_MAC |
Line 818... | Line 794... | ||
818 | 794 | ||
Line 819... | Line 795... | ||
819 | ret 8 |
795 | ret 8 |
Line 820... | Line 796... | ||
820 | 796 | ||
821 | .wait_to_send: |
- | |
822 | - | ||
823 | ; mov ecx, [timer_ticks] |
- | |
824 | ; add ecx, 100 |
- | |
825 | ; .l2: |
- | |
826 | ; test [eax + x_head.status], 0x8000 |
- | |
827 | ; jz .do_send |
- | |
828 | ; mov esi, 10 |
- | |
Line -... | Line 797... | ||
- | 797 | .wait_to_send: |
|
- | 798 | ||
- | 799 | DEBUGF 2,"Waiting for TX buffer\n" |
|
- | 800 | ||
- | 801 | call GetTimerTicks ; returns in eax |
|
- | 802 | lea edx, [eax + 100] |
|
- | 803 | .l2: |
|
- | 804 | test [edi + x_head.status], DSC_OWNER_MAC |
|
- | 805 | jz .do_send |
|
- | 806 | mov esi, 10 |
|
- | 807 | call Sleep |
|
- | 808 | call GetTimerTicks |
|
829 | ; call Sleep |
809 | cmp edx, eax |
830 | ; cmp ecx, [timer_ticks] |
810 | jl .l2 |
831 | ; jl .l2 |
811 | |
832 | 812 | DEBUGF 1,"Send timeout\n" |
|
833 | xor eax, eax |
813 | xor eax, eax |
Line 846... | Line 826... | ||
846 | ;; ;; |
826 | ;; ;; |
847 | ;;;;;;;;;;;;;;;;;;;;;;; |
827 | ;;;;;;;;;;;;;;;;;;;;;;; |
848 | align 4 |
828 | align 4 |
849 | int_handler: |
829 | int_handler: |
Line 850... | Line 830... | ||
850 | 830 | ||
Line 851... | Line 831... | ||
851 | DEBUGF 1,"\nIRQ %x ", eax:2 ; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO |
831 | DEBUGF 2,"\nIRQ %x ", eax:2 ; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO |
Line 852... | Line 832... | ||
852 | 832 | ||
853 | ; Find pointer of device wich made IRQ occur |
833 | ; Find pointer of device wich made IRQ occur |
Line 864... | Line 844... | ||
864 | set_io 0 |
844 | set_io 0 |
865 | set_io MISR |
845 | set_io MISR |
866 | in ax, dx |
846 | in ax, dx |
867 | out dx, ax ; send it back to ACK |
847 | out dx, ax ; send it back to ACK |
Line 868... | Line 848... | ||
868 | 848 | ||
Line 869... | Line 849... | ||
869 | DEBUGF 1,"MISR=%x\n", eax:4 |
849 | DEBUGF 2,"MISR=%x\n", eax:4 |
Line 870... | Line 850... | ||
870 | 850 | ||
871 | ; Check if we are interessed in some of the reasons |
851 | ; Check if we are interessed in some of the reasons |
Line 904... | Line 884... | ||
904 | 884 | ||
905 | mov cx, [edx + x_head.status] |
885 | mov cx, [edx + x_head.status] |
906 | test cx, DSC_OWNER_MAC |
886 | test cx, DSC_OWNER_MAC |
Line 907... | Line 887... | ||
907 | jnz .no_RX |
887 | jnz .no_RX |
Line 908... | Line 888... | ||
908 | 888 | ||
909 | DEBUGF 1,"packet status=0x%x\n", cx |
889 | DEBUGF 2,"packet status=0x%x\n", cx |
Line 910... | Line 890... | ||
910 | 890 | ||
Line 923... | Line 903... | ||
923 | push .more_RX |
903 | push .more_RX |
Line 924... | Line 904... | ||
924 | 904 | ||
925 | push ecx |
905 | push ecx |
Line 926... | Line 906... | ||
926 | push [edx + x_head.skb_ptr] |
906 | push [edx + x_head.skb_ptr] |
Line 927... | Line 907... | ||
927 | 907 | ||
Line 928... | Line 908... | ||
928 | DEBUGF 1,"packet ptr=0x%x\n", [edx + x_head.skb_ptr] |
908 | DEBUGF 2,"packet ptr=0x%x\n", [edx + x_head.skb_ptr] |
929 | 909 | ||
930 | ; reset the RX descriptor |
910 | ; reset the RX descriptor |
931 | 911 | ||
932 | push edx |
912 | push edx |
933 | stdcall KernelAlloc, 2000 |
913 | stdcall KernelAlloc, MAX_BUF_SIZE |
934 | pop edx |
914 | pop edx |
Line 956... | Line 936... | ||
956 | movzx edi, [device.last_tx] |
936 | movzx edi, [device.last_tx] |
957 | shl edi, 5 |
937 | shl edi, 5 |
958 | lea edi, [device.tx_ring + edi] |
938 | lea edi, [device.tx_ring + edi] |
Line 959... | Line 939... | ||
959 | 939 | ||
960 | test [edi + x_head.status], DSC_OWNER_MAC |
940 | test [edi + x_head.status], DSC_OWNER_MAC |
Line 961... | Line 941... | ||
961 | jnz .tx_loop_end |
941 | jnz .no_TX |
962 | 942 | ||
Line 963... | Line 943... | ||
963 | cmp [edi + x_head.skb_ptr], 0 |
943 | cmp [edi + x_head.skb_ptr], 0 |
Line 964... | Line 944... | ||
964 | je .tx_loop_end |
944 | je .no_TX |
965 | - | ||
966 | DEBUGF 1,"Freeing buffer 0x%x\n", [edi + x_head.skb_ptr] |
945 | |
- | 946 | DEBUGF 2,"Freeing buffer 0x%x\n", [edi + x_head.skb_ptr] |
|
Line 967... | Line 947... | ||
967 | 947 | ||
968 | push [edi + x_head.skb_ptr] |
948 | push [edi + x_head.skb_ptr] |
969 | call KernelFree |
- | |
Line 970... | Line 949... | ||
970 | mov [edi + x_head.skb_ptr], 0 |
949 | mov [edi + x_head.skb_ptr], 0 |
Line 971... | Line 950... | ||
971 | 950 | call KernelFree |
|
972 | inc [device.last_tx] |
951 | |
973 | and [device.last_tx], TX_RING_SIZE - 1 |
952 | inc [device.last_tx] |
Line 983... | Line 962... | ||
983 | 962 | ||
984 | 963 | ||
Line 985... | Line 964... | ||
985 | align 4 |
964 | align 4 |
Line 986... | Line 965... | ||
986 | init_mac_regs: |
965 | init_mac_regs: |
987 | 966 | ||
988 | DEBUGF 1,"initializing MAC regs\n" |
967 | DEBUGF 2,"initializing MAC regs\n" |
989 | 968 | ||
Line 1012... | Line 991... | ||
1012 | ; Read a word data from PHY Chip |
991 | ; Read a word data from PHY Chip |
Line 1013... | Line 992... | ||
1013 | 992 | ||
1014 | align 4 |
993 | align 4 |
Line 1015... | Line 994... | ||
1015 | proc phy_read stdcall, phy_addr:dword, reg:dword |
994 | proc phy_read stdcall, phy_addr:dword, reg:dword |
Line 1016... | Line 995... | ||
1016 | 995 | ||
1017 | DEBUGF 1,"PHY read, addr=0x%x reg=0x%x\n", [phy_addr]:8, [reg]:8 |
996 | DEBUGF 2,"PHY read, addr=0x%x reg=0x%x\n", [phy_addr]:8, [reg]:8 |
1018 | 997 | ||
1019 | mov eax, [phy_addr] |
998 | mov eax, [phy_addr] |
Line 1036... | Line 1015... | ||
1036 | 1015 | ||
1037 | set_io MMRD |
1016 | set_io MMRD |
1038 | in ax, dx |
1017 | in ax, dx |
Line 1039... | Line 1018... | ||
1039 | and eax, 0xFFFF |
1018 | and eax, 0xFFFF |
Line 1040... | Line 1019... | ||
1040 | 1019 | ||
Line 1041... | Line 1020... | ||
1041 | DEBUGF 1,"PHY read, val=0x%x\n", eax:4 |
1020 | DEBUGF 2,"PHY read, val=0x%x\n", eax:4 |
Line 1050... | Line 1029... | ||
1050 | ; Write a word data to PHY Chip |
1029 | ; Write a word data to PHY Chip |
Line 1051... | Line 1030... | ||
1051 | 1030 | ||
1052 | align 4 |
1031 | align 4 |
Line 1053... | Line 1032... | ||
1053 | proc phy_write stdcall, phy_addr:dword, reg:dword, val:dword |
1032 | proc phy_write stdcall, phy_addr:dword, reg:dword, val:dword |
Line 1054... | Line 1033... | ||
1054 | 1033 | ||
1055 | DEBUGF 1,"PHY write, addr=0x%x reg=0x%x val=0x%x\n", [phy_addr]:8, [reg]:8, [val]:8 |
1034 | DEBUGF 2,"PHY write, addr=0x%x reg=0x%x val=0x%x\n", [phy_addr]:8, [reg]:8, [val]:8 |
1056 | 1035 | ||
1057 | mov eax, [val] |
1036 | mov eax, [val] |
Line 1076... | Line 1055... | ||
1076 | jz @f |
1055 | jz @f |
1077 | dec ecx |
1056 | dec ecx |
1078 | jnz .write |
1057 | jnz .write |
1079 | @@: |
1058 | @@: |
Line 1080... | Line 1059... | ||
1080 | 1059 | ||
Line 1081... | Line 1060... | ||
1081 | DEBUGF 1,"PHY write ok\n" |
1060 | DEBUGF 2,"PHY write ok\n" |
1082 | 1061 |