Subversion Repositories Kolibri OS

Rev

Rev 425 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
425 victor 1
$Revision: 431 $
261 hidnplayr 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3
;;                                                                    ;;
431 serge 4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved.       ;;
5
;; Distributed under terms of the GNU General Public License          ;;
6
;;                                                                    ;;
261 hidnplayr 7
;;  SIS900.INC                                                        ;;
8
;;                                                                    ;;
9
;;  Ethernet driver for Menuet OS                                     ;;
10
;;                                                                    ;;
11
;;  Version 0.4  26 April 2004                                        ;;
12
;;                                                                    ;;
13
;;  This driver is based on the SIS900 driver from                    ;;
14
;;  the etherboot 5.0.6 project. The copyright statement is           ;;
15
;;                                                                    ;;
16
;;          GNU GENERAL PUBLIC LICENSE                                ;;
17
;;             Version 2, June 1991                                   ;;
18
;;                                                                    ;;
19
;;  remaining parts Copyright 2004 Jason Delozier,                    ;;
20
;;   cordata51@hotmail.com                                            ;;
21
;;                                                                    ;;
22
;;  See file COPYING for details                                      ;;
23
;;                                                                    ;;
24
;;  Updates:                                                          ;;
25
;;    Revision Look up table and SIS635 Mac Address by Jarek Pelczar  ;;
26
;;                                                                    ;;
27
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28
;********************************************************************
29
;   Interface
30
;      SIS900_reset
31
;      SIS900_probe
32
;      SIS900_poll
33
;      SIS900_transmit
34
;
35
;********************************************************************
36
;********************************************************************
37
;  Comments:
38
;    Known to work with the following SIS900 ethernet cards:
39
;      -  Device ID: 0x0900   Vendor ID: 0x1039   Revision: 0x91
40
;      -  Device ID: 0x0900   Vendor ID: 0x1039   Revision: 0x90
41
;
42
;    If your card is not listed, try it and let me know if it
43
;    functions properly and it will be aded to the list.  If not
44
;    we may be able to add support for it.
45
;
46
;  How To Use:
47
;    Add the following lines to Ethernet.inc in their appropriate locations
48
;
49
;         include "Sis900.INC"
50
;         dd  0x09001039, SIS900_probe, SIS900_reset, SIS900_poll,
51
; SIS900_transmit
52
;         dd  0x70161039, SIS900_probe, SIS900_reset, SIS900_poll,
53
; SIS900_transmit   ;untested
54
;
55
;  ToDo:
56
;     -  Enable MII interface for reading speed
57
;        and duplex settings.
58
;
59
;     -  Update Poll routine to support packet fragmentation.
60
;
61
;     -  Add additional support for other sis900 based cards
62
;
63
;********************************************************************
64
 
65
; comment the next line out if you don't want debug info printed
66
; on the debug board. This option adds a lot of bytes to the driver
67
; so it's worth to comment it out.
68
;        SIS900_DEBUG equ 1
69
 
70
 
71
;* buffers and descriptors
72
cur_rx  db  0
73
NUM_RX_DESC    equ    4               ;* Number of RX descriptors *
74
NUM_TX_DESC    equ    1               ;* Number of TX descriptors *
75
RX_BUFF_SZ          equ    1520            ;* Buffer size for each Rx buffer *
76
TX_BUFF_SZ          equ    1516            ;* Buffer size for each Tx buffer *
77
 
78
uglobal
79
align   4
80
txd: times (3 * NUM_TX_DESC) dd 0
81
rxd: times (3 * NUM_RX_DESC) dd 0
82
endg
83
 
84
txb equ eth_data_start
85
rxb equ txb + (NUM_TX_DESC * TX_BUFF_SZ)
86
SIS900_ETH_ALEN equ     6       ;* Size of Ethernet address *
87
SIS900_ETH_HLEN equ     14      ;* Size of ethernet header *
88
SIS900_ETH_ZLEN equ     60      ;* Minimum packet length *
89
SIS900_DSIZE equ 0x00000fff
90
SIS900_CRC_SIZE equ 4
91
SIS900_RFADDR_shift equ 16
92
;SIS900 Symbolic offsets to registers.
93
    SIS900_cr           equ     0x0               ; Command Register
94
    SIS900_cfg          equ     0x4       ; Configuration Register
95
    SIS900_mear     equ     0x8       ; EEPROM Access Register
96
    SIS900_ptscr    equ     0xc       ; PCI Test Control Register
97
    SIS900_isr          equ     0x10      ; Interrupt Status Register
98
    SIS900_imr          equ     0x14      ; Interrupt Mask Register
99
    SIS900_ier          equ     0x18      ; Interrupt Enable Register
100
    SIS900_epar         equ     0x18      ; Enhanced PHY Access Register
101
    SIS900_txdp     equ     0x20      ; Transmit Descriptor Pointer Register
102
    SIS900_txcfg    equ     0x24      ; Transmit Configuration Register
103
    SIS900_rxdp     equ     0x30      ; Receive Descriptor Pointer Register
104
    SIS900_rxcfg    equ     0x34      ; Receive Configuration Register
105
    SIS900_flctrl   equ     0x38      ; Flow Control Register
106
    SIS900_rxlen    equ     0x3c      ; Receive Packet Length Register
107
    SIS900_rfcr     equ     0x48      ; Receive Filter Control Register
108
    SIS900_rfdr     equ     0x4C      ; Receive Filter Data Register
109
    SIS900_pmctrl   equ     0xB0      ; Power Management Control Register
110
    SIS900_pmer         equ     0xB4      ; Power Management Wake-up Event Register
111
;SIS900 Command Register Bits
112
    SIS900_RELOAD       equ      0x00000400
113
    SIS900_ACCESSMODE   equ      0x00000200
114
    SIS900_RESET        equ      0x00000100
115
    SIS900_SWI          equ      0x00000080
116
    SIS900_RxRESET      equ      0x00000020
117
    SIS900_TxRESET      equ      0x00000010
118
    SIS900_RxDIS        equ      0x00000008
119
    SIS900_RxENA        equ      0x00000004
120
    SIS900_TxDIS        equ      0x00000002
121
    SIS900_TxENA        equ      0x00000001
122
;SIS900 Configuration Register Bits
123
    SIS900_DESCRFMT      equ    0x00000100 ; 7016 specific
124
    SIS900_REQALG        equ    0x00000080
125
    SIS900_SB            equ    0x00000040
126
    SIS900_POW           equ    0x00000020
127
    SIS900_EXD           equ    0x00000010
128
    SIS900_PESEL         equ    0x00000008
129
    SIS900_LPM           equ    0x00000004
130
    SIS900_BEM           equ    0x00000001
131
    SIS900_RND_CNT       equ    0x00000400
132
    SIS900_FAIR_BACKOFF  equ    0x00000200
133
    SIS900_EDB_MASTER_EN equ    0x00002000
134
;SIS900 Eeprom Access Reigster Bits
135
    SIS900_MDC        equ      0x00000040
136
    SIS900_MDDIR      equ      0x00000020
137
    SIS900_MDIO       equ      0x00000010  ; 7016 specific
138
    SIS900_EECS       equ      0x00000008
139
    SIS900_EECLK      equ      0x00000004
140
    SIS900_EEDO       equ      0x00000002
141
    SIS900_EEDI       equ      0x00000001
142
;SIS900 TX Configuration Register Bits
143
    SIS900_ATP        equ      0x10000000 ;Automatic Transmit Padding
144
    SIS900_MLB        equ      0x20000000 ;Mac Loopback Enable
145
    SIS900_HBI        equ      0x40000000 ;HeartBeat Ignore (Req for full-dup)
146
    SIS900_CSI        equ      0x80000000 ;CarrierSenseIgnore (Req for full-du
147
;SIS900 RX Configuration Register Bits
148
    SIS900_AJAB       equ      0x08000000 ;
149
    SIS900_ATX        equ      0x10000000 ;Accept Transmit Packets
150
    SIS900_ARP        equ      0x40000000 ;accept runt packets (<64bytes)
151
    SIS900_AEP        equ      0x80000000 ;accept error packets
152
;SIS900 Interrupt Reigster Bits
153
    SIS900_WKEVT           equ      0x10000000
154
    SIS900_TxPAUSEEND      equ      0x08000000
155
    SIS900_TxPAUSE         equ      0x04000000
156
    SIS900_TxRCMP          equ      0x02000000
157
    SIS900_RxRCMP          equ      0x01000000
158
    SIS900_DPERR           equ      0x00800000
159
    SIS900_SSERR           equ      0x00400000
160
    SIS900_RMABT           equ      0x00200000
161
    SIS900_RTABT           equ      0x00100000
162
    SIS900_RxSOVR          equ      0x00010000
163
    SIS900_HIBERR          equ      0x00008000
164
    SIS900_SWINT           equ      0x00001000
165
    SIS900_MIBINT          equ      0x00000800
166
    SIS900_TxURN           equ      0x00000400
167
    SIS900_TxIDLE          equ      0x00000200
168
    SIS900_TxERR           equ      0x00000100
169
    SIS900_TxDESC          equ      0x00000080
170
    SIS900_TxOK            equ      0x00000040
171
    SIS900_RxORN           equ      0x00000020
172
    SIS900_RxIDLE          equ      0x00000010
173
    SIS900_RxEARLY         equ      0x00000008
174
    SIS900_RxERR           equ      0x00000004
175
    SIS900_RxDESC          equ      0x00000002
176
    SIS900_RxOK            equ      0x00000001
177
;SIS900 Interrupt Enable Reigster Bits
178
    SIS900_IE      equ      0x00000001
179
;SIS900 Revision ID
180
        SIS900B_900_REV       equ      0x03
181
        SIS630A_900_REV       equ      0x80
182
        SIS630E_900_REV       equ      0x81
183
        SIS630S_900_REV       equ      0x82
184
        SIS630EA1_900_REV     equ      0x83
185
        SIS630ET_900_REV      equ      0x84
186
        SIS635A_900_REV       equ      0x90
187
        SIS900_960_REV        equ      0x91
188
;SIS900 Receive Filter Control Register Bits
189
    SIS900_RFEN          equ 0x80000000
190
    SIS900_RFAAB         equ 0x40000000
191
    SIS900_RFAAM         equ 0x20000000
192
    SIS900_RFAAP         equ 0x10000000
193
    SIS900_RFPromiscuous equ 0x70000000
194
;SIS900 Reveive Filter Data Mask
195
    SIS900_RFDAT equ  0x0000FFFF
196
;SIS900 Eeprom Address
197
    SIS900_EEPROMSignature equ 0x00
198
    SIS900_EEPROMVendorID  equ 0x02
199
    SIS900_EEPROMDeviceID  equ 0x03
200
    SIS900_EEPROMMACAddr   equ 0x08
201
    SIS900_EEPROMChecksum  equ 0x0b
202
;The EEPROM commands include the alway-set leading bit.
203
;SIS900 Eeprom Command
204
    SIS900_EEread          equ 0x0180
205
    SIS900_EEwrite         equ 0x0140
206
    SIS900_EEerase         equ 0x01C0
207
    SIS900_EEwriteEnable   equ 0x0130
208
    SIS900_EEwriteDisable  equ 0x0100
209
    SIS900_EEeraseAll      equ 0x0120
210
    SIS900_EEwriteAll      equ 0x0110
211
    SIS900_EEaddrMask      equ 0x013F
212
    SIS900_EEcmdShift      equ 16
213
;For SiS962 or SiS963, request the eeprom software access
214
        SIS900_EEREQ    equ 0x00000400
215
        SIS900_EEDONE   equ 0x00000200
216
        SIS900_EEGNT    equ 0x00000100
217
;General Varibles
218
        SIS900_pci_revision:     db       0
219
        SIS900_Status                dd   0x03000000
220
sis900_specific_table:
221
;    dd SIS630A_900_REV,Get_Mac_SIS630A_900_REV,0
222
;    dd SIS630E_900_REV,Get_Mac_SIS630E_900_REV,0
223
    dd SIS630S_900_REV,Get_Mac_SIS635_900_REV,0
224
    dd SIS630EA1_900_REV,Get_Mac_SIS635_900_REV,0
225
    dd SIS630ET_900_REV,Get_Mac_SIS635_900_REV,0;SIS630ET_900_REV_SpecialFN
226
    dd SIS635A_900_REV,Get_Mac_SIS635_900_REV,0
227
    dd SIS900_960_REV,SIS960_get_mac_addr,0
228
    dd SIS900B_900_REV,SIS900_get_mac_addr,0
229
    dd 0,0,0,0 ; end of list
230
sis900_get_mac_func:    dd 0
231
sis900_special_func:    dd 0
232
sis900_table_entries:   db 8
233
 
234
;***************************************************************************
235
;   Function
236
;      SIS900_probe
237
;   Description
238
;      Searches for an ethernet card, enables it and clears the rx buffer
239
;      If a card was found, it enables the ethernet -> TCPIP link
240
;not done  - still need to probe mii transcievers
241
;***************************************************************************
242
if defined SIS900_DEBUG
243
SIS900_Debug_Str_Unsupported db 'Sorry your card is unsupported ',13,10,0
244
end if
245
SIS900_probe:
246
;******Wake Up Chip*******
247
   mov     al, 4
248
   mov     bh, [pci_dev]
249
   mov     ecx, 0
250
   mov     ah, [pci_bus]
251
   mov     bl, 0x40
252
   call    pci_write_reg
253
;*******Set some PCI Settings*********
254
   call    SIS900_adjust_pci_device
255
;*****Get Card Revision******
256
   mov     al, 1                                        ;one byte to read
257
   mov     bh, [pci_dev]
258
   mov     ah, [pci_bus]
259
   mov     bl, 0x08                                 ;Revision Register
260
   call    pci_read_reg
261
   mov [SIS900_pci_revision], al        ;save the revision for later use
262
;****** Look up through the sis900_specific_table
263
   mov     esi,sis900_specific_table
264
.probe_loop:
265
   cmp     dword [esi],0                ; Check if we reached end of the list
266
   je      .probe_loop_failed
267
   cmp     al,[esi]                     ; Check if revision is OK
268
   je      .probe_loop_ok
269
   add     esi,12                       ; Advance to next entry
270
   jmp     .probe_loop
271
.probe_loop_failed:
272
   jmp     SIS900_Probe_Unsupported
273
;*********Find Get Mac Function*********
274
.probe_loop_ok:
275
   mov      eax,[esi+4]         ; Get pointer to "get MAC" function
276
   mov      [sis900_get_mac_func],eax
277
   mov      eax,[esi+8]         ; Get pointer to special initialization fn
278
   mov      [sis900_special_func],eax
279
;******** Get MAC ********
280
   call     dword [sis900_get_mac_func]
281
;******** Call special initialization fn if requested ********
282
   cmp      dword [sis900_special_func],0
283
   je       .no_special_init
284
   call     dword [sis900_special_func]
285
.no_special_init:
286
;******** Set table entries ********
287
   mov      al,[SIS900_pci_revision]
288
   cmp      al,SIS635A_900_REV
289
   jae      .ent16
290
   cmp      al,SIS900B_900_REV
291
   je       .ent16
292
   jmp      .ent8
293
.ent16:
294
   mov      byte [sis900_table_entries],16
295
.ent8:
296
;*******Probe for mii transceiver*******
297
;TODO!!*********************
298
;*******Initialize Device*******
299
   call sis900_init
300
   ret
301
 
302
SIS900_Probe_Unsupported:
303
if defined SIS900_DEBUG
304
   mov     esi, SIS900_Debug_Str_Unsupported
305
   call    sys_msg_board_str
306
end if
307
   ret
308
;***************************************************************************
309
; Function: sis900_init
310
;
311
; Description: resets the ethernet controller chip and various
312
;    data structures required for sending and receiving packets.
313
;
314
; Arguments:
315
;
316
; returns:   none
317
;not done
318
;***************************************************************************
319
sis900_init:
320
   call SIS900_reset               ;Done
321
   call SIS900_init_rxfilter   ;Done
322
   call SIS900_init_txd        ;Done
323
   call SIS900_init_rxd            ;Done
324
   call SIS900_set_rx_mode     ;done
325
   call SIS900_set_tx_mode
326
   ;call SIS900_check_mode
327
   ret
328
 
329
;***************************************************************************
330
;   Function
331
;      SIS900_reset
332
;   Description
333
;      disables interrupts and soft resets the controller chip
334
;
335
;done+
336
;***************************************************************************
337
if defined SIS900_DEBUG
338
   SIS900_Debug_Reset_Failed db 'Reset Failed ',0
339
end if
340
SIS900_reset:
341
   ;******Disable Interrupts and reset Receive Filter*******
342
   mov      ebp, [io_addr]      ; base address
343
   xor      eax, eax            ; 0 to initialize
344
   lea      edx,[ebp+SIS900_ier]
345
   out      dx, eax                     ; Write 0 to location
346
   lea      edx,[ebp+SIS900_imr]
347
   out      dx, eax                     ; Write 0 to location
348
   lea      edx,[ebp+SIS900_rfcr]
349
   out      dx, eax                     ; Write 0 to location
350
   ;*******Reset Card***********************************************
351
   lea      edx,[ebp+SIS900_cr]
352
   in       eax, dx                             ; Get current Command Register
353
   or       eax, SIS900_RESET           ; set flags
354
   or       eax, SIS900_RxRESET     ;
355
   or           eax, SIS900_TxRESET         ;
356
   out      dx, eax                             ; Write new Command Register
357
   ;*******Wait Loop************************************************
358
   lea      edx,[ebp+SIS900_isr]
359
   mov      ecx, [SIS900_Status]    ; Status we would like to see from card
360
   mov      ebx, 2001               ; only loop 1000 times
361
SIS900_Wait:
362
   dec      ebx                                     ; 1 less loop
363
   jz       SIS900_DoneWait_e           ; 1000 times yet?
364
   in       eax, dx                                 ; move interrup status to eax
365
   and      eax, ecx
366
   xor      ecx, eax
367
   jz       SIS900_DoneWait
368
   jmp      SIS900_Wait
369
SIS900_DoneWait_e:
370
if defined SIS900_DEBUG
371
   mov esi, SIS900_Debug_Reset_Failed
372
   call sys_msg_board_str
373
end if
374
SIS900_DoneWait:
375
   ;*******Set Configuration Register depending on Card Revision********
376
   lea      edx,[ebp+SIS900_cfg]
377
   mov      eax, SIS900_PESEL               ; Configuration Register Bit
378
   mov      bl, [SIS900_pci_revision]   ; card revision
379
   mov      cl, SIS635A_900_REV         ; Check card revision
380
   cmp      bl, cl
381
   je       SIS900_RevMatch
382
   mov      cl, SIS900B_900_REV         ; Check card revision
383
   cmp      bl, cl
384
   je       SIS900_RevMatch
385
   out      dx, eax                                 ; no revision match
386
   jmp      SIS900_Reset_Complete
387
SIS900_RevMatch:                                        ; Revision match
388
   or       eax, SIS900_RND_CNT         ; Configuration Register Bit
389
   out      dx, eax
390
SIS900_Reset_Complete:
391
   mov      eax, [pci_data]
392
   mov      [eth_status], eax
393
   ret
394
 
395
;***************************************************************************
396
; Function: sis_init_rxfilter
397
;
398
; Description: sets receive filter address to our MAC address
399
;
400
; Arguments:
401
;
402
; returns:
403
;done+
404
;***************************************************************************
405
SIS900_init_rxfilter:
406
   ;****Get Receive Filter Control Register ********
407
   mov      ebp, [io_addr]          ; base address
408
   lea      edx,[ebp+SIS900_rfcr]
409
   in       eax, dx                         ; get register
410
   push     eax
411
   ;****disable packet filtering before setting filter*******
412
   mov      eax, SIS900_RFEN    ;move receive filter enable flag
413
   not      eax                         ;1s complement
414
   pop      ebx                         ;and with our saved register
415
   and      eax, ebx                    ;disable receiver
416
   push     ebx                 ;save filter for another use
417
   out      dx, eax                     ;set receive disabled
418
   ;********load MAC addr to filter data register*********
419
   xor      ecx, ecx
420
SIS900_RXINT_Mac_Write:
421
   ;high word of eax tells card which mac byte to write
422
   mov      eax, ecx
423
   lea      edx,[ebp+SIS900_rfcr]
424
   shl      eax, 16                                             ;
425
   out      dx, eax                                             ;
426
   lea      edx,[ebp+SIS900_rfdr]
427
   mov      ax,  word [node_addr+ecx*2] ; Get Mac ID word
428
   out      dx, ax                                              ; Send Mac ID
429
   inc      cl                                                  ; send next word
430
   cmp      cl, 3                                               ; more to send?
431
   jne      SIS900_RXINT_Mac_Write
432
   ;********enable packet filitering *****
433
   pop      eax                             ;old register value
434
   lea      edx,[ebp+SIS900_rfcr]
435
   or       eax, SIS900_RFEN    ;enable filtering
436
   out      dx, eax             ;set register
437
   ret
438
 
439
;***************************************************************************
440
;*
441
;* Function: sis_init_txd
442
;*
443
;* Description: initializes the Tx descriptor
444
;*
445
;* Arguments:
446
;*
447
;* returns:
448
;*done
449
;***************************************************************************
450
SIS900_init_txd:
451
   ;********** initialize TX descriptor **************
452
   mov     [txd], dword 0       ;put link to next descriptor in link field
453
   mov     [txd+4],dword 0      ;clear status field
454
   mov     [txd+8], dword txb   ;save address to buffer ptr field
455
   ;*************** load Transmit Descriptor Register ***************
456
   mov     dx, [io_addr]            ; base address
457
   add     dx, SIS900_txdp      ; TX Descriptor Pointer
458
   mov     eax, txd                         ; First Descriptor
459
   out     dx, eax                              ; move the pointer
460
   ret
461
 
462
;***************************************************************************
463
;* Function: sis_init_rxd
464
;*
465
;* Description: initializes the Rx descriptor ring
466
;*
467
;* Arguments:
468
;*
469
;* Returns:
470
;*done
471
;***************************************************************************
472
SIS900_init_rxd:
473
   xor      ecx,ecx
474
   mov      [cur_rx], cl                                        ;Set cuurent rx discriptor to 0
475
   ;******** init RX descriptors ********
476
SIS900_init_rxd_Loop:
477
    mov     eax, ecx                                        ;current descriptor
478
    imul    eax, 12                         ;
479
    mov     ebx, ecx                                        ;determine next link descriptor
480
    inc     ebx                             ;
481
    cmp     ebx, NUM_RX_DESC                ;
482
    jne     SIS900_init_rxd_Loop_0          ;
483
    xor     ebx, ebx                        ;
484
SIS900_init_rxd_Loop_0:                    ;
485
    imul    ebx, 12                         ;
486
    add     ebx, rxd                        ;
487
    mov     [rxd+eax], ebx                                      ;save link to next descriptor
488
    mov     [rxd+eax+4],dword RX_BUFF_SZ        ;status bits init to buf size
489
    mov     ebx, ecx                                            ;find where the buf is located
490
    imul    ebx,RX_BUFF_SZ                  ;
491
    add     ebx, rxb                        ;
492
    mov     [rxd+eax+8], ebx                            ;save buffer pointer
493
    inc     ecx                                                     ;next descriptor
494
    cmp     ecx, NUM_RX_DESC                ;
495
    jne     SIS900_init_rxd_Loop            ;
496
    ;********* load Receive Descriptor Register with address of first
497
    ; descriptor*********
498
    mov     dx, [io_addr]
499
    add     dx, SIS900_rxdp
500
    mov     eax, rxd
501
    out     dx, eax
502
    ret
503
 
504
;***************************************************************************
505
;* Function: sis900_set_tx_mode
506
;*
507
;* Description:
508
;*    sets the transmit mode to allow for full duplex
509
;*
510
;*
511
;* Arguments:
512
;*
513
;* Returns:
514
;*
515
;* Comments:
516
;*     If you are having problems transmitting packet try changing the
517
;*     Max DMA Burst, Possible settings are as follows:
518
;*         0x00000000 = 512 bytes
519
;*         0x00100000 = 4 bytes
520
;*         0x00200000 = 8 bytes
521
;*         0x00300000 = 16 bytes
522
;*         0x00400000 = 32 bytes
523
;*         0x00500000 = 64 bytes
524
;*         0x00600000 = 128 bytes
525
;*         0x00700000 = 256 bytes
526
;***************************************************************************
527
SIS900_set_tx_mode:
528
   mov      ebp,[io_addr]
529
   lea      edx,[ebp+SIS900_cr]
530
   in       eax, dx                         ; Get current Command Register
531
   or       eax, SIS900_TxENA   ;Enable Receive
532
   out      dx, eax
533
   lea      edx,[ebp+SIS900_txcfg]; Transmit config Register offset
534
   mov      eax, SIS900_ATP             ;allow automatic padding
535
   or       eax, SIS900_HBI             ;allow heartbeat ignore
536
   or       eax, SIS900_CSI             ;allow carrier sense ignore
537
   or       eax, 0x00600000     ;Max DMA Burst
538
   or       eax, 0x00000100     ;TX Fill Threshold
539
   or       eax, 0x00000020     ;TX Drain Threshold
540
   out      dx, eax
541
   ret
542
 
543
;***************************************************************************
544
;* Function: sis900_set_rx_mode
545
;*
546
;* Description:
547
;*    sets the receive mode to accept all broadcast packets and packets
548
;*    with our MAC address, and reject all multicast packets.  Also allows
549
;*    full-duplex
550
;*
551
;* Arguments:
552
;*
553
;* Returns:
554
;*
555
;* Comments:
556
;*     If you are having problems receiving packet try changing the
557
;*     Max DMA Burst, Possible settings are as follows:
558
;*         0x00000000 = 512 bytes
559
;*         0x00100000 = 4 bytes
560
;*         0x00200000 = 8 bytes
561
;*         0x00300000 = 16 bytes
562
;*         0x00400000 = 32 bytes
563
;*         0x00500000 = 64 bytes
564
;*         0x00600000 = 128 bytes
565
;*         0x00700000 = 256 bytes
566
;***************************************************************************
567
SIS900_mc_filter: times 16 dw 0
568
SIS900_set_rx_mode:
569
   mov      ebp,[io_addr]
570
    ;**************update Multicast Hash Table in Receive Filter
571
   mov      ebx, 0xffff
572
   xor      cl, cl
573
SIS900_set_rx_mode_Loop:
574
   mov      eax, ecx
575
   shl      eax, 1
576
   mov      [SIS900_mc_filter+eax], ebx
577
   lea      edx,[ebp+SIS900_rfcr]           ; Receive Filter Control Reg offset
578
   mov      eax, 4                                          ;determine table entry
579
   add      al, cl
580
   shl      eax, 16
581
   out      dx, eax                                         ;tell card which entry to modify
582
   lea      edx,[ebp+SIS900_rfdr]           ; Receive Filter Control Reg offset
583
   mov      eax, ebx                                ;entry value
584
   out      dx, ax                                          ;write value to table in card
585
   inc      cl                                              ;next entry
586
   cmp      cl,[sis900_table_entries]   ;
587
   jl       SIS900_set_rx_mode_Loop
588
   ;*******Set Receive Filter Control Register*************
589
   lea      edx,[ebp+SIS900_rfcr]       ; Receive Filter Control Register offset
590
   mov      eax, SIS900_RFAAB           ;accecpt all broadcast packets
591
   or       eax, SIS900_RFAAM           ;accept all multicast packets
592
   or       eax, SIS900_RFAAP           ;Accept all packets
593
   or       eax, SIS900_RFEN            ;enable receiver filter
594
   out      dx, eax
595
   ;******Enable Receiver************
596
   lea      edx,[ebp+SIS900_cr] ; Command Register offset
597
   in       eax, dx                         ; Get current Command Register
598
   or       eax, SIS900_RxENA   ;Enable Receive
599
   out      dx, eax
600
   ;*********Set
601
   lea      edx,[ebp+SIS900_rxcfg]      ; Receive Config Register offset
602
   mov      eax, SIS900_ATX                     ;Accept Transmit Packets
603
                                    ; (Req for full-duplex and PMD Loopback)
604
   or       eax, 0x00600000                     ;Max DMA Burst
605
   or       eax, 0x00000002                     ;RX Drain Threshold, 8X8 bytes or 64bytes
606
   out      dx, eax                                     ;
607
   ret
608
 
609
;***************************************************************************
610
; *     SIS960_get_mac_addr: - Get MAC address for SiS962 or SiS963 model
611
; *     @pci_dev: the sis900 pci device
612
; *     @net_dev: the net device to get address for
613
; *
614
; *     SiS962 or SiS963 model, use EEPROM to store MAC address. And EEPROM
615
; *     is shared by
616
; *     LAN and 1394. When access EEPROM, send EEREQ signal to hardware first
617
; *     and wait for EEGNT. If EEGNT is ON, EEPROM is permitted to be access
618
; *     by LAN, otherwise is not. After MAC address is read from EEPROM, send
619
; *     EEDONE signal to refuse EEPROM access by LAN.
620
; *     The EEPROM map of SiS962 or SiS963 is different to SiS900.
621
; *     The signature field in SiS962 or SiS963 spec is meaningless.
622
; *     MAC address is read into @net_dev->dev_addr.
623
; *done
624
;*
625
;* Return 0 is EAX = failure
626
;*Done+
627
;***************************************************************************
628
if defined SIS900_DEBUG
629
SIS900_Debug_Str_GetMac_Start db 'Attempting to get SIS900 Mac ID: ',13,10,0
630
SIS900_Debug_Str_GetMac_Failed db 'Access to EEprom Failed',13,10,0
631
SIS900_Debug_Str_GetMac_Address db 'Your Mac ID is: ',0
632
SIS900_Debug_Str_GetMac_Address2 db 'Your SIS96x Mac ID is: ',0
633
end if
634
SIS960_get_mac_addr:
635
   mov      ebp,[io_addr]
636
   ;**********Send Request for eeprom access*********************
637
   lea      edx,[ebp+SIS900_mear]               ; Eeprom access register
638
   mov      eax, SIS900_EEREQ                   ; Request access to eeprom
639
   out      dx, eax                                             ; Send request
640
   xor      ebx,ebx                                             ;
641
   ;******Loop 4000 times and if access not granted error out*****
642
SIS96X_Get_Mac_Wait:
643
   in       eax, dx                                     ;get eeprom status
644
   and      eax, SIS900_EEGNT       ;see if eeprom access granted flag is set
645
   jnz      SIS900_Got_EEP_Access       ;if it is, go access the eeprom
646
   inc      ebx                                         ;else keep waiting
647
   cmp      ebx, 4000                           ;have we tried 4000 times yet?
648
   jl       SIS96X_Get_Mac_Wait     ;if not ask again
649
   xor      eax, eax                ;return zero in eax indicating failure
650
   ;*******Debug **********************
651
if defined SIS900_DEBUG
652
   mov esi,SIS900_Debug_Str_GetMac_Failed
653
   call sys_msg_board_str
654
end if
655
   jmp SIS960_get_mac_addr_done
656
   ;**********EEprom access granted, read MAC from card*************
657
SIS900_Got_EEP_Access:
658
    ; zero based so 3-16 bit reads will take place
659
   mov      ecx, 2
660
SIS96x_mac_read_loop:
661
   mov      eax, SIS900_EEPROMMACAddr    ;Base Mac Address
662
   add      eax, ecx                                 ;Current Mac Byte Offset
663
   push     ecx
664
   call     sis900_read_eeprom           ;try to read 16 bits
665
   pop      ecx
666
   mov      [node_addr+ecx*2], ax        ;save 16 bits to the MAC ID varible
667
   dec      ecx                          ;one less word to read
668
   jns      SIS96x_mac_read_loop         ;if more read more
669
   mov      eax, 1                       ;return non-zero indicating success
670
   ;*******Debug Print MAC ID to debug window**********************
671
if defined SIS900_DEBUG
672
   mov esi,SIS900_Debug_Str_GetMac_Address2
673
   call sys_msg_board_str
674
   mov edx, node_addr
675
   call Create_Mac_String
676
end if
677
   ;**********Tell EEPROM We are Done Accessing It*********************
678
SIS960_get_mac_addr_done:
679
   lea      edx,[ebp+SIS900_mear]               ; Eeprom access register
680
   mov      eax, SIS900_EEDONE           ;tell eeprom we are done
681
   out      dx,eax
682
   ret
683
;***************************************************************************
684
;*      sis900_get_mac_addr: - Get MAC address for stand alone SiS900 model
685
;*      @pci_dev: the sis900 pci device
686
;*      @net_dev: the net device to get address for
687
;*
688
;*      Older SiS900 and friends, use EEPROM to store MAC address.
689
;*      MAC address is read from read_eeprom() into @net_dev->dev_addr.
690
;* done/untested
691
;***************************************************************************
692
SIS900_get_mac_addr:
693
   ;*******Debug **********************
694
if defined SIS900_DEBUG
695
   mov esi,SIS900_Debug_Str_GetMac_Start
696
   call sys_msg_board_str
697
end if
698
   ;******** check to see if we have sane EEPROM *******
699
   mov      eax, SIS900_EEPROMSignature  ;Base Eeprom Signature
700
   call     sis900_read_eeprom           ;try to read 16 bits
701
   cmp ax, 0xffff
702
   je SIS900_Bad_Eeprom
703
   cmp ax, 0
704
   je SIS900_Bad_Eeprom
705
   ;**************Read MacID**************
706
   ; zero based so 3-16 bit reads will take place
707
   mov      ecx, 2
708
SIS900_mac_read_loop:
709
   mov      eax, SIS900_EEPROMMACAddr    ;Base Mac Address
710
   add      eax, ecx                                 ;Current Mac Byte Offset
711
   push     ecx
712
   call     sis900_read_eeprom           ;try to read 16 bits
713
   pop      ecx
714
   mov      [node_addr+ecx*2], ax        ;save 16 bits to the MAC ID storage
715
   dec      ecx                          ;one less word to read
716
   jns      SIS900_mac_read_loop         ;if more read more
717
   mov      eax, 1                       ;return non-zero indicating success
718
   ;*******Debug Print MAC ID to debug window**********************
719
if defined SIS900_DEBUG
720
   mov esi,SIS900_Debug_Str_GetMac_Address
721
   call sys_msg_board_str
722
   mov edx, node_addr
723
   call Create_Mac_String
724
end if
725
   ret
726
 
727
SIS900_Bad_Eeprom:
728
   xor eax, eax
729
   ;*******Debug **********************
730
if defined SIS900_DEBUG
731
   mov esi,SIS900_Debug_Str_GetMac_Failed
732
   call sys_msg_board_str
733
end if
734
   ret
735
;***************************************************************************
736
;*      Get_Mac_SIS635_900_REV: - Get MAC address for model 635
737
;*
738
;*
739
;***************************************************************************
740
Get_Mac_SIS635_900_REV:
741
if defined SIS900_DEBUG
742
    mov     esi,SIS900_Debug_Str_GetMac_Start
743
    call    sys_msg_board_str
744
end if
745
    mov     ebp,[io_addr]
746
    lea     edx,[ebp+SIS900_rfcr]
747
    in      eax,dx
748
    mov     edi,eax ; EDI=rfcrSave
749
    lea     edx,[ebp+SIS900_cr]
750
    or      eax,SIS900_RELOAD
751
    out     dx,eax
752
    xor     eax,eax
753
    out     dx,eax
754
    ; Disable packet filtering before setting filter
755
    lea     edx,[ebp+SIS900_rfcr]
756
    mov     eax,edi
757
    and     edi,not SIS900_RFEN
758
    out     dx,eax
759
    ; Load MAC to filter data register
760
    xor     ecx,ecx
761
    mov     esi,node_addr
762
.get_mac_loop:
763
    lea     edx,[ebp+SIS900_rfcr]
764
    mov     eax,ecx
765
    shl     eax,SIS900_RFADDR_shift
766
    out     dx,eax
767
    lea     edx,[ebp+SIS900_rfdr]
768
    in      eax,dx
769
    mov     [esi],ax
770
    add     esi,2
771
    inc     ecx
772
    cmp     ecx,3
773
    jne .get_mac_loop
774
    ; Enable packet filtering
775
    ;lea     edx,[ebp+SIS900_rfcr]
776
    ;mov     eax,edi
777
    ;or      eax,SIS900_RFEN
778
    ;out     dx, eax
779
   ;*******Debug Print MAC ID to debug window**********************
780
if defined SIS900_DEBUG
781
    mov     esi,SIS900_Debug_Str_GetMac_Address
782
    call    sys_msg_board_str
783
    mov     edx, node_addr
784
    call    Create_Mac_String
785
end if
786
    ret
787
;***************************************************************************
788
;* Function: sis900_read_eeprom
789
;*
790
;* Description: reads and returns a given location from EEPROM
791
;*
792
;* Arguments: eax - location:       requested EEPROM location
793
;*
794
;* Returns:   eax :                contents of requested EEPROM location
795
;*
796
; Read Serial EEPROM through EEPROM Access Register, Note that location is
797
;   in word (16 bits) unit */
798
;done+
799
;***************************************************************************
800
sis900_read_eeprom:
801
   push      esi
802
   push      edx
803
   push      ecx
804
   push      ebx
805
   mov       ebp,[io_addr]
806
   mov       ebx, eax              ;location of Mac byte to read
807
   or        ebx, SIS900_EEread    ;
808
   lea       edx,[ebp+SIS900_mear] ; Eeprom access register
809
   xor       eax, eax              ; start send
810
   out       dx,eax
811
   call      SIS900_Eeprom_Delay_1
812
   mov       eax, SIS900_EECLK
813
   out       dx, eax
814
   call      SIS900_Eeprom_Delay_1
815
    ;************ Shift the read command (9) bits out. *********
816
   mov       cl, 8                                      ;
817
sis900_read_eeprom_Send:
818
   mov       eax, 1
819
   shl       eax, cl
820
   and       eax, ebx
821
   jz SIS900_Read_Eeprom_8
822
   mov       eax, 9
823
   jmp       SIS900_Read_Eeprom_9
824
SIS900_Read_Eeprom_8:
825
   mov       eax, 8
826
SIS900_Read_Eeprom_9:
827
   out       dx, eax
828
   call      SIS900_Eeprom_Delay_1
829
   or        eax, SIS900_EECLK
830
   out       dx, eax
831
   call      SIS900_Eeprom_Delay_1
832
   cmp       cl, 0
833
   je        sis900_read_eeprom_Send_Done
834
   dec       cl
835
   jmp       sis900_read_eeprom_Send
836
   ;*********************
837
sis900_read_eeprom_Send_Done:
838
   mov       eax, SIS900_EECS           ;
839
   out       dx, eax
840
   call      SIS900_Eeprom_Delay_1
841
    ;********** Read 16-bits of data in ***************
842
    mov      cx, 16                             ;16 bits to read
843
sis900_read_eeprom_Send2:
844
    mov      eax, SIS900_EECS
845
    out      dx, eax
846
    call     SIS900_Eeprom_Delay_1
847
    or       eax, SIS900_EECLK
848
    out      dx, eax
849
    call     SIS900_Eeprom_Delay_1
850
    in       eax, dx
851
    shl      ebx, 1
852
    and      eax, SIS900_EEDO
853
    jz       SIS900_Read_Eeprom_0
854
    or       ebx, 1
855
SIS900_Read_Eeprom_0:
856
   dec       cx
857
   jnz       sis900_read_eeprom_Send2
858
   ;************** Terminate the EEPROM access. **************
859
   xor       eax, eax
860
   out       dx, eax
861
   call      SIS900_Eeprom_Delay_1
862
   mov       eax, SIS900_EECLK
863
   out       dx, eax
864
   mov       eax, ebx
865
   and       eax, 0x0000ffff                    ;return only 16 bits
866
   pop       ebx
867
   pop       ecx
868
   pop       edx
869
   pop       esi
870
   ret
871
;***************************************************************************
872
;   Function
873
;      SIS900_Eeprom_Delay_1
874
;   Description
875
;
876
;
877
;
878
;
879
;***************************************************************************
880
SIS900_Eeprom_Delay_1:
881
   push eax
882
   in eax, dx
883
   pop eax
884
   ret
885
 
886
;***************************************************************************
887
;   Function
888
;      SIS900_poll
889
;   Description
890
;      polls card to see if there is a packet waiting
891
;
892
;  Currently only supports one descriptor per packet, if packet is fragmented
893
;  between multiple descriptors you will lose part of the packet
894
;***************************************************************************
895
if defined SIS900_DEBUG
896
SIS900_Debug_Pull_Packet_good db 'Good Packet Waiting: ',13,10,0
897
SIS900_Debug_Pull_Bad_Packet_Status db 'Bad Packet Waiting: Status',13,10,0
898
SIS900_Debug_Pull_Bad_Packet_Size db 'Bad Packet Waiting: Size',13,10,0
899
end if
900
SIS900_poll:
901
    ;**************Get Status **************
902
    xor       eax, eax                      ;get RX_Status
903
    mov      [eth_rx_data_len], ax
904
    mov       al, [cur_rx]          ;find current discriptor
905
    imul      eax, 12               ;
906
    mov       ecx, [rxd+eax+4]          ; get receive status
907
    ;**************Check Status **************
908
    mov       ebx, ecx                          ;move status
909
    ;Check RX_Status to see if packet is waiting
910
    and       ebx, 0x80000000
911
    jnz       SIS900_poll_IS_packet
912
    ret
913
   ;**********There is a packet waiting check it for errors**************
914
SIS900_poll_IS_packet:
915
    mov       ebx, ecx                          ;move status
916
    and       ebx, 0x67C0000            ;see if there are any errors
917
    jnz       SIS900_Poll_Error_Status
918
   ;**************Check size of packet*************
919
   and       ecx, SIS900_DSIZE                                  ;get packet size minus CRC
920
   cmp       cx, SIS900_CRC_SIZE
921
   ;make sure packet contains data
922
   jle       SIS900_Poll_Error_Size
923
   ;*******Copy Good Packet to receive buffer******
924
   sub      cx, SIS900_CRC_SIZE                             ;dont want crc
925
   mov      word [eth_rx_data_len], cx          ;save size of packet
926
   ;**********Continue copying packet****************
927
   push     ecx
928
   ; first copy dword-wise, divide size by 4
929
   shr      ecx, 2
930
   mov      esi, [rxd+eax+8]                            ; set source
931
   mov      edi, Ether_buffer               ; set destination
932
   cld                                                                          ; clear direction
933
   rep      movsd                                                       ; copy the dwords
934
   pop      ecx
935
   and      ecx, 3                                                  ;
936
   rep      movsb
937
   ;********Debug, tell user we have a good packet*************
938
if defined SIS900_DEBUG
939
   mov      esi, SIS900_Debug_Pull_Packet_good
940
   call     sys_msg_board_str
941
end if
942
   jmp SIS900_Poll_Cnt                      ;
943
   ;*************Error occured let user know through debug window***********
944
SIS900_Poll_Error_Status:
945
if defined SIS900_DEBUG
946
                mov      esi, SIS900_Debug_Pull_Bad_Packet_Status
947
                call     sys_msg_board_str
948
end if
949
                jmp      SIS900_Poll_Cnt
950
SIS900_Poll_Error_Size:
951
if defined SIS900_DEBUG
952
                mov      esi, SIS900_Debug_Pull_Bad_Packet_Size
953
                call     sys_msg_board_str
954
end if
955
   ;*************Increment to next available descriptor**************
956
SIS900_Poll_Cnt:
957
    ;Reset status, allow ethernet card access to descriptor
958
   mov      ecx, RX_BUFF_SZ
959
   mov      [rxd+eax+4], ecx                ;
960
   inc      [cur_rx]                                            ;get next descriptor
961
   and      [cur_rx],3                      ;only 4 descriptors 0-3
962
   ;******Enable Receiver************
963
   mov          ebp, [io_addr]      ; Base Address
964
   lea      edx,[ebp+SIS900_cr] ; Command Register offset
965
   in       eax, dx                         ; Get current Command Register
966
   or       eax, SIS900_RxENA   ;Enable Receive
967
   out      dx, eax
968
   ret
969
;***************************************************************************
970
;   Function
971
;      SIS900_transmit
972
;   Description
973
;      Transmits a packet of data via the ethernet card
974
;         Pointer to 48 bit destination address in edi
975
;         Type of packet in bx
976
;         size of packet in ecx
977
;         pointer to packet data in esi
978
;
979
;      only one transmit descriptor is used
980
;
981
;***************************************************************************
982
if defined SIS900_DEBUG
983
SIS900_Debug_Transmit_Packet db 'Transmitting Packet: ',13,10,0
984
SIS900_Debug_Transmit_Packet_Err db 'Transmitting Packet Error: ',13,10,0
985
end if
986
SIS900_transmit:
987
   mov          ebp, [io_addr]      ; Base Address
988
   ;******** Stop the transmitter ********
989
   lea      edx,[ebp+SIS900_cr] ; Command Register offset
990
   in       eax, dx                         ; Get current Command Register
991
   or       eax, SIS900_TxDIS   ; Disable Transmitter
992
   out      dx, eax
993
   ;*******load Transmit Descriptor Register *******
994
   lea      edx,[ebp+SIS900_txdp]
995
   mov      eax, txd
996
   out      dx, eax
997
   ;******* copy packet to descriptor*******
998
   push    esi
999
   mov     esi, edi                ;copy destination addess
1000
   mov     edi, txb
1001
   cld
1002
   movsd
1003
   movsw
1004
   mov     esi, node_addr  ;copy my mac address
1005
   movsd
1006
   movsw
1007
   mov     [edi], bx       ;copy packet type
1008
   add     edi, 2
1009
   pop     esi             ;restore pointer to source of packet
1010
   push    ecx             ;save packet size
1011
   shr     ecx, 2          ;divide by 4, size in bytes send in dwords
1012
   rep     movsd                   ;copy data to decriptor
1013
   pop     ecx                     ;restore packet size
1014
   push    ecx             ;save packet size
1015
   and     ecx, 3          ;last three bytes if not a multiple of 4
1016
   rep     movsb
1017
   ;**************set length tag**************
1018
   pop     ecx                           ;restore packet size
1019
   add     ecx, SIS900_ETH_HLEN  ;add header to length
1020
   and     ecx, SIS900_DSIZE     ;
1021
   ;**************pad to minimum packet size **************not needed
1022
   ;cmp       ecx, SIS900_ETH_ZLEN
1023
   ;jge       SIS900_transmit_Size_Ok
1024
   ;push      ecx
1025
   ;mov       ebx, SIS900_ETH_ZLEN
1026
   ;sub       ebx, ecx
1027
   ;mov       ecx, ebx
1028
   ;rep       movsb
1029
   ;pop       ecx
1030
SIS900_transmit_Size_Ok:
1031
   mov      [txd+4], dword 0x80000000                   ;card owns descriptor
1032
   or       [txd+4], ecx                                                ;set size of packet
1033
if defined SIS900_DEBUG
1034
   mov      esi, SIS900_Debug_Transmit_Packet
1035
   call     sys_msg_board_str
1036
end if
1037
   ;***************restart the transmitter ********
1038
   lea      edx,[ebp+SIS900_cr]
1039
   in       eax, dx                         ; Get current Command Register
1040
   or       eax, SIS900_TxENA   ; Enable Transmitter
1041
   out      dx, eax
1042
   ;****make sure packet transmitted successfully****
1043
;   mov      esi,10
1044
;   call     delay_ms
1045
   mov      eax, [txd+4]
1046
   and      eax, 0x6200000
1047
   jz       SIS900_transmit_OK
1048
   ;**************Tell user there was an error through debug window
1049
if defined SIS900_DEBUG
1050
   mov      esi, SIS900_Debug_Transmit_Packet_Err
1051
   call     sys_msg_board_str
1052
end if
1053
SIS900_transmit_OK:
1054
   ;******** Disable interrupts by clearing the interrupt mask. ********
1055
   lea      edx,[ebp+SIS900_imr]            ; Interupt Mask Register
1056
   xor      eax, eax
1057
   out      dx,eax
1058
   ret
1059
 
1060
;***************************************************************************
1061
;* Function: Create_Mac_String
1062
;*
1063
;* Description: Converts the 48 bit value to a string for display
1064
;*
1065
;* String Format: XX:XX:XX:XX:XX:XX
1066
;*
1067
;* Arguments: node_addr is location of 48 bit MAC ID
1068
;*
1069
;* Returns:   Prints string to general debug window
1070
;*
1071
;*
1072
;done
1073
;***************************************************************************
1074
if defined SIS900_DEBUG
1075
 
1076
SIS900_Char_String    db '0','1','2','3','4','5','6','7','8','9'
1077
                      db 'A','B','C','D','E','F'
1078
Mac_str_build: times 20 db 0
1079
Create_Mac_String:
1080
   pusha
1081
   xor ecx, ecx
1082
Create_Mac_String_loop:
1083
   mov al,byte [edx+ecx];[node_addr+ecx]
1084
   push eax
1085
   shr eax, 4
1086
   and eax, 0x0f
1087
   mov bl, byte [SIS900_Char_String+eax]
1088
   mov [Mac_str_build+ecx*3], bl
1089
   pop eax
1090
   and eax, 0x0f
1091
   mov bl, byte [SIS900_Char_String+eax]
1092
   mov [Mac_str_build+1+ecx*3], bl
1093
   cmp ecx, 5
1094
   je Create_Mac_String_done
1095
   mov bl, ':'
1096
   mov [Mac_str_build+2+ecx*3], bl
1097
   inc ecx
1098
   jmp Create_Mac_String_loop
1099
Create_Mac_String_done:                                 ;Insert CR and Zero Terminate
1100
   mov [Mac_str_build+2+ecx*3],byte 13
1101
   mov [Mac_str_build+3+ecx*3],byte 10
1102
   mov [Mac_str_build+4+ecx*3],byte 0
1103
   mov esi, Mac_str_build
1104
   call sys_msg_board_str                               ;Print String to message board
1105
   popa
1106
   ret
1107
end if
1108
;***************************************************************************
1109
;*      Set device to be a busmaster in case BIOS neglected to do so.
1110
;*      Also adjust PCI latency timer to a reasonable value, 64.
1111
;***************************************************************************
1112
SIS900_adjust_pci_device:
1113
   ;*******Get current setting************************
1114
   mov     al, 2                                        ;read a word
1115
   mov     bh, [pci_dev]
1116
   mov     ah, [pci_bus]
1117
   mov     bl, 0x04                                 ;from command Register
1118
   call    pci_read_reg
1119
   ;******see if its already set as bus master********
1120
   mov      bx, ax
1121
   and      bx,5
1122
   cmp      bx,5
1123
   je       SIS900_adjust_pci_device_Latency
1124
   ;******Make card a bus master*******
1125
   mov      cx, ax                              ;value to write
1126
   mov     bh, [pci_dev]
1127
   mov     al, 2                                ;write a word
1128
   or       cx,5
1129
   mov     ah, [pci_bus]
1130
   mov     bl, 0x04                             ;to command register
1131
   call    pci_write_reg
1132
   ;******Check latency setting***********
1133
SIS900_adjust_pci_device_Latency:
1134
   ;*******Get current latency setting************************
1135
   mov     al, 1                                        ;read a byte
1136
   mov     bh, [pci_dev]
1137
   mov     ah, [pci_bus]
1138
   mov     bl, 0x0D                                 ;from Lantency Timer Register
1139
   call    pci_read_reg
1140
   ;******see if its aat least 64 clocks********
1141
   cmp      ax,64
1142
   jge      SIS900_adjust_pci_device_Done
1143
   ;******Set latency to 32 clocks*******
1144
   mov     cx, 64                               ;value to write
1145
   mov     bh, [pci_dev]
1146
   mov     al, 1                                ;write a byte
1147
   mov     ah, [pci_bus]
1148
   mov     bl, 0x0D                             ;to Lantency Timer Register
1149
   call    pci_write_reg
1150
   ;******Check latency setting***********
1151
SIS900_adjust_pci_device_Done:
1152
   ret