Subversion Repositories Kolibri OS

Rev

Rev 2852 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2852 Rev 2981
Line 51... Line 51...
51
        .rx_buffer      dd ?
51
        .rx_buffer      dd ?
52
        .tx_buffer      dd ?
52
        .tx_buffer      dd ?
Line 53... Line 53...
53
 
53
 
Line 54... Line 54...
54
        .ee_bus_width   dd ?
54
        .ee_bus_width   dd ?
Line 55... Line 55...
55
 
55
 
56
        rb 5+8 ;;;; align
56
                        rb 0x100 - (($ - device) and 0xff)
57
 
57
 
58
        rxfd:
58
        rxfd:
59
        .status         dw ?
59
        .status         dw ?
60
        .command        dw ?
60
        .command        dw ?
61
        .link           dd ?
61
        .link           dd ?
62
        .rx_buf_addr    dd ?
62
        .rx_buf_addr    dd ?
Line 63... Line 63...
63
        .count          dw ?
63
        .count          dw ?
Line 64... Line 64...
64
        .size           dw ?
64
        .size           dw ?
65
        .packet         dd ?
65
        .packet         dd ?
66
 
66
 
67
        rb 12 ;;;;
67
                        rb 0x100 - (($ - device) and 0xff)
Line 75... Line 75...
75
        .tx_buf_addr0   dd ?
75
        .tx_buf_addr0   dd ?
76
        .tx_buf_size0   dd ?
76
        .tx_buf_size0   dd ?
77
        .tx_buf_addr1   dd ?
77
        .tx_buf_addr1   dd ?
78
        .tx_buf_size1   dd ?
78
        .tx_buf_size1   dd ?
Line -... Line 79...
-
 
79
 
-
 
80
                        rb 0x100 - (($ - device) and 0xff)
79
 
81
 
80
        confcmd:
82
        confcmd:
81
        .status:        dw ?
83
        .status:        dw ?
82
        .command:       dw ?
84
        .command:       dw ?
83
        .link:          dd ?
85
        .link:          dd ?
Line -... Line 86...
-
 
86
        .data           rb 64
-
 
87
 
84
        .data           rb 64
88
                        rb 0x100 - (($ - device) and 0xff)
85
 
89
 
86
        lstats:
90
        lstats:
87
        tx_good_frames          dd ?
91
        tx_good_frames          dd ?
88
        tx_coll16_errs          dd ?
92
        tx_coll16_errs          dd ?
Line 100... Line 104...
100
        rx_resource_errs        dd ?
104
        rx_resource_errs        dd ?
101
        rx_overrun_errs         dd ?
105
        rx_overrun_errs         dd ?
102
        rx_colls_errs           dd ?
106
        rx_colls_errs           dd ?
103
        rx_runt_errs            dd ?
107
        rx_runt_errs            dd ?
Line 104... Line 108...
104
 
108
 
Line 105... Line 109...
105
        device_size = $ - device
109
        sizeof.device_struct = $ - device
Line 106... Line 110...
106
 
110
 
Line 107... Line 111...
107
end virtual
111
end virtual
108
 
112
 
109
 
113
 
110
; Serial EEPROM
114
; Serial EEPROM
Line 111... Line 115...
111
 
115
 
112
EE_SK           =   1 shl 16   ; serial clock
116
EE_SK           =   1 shl 0   ; serial clock
113
EE_CS           =   1 shl 17   ; chip select
117
EE_CS           =   1 shl 1   ; chip select
Line 180... Line 184...
180
        cmp [state], 1
184
        cmp [state], 1
181
        jne .exit
185
        jne .exit
Line 182... Line 186...
182
 
186
 
Line 183... Line 187...
183
  .entry:
187
  .entry:
184
 
188
 
185
        DEBUGF 1,"Loading i8255x driver\n"
189
        DEBUGF 1,"Loading %s driver\n", my_service
Line 186... Line 190...
186
        stdcall RegService, my_service, service_proc
190
        stdcall RegService, my_service, service_proc
187
        ret
191
        ret
Line 250... Line 254...
250
 
254
 
251
 
255
 
252
; This device doesnt have its own eth_device structure yet, lets create one
256
; This device doesnt have its own eth_device structure yet, lets create one
253
  .firstdevice:
257
  .firstdevice:
Line 254... Line -...
254
        cmp     [devices], MAX_DEVICES                  ; First check if the driver can handle one more card
-
 
255
        jge     .fail
-
 
256
 
-
 
257
        push    edx
-
 
258
        stdcall KernelAlloc, device_size
-
 
259
        pop     edx
258
        cmp     [devices], MAX_DEVICES                  ; First check if the driver can handle one more card
Line 260... Line 259...
260
        test    eax, eax
259
        jae     .fail
Line 261... Line 260...
261
        jz      .fail
260
 
262
        mov     ebx, eax                                ; ebx is always used as a pointer to the structure (in driver, but also in kernel code)
261
        allocate_and_clear ebx, sizeof.device_struct, .fail      ; Allocate the buffer for device structure
263
 
262
 
264
; Fill in the direct call addresses into the struct
263
; Fill in the direct call addresses into the struct
265
 
264
 
266
        mov     [device.reset], reset
265
        mov     [device.reset], reset
Line 267... Line 266...
267
        mov     [device.transmit], transmit
266
        mov     [device.transmit], transmit
Line 658... Line 657...
658
;;;;;;;;;;;;;;;;;;;;;;;
657
;;;;;;;;;;;;;;;;;;;;;;;
Line 659... Line 658...
659
 
658
 
660
align 4
659
align 4
Line 661... Line 660...
661
int_handler:
660
int_handler:
Line 662... Line 661...
662
 
661
 
Line 663... Line -...
663
        DEBUGF  1,"IRQ %x ",eax:2                   ; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO
-
 
664
 
662
        DEBUGF  1,"\n%s int\n", my_service
665
; find pointer of device wich made IRQ occur
663
 
666
 
664
; find pointer of device wich made IRQ occur
-
 
665
 
667
        mov     esi, device_list
666
        mov     ecx, [devices]
668
        mov     ecx, [devices]
667
        test    ecx, ecx
Line 669... Line 668...
669
        test    ecx, ecx
668
        jz      .nothing
670
        jz      .fail
669
        mov     esi, device_list
671
.nextdevice:
670
  .nextdevice:
672
        mov     ebx, dword [esi]
671
        mov     ebx, [esi]
673
 
-
 
674
        set_io  0
-
 
675
  ;;      set_io  REG_ISR
-
 
676
   ;;     in      ax , dx
672
 
677
    ;;    out     dx , ax                             ; send it back to ACK
673
        set_io  0
678
 
674
        set_io  REG_ISR
-
 
675
        in      ax, dx
679
        add     esi, 4
676
        out     dx, ax                              ; send it back to ACK
680
 
677
        test    ax, ax
681
        test    ax , ax
678
        jnz     .got_it
682
        jnz     .got_it
679
  .continue:
Line 683... Line 680...
683
 
680
        add     esi, 4
Line -... Line 681...
-
 
681
        dec     ecx
Line 684... Line 682...
684
        dec     ecx
682
        jnz     .nextdevice
Line 685... Line 683...
685
        jnz     .nextdevice
683
  .nothing:
686
 
684
        ret                                         ; If no device was found, abort (The irq was probably for a device, not registered to this driver)
Line 728... Line 726...
728
  .nw:
726
  .nw:
729
        jz      .nd
727
        jz      .nd
730
        rep     movsd
728
        rep     movsd
731
  .nd:
729
  .nd:
Line 732... Line 730...
732
 
730
 
Line 733... Line 731...
733
        jmp     EthReceiver                         ; Send it to kernel
731
        jmp     Eth_input
734
 
732
 
Line 735... Line 733...
735
  .nodata:
733
  .nodata:
Line 897... Line 895...
897
ee_get_width:
895
ee_get_width:
Line 898... Line 896...
898
 
896
 
899
        set_io  0
897
        set_io  0
Line 900... Line 898...
900
        set_io  reg_eeprom
898
        set_io  reg_eeprom
901
 
899
 
902
        mov     esi, EE_READ shl 28
-
 
903
        xor     ecx, ecx
900
        mov     si, EE_READ shl 12
904
 
901
        xor     ecx, ecx
905
  .loop:
902
  .loop:
906
        mov     eax, EE_CS
903
        mov     ax, EE_CS
Line 907... Line 904...
907
        out     dx , eax
904
        out     dx, ax
908
        delay
905
        delay
909
 
906
 
Line 910... Line 907...
910
        or      eax, EE_SK
907
        or      ax, EE_SK
Line 911... Line 908...
911
        out     dx , eax
908
        out     dx, ax
912
        delay
909
        delay
913
 
910
 
Line 914... Line 911...
914
        inc     ecx
911
        inc     ecx
-
 
912
 
Line 915... Line -...
915
 
-
 
916
        in      eax, dx
-
 
917
        test    eax, EE_DO
-
 
918
        jnz     .loop
-
 
919
 
-
 
920
        mov     [device.ee_bus_width], ecx
-
 
921
 
-
 
922
;------------------------------
-
 
923
; Now read the data from eeprom
-
 
924
 
-
 
925
        mov     ecx, 16
-
 
926
  .loop2:
-
 
927
        mov     eax, EE_CS + EE_SK
-
 
Line 928... Line 913...
928
        out     dx , eax
913
        in      ax, dx
929
        delay
914
        test    ax, EE_DO
Line 930... Line 915...
930
 
915
        jnz     .loop
Line 998... Line 983...
998
        test    eax, 1 shl 28           ; ready bit
983
        test    eax, 1 shl 28           ; ready bit
999
        jz      .wait
984
        jz      .wait
Line 1000... Line 985...
1000
 
985
 
Line -... Line 986...
-
 
986
        ret
-
 
987
 
-
 
988
read_mac:
-
 
989
 
Line 1001... Line 990...
1001
        ret
990
        ret
1002
 
991
 
Line -... Line 992...
-
 
992
 
-
 
993
 
-
 
994
align 4
-
 
995
MAC_read_eeprom:
-
 
996
 
1003
 
997
        mov     esi, 0
-
 
998
        call    ee_read
-
 
999
 
-
 
1000
        mov     esi, 1
-
 
1001
        call    ee_read
-
 
1002
 
-
 
1003
        mov     esi, 14
Line 1004... Line 1004...
1004
 
1004
        call    ee_read
Line 1005... Line 1005...
1005
align 4
1005