Subversion Repositories Kolibri OS

Rev

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

Rev 4470 Rev 4597
Line 13... Line 13...
13
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;          GNU GENERAL PUBLIC LICENSE                             ;;
14
;;             Version 2, June 1991                                ;;
14
;;             Version 2, June 1991                                ;;
15
;;                                                                 ;;
15
;;                                                                 ;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 17... Line 17...
17
 
17
 
-
 
18
format PE DLL native
Line 18... Line 19...
18
format MS COFF
19
entry START
19
 
20
 
-
 
21
        CURRENT_API             = 0x0200
Line 20... Line 22...
20
        API_VERSION             = 0x01000100
22
        COMPATIBLE_API          = 0x0100
Line 21... Line -...
21
        DRIVER_VERSION          = 5
-
 
22
 
23
        API_VERSION             = (COMPATIBLE_API shl 16) + CURRENT_API
23
        MAX_DEVICES             = 16
24
 
Line 24... Line 25...
24
 
25
        MAX_DEVICES             = 16
Line 43... Line 44...
43
 
44
 
44
        RX_FIFO_THRESH          = 4             ; Rx buffer level before first PCI xfer.
45
        RX_FIFO_THRESH          = 4             ; Rx buffer level before first PCI xfer.
45
        RX_DMA_BURST            = 4             ; Maximum PCI burst, '4' is 256 bytes
46
        RX_DMA_BURST            = 4             ; Maximum PCI burst, '4' is 256 bytes
Line -... Line 47...
-
 
47
        TX_DMA_BURST            = 4
Line -... Line 48...
-
 
48
 
46
        TX_DMA_BURST            = 4
49
section '.flat' readable writable executable
47
 
50
 
48
 
-
 
49
include '../struct.inc'
-
 
50
include '../macros.inc'
51
include '../proc32.inc'
51
include '../proc32.inc'
52
include '../struct.inc'
52
include '../imports.inc'
-
 
53
include '../fdo.inc'
-
 
54
include '../netdrv.inc'
-
 
55
 
-
 
Line 56... Line 53...
56
public START
53
include '../macros.inc'
Line 57... Line 54...
57
public service_proc
54
include '../fdo.inc'
58
public version
55
include '../netdrv_pe.inc'
Line 170... Line 167...
170
RX_BUF_LEN      equ (8192 << RX_BUF_LEN_IDX)    ; Size of the in-memory receive ring.
167
RX_BUF_LEN      equ (8192 << RX_BUF_LEN_IDX)    ; Size of the in-memory receive ring.
Line 171... Line 168...
171
 
168
 
172
IO_SIZE         = 256       ; RDC MAC I/O Size
169
IO_SIZE         = 256       ; RDC MAC I/O Size
Line -... Line 170...
-
 
170
MAX_MAC         = 2         ; MAX RDC MAC
Line 173... Line -...
173
MAX_MAC         = 2         ; MAX RDC MAC
-
 
174
 
-
 
175
 
171
 
176
virtual at 0
172
struct  x_head
177
x_head:
173
 
178
  .status         dw ?   ;0-1
174
        status          dw ?   ;0-1
179
  .len            dw ?   ;2-3
175
        len             dw ?   ;2-3
180
  .buf            dd ?   ;4-7
176
        buf             dd ?   ;4-7
181
  .ndesc          dd ?   ;8-B
177
        ndesc           dd ?   ;8-B
182
  .rev1           dd ?   ;C-F
178
        rev1            dd ?   ;C-F
183
  .vbufp          dd ?   ;10-13
179
        vbufp           dd ?   ;10-13
184
  .vndescp        dd ?   ;14-17
-
 
185
  .skb_ptr        dd ?   ;18-1B
-
 
186
  .rev2           dd ?   ;1C-1F
180
        vndescp         dd ?   ;14-17
187
  .sizeof:
181
        skb_ptr         dd ?   ;18-1B
188
end virtual
-
 
189
 
182
        rev2            dd ?   ;1C-1F
190
 
-
 
191
virtual at ebx
183
 
192
 
184
ends
193
        device:
185
 
194
 
186
 
195
        ETH_DEVICE
-
 
196
 
187
struct  device          ETH_DEVICE
197
        .io_addr        dd ?
188
 
198
 
189
        io_addr         dd ?
-
 
190
        pci_bus         dd ?
-
 
191
        pci_dev         dd ?
199
        .cur_rx         dw ?
192
        irq_line        db ?
200
        .cur_tx         dw ?
193
                        rb 3    ; align 4
201
        .last_tx        dw ?
194
 
202
        .phy_addr       dd ?
195
        cur_rx          dw ?
203
        .phy_mode       dw ?
196
        cur_tx          dw ?
204
        .mcr0           dw ?
-
 
205
        .mcr1           dw ?
197
        last_tx         dw ?
206
        .switch_sig     dw ?
198
        phy_addr        dd ?
207
 
199
        phy_mode        dw ?
208
        .pci_bus        dd ?
200
        mcr0            dw ?
209
        .pci_dev        dd ?
201
        mcr1            dw ?
210
        .irq_line       db ?
-
 
211
 
202
        switch_sig      dw ?
212
        rb 1            ; dword alignment
203
 
213
 
-
 
214
        .tx_ring:       rb (((x_head.sizeof*TX_RING_SIZE)+32) and 0xfffffff0)
-
 
Line 215... Line 204...
215
        .rx_ring:       rb (((x_head.sizeof*RX_RING_SIZE)+32) and 0xfffffff0)
204
        rb 0x100 - ($ and 0xff) ; align 256
Line 216... Line -...
216
 
-
 
217
        .size = $ - device
-
 
218
 
205
        tx_ring         rb ((TX_RING_SIZE*sizeof.x_head+32) and 0xfffffff0)
219
end virtual
206
        rx_ring         rb ((RX_RING_SIZE*sizeof.x_head+32) and 0xfffffff0)
220
 
207
 
221
 
208
ends
222
 
209
 
223
section '.flat' code readable align 16
210
 
Line 224... Line -...
224
 
-
 
225
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
211
 
226
;;                        ;;
-
 
227
;; proc START             ;;
-
 
228
;;                        ;;
-
 
Line -... Line 212...
-
 
212
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
229
;; (standard driver proc) ;;
213
;;                        ;;
Line 230... Line 214...
230
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
214
;; proc START             ;;
231
 
215
;;                        ;;
232
align 4
216
;; (standard driver proc) ;;
Line 233... Line 217...
233
proc START stdcall, state:dword
217
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
234
 
-
 
235
        cmp [state], 1
218
 
236
        jne .exit
219
proc START c, reason:dword, cmdline:dword
Line 237... Line 220...
237
 
220
 
Line 254... Line 237...
254
;; proc SERVICE_PROC      ;;
237
;; proc SERVICE_PROC      ;;
255
;;                        ;;
238
;;                        ;;
256
;; (standard driver proc) ;;
239
;; (standard driver proc) ;;
257
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
240
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 258... Line -...
258
 
-
 
259
align 4
241
 
Line 260... Line 242...
260
proc service_proc stdcall, ioctl:dword
242
proc service_proc stdcall, ioctl:dword
261
 
243
 
Line 296... Line 278...
296
 
278
 
297
;        mov     eax, [edx + IOCTL.input]                      ; get the pci bus and device numbers
279
;        mov     eax, [edx + IOCTL.input]               ; get the pci bus and device numbers
298
        mov     ax , [eax+1]                            ;
280
        mov     ax , [eax+1]                            ;
299
  .nextdevice:
281
  .nextdevice:
300
        mov     ebx, [esi]
282
        mov     ebx, [esi]
301
        cmp     al, byte[device.pci_bus]
283
        cmp     al, byte[ebx + device.pci_bus]
302
        jne     @f
284
        jne     @f
303
        cmp     ah, byte[device.pci_dev]
285
        cmp     ah, byte[ebx + device.pci_dev]
304
        je      .find_devicenum                         ; Device is already loaded, let's find it's device number
286
        je      .find_devicenum                         ; Device is already loaded, let's find it's device number
305
       @@:
287
       @@:
306
        add     esi, 4
288
        add     esi, 4
Line 310... Line 292...
310
; This device doesnt have its own eth_device structure yet, lets create one
292
; This device doesnt have its own eth_device structure yet, lets create one
311
  .firstdevice:
293
  .firstdevice:
312
        cmp     [devices], MAX_DEVICES                  ; First check if the driver can handle one more card
294
        cmp     [devices], MAX_DEVICES                  ; First check if the driver can handle one more card
313
        jae     .fail
295
        jae     .fail
Line 314... Line 296...
314
 
296
 
Line 315... Line 297...
315
        allocate_and_clear ebx, device.size, .fail      ; Allocate the buffer for device structure
297
        allocate_and_clear ebx, sizeof.device, .fail    ; Allocate the buffer for device structure
Line 316... Line 298...
316
 
298
 
317
; Fill in the direct call addresses into the struct
299
; Fill in the direct call addresses into the struct
318
 
300
 
319
        mov     [device.reset], reset
301
        mov     [ebx + device.reset], reset
Line 320... Line 302...
320
        mov     [device.transmit], transmit
302
        mov     [ebx + device.transmit], transmit
Line 321... Line 303...
321
        mov     [device.unload], unload
303
        mov     [ebx + device.unload], unload
322
        mov     [device.name], my_service
304
        mov     [ebx + device.name], my_service
323
 
305
 
324
; save the pci bus and device numbers
306
; save the pci bus and device numbers
325
 
307
 
Line 326... Line 308...
326
        mov     eax, [edx + IOCTL.input]
308
        mov     eax, [edx + IOCTL.input]
Line -... Line 309...
-
 
309
        movzx   ecx, byte[eax+1]
327
        movzx   ecx, byte[eax+1]
310
        mov     [ebx + device.pci_bus], ecx
Line 328... Line 311...
328
        mov     [device.pci_bus], ecx
311
        movzx   ecx, byte[eax+2]
Line -... Line 312...
-
 
312
        mov     [ebx + device.pci_dev], ecx
329
        movzx   ecx, byte[eax+2]
313
 
Line 330... Line 314...
330
        mov     [device.pci_dev], ecx
314
; Now, it's time to find the base io addres of the PCI device
331
 
315
 
Line 332... Line 316...
332
; Now, it's time to find the base io addres of the PCI device
316
        stdcall PCI_find_io, [ebx + device.pci_bus], [ebx + device.pci_dev]
333
 
-
 
334
        PCI_find_io
-
 
335
 
-
 
336
; We've found the io address, find IRQ now
-
 
337
 
-
 
Line 338... Line 317...
338
        PCI_find_irq
317
        mov     [ebx + device.io_addr], eax
339
 
318
 
340
        DEBUGF  1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
319
; We've found the io address, find IRQ now
Line -... Line 320...
-
 
320
 
-
 
321
        invoke  PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.interrupt_line
-
 
322
        mov     [ebx + device.irq_line], al
-
 
323
 
341
        [device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
324
        DEBUGF  1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
342
 
325
        [ebx + device.pci_dev]:1,[ebx + device.pci_bus]:1,[ebx + device.irq_line]:1,[ebx + device.io_addr]:8
343
; Ok, the eth_device structure is ready, let's probe the device
-
 
Line 344... Line 326...
344
        cli
326
 
345
 
327
; Ok, the eth_device structure is ready, let's probe the device
Line 346... Line 328...
346
        call    probe                                                   ; this function will output in eax
328
 
Line 347... Line 329...
347
        test    eax, eax
329
        mov     eax, [devices]                                          ; Add the device structure to our device list
Line 348... Line 330...
348
        jnz     .err_sti                                                ; If an error occured, exit
330
        mov     [device_list+4*eax], ebx                                ; (IRQ handler uses this list to find device)
349
 
331
        inc     [devices]                                               ;
350
        mov     eax, [devices]                                          ; Add the device structure to our device list
332
 
351
        mov     [device_list+4*eax], ebx                                ; (IRQ handler uses this list to find device)
333
        call    probe                                                   ; this function will output in eax
352
        inc     [devices]                                               ;
334
        test    eax, eax
353
 
335
        jnz     .err2
354
        mov     [device.type], NET_TYPE_ETH
336
 
Line 355... Line 337...
355
        call    NetRegDev
337
        mov     [ebx + device.type], NET_TYPE_ETH
Line 356... Line 338...
356
        sti
338
        invoke  NetRegDev
357
 
339
 
Line 358... Line 340...
358
        cmp     eax, -1
340
        cmp     eax, -1
359
        je      .destroy
341
        je      .destroy
360
 
-
 
361
        ret
342
 
362
 
343
        ret
363
; If the device was already loaded, find the device number and return it in eax
-
 
364
 
344
 
-
 
345
; If the device was already loaded, find the device number and return it in eax
365
  .find_devicenum:
346
 
366
        DEBUGF  1,"Trying to find device number of already registered device\n"
347
  .find_devicenum:
Line 367... Line 348...
367
        call    NetPtrToNum                                             ; This kernel procedure converts a pointer to device struct in ebx
348
        DEBUGF  2,"Trying to find device number of already registered device\n"
368
                                                                        ; into a device number in edi
349
        invoke  NetPtrToNum                                             ; This kernel procedure converts a pointer to device struct in ebx
Line 395... Line 376...
395
;;                                                                        ;;
376
;;                                                                        ;;
396
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
377
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
Line 397... Line 378...
397
 
378
 
398
 
379
 
Line 399... Line 380...
399
;mdio_read:
380
;mdio_read:
Line 400... Line 381...
400
;        stdcall phy_read, [device.io_addr], [device.phy_addr], ecx
381
;        stdcall phy_read, [ebx + device.io_addr], [ebx + device.phy_addr], ecx
401
 
382
 
Line 402... Line 383...
402
;        ret
383
;        ret
Line 403... Line 384...
403
 
384
 
Line 428... Line 409...
428
;;
409
;;
429
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
410
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 430... Line 411...
430
 
411
 
431
align 4
412
align 4
432
probe:
413
probe:
Line 433... Line 414...
433
        DEBUGF  1,"Probing R6040 device\n"
414
        DEBUGF  1,"Probing\n"
-
 
415
 
-
 
416
; Make the device a bus master
-
 
417
        invoke  PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command
Line 434... Line 418...
434
 
418
        or      al, PCI_CMD_MASTER
435
        PCI_make_bus_master
419
        invoke  PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax
Line 436... Line 420...
436
 
420
 
437
        ; If PHY status change register is still set to zero
421
        ; If PHY status change register is still set to zero
438
        ; it means the bootloader didn't initialize it
422
        ; it means the bootloader didn't initialize it
439
 
423
 
440
        set_io  0
424
        set_io  [ebx + device.io_addr], 0
441
        set_io  PHY_CC
425
        set_io  [ebx + device.io_addr], PHY_CC
442
        in      ax, dx
426
        in      ax, dx
Line 448... Line 432...
448
 
432
 
Line 449... Line 433...
449
        call    read_mac
433
        call    read_mac
450
 
434
 
451
        ; Some bootloaders/BIOSes do not initialize MAC address, warn about that
435
        ; Some bootloaders/BIOSes do not initialize MAC address, warn about that
452
        and     eax, 0xFF
436
        and     eax, 0xFF
453
        or      eax, dword [device.mac]
437
        or      eax, dword [ebx + device.mac]
454
        test    eax, eax
438
        test    eax, eax
Line 455... Line 439...
455
        jnz     @f
439
        jnz     @f
456
        DEBUGF  2, "MAC address not initialized!\n"
440
        DEBUGF  2, "MAC address not initialized!\n"
457
 
441
 
458
     @@:
442
     @@:
459
        ; Init RDC private data
443
        ; Init RDC private data
Line 460... Line 444...
460
        mov     [device.mcr0], MCR0_XMTEN or MCR0_RCVEN
444
        mov     [ebx + device.mcr0], MCR0_XMTEN or MCR0_RCVEN
461
        mov     [device.phy_addr], PHY1_ADDR
445
        mov     [ebx + device.phy_addr], PHY1_ADDR
462
        mov     [device.switch_sig], 0
446
        mov     [ebx + 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, [device.phy_addr], 2
449
        stdcall phy_read, [ebx + device.phy_addr], 2
466
        cmp     ax, 0xFFFF
450
        cmp     ax, 0xFFFF
Line 476... Line 460...
476
        ; Initialize and alloc RX/TX buffers
460
        ; Initialize and alloc RX/TX buffers
477
        call    init_txbufs
461
        call    init_txbufs
478
        call    init_rxbufs
462
        call    init_rxbufs
Line 479... Line 463...
479
 
463
 
480
        ; Read the PHY ID
464
        ; Read the PHY ID
481
        mov     [device.phy_mode], MCR0_FD
465
        mov     [ebx + device.phy_mode], MCR0_FD
482
        stdcall phy_read, 0, 2
466
        stdcall phy_read, 0, 2
483
        mov     [device.switch_sig], ax
467
        mov     [ebx + device.switch_sig], ax
484
        cmp     ax, ICPLUS_PHY_ID
468
        cmp     ax, ICPLUS_PHY_ID
485
        jne     @f
469
        jne     @f
486
        stdcall phy_write, 29, 31, 0x175C ; Enable registers
470
        stdcall phy_write, 29, 31, 0x175C ; Enable registers
487
        jmp     .phy_readen
471
        jmp     .phy_readen
Line 488... Line 472...
488
      @@:
472
      @@:
489
 
473
 
490
        ; PHY Mode Check
474
        ; PHY Mode Check
Line 491... Line 475...
491
        stdcall phy_write, [device.phy_addr], 4, PHY_CAP
475
        stdcall phy_write, [ebx + device.phy_addr], 4, PHY_CAP
492
        stdcall phy_write, [device.phy_addr], 0, PHY_MODE
476
        stdcall phy_write, [ebx + device.phy_addr], 0, PHY_MODE
493
 
477
 
494
      if PHY_MODE = 0x3100
478
      if PHY_MODE = 0x3100
495
        call    phy_mode_chk
479
        call    phy_mode_chk
Line 496... Line 480...
496
        mov     [device.phy_mode], ax
480
        mov     [ebx + device.phy_mode], ax
497
        jmp     .phy_readen
481
        jmp     .phy_readen
498
      end if
482
      end if
Line 499... Line 483...
499
 
483
 
Line 500... Line 484...
500
      if not (PHY_MODE and 0x0100)
484
      if not (PHY_MODE and 0x0100)
501
        mov     [device.phy_mode], 0
485
        mov     [ebx + device.phy_mode], 0
502
      end if
486
      end if
Line 503... Line 487...
503
 
487
 
504
      .phy_readen:
488
      .phy_readen:
505
 
489
 
506
        ; Set duplex mode
490
        ; Set duplex mode
Line 521... Line 505...
521
 
505
 
522
        ; Initialize all Mac registers
506
        ; Initialize all Mac registers
Line 523... Line -...
523
        call    init_mac_regs
-
 
524
 
507
        call    init_mac_regs
525
 
508
 
Line 526... Line 509...
526
 
509
 
Line 527... Line 510...
527
align 4
510
align 4
528
reset:
511
reset:
529
 
512
 
530
        DEBUGF  1,"Resetting R6040\n"
513
        DEBUGF  1,"Resetting\n"
531
 
514
 
Line 532... Line -...
532
        ; Mask off Interrupt
-
 
533
        xor     ax, ax
515
        ; Mask off Interrupt
Line 534... Line 516...
534
        set_io  0
516
        xor     ax, ax
535
        set_io  MIER
517
        set_io  [ebx + device.io_addr], 0
536
        out     dx, ax
518
        set_io  [ebx + device.io_addr], MIER
537
 
519
        out     dx, ax
538
 
520
 
539
; attach int handler
521
; attach int handler
540
 
522
 
541
        movzx   eax, [device.irq_line]
523
        movzx   eax, [ebx + device.irq_line]
542
        DEBUGF  1,"Attaching int handler to irq %x\n", eax:1
524
        DEBUGF  1,"Attaching int handler to irq %x\n", eax:1
Line 543... Line -...
543
        stdcall AttachIntHandler, eax, int_handler, dword 0
-
 
544
        test    eax, eax
525
        invoke  AttachIntHandler, eax, int_handler, ebx
545
        jnz     @f
526
        test    eax, eax
546
        DEBUGF  2,"Could not attach int handler!\n"
527
        jnz     @f
547
;        or      eax, -1
528
        DEBUGF  2,"Could not attach int handler!\n"
548
;        ret
529
        or      eax, -1
Line 549... Line 530...
549
       @@:
530
        ret
550
 
531
       @@:
551
 
532
 
Line 564... Line 545...
564
        test    ecx, ecx
545
        test    ecx, ecx
565
        jnz     .read
546
        jnz     .read
566
  @@:
547
  @@:
567
        ;Reset internal state machine
548
        ;Reset internal state machine
568
        mov     ax,  2
549
        mov     ax,  2
569
        set_io  MAC_SM
550
        set_io  [ebx + device.io_addr], MAC_SM
570
        out     dx, ax
551
        out     dx, ax
Line 571... Line 552...
571
 
552
 
572
        xor     ax, ax
553
        xor     ax, ax
Line 573... Line 554...
573
        out     dx, ax
554
        out     dx, ax
574
 
555
 
Line 575... Line 556...
575
        mov     esi, 5
556
        mov     esi, 5
576
        stdcall Sleep
557
        invoke  Sleep
577
 
558
 
578
        ;MAC Bus Control Register
559
        ;MAC Bus Control Register
579
        mov     ax, MBCR_DEFAULT
560
        mov     ax, MBCR_DEFAULT
Line 580... Line 561...
580
        set_io  0
561
        set_io  [ebx + device.io_addr], 0
581
        set_io  MBCR
562
        set_io  [ebx + device.io_addr], MBCR
582
        out     dx, ax
563
        out     dx, ax
583
 
564
 
Line 584... Line 565...
584
        ;Buffer Size Register
565
        ;Buffer Size Register
585
        mov     ax, MAX_BUF_SIZE
566
        mov     ax, MAX_BUF_SIZE
586
        set_io  MR_BSR
567
        set_io  [ebx + device.io_addr], MR_BSR
587
        out     dx, ax
568
        out     dx, ax
588
 
569
 
589
        ;Write TX ring start address
570
        ;Write TX ring start address
590
        lea     eax, [device.tx_ring]
571
        lea     eax, [ebx + device.tx_ring]
591
        GetRealAddr
572
        invoke  GetPhysAddr
Line 592... Line 573...
592
        set_io  MTD_SA0
573
        set_io  [ebx + device.io_addr], MTD_SA0
593
        out     dx, ax
574
        out     dx, ax
594
        shr     eax, 16
575
        shr     eax, 16
595
        set_io  MTD_SA1
576
        set_io  [ebx + device.io_addr], MTD_SA1
596
        out     dx, ax
577
        out     dx, ax
597
 
578
 
598
        ;Write RX ring start address
579
        ;Write RX ring start address
599
        lea     eax, [device.rx_ring]
580
        lea     eax, [ebx + device.rx_ring]
Line 600... Line 581...
600
        GetRealAddr
581
        invoke  GetPhysAddr
601
        set_io  MRD_SA0
582
        set_io  [ebx + device.io_addr], MRD_SA0
602
        out     dx, ax
583
        out     dx, ax
603
        shr     eax, 16
584
        shr     eax, 16
Line 604... Line 585...
604
        set_io  MRD_SA1
585
        set_io  [ebx + device.io_addr], MRD_SA1
605
        out     dx, ax
586
        out     dx, ax
606
 
587
 
607
        ;Set interrupt waiting time and packet numbers
588
        ;Set interrupt waiting time and packet numbers
Line 608... Line 589...
608
        xor     ax, ax
589
        xor     ax, ax
609
        set_io  MT_ICR
590
        set_io  [ebx + device.io_addr], MT_ICR
610
        out     dx, ax
591
        out     dx, ax
611
 
592
 
612
        ;Enable interrupts
593
        ;Enable interrupts
Line 613... Line 594...
613
        mov     ax, INT_MASK
594
        mov     ax, INT_MASK
614
        set_io  MIER
595
        set_io  [ebx + device.io_addr], MIER
615
        out     dx, ax
-
 
616
 
596
        out     dx, ax
617
        ;Enable RX
597
 
618
        mov     ax, [device.mcr0]
-
 
619
        or      ax, MCR0_RCVEN
598
        ;Enable RX
620
        set_io  0
599
        mov     ax, [ebx + device.mcr0]
Line 621... Line 600...
621
        out     dx, ax
600
        or      ax, MCR0_RCVEN
622
 
601
        set_io  [ebx + device.io_addr], 0
Line 623... Line 602...
623
        ;Let TX poll the descriptors
602
        out     dx, ax
624
        ;we may got called by tx_timeout which has left
603
 
Line 625... Line 604...
625
        ;some unset tx buffers
604
        ;Let TX poll the descriptors
626
        xor     ax, ax
605
        ;we may got called by tx_timeout which has left some unset tx buffers
627
        inc     ax
606
        xor     ax, ax
Line 644... Line 623...
644
align 4
623
align 4
645
init_txbufs:
624
init_txbufs:
Line 646... Line 625...
646
 
625
 
Line 647... Line 626...
647
        DEBUGF  1,"Init TxBufs\n"
626
        DEBUGF  1,"Init TxBufs\n"
648
 
627
 
649
        lea     esi, [device.tx_ring]
628
        lea     esi, [ebx + device.tx_ring]
650
        lea     eax, [device.tx_ring + x_head.sizeof]
629
        lea     eax, [ebx + device.tx_ring + sizeof.x_head]
Line 651... Line 630...
651
        GetRealAddr
630
        invoke  GetPhysAddr
652
        mov     ecx, TX_RING_SIZE
631
        mov     ecx, TX_RING_SIZE
653
 
632
 
654
    .next_desc:
633
    .next_desc:
655
        mov     [esi + x_head.ndesc], eax
-
 
656
        mov     [esi + x_head.skb_ptr], 0
634
        mov     [esi + x_head.ndesc], eax
657
        mov     [esi + x_head.status], DSC_OWNER_MAC
635
        mov     [esi + x_head.skb_ptr], 0
658
 
-
 
659
        add     eax, x_head.sizeof
636
        mov     [esi + x_head.status], DSC_OWNER_MAC
660
        add     esi, x_head.sizeof
637
        add     eax, sizeof.x_head
Line 661... Line 638...
661
 
638
        add     esi, sizeof.x_head
662
        dec     ecx
639
        dec     ecx
663
        jnz     .next_desc
640
        jnz     .next_desc
Line 664... Line 641...
664
 
641
 
Line 665... Line 642...
665
        lea     eax, [device.tx_ring]
642
        lea     eax, [ebx + device.tx_ring]
666
        GetRealAddr
643
        invoke  GetPhysAddr
Line 667... Line 644...
667
        mov     [device.tx_ring + x_head.sizeof*(TX_RING_SIZE - 1) + x_head.ndesc], eax
644
        mov     dword[ebx + device.tx_ring + sizeof.x_head*(TX_RING_SIZE-1) + x_head.ndesc], eax
Line 668... Line 645...
668
 
645
 
669
        ret
646
        ret
670
 
647
 
671
 
648
 
672
 
649
 
Line 673... Line 650...
673
align 4
650
align 4
674
init_rxbufs:
651
init_rxbufs:
Line 675... Line 652...
675
 
652
 
676
        DEBUGF  1,"Init RxBufs\n"
653
        DEBUGF  1,"Init RxBufs\n"
677
 
654
 
Line 678... Line 655...
678
        lea     esi, [device.rx_ring]
655
        lea     esi, [ebx + device.rx_ring]
679
        lea     eax, [device.rx_ring + x_head.sizeof]
656
        lea     eax, [ebx + device.rx_ring + sizeof.x_head]
680
        GetRealAddr
657
        invoke  GetPhysAddr
681
        mov     edx, eax
658
        mov     edx, eax
Line 682... Line 659...
682
        mov     ecx, RX_RING_SIZE
659
        mov     ecx, RX_RING_SIZE
683
 
660
 
Line 684... Line 661...
684
    .next_desc:
661
    .next_desc:
685
        mov     [esi + x_head.ndesc], edx
662
        mov     [esi + x_head.ndesc], edx
Line 686... Line 663...
686
 
663
 
687
        push    esi ecx edx
664
        push    esi ecx edx
688
        stdcall KernelAlloc, MAX_BUF_SIZE
665
        invoke  KernelAlloc, MAX_BUF_SIZE
689
        pop     edx ecx esi
666
        pop     edx ecx esi
Line 690... Line 667...
690
 
667
 
Line 712... Line 689...
712
phy_mode_chk:
689
phy_mode_chk:
Line 713... Line 690...
713
 
690
 
Line 714... Line 691...
714
        DEBUGF  1,"Checking PHY mode\n"
691
        DEBUGF  1,"Checking PHY mode\n"
715
 
692
 
716
        ; PHY Link Status Check
693
        ; PHY Link Status Check
717
        stdcall phy_read, [device.phy_addr], MII_BMSR
694
        stdcall phy_read, [ebx + device.phy_addr], MII_BMSR
Line 718... Line 695...
718
        test    ax, BMSR_LSTATUS
695
        test    ax, BMSR_LSTATUS
719
        jz      .ret_0x8000
696
        jz      .ret_0x8000
720
 
697
 
Line 721... Line 698...
721
        ; PHY Chip Auto-Negotiation Status
698
        ; PHY Chip Auto-Negotiation Status
722
        test    ax, BMSR_ANEGCOMPLETE
699
        test    ax, BMSR_ANEGCOMPLETE
723
        jnz     .auto_nego
700
        jnz     .auto_nego
724
 
701
 
Line 725... Line 702...
725
        ; Force Mode
702
        ; Force Mode
726
        stdcall phy_read, [device.phy_addr], MII_BMCR
703
        stdcall phy_read, [ebx + device.phy_addr], MII_BMCR
727
        test    ax, BMCR_FULLDPLX
704
        test    ax, BMCR_FULLDPLX
728
        jnz     .ret_0x8000
705
        jnz     .ret_0x8000
729
 
706
 
730
  .auto_nego:
707
  .auto_nego:
731
        ; Auto Negotiation Mode
708
        ; Auto Negotiation Mode
732
        stdcall phy_read, [device.phy_addr], MII_LPA
709
        stdcall phy_read, [ebx + device.phy_addr], MII_LPA
Line 733... Line 710...
733
        mov     cx, ax
710
        mov     cx, ax
Line 749... Line 726...
749
 
726
 
750
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
727
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
751
;;                                         ;;
728
;;                                         ;;
752
;; Transmit                                ;;
729
;; Transmit                                ;;
753
;;                                         ;;
-
 
754
;; In: buffer pointer in [esp+4]           ;;
-
 
755
;;     size of buffer in [esp+8]           ;;
730
;;                                         ;;
756
;;     pointer to device structure in ebx  ;;
731
;; In: pointer to device structure in ebx  ;;
757
;;                                         ;;
732
;;                                         ;;
-
 
733
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
734
 
-
 
735
proc transmit stdcall bufferptr, buffersize
758
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
736
 
759
align 4
737
        pushf
-
 
738
        cli
760
transmit:
739
 
761
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [esp+4], [esp+8]
740
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize]
762
        mov     eax, [esp+4]
741
        mov     eax, [bufferptr]
763
        DEBUGF  1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
742
        DEBUGF  1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
764
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
743
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
765
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
744
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
Line 766... Line 745...
766
        [eax+13]:2,[eax+12]:2
745
        [eax+13]:2,[eax+12]:2
767
 
746
 
768
        cmp     dword [esp+8], 1514
747
        cmp     [buffersize], 1514
769
        ja      .fail
748
        ja      .fail
Line 770... Line 749...
770
        cmp     dword [esp+8], 60
749
        cmp     [buffersize], 60
771
        jb      .fail
750
        jb      .fail
772
 
751
 
773
        movzx   edi, [device.cur_tx]
752
        movzx   edi, [ebx + device.cur_tx]
Line 774... Line 753...
774
        shl     edi, 5
753
        shl     edi, 5
Line 775... Line 754...
775
        add     edi, ebx
754
        add     edi, ebx
776
        add     edi, device.tx_ring - ebx
755
        add     edi, device.tx_ring
Line 777... Line 756...
777
 
756
 
778
        DEBUGF  1,"TX buffer status: 0x%x\n", [edi + x_head.status]:4
757
        DEBUGF  1,"TX buffer status: 0x%x\n", [edi + x_head.status]:4
Line 779... Line 758...
779
 
758
 
780
        test    [edi + x_head.status], DSC_OWNER_MAC    ; check if buffer is available
759
        test    [edi + x_head.status], DSC_OWNER_MAC    ; check if buffer is available
781
        jnz     .wait_to_send
760
        jnz     .wait_to_send
782
 
761
 
783
  .do_send:
762
  .do_send:
784
        DEBUGF  1,"Sending now\n"
763
        DEBUGF  1,"Sending now\n"
785
 
764
 
Line 786... Line 765...
786
        mov     eax, [esp+4]
765
        mov     eax, [bufferptr]
787
        mov     [edi + x_head.skb_ptr], eax
766
        mov     [edi + x_head.skb_ptr], eax
788
        GetRealAddr
767
        invoke  GetPhysAddr
789
        mov     [edi + x_head.buf], eax
768
        mov     [edi + x_head.buf], eax
790
        mov     ecx, [esp+8]
769
        mov     ecx, [buffersize]
Line 791... Line 770...
791
        mov     [edi + x_head.len], cx
770
        mov     [edi + x_head.len], cx
792
        mov     [edi + x_head.status], DSC_OWNER_MAC
771
        mov     [edi + x_head.status], DSC_OWNER_MAC
Line 793... Line 772...
793
 
772
 
794
        ; Trigger the MAC to check the TX descriptor
773
        ; Trigger the MAC to check the TX descriptor
795
        mov     ax, 0x01
774
        mov     ax, 0x01
796
        set_io  0
775
        set_io  [ebx + device.io_addr], 0
797
        set_io  MTPR
776
        set_io  [ebx + device.io_addr], MTPR
Line 798... Line 777...
798
        out     dx, ax
777
        out     dx, ax
-
 
778
 
799
 
779
        inc     [ebx + device.cur_tx]
Line 800... Line 780...
800
        inc     [device.cur_tx]
780
        and     [ebx + device.cur_tx], TX_RING_SIZE - 1
801
        and     [device.cur_tx], TX_RING_SIZE - 1
-
 
802
 
781
 
Line 803... Line 782...
803
; Update stats
782
; Update stats
804
        inc     [device.packets_tx]
783
        inc     [ebx + device.packets_tx]
805
        mov     eax, [esp+8]
784
        mov     eax, [buffersize]
806
        add     dword [device.bytes_tx], eax
785
        add     dword[ebx + device.bytes_tx], eax
807
        adc     dword [device.bytes_tx + 4], 0
786
        adc     dword[ebx + device.bytes_tx + 4], 0
808
 
787
 
809
        xor     eax, eax
788
        xor     eax, eax
810
        ret     8
789
        popf
811
 
790
        ret
812
  .wait_to_send:
791
 
Line 813... Line 792...
813
 
792
  .wait_to_send:
814
        DEBUGF  1,"Waiting for TX buffer\n"
-
 
815
 
-
 
816
        call    GetTimerTicks           ; returns in eax
793
        DEBUGF  1,"Waiting for TX buffer\n"
817
        lea     edx, [eax + 100]
794
 
818
     .l2:
795
        invoke  GetTimerTicks           ; returns in eax
-
 
796
        lea     edx, [eax + 100]
819
        test    [edi + x_head.status], DSC_OWNER_MAC
797
     .l2:
820
        jz      .do_send
798
        test    [edi + x_head.status], DSC_OWNER_MAC
821
        mov     esi, 10
-
 
Line -... Line 799...
-
 
799
        jz      .do_send
Line 822... Line 800...
822
        call    Sleep
800
        mov     esi, 10
823
        call    GetTimerTicks
801
        invoke  Sleep
Line 857... Line 835...
857
        jz      .nothing
835
        jz      .nothing
858
        mov     esi, device_list
836
        mov     esi, device_list
859
  .nextdevice:
837
  .nextdevice:
860
        mov     ebx, [esi]
838
        mov     ebx, [esi]
Line 861... Line 839...
861
 
839
 
862
        set_io  0
840
        set_io  [ebx + device.io_addr], 0
863
        set_io  MISR
841
        set_io  [ebx + device.io_addr], MISR
864
        in      ax, dx
842
        in      ax, dx
865
        out     dx, ax                  ; send it back to ACK
843
        out     dx, ax                  ; send it back to ACK
866
        test    ax, ax
844
        test    ax, ax
867
        jnz     .got_it
845
        jnz     .got_it
Line 871... Line 849...
871
        jnz     .nextdevice
849
        jnz     .nextdevice
872
  .nothing:
850
  .nothing:
873
        pop     edi esi ebx
851
        pop     edi esi ebx
874
        xor     eax, eax
852
        xor     eax, eax
Line 875... Line 853...
875
 
853
 
876
        ret                             ; If no device was found, abort (The irq was probably for a device, not registered to this driver)
-
 
Line 877... Line 854...
877
 
854
        ret                             ; If no device was found, abort
Line 878... Line 855...
878
 
855
 
Line 890... Line 867...
890
        push    ebx
867
        push    ebx
891
  .more_RX:
868
  .more_RX:
892
        pop     ebx
869
        pop     ebx
Line 893... Line 870...
893
 
870
 
894
        ; Find the current RX descriptor
871
        ; Find the current RX descriptor
895
        movzx   edx, [device.cur_rx]
872
        movzx   edx, [ebx + device.cur_rx]
896
        shl     edx, 5
873
        shl     edx, 5
Line 897... Line 874...
897
        lea     edx, [device.rx_ring + edx]
874
        lea     edx, [ebx + device.rx_ring + edx]
898
 
875
 
899
        ; Check the descriptor status
876
        ; Check the descriptor status
900
        mov     cx, [edx + x_head.status]
877
        mov     cx, [edx + x_head.status]
Line 910... Line 887...
910
        movzx   ecx, [edx + x_head.len]
887
        movzx   ecx, [edx + x_head.len]
911
        and     ecx, 0xFFF
888
        and     ecx, 0xFFF
912
        sub     ecx, 4                  ; Do not count the CRC
889
        sub     ecx, 4                  ; Do not count the CRC
Line 913... Line 890...
913
 
890
 
914
        ; Update stats
891
        ; Update stats
915
        add     dword[device.bytes_rx], ecx
892
        add     dword[ebx + device.bytes_rx], ecx
916
        adc     dword[device.bytes_rx + 4], 0
893
        adc     dword[ebx + device.bytes_rx + 4], 0
Line 917... Line 894...
917
        inc     dword[device.packets_rx]
894
        inc     dword[ebx + device.packets_rx]
918
 
895
 
919
        ; Push packet size and pointer, kernel will need it..
896
        ; Push packet size and pointer, kernel will need it..
Line 925... Line 902...
925
 
902
 
Line 926... Line 903...
926
        DEBUGF  1,"packet ptr=0x%x\n", [edx + x_head.skb_ptr]
903
        DEBUGF  1,"packet ptr=0x%x\n", [edx + x_head.skb_ptr]
927
 
904
 
928
        ; reset the RX descriptor
905
        ; reset the RX descriptor
929
        push    edx
906
        push    edx
930
        stdcall KernelAlloc, MAX_BUF_SIZE
907
        invoke  KernelAlloc, MAX_BUF_SIZE
931
        pop     edx
908
        pop     edx
932
        mov     [edx + x_head.skb_ptr], eax
909
        mov     [edx + x_head.skb_ptr], eax
933
        GetRealAddr
910
        invoke  GetPhysAddr
Line 934... Line 911...
934
        mov     [edx + x_head.buf], eax
911
        mov     [edx + x_head.buf], eax
935
        mov     [edx + x_head.status], DSC_OWNER_MAC
912
        mov     [edx + x_head.status], DSC_OWNER_MAC
936
 
913
 
Line 937... Line 914...
937
        ; Use next descriptor next time
914
        ; Use next descriptor next time
938
        inc     [device.cur_rx]
915
        inc     [ebx + device.cur_rx]
Line 939... Line 916...
939
        and     [device.cur_rx], RX_RING_SIZE - 1
916
        and     [ebx + device.cur_rx], RX_RING_SIZE - 1
Line 940... Line 917...
940
 
917
 
941
        ; At last, send packet to kernel
918
        ; At last, send packet to kernel
Line 942... Line 919...
942
        jmp     Eth_input
919
        jmp     [Eth_input]
943
 
920
 
944
 
921
 
945
  .no_RX:
922
  .no_RX:
Line 946... Line 923...
946
 
923
 
947
        test    word[esp], TX_FINISH
924
        test    word[esp], TX_FINISH
Line 948... Line 925...
948
        jz      .no_TX
925
        jz      .no_TX
Line 960... Line 937...
960
 
937
 
Line 961... Line 938...
961
        DEBUGF  1,"Freeing buffer 0x%x\n", [edi + x_head.skb_ptr]
938
        DEBUGF  1,"Freeing buffer 0x%x\n", [edi + x_head.skb_ptr]
962
 
939
 
963
        push    [edi + x_head.skb_ptr]
940
        push    [edi + x_head.skb_ptr]
Line 964... Line 941...
964
        mov     [edi + x_head.skb_ptr], 0
941
        mov     [edi + x_head.skb_ptr], 0
965
        call    KernelFree
942
        invoke  KernelFree
Line 966... Line 943...
966
 
943
 
Line 967... Line 944...
967
        inc     [device.last_tx]
944
        inc     [ebx + device.last_tx]
968
        and     [device.last_tx], TX_RING_SIZE - 1
945
        and     [ebx + device.last_tx], TX_RING_SIZE - 1
Line 1020... Line 997...
1020
 
997
 
Line 1021... Line 998...
1021
        DEBUGF  1,"initializing MAC regs\n"
998
        DEBUGF  1,"initializing MAC regs\n"
1022
 
999
 
1023
        ; MAC operation register
1000
        ; MAC operation register
1024
        mov     ax, 1
1001
        mov     ax, 1
1025
        set_io  0
1002
        set_io  [ebx + device.io_addr], 0
1026
        set_io  MCR1
1003
        set_io  [ebx + device.io_addr], MCR1
1027
        out     dx, ax
1004
        out     dx, ax
1028
        ; Reset MAC
1005
        ; Reset MAC
1029
        mov     ax, 2
1006
        mov     ax, 2
1030
        set_io  MAC_SM
1007
        set_io  [ebx + device.io_addr], MAC_SM
1031
        out     dx, ax
1008
        out     dx, ax
1032
        ; Reset internal state machine
1009
        ; Reset internal state machine
1033
        xor     ax, ax
1010
        xor     ax, ax
1034
        out     dx, ax
1011
        out     dx, ax
Line 1035... Line 1012...
1035
        mov     esi, 5
1012
        mov     esi, 5
Line 1036... Line 1013...
1036
        stdcall Sleep
1013
        invoke  Sleep
Line 1051... Line 1028...
1051
 
1028
 
1052
        mov     eax, [phy_addr]
1029
        mov     eax, [phy_addr]
1053
        shl     eax, 8
1030
        shl     eax, 8
1054
        add     eax, [reg]
1031
        add     eax, [reg]
1055
        add     eax, MDIO_READ
1032
        add     eax, MDIO_READ
1056
        set_io  0
1033
        set_io  [ebx + device.io_addr], 0
1057
        set_io  MMDIO
1034
        set_io  [ebx + device.io_addr], MMDIO
Line 1058... Line 1035...
1058
        out     dx, ax
1035
        out     dx, ax
1059
 
1036
 
1060
        ;Wait for the read bit to be cleared.
1037
        ;Wait for the read bit to be cleared.
Line 1065... Line 1042...
1065
        jz      @f
1042
        jz      @f
1066
        dec     ecx
1043
        dec     ecx
1067
        jnz     .read
1044
        jnz     .read
1068
  @@:
1045
  @@:
Line 1069... Line 1046...
1069
 
1046
 
1070
        set_io  MMRD
1047
        set_io  [ebx + device.io_addr],   MMRD
1071
        in      ax, dx
1048
        in      ax, dx
Line 1072... Line 1049...
1072
        and     eax, 0xFFFF
1049
        and     eax, 0xFFFF
Line 1083... Line 1060...
1083
; Write a word data to PHY Chip
1060
; Write a word data to PHY Chip
Line 1084... Line 1061...
1084
 
1061
 
1085
align 4
1062
align 4
Line 1086... Line 1063...
1086
proc  phy_write stdcall, phy_addr:dword, reg:dword, val:dword
1063
proc  phy_write stdcall, phy_addr:dword, reg:dword, val:dword
-
 
1064
 
Line 1087... Line 1065...
1087
 
1065
        DEBUGF  1,"PHY write, addr=0x%x reg=0x%x val=0x%x\n", \
1088
        DEBUGF  1,"PHY write, addr=0x%x reg=0x%x val=0x%x\n", [phy_addr]:8, [reg]:8, [val]:8
1066
        [phy_addr]:8, [reg]:8, [val]:8
1089
 
1067
 
1090
        mov     eax, [val]
1068
        mov     eax, [val]
Line 1091... Line 1069...
1091
        set_io  0
1069
        set_io  [ebx + device.io_addr], 0
1092
        set_io  MMWD
1070
        set_io  [ebx + device.io_addr], MMWD
1093
        out     dx, ax
1071
        out     dx, ax
1094
 
1072
 
1095
        ;Write the command to the MDIO bus
1073
        ;Write the command to the MDIO bus
1096
        mov     eax, [phy_addr]
1074
        mov     eax, [phy_addr]
1097
        shl     eax, 8
1075
        shl     eax, 8
Line 1098... Line 1076...
1098
        add     eax, [reg]
1076
        add     eax, [reg]
1099
        add     eax, MDIO_WRITE
1077
        add     eax, MDIO_WRITE
1100
        set_io  MMDIO
1078
        set_io  [ebx + device.io_addr], MMDIO
Line 1121... Line 1099...
1121
read_mac:
1099
read_mac:
Line 1122... Line 1100...
1122
 
1100
 
Line 1123... Line 1101...
1123
        DEBUGF  1,"Reading MAC:\n"
1101
        DEBUGF  1,"Reading MAC:\n"
1124
 
1102
 
1125
        mov     cx, 3
1103
        mov     cx, 3
1126
        lea     edi, [device.mac]
1104
        lea     edi, [ebx + device.mac]
1127
        set_io  0
1105
        set_io  [ebx + device.io_addr], 0
1128
        set_io  MID_0L
1106
        set_io  [ebx + device.io_addr], MID_0L
1129
     .mac:
1107
     .mac:
1130
        in      ax, dx
1108
        in      ax, dx
1131
        stosw
1109
        stosw
1132
        inc     dx
1110
        inc     dx
1133
        inc     dx
1111
        inc     dx
Line -... Line 1112...
-
 
1112
        dec     cx
1134
        dec     cx
1113
        jnz     .mac
Line 1135... Line 1114...
1135
        jnz     .mac
1114
 
Line 1136... Line 1115...
1136
 
1115
        DEBUGF  1,"%x-%x-%x-%x-%x-%x\n",\
Line 1137... Line 1116...
1137
        DEBUGF  1,"%x-%x-%x-%x-%x-%x\n",[edi-6]:2, [edi-5]:2, [edi-4]:2, [edi-3]:2, [edi-2]:2, [edi-1]:2
1116
        [edi-6]:2, [edi-5]:2, [edi-4]:2, [edi-3]:2, [edi-2]:2, [edi-1]:2
-
 
1117
 
-
 
1118
        ret
1138
 
1119
 
Line 1139... Line -...
1139
        ret
-
 
1140
 
-
 
1141
 
1120
 
Line 1142... Line 1121...
1142
 
1121
 
Line -... Line 1122...
-
 
1122
 
-
 
1123
; End of code
1143
 
1124