Rev 3557 | Rev 4470 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3557 | Rev 3855 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | 18 | ||
Line 19... | Line 19... | ||
19 | API_VERSION = 0x01000100 |
19 | API_VERSION = 0x01000100 |
20 | 20 | ||
21 | DEBUG = 1 |
21 | DEBUG = 1 |
Line 22... | Line 22... | ||
22 | __DEBUG__ = 1 |
22 | __DEBUG__ = 1 |
23 | __DEBUG_LEVEL__ = 2 |
23 | __DEBUG_LEVEL__ = 2 ; 1 = verbose, 2 = errors only |
Line 24... | Line 24... | ||
24 | 24 | ||
Line 369... | Line 369... | ||
369 | cmp [state], 1 |
369 | cmp [state], 1 |
370 | jne .exit |
370 | jne .exit |
Line 371... | Line 371... | ||
371 | 371 | ||
Line 372... | Line 372... | ||
372 | .entry: |
372 | .entry: |
373 | 373 | ||
374 | DEBUGF 2,"Loading %s driver\n", my_service |
374 | DEBUGF 1,"Loading driver\n" |
Line 375... | Line 375... | ||
375 | stdcall RegService, my_service, service_proc |
375 | stdcall RegService, my_service, service_proc |
376 | ret |
376 | ret |
Line 506... | Line 506... | ||
506 | .destroy: |
506 | .destroy: |
507 | ; todo: reset device into virgin state |
507 | ; todo: reset device into virgin state |
Line 508... | Line 508... | ||
508 | 508 | ||
509 | dec [devices] |
509 | dec [devices] |
510 | .err: |
510 | .err: |
511 | DEBUGF 1,"Error, removing all data !\n" |
511 | DEBUGF 2,"Error, removing all data !\n" |
Line 512... | Line 512... | ||
512 | stdcall KernelFree, ebx |
512 | stdcall KernelFree, ebx |
513 | 513 | ||
514 | .fail: |
514 | .fail: |
Line 596... | Line 596... | ||
596 | call switch_to_dwio |
596 | call switch_to_dwio |
Line 597... | Line 597... | ||
597 | 597 | ||
Line 598... | Line 598... | ||
598 | jmp .L1 |
598 | jmp .L1 |
599 | 599 | ||
600 | .no_dev: |
600 | .no_dev: |
601 | DEBUGF 1,"PCnet device not found!\n" |
601 | DEBUGF 1,"device not found!\n" |
Line 602... | Line 602... | ||
602 | mov eax, 1 |
602 | mov eax, 1 |
603 | ret |
603 | ret |
Line 643... | Line 643... | ||
643 | cmp ax, 0x2626 |
643 | cmp ax, 0x2626 |
644 | je .L8 |
644 | je .L8 |
645 | cmp ax, 0x2627 |
645 | cmp ax, 0x2627 |
646 | je .L9 |
646 | je .L9 |
Line 647... | Line 647... | ||
647 | 647 | ||
648 | DEBUGF 1,"Invalid chip rev\n" |
648 | DEBUGF 1,"Invalid chip rev\n" |
649 | jmp .no_dev |
649 | jmp .no_dev |
650 | .L2: |
650 | .L2: |
651 | mov [device.name], device_l2 |
651 | mov [device.name], device_l2 |
652 | jmp .L10 |
652 | jmp .L10 |
Line 682... | Line 682... | ||
682 | .L9: |
682 | .L9: |
683 | mov [device.name], device_l9 |
683 | mov [device.name], device_l9 |
684 | ; mov [device.fdx], 1 |
684 | ; mov [device.fdx], 1 |
685 | mov [device.mii], 1 |
685 | mov [device.mii], 1 |
686 | .L10: |
686 | .L10: |
687 | DEBUGF 1,"device name: %s\n", [device.name] |
687 | DEBUGF 1,"device name: %s\n", [device.name] |
Line 688... | Line 688... | ||
688 | 688 | ||
689 | cmp [device.fset], 1 |
689 | cmp [device.fset], 1 |
690 | jne .L11 |
690 | jne .L11 |
691 | mov ecx, BCR_BUSCTL |
691 | mov ecx, BCR_BUSCTL |
Line 721... | Line 721... | ||
721 | movzx eax, [device.irq_line] |
721 | movzx eax, [device.irq_line] |
722 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
722 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
723 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
723 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
724 | test eax, eax |
724 | test eax, eax |
725 | jnz @f |
725 | jnz @f |
726 | DEBUGF 1,"\nCould not attach int handler!\n" |
726 | DEBUGF 2,"Could not attach int handler!\n" |
727 | ; or eax, -1 |
727 | ; or eax, -1 |
728 | ; ret |
728 | ; ret |
729 | @@: |
729 | @@: |
Line 730... | Line 730... | ||
730 | 730 | ||
Line 800... | Line 800... | ||
800 | jmp .L9 |
800 | jmp .L9 |
801 | .L6: |
801 | .L6: |
802 | test [device.options], PORT_ASEL |
802 | test [device.options], PORT_ASEL |
803 | jz .L9 |
803 | jz .L9 |
804 | mov ecx, BCR_MIICTL |
804 | mov ecx, BCR_MIICTL |
805 | DEBUGF 1,"ASEL, enable auto-negotiation\n" |
805 | DEBUGF 1,"ASEL, enable auto-negotiation\n" |
806 | call [device.read_bcr] |
806 | call [device.read_bcr] |
807 | and eax, not 0x98 |
807 | and eax, not 0x98 |
808 | or eax, 0x20 |
808 | or eax, 0x20 |
809 | call [device.write_bcr] |
809 | call [device.write_bcr] |
810 | .L9: |
810 | .L9: |
Line 859... | Line 859... | ||
859 | .next: |
859 | .next: |
860 | inc [device.phy] |
860 | inc [device.phy] |
861 | cmp [device.phy], MAX_PHYS |
861 | cmp [device.phy], MAX_PHYS |
862 | jb .mii_loop |
862 | jb .mii_loop |
Line 863... | Line 863... | ||
863 | 863 | ||
Line 864... | Line 864... | ||
864 | DEBUGF 1, "No PHY found!\n" |
864 | DEBUGF 2, "No PHY found!\n" |
865 | 865 | ||
Line 866... | Line 866... | ||
866 | or eax, -1 |
866 | or eax, -1 |
Line 916... | Line 916... | ||
916 | test ax, CSR_IDONE |
916 | test ax, CSR_IDONE |
917 | jnz @f |
917 | jnz @f |
Line 918... | Line 918... | ||
918 | 918 | ||
919 | dec esi |
919 | dec esi |
920 | jnz @r |
920 | jnz @r |
921 | DEBUGF 1,"Initialize timeout!\n" |
921 | DEBUGF 2,"Initialize timeout!\n" |
Line 922... | Line 922... | ||
922 | @@: |
922 | @@: |
923 | 923 | ||
924 | ; Start the device and enable interrupts |
924 | ; Start the device and enable interrupts |
Line 932... | Line 932... | ||
932 | ; get link status |
932 | ; get link status |
933 | mov [device.state], ETH_LINK_UNKOWN |
933 | mov [device.state], ETH_LINK_UNKOWN |
Line 934... | Line 934... | ||
934 | 934 | ||
Line 935... | Line 935... | ||
935 | call check_media |
935 | call check_media |
936 | 936 | ||
937 | DEBUGF 1,"reset complete\n" |
937 | DEBUGF 1,"reset complete\n" |
Line 938... | Line 938... | ||
938 | xor eax, eax |
938 | xor eax, eax |
939 | ret |
939 | ret |
Line 940... | Line 940... | ||
940 | 940 | ||
Line 941... | Line 941... | ||
941 | 941 | ||
942 | align 4 |
942 | align 4 |
943 | init_ring: |
943 | init_ring: |
944 | 944 | ||
Line 1037... | Line 1037... | ||
1037 | call [device.write_csr] |
1037 | call [device.write_csr] |
Line 1038... | Line 1038... | ||
1038 | 1038 | ||
1039 | ; get next descriptor 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, ... |
1039 | ; get next descriptor 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, ... |
1040 | inc [device.cur_tx] |
1040 | inc [device.cur_tx] |
1041 | and [device.cur_tx], TX_RING_SIZE - 1 |
- | |
Line 1042... | Line 1041... | ||
1042 | DEBUGF 1," - Packet Sent! " |
1041 | and [device.cur_tx], TX_RING_SIZE - 1 |
1043 | 1042 | ||
1044 | ; Update stats |
1043 | ; Update stats |
1045 | inc [device.packets_tx] |
1044 | inc [device.packets_tx] |
Line 1051... | Line 1050... | ||
1051 | DEBUGF 1," - Done!\n" |
1050 | DEBUGF 1," - Done!\n" |
1052 | xor eax, eax |
1051 | xor eax, eax |
1053 | ret 8 |
1052 | ret 8 |
Line 1054... | Line 1053... | ||
1054 | 1053 | ||
1055 | .nospace: |
1054 | .nospace: |
1056 | DEBUGF 1, 'ERROR: no free transmit descriptors\n' |
1055 | DEBUGF 2, "ERROR: no free transmit descriptors\n" |
1057 | stdcall KernelFree, [esp+4] |
1056 | stdcall KernelFree, [esp+4] |
1058 | or eax, -1 |
1057 | or eax, -1 |
Line 1069... | Line 1068... | ||
1069 | align 4 |
1068 | align 4 |
1070 | int_handler: |
1069 | int_handler: |
Line 1071... | Line 1070... | ||
1071 | 1070 | ||
Line 1072... | Line 1071... | ||
1072 | push ebx esi edi |
1071 | push ebx esi edi |
Line 1073... | Line 1072... | ||
1073 | 1072 | ||
Line 1074... | Line 1073... | ||
1074 | DEBUGF 1,"\n%s int\n", my_service |
1073 | DEBUGF 1,"INT\n" |
1075 | 1074 | ||
Line 1228... | Line 1227... | ||
1228 | ;; Read MAC address ;; |
1227 | ;; Read MAC address ;; |
1229 | ;; ;; |
1228 | ;; ;; |
1230 | ;;;;;;;;;;;;;;;;;;;;;; |
1229 | ;;;;;;;;;;;;;;;;;;;;;; |
1231 | align 4 |
1230 | align 4 |
1232 | read_mac: |
1231 | read_mac: |
1233 | DEBUGF 1,"Reading MAC" |
1232 | DEBUGF 1,"Reading MAC:\n" |
Line 1234... | Line 1233... | ||
1234 | 1233 | ||
1235 | mov edx, [device.io_addr] |
1234 | mov edx, [device.io_addr] |
1236 | add dx, 6 |
1235 | add dx, 6 |
1237 | @@: |
1236 | @@: |
1238 | dec dx |
1237 | dec dx |
1239 | dec dx |
1238 | dec dx |
1240 | in ax, dx |
1239 | in ax, dx |
1241 | push ax |
- | |
1242 | DEBUGF 1,"." |
1240 | push ax |
1243 | cmp edx, [device.io_addr] |
1241 | cmp edx, [device.io_addr] |
Line 1244... | Line 1242... | ||
1244 | ja @r |
1242 | ja @r |
Line 1245... | Line 1243... | ||
1245 | 1243 | ||
1246 | DEBUGF 1," %x-%x-%x-%x-%x-%x\n",[esp+0]:2,[esp+1]:2,[esp+2]:2,[esp+3]:2,[esp+4]:2,[esp+5]:2 |
1244 | DEBUGF 1,"%x-%x-%x-%x-%x-%x\n",[esp+0]:2,[esp+1]:2,[esp+2]:2,[esp+3]:2,[esp+4]:2,[esp+5]:2 |
1247 | 1245 | ||
1248 | lea edi, [device.mac] |
1246 | lea edi, [device.mac] |
Line 1523... | Line 1521... | ||
1523 | check_media: |
1521 | check_media: |
Line 1524... | Line 1522... | ||
1524 | 1522 | ||
Line 1525... | Line 1523... | ||
1525 | DEBUGF 1, "check_media\n" |
1523 | DEBUGF 1, "check_media\n" |
1526 | 1524 | ||
Line 1527... | Line 1525... | ||
1527 | test [device.mii], 1 |
1525 | test [device.mii], 1 |
1528 | jnz mii_link_ok |
1526 | jnz mii_link_ok |
1529 | 1527 |