2009-09-17 13:55:38 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2013-01-03 14:25:22 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
2009-09-17 13:55:38 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2010-07-15 20:54:19 +02:00
|
|
|
;; RTL8029/ne2000 driver for KolibriOS ;;
|
|
|
|
;; ;;
|
|
|
|
;; based on RTL8029.asm driver for menuetos ;;
|
|
|
|
;; and realtek8029.asm for SolarOS by Eugen Brasoveanu ;;
|
2009-09-17 13:55:38 +02:00
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
2009-09-25 23:09:41 +02:00
|
|
|
;; with help from CleverMouse ;;
|
2009-09-17 13:55:38 +02:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
format MS COFF
|
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
API_VERSION = 0x01000100
|
|
|
|
DRIVER_VERSION = 5
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
MAX_DEVICES = 16
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUG = 1
|
|
|
|
__DEBUG__ = 1
|
|
|
|
__DEBUG_LEVEL__ = 1
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
include 'proc32.inc'
|
|
|
|
include 'imports.inc'
|
|
|
|
include 'fdo.inc'
|
2010-06-11 18:44:47 +02:00
|
|
|
include 'netdrv.inc'
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-06-11 18:44:47 +02:00
|
|
|
virtual at ebx
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
device:
|
2010-06-11 18:44:47 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ETH_DEVICE
|
2010-06-11 18:44:47 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.io_addr dd ?
|
|
|
|
.irq_line db ?
|
|
|
|
.pci_bus db ?
|
|
|
|
.pci_dev db ?
|
|
|
|
|
|
|
|
.flags db ?
|
|
|
|
.vendor db ?
|
|
|
|
|
|
|
|
.memsize db ?
|
|
|
|
.rx_start db ?
|
|
|
|
.tx_start db ?
|
|
|
|
.bmem dd ?
|
|
|
|
.rmem dd ?
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
.size = $ - device
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
end virtual
|
|
|
|
|
2010-06-11 18:44:47 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
public START
|
|
|
|
public service_proc
|
|
|
|
public version
|
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
P0_COMMAND = 0x00
|
|
|
|
P0_PSTART = 0x01
|
|
|
|
P0_PSTOP = 0x02
|
|
|
|
P0_BOUND = 0x03
|
|
|
|
P0_TSR = 0x04
|
|
|
|
P0_TPSR = 0x04
|
|
|
|
P0_TBCR0 = 0x05
|
|
|
|
P0_TBCR1 = 0x06
|
|
|
|
P0_ISR = 0x07
|
|
|
|
P0_RSAR0 = 0x08
|
|
|
|
P0_RSAR1 = 0x09
|
|
|
|
P0_RBCR0 = 0x0A
|
|
|
|
P0_RBCR1 = 0x0B
|
|
|
|
P0_RSR = 0x0C
|
|
|
|
P0_RCR = 0x0C
|
|
|
|
P0_TCR = 0x0D
|
|
|
|
P0_DCR = 0x0E
|
|
|
|
P0_IMR = 0x0F
|
|
|
|
|
|
|
|
P1_COMMAND = 0x00
|
|
|
|
P1_PAR0 = 0x01
|
|
|
|
P1_PAR1 = 0x02
|
|
|
|
P1_PAR2 = 0x03
|
|
|
|
P1_PAR3 = 0x04
|
|
|
|
P1_PAR4 = 0x05
|
|
|
|
P1_PAR5 = 0x06
|
|
|
|
P1_CURR = 0x07
|
|
|
|
P1_MAR0 = 0x08
|
|
|
|
|
|
|
|
CMD_PS0 = 0x00 ; Page 0 select
|
|
|
|
CMD_PS1 = 0x40 ; Page 1 select
|
|
|
|
CMD_PS2 = 0x80 ; Page 2 select
|
|
|
|
CMD_RD2 = 0x20 ; Remote DMA control
|
|
|
|
CMD_RD1 = 0x10
|
|
|
|
CMD_RD0 = 0x08
|
|
|
|
CMD_TXP = 0x04 ; transmit packet
|
|
|
|
CMD_STA = 0x02 ; start
|
|
|
|
CMD_STP = 0x01 ; stop
|
|
|
|
|
|
|
|
CMD_RDMA_READ = 001b shl 3
|
|
|
|
CMD_RDMA_WRITE = 010b shl 3
|
|
|
|
CMD_RDMA_SEND_PACKET = 011b shl 3
|
|
|
|
CMD_RDMA_ABORT = 100b shl 3 ; really is 1xx, Abort/Complete Remote DMA
|
|
|
|
; RDMA_MASK = 111b shl 3 ; internal, mask
|
|
|
|
|
|
|
|
RCR_MON = 0x20 ; monitor mode
|
|
|
|
|
|
|
|
DCR_FT1 = 0x40
|
|
|
|
DCR_LS = 0x08 ; Loopback select
|
|
|
|
DCR_WTS = 0x01 ; Word transfer select
|
|
|
|
|
|
|
|
ISR_PRX = 0x01 ; successful recv
|
|
|
|
ISR_PTX = 0x02 ; successful xmit
|
|
|
|
ISR_RXE = 0x04 ; receive error
|
|
|
|
ISR_TXE = 0x08 ; transmit error
|
|
|
|
ISR_OVW = 0x10 ; Overflow
|
|
|
|
ISR_CNT = 0x20 ; Counter overflow
|
|
|
|
ISR_RDC = 0x40 ; Remote DMA complete
|
|
|
|
ISR_RST = 0x80 ; reset
|
|
|
|
|
|
|
|
IRQ_MASK = ISR_PRX ;+ ISR_PTX ;+ ISR_RDC + ISR_PTX + ISR_TXE
|
|
|
|
|
|
|
|
RSTAT_PRX = 1 shl 0 ; successful recv
|
|
|
|
RSTAT_CRC = 1 shl 1 ; CRC error
|
|
|
|
RSTAT_FAE = 1 shl 2 ; Frame alignment error
|
|
|
|
RSTAT_OVER = 1 shl 3 ; FIFO overrun
|
|
|
|
|
|
|
|
TXBUF_SIZE = 6
|
|
|
|
RXBUF_END = 32
|
|
|
|
PAGE_SIZE = 256
|
|
|
|
|
|
|
|
ETH_ZLEN = 60
|
|
|
|
ETH_FRAME_LEN = 1514
|
|
|
|
|
|
|
|
FLAG_PIO = 1 shl 0
|
|
|
|
FLAG_16BIT = 1 shl 1
|
|
|
|
|
|
|
|
VENDOR_NONE = 0
|
|
|
|
VENDOR_WD = 1
|
|
|
|
VENDOR_NOVELL = 2
|
|
|
|
VENDOR_3COM = 3
|
|
|
|
|
|
|
|
NE_ASIC = 0x10
|
|
|
|
NE_RESET = 0x0F ; Used to reset card
|
|
|
|
NE_DATA = 0x00 ; Used to read/write NIC mem
|
|
|
|
|
|
|
|
MEM_8k = 32
|
|
|
|
MEM_16k = 64
|
|
|
|
MEM_32k = 128
|
|
|
|
|
|
|
|
ISA_MAX_ADDR = 0x400
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
section '.flat' code readable align 16
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;
|
|
|
|
;; proc START
|
|
|
|
;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2010-06-11 18:44:47 +02:00
|
|
|
align 4
|
2009-09-17 13:55:38 +02:00
|
|
|
proc START stdcall, state:dword
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [state], 1
|
|
|
|
jne .exit
|
2009-09-17 13:55:38 +02:00
|
|
|
.entry:
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 2,"Registering %s driver\n", my_service
|
2012-02-23 22:18:16 +01:00
|
|
|
stdcall RegService, my_service, service_proc
|
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
.fail:
|
|
|
|
.exit:
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;
|
|
|
|
;; proc SERVICE_PROC
|
|
|
|
;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2010-06-11 18:44:47 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
align 4
|
2010-06-11 18:44:47 +02:00
|
|
|
proc service_proc stdcall, ioctl:dword
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov edx, [ioctl]
|
|
|
|
mov eax, [IOCTL.io_code]
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
;------------------------------------------------------
|
2012-02-23 22:18:16 +01:00
|
|
|
;---------------
|
|
|
|
cmp eax, 0 ;SRV_GETVERSION
|
|
|
|
jne @F ;---------------
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [IOCTL.out_size], 4
|
|
|
|
jl .fail
|
|
|
|
mov eax, [IOCTL.output]
|
|
|
|
mov [eax], dword API_VERSION
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
2012-04-02 20:49:13 +02:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
;------------------------------------------------------
|
2012-02-23 22:18:16 +01:00
|
|
|
@@: ;---------
|
|
|
|
cmp eax, 1 ;SRV_HOOK
|
|
|
|
jne @F ;---------
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"Checking if device is already listed..\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [IOCTL.input]
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [IOCTL.inp_size], 3
|
|
|
|
jl .fail
|
|
|
|
cmp byte [eax], 1
|
|
|
|
je .pci
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [IOCTL.inp_size], 4
|
|
|
|
jl .fail
|
|
|
|
cmp byte [eax], 0
|
|
|
|
je .isa
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
jmp .fail
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
.pci:
|
|
|
|
|
2010-06-11 18:44:47 +02:00
|
|
|
; check if the device is already listed
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov esi, device_list
|
|
|
|
mov ecx, [devices]
|
|
|
|
test ecx, ecx
|
|
|
|
jz .firstdevice_pci
|
2010-06-11 18:44:47 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov ax, [eax+1] ; get the pci bus and device numbers
|
2009-09-17 13:55:38 +02:00
|
|
|
.nextdevice:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ebx, [esi]
|
2013-01-03 14:25:22 +01:00
|
|
|
cmp ax, word [device.pci_bus] ; compare with pci and device num in device list (notice the usage of word instead of byte)
|
2012-02-23 22:18:16 +01:00
|
|
|
je .find_devicenum ; Device is already loaded, let's find it's device number
|
|
|
|
add esi, 4
|
|
|
|
loop .nextdevice
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
.firstdevice_pci:
|
2012-02-23 22:18:16 +01:00
|
|
|
call create_new_struct
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [IOCTL.input]
|
2013-01-03 14:25:22 +01:00
|
|
|
mov cl, [eax+1]
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.pci_bus], cl
|
2013-01-03 14:25:22 +01:00
|
|
|
mov cl, [eax+2]
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.pci_dev], cl
|
2010-06-11 18:44:47 +02:00
|
|
|
|
|
|
|
; Now, it's time to find the base io addres of the PCI device
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
find_io [device.pci_bus], [device.pci_dev], [device.io_addr]
|
2010-06-11 18:44:47 +02:00
|
|
|
|
|
|
|
; We've found the io address, find IRQ now
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
find_irq [device.pci_bus], [device.pci_dev], [device.irq_line]
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
jmp .hook
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
.isa:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov esi, device_list
|
|
|
|
mov ecx, [devices]
|
|
|
|
test ecx, ecx
|
|
|
|
jz .firstdevice_isa
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, [eax+3]
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx edi, word [eax+1]
|
2009-09-17 13:55:38 +02:00
|
|
|
.nextdevice_isa:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ebx, [esi]
|
|
|
|
cmp edi, [device.io_addr]
|
|
|
|
jne .maybenext
|
2013-01-03 14:25:22 +01:00
|
|
|
cmp al, [device.irq_line]
|
2012-02-23 22:18:16 +01:00
|
|
|
je find_device_num
|
2009-09-17 13:55:38 +02:00
|
|
|
.maybenext:
|
2012-02-23 22:18:16 +01:00
|
|
|
add esi, 4
|
|
|
|
loop .nextdevice_isa
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.firstdevice_isa:
|
2012-02-23 22:18:16 +01:00
|
|
|
call create_new_struct
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [IOCTL.input]
|
2013-01-03 14:25:22 +01:00
|
|
|
movzx ecx, word [eax+1]
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.io_addr], ecx
|
|
|
|
mov cl, [eax+3]
|
|
|
|
mov [device.irq_line], cl
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
.hook:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
|
|
|
|
[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
call probe ; this function will output in eax
|
|
|
|
test eax, eax
|
|
|
|
jnz .err ; If an error occured, exit
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [devices]
|
|
|
|
mov [device_list+4*eax], ebx
|
|
|
|
inc [devices]
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.type], NET_TYPE_ETH
|
|
|
|
call NetRegDev
|
2010-07-12 01:13:12 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp eax, -1
|
|
|
|
jz .err
|
2012-04-02 20:49:13 +02:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-06-11 18:44:47 +02:00
|
|
|
|
|
|
|
; If the device was already loaded, find the device number and return it in eax
|
|
|
|
|
|
|
|
.find_devicenum:
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1,"Trying to find device number of already registered device\n"
|
|
|
|
call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx
|
|
|
|
; into a device number in edi
|
|
|
|
mov eax, edi ; Application wants it in eax instead
|
|
|
|
DEBUGF 1,"Kernel says: %u\n", eax
|
|
|
|
ret
|
2010-06-11 18:44:47 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
.err:
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1,"Failed, removing device structure\n"
|
|
|
|
stdcall KernelFree, ebx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
jmp .fail
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
;------------------------------------------------------
|
|
|
|
@@:
|
|
|
|
.fail:
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax, -1
|
2012-04-02 20:49:13 +02:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
;------------------------------------------------------
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
|
|
create_new_struct:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [devices], MAX_DEVICES
|
2013-01-03 14:25:22 +01:00
|
|
|
jae .fail
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
allocate_and_clear ebx, device.size, .fail ; Allocate the buffer for device structure
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.reset], reset
|
|
|
|
mov [device.transmit], transmit
|
|
|
|
mov [device.get_MAC], read_mac
|
|
|
|
mov [device.set_MAC], write_mac
|
|
|
|
mov [device.unload], unload
|
|
|
|
mov [device.name], my_service
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-26 21:06:33 +02:00
|
|
|
.fail:
|
2013-01-03 14:25:22 +01:00
|
|
|
add esp, 4 ; return to caller of 'hook'
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax, -1
|
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
find_device_num:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1,"Trying to find device number of already registered device\n"
|
|
|
|
mov ebx, eax
|
|
|
|
call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx
|
|
|
|
; into a device number in edi
|
|
|
|
mov eax, edi ; Application wants it in eax instead
|
|
|
|
DEBUGF 1,"Kernel says: %u\n", eax
|
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
|
|
|
|
;; ;;
|
|
|
|
;; Actual Hardware dependent code starts here ;;
|
|
|
|
;; ;;
|
|
|
|
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
|
|
|
|
|
|
|
|
|
|
|
|
unload: ; TODO
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax, -1
|
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;
|
|
|
|
;; probe: enables the device and clears the rx buffer
|
|
|
|
;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
probe:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.vendor], VENDOR_NONE
|
|
|
|
mov [device.bmem], 0
|
|
|
|
|
|
|
|
DEBUGF 2,"Trying 16-bit mode\n"
|
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov [device.flags], FLAG_16BIT + FLAG_PIO
|
|
|
|
mov [device.memsize], MEM_32k
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.tx_start], 64
|
|
|
|
mov [device.rx_start], TXBUF_SIZE + 64
|
|
|
|
|
|
|
|
set_io 0
|
|
|
|
set_io P0_DCR
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, DCR_WTS + DCR_FT1 + DCR_LS ; word transfer select +
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
|
|
|
|
|
|
|
set_io P0_PSTART
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, MEM_16k
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
|
|
|
|
|
|
|
set_io P0_PSTOP
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, MEM_32k
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov esi, my_service
|
2012-02-23 22:18:16 +01:00
|
|
|
mov di, 16384
|
|
|
|
mov cx, 14
|
2013-01-03 14:25:22 +01:00
|
|
|
call PIO_write
|
2012-02-23 22:18:16 +01:00
|
|
|
|
|
|
|
mov si, 16384
|
|
|
|
mov cx, 14
|
2013-01-03 14:25:22 +01:00
|
|
|
sub esp, 16
|
|
|
|
mov edi, esp
|
|
|
|
call PIO_read
|
2012-02-23 22:18:16 +01:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov esi, esp
|
|
|
|
add esp, 16
|
|
|
|
mov edi, my_service
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ecx, 13
|
2013-01-03 14:25:22 +01:00
|
|
|
repe cmpsb
|
|
|
|
je ep_set_vendor
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 2,"16-bit mode failed\n"
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"Trying 8-bit mode\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.flags], FLAG_PIO
|
2013-01-03 14:25:22 +01:00
|
|
|
mov [device.memsize], MEM_16k
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.tx_start], 32
|
|
|
|
mov [device.rx_start], TXBUF_SIZE + 32
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io NE_ASIC + NE_RESET
|
2012-02-23 22:18:16 +01:00
|
|
|
in al, dx
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
in al, 0x84
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io P0_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_RD2 + CMD_STP
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RCR
|
|
|
|
mov al, RCR_MON
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_DCR
|
|
|
|
mov al, DCR_FT1 + DCR_LS
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_PSTART
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, MEM_8k
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_PSTOP
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, MEM_16k
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov esi, my_service
|
2012-02-23 22:18:16 +01:00
|
|
|
mov di, 8192
|
|
|
|
mov cx, 14
|
2013-01-03 14:25:22 +01:00
|
|
|
call PIO_write
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov si, 8192
|
|
|
|
mov cx, 14
|
2013-01-03 14:25:22 +01:00
|
|
|
sub esp, 16
|
|
|
|
mov edi, esp
|
|
|
|
call PIO_read
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov esi, my_service
|
|
|
|
mov edi, esp
|
|
|
|
add esp, 16
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ecx, 13
|
2013-01-03 14:25:22 +01:00
|
|
|
repe cmpsb
|
|
|
|
je ep_set_vendor
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"This is not a valid ne2000 device!\n"
|
|
|
|
or eax, -1
|
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
ep_set_vendor:
|
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 2,"Mode ok\n"
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [device.io_addr], ISA_MAX_ADDR
|
2013-01-03 14:25:22 +01:00
|
|
|
jbe .isa
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"Card is using PCI bus\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov [device.vendor], VENDOR_NOVELL ;;; FIXME
|
|
|
|
jmp ep_check_have_vendor
|
|
|
|
|
|
|
|
.isa:
|
|
|
|
DEBUGF 2,"Card is using ISA bus\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.vendor], VENDOR_NOVELL
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
ep_check_have_vendor:
|
|
|
|
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, [device.vendor]
|
|
|
|
cmp al, VENDOR_NONE
|
2013-01-03 14:25:22 +01:00
|
|
|
; je exit
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp al, VENDOR_3COM
|
|
|
|
je reset
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [device.bmem]
|
|
|
|
mov [device.rmem], eax
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;
|
|
|
|
;; reset: Place the chip into a virgin state
|
|
|
|
;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
reset:
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"Resetting device\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
; attach int handler
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx eax, [device.irq_line]
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"Attaching int handler to irq %x\n", eax:1
|
2012-02-23 22:18:16 +01:00
|
|
|
stdcall AttachIntHandler, eax, int_handler, dword 0
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; Stop card + DMA
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
2013-01-03 14:25:22 +01:00
|
|
|
; set_io P0_COMMAND
|
|
|
|
mov al, CMD_PS0 + CMD_RDMA_ABORT + CMD_STP
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; initialize DCR
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_DCR
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, DCR_FT1 + DCR_LS
|
2012-02-23 22:18:16 +01:00
|
|
|
test [device.flags], FLAG_16BIT
|
2013-01-03 14:25:22 +01:00
|
|
|
jz @f
|
|
|
|
or al, DCR_WTS ; word transfer select
|
|
|
|
@@:
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-15 20:54:19 +02:00
|
|
|
; clear remote bytes count
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RBCR0
|
2013-01-03 14:25:22 +01:00
|
|
|
xor al, al
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RBCR1
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; initialize Receive configuration register (until all init is done)
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RCR
|
|
|
|
mov al, 0x20 ; monitor mode
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; transmit configuration register to monitor mode (until all ini is done)
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_TCR
|
|
|
|
mov al, 2 ; internal loopback
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; clear interupt status
|
|
|
|
set_io P0_ISR
|
|
|
|
mov al, 0xff
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
; clear IRQ mask ;;;;; CHECKME ;;;;;
|
|
|
|
set_io P0_IMR
|
|
|
|
xor al, al
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; set transmit pointer
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_TPSR
|
|
|
|
mov al, [device.tx_start]
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; set pagestart pointer
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_PSTART
|
|
|
|
mov al, [device.rx_start]
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; set pagestop pointer
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_PSTOP
|
|
|
|
mov al, [device.memsize]
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; set boundary pointer
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_BOUND
|
|
|
|
mov al, [device.memsize]
|
|
|
|
dec al
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; set curr pointer
|
|
|
|
set_io P0_COMMAND
|
|
|
|
mov al, CMD_PS1 ;+ CMD_RD2 + CMD_STP ; page 1, stop mode
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P1_CURR
|
|
|
|
mov al, [device.rx_start]
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io P0_COMMAND
|
|
|
|
mov al, CMD_PS0 ;+ CMD_RD2 + CMD_STA ; go to page 0, start mode
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; Read MAC address and set it to registers
|
2012-02-23 22:18:16 +01:00
|
|
|
call read_mac
|
2013-01-03 14:25:22 +01:00
|
|
|
push .macret
|
|
|
|
sub esp, 6
|
|
|
|
lea esi, [device.mac]
|
|
|
|
mov edi, esp
|
|
|
|
movsd
|
|
|
|
movsw
|
|
|
|
jmp write_mac
|
|
|
|
.macret:
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
; set IRQ mask
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io 0
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_IMR
|
|
|
|
mov al, IRQ_MASK
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; start mode
|
|
|
|
set_io P0_COMMAND
|
|
|
|
mov al, CMD_STA
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
; clear transmit control register
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_TCR
|
2013-01-03 14:25:22 +01:00
|
|
|
xor al, al ; no loopback
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
; set receive control register ;;;;
|
|
|
|
set_io P0_RCR
|
|
|
|
mov al, 4 ; accept broadcast
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2009-09-25 23:09:41 +02:00
|
|
|
; clear packet/byte counters
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
lea edi, [device.bytes_tx]
|
|
|
|
mov ecx, 6
|
|
|
|
rep stosd
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2010-07-15 20:54:19 +02:00
|
|
|
; Set the mtu, kernel will be able to send now
|
2013-01-03 14:25:22 +01:00
|
|
|
mov [device.mtu], ETH_FRAME_LEN
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
; Indicate that we have successfully reset the card
|
2012-04-02 20:49:13 +02:00
|
|
|
xor eax, eax
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"Done!\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; transmit
|
2009-11-08 19:00:01 +01:00
|
|
|
; buffer in [esp+4], size in [esp+8], pointer to device struct in ebx
|
2009-09-17 13:55:38 +02:00
|
|
|
;***************************************************************************
|
|
|
|
|
|
|
|
align 4
|
|
|
|
transmit:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov esi, [esp + 4]
|
|
|
|
mov ecx, [esp + 8]
|
|
|
|
DEBUGF 2,"Transmitting packet, buffer:%x, size:%u\n",esi, ecx
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 2,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
|
|
|
|
[esi+0]:2,[esi+1]:2,[esi+2]:2,[esi+3]:2,[esi+4]:2,[esi+5]:2,[esi+6]:2,[esi+7]:2,[esi+8]:2,[esi+9]:2,[esi+10]:2,[esi+11]:2,[esi+13]:2,[esi+12]:2
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp ecx, ETH_FRAME_LEN
|
|
|
|
jg .err ; packet is too long
|
2013-01-03 14:25:22 +01:00
|
|
|
cmp ecx, ETH_ZLEN
|
2012-02-23 22:18:16 +01:00
|
|
|
jl .err ; packet is too short
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx edi, [device.tx_start]
|
|
|
|
shl edi, 8
|
|
|
|
push cx
|
2013-01-03 14:25:22 +01:00
|
|
|
call PIO_write
|
2012-02-23 22:18:16 +01:00
|
|
|
pop cx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
2013-01-03 14:25:22 +01:00
|
|
|
; set_io P0_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_PS0 + CMD_RD2 + CMD_STA
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_TPSR
|
|
|
|
mov al, [device.tx_start]
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_TBCR0
|
|
|
|
mov al, cl
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_TBCR1
|
|
|
|
mov al, ch
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io P0_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_PS0 + CMD_TXP + CMD_RD2 + CMD_STA
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2," - Packet Sent!\n"
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
inc [device.packets_tx]
|
|
|
|
mov eax, [esp + 8] ; Get packet size in eax
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
add dword [device.bytes_tx], eax
|
|
|
|
adc dword [device.bytes_tx + 4], 0
|
|
|
|
|
|
|
|
stdcall KernelFree, [esp+4]
|
|
|
|
xor eax, eax
|
|
|
|
ret 8
|
2010-06-11 18:44:47 +02:00
|
|
|
|
|
|
|
.err:
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 2," - Error!\n"
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax, -1
|
|
|
|
stdcall KernelFree, [esp+4]
|
|
|
|
ret 8
|
2010-07-26 21:06:33 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;
|
|
|
|
; Interrupt handler
|
|
|
|
;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2012-08-25 19:56:09 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
align 4
|
|
|
|
int_handler:
|
|
|
|
|
2012-08-25 19:56:09 +02:00
|
|
|
DEBUGF 1,"\n%s int\n", my_service
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
; find pointer of device wich made INT occur
|
2012-08-25 19:56:09 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ecx, [devices]
|
2012-08-25 19:56:09 +02:00
|
|
|
test ecx, ecx
|
|
|
|
jz .nothing
|
|
|
|
mov esi, device_list
|
|
|
|
.nextdevice:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ebx, [esi]
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
2013-01-03 14:25:22 +01:00
|
|
|
; set_io P0_COMMAND
|
|
|
|
mov al, CMD_PS0
|
|
|
|
out dx, al
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_ISR
|
|
|
|
in al, dx
|
2012-08-25 19:56:09 +02:00
|
|
|
test al, al
|
|
|
|
jnz .got_it
|
|
|
|
.continue:
|
2012-02-23 22:18:16 +01:00
|
|
|
add esi, 4
|
2012-08-25 19:56:09 +02:00
|
|
|
dec ecx
|
|
|
|
jnz .nextdevice
|
|
|
|
.nothing:
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-08-25 19:56:09 +02:00
|
|
|
.got_it:
|
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"Device=%x status=%x\n", ebx, eax:2
|
2012-08-25 19:56:09 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
test al, ISR_PRX ; packet received ok ?
|
2012-08-25 19:56:09 +02:00
|
|
|
jz .no_rx
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
test [device.flags], FLAG_PIO
|
|
|
|
jz .no_rx ; FIXME: Only PIO mode supported for now
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
;
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
pushd .no_rx
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; allocate a buffer
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
stdcall KernelAlloc, ETH_FRAME_LEN
|
|
|
|
test eax, eax
|
|
|
|
jz .fail_2
|
|
|
|
pushd 0
|
|
|
|
push eax
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; read offset for current packet from device
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io 0
|
|
|
|
set_io P0_BOUND ; boundary ptr is offset to next packet we need to read.
|
2012-02-23 22:18:16 +01:00
|
|
|
in al, dx
|
|
|
|
inc al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp al, [device.memsize]
|
2013-01-03 14:25:22 +01:00
|
|
|
jb @f
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, [device.rx_start]
|
2013-01-03 14:25:22 +01:00
|
|
|
@@:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ch, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io P0_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_PS1
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P1_CURR
|
2013-01-03 14:25:22 +01:00
|
|
|
in al, dx ; get current page in cl
|
2012-02-23 22:18:16 +01:00
|
|
|
mov cl, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io P1_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_PS0
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp cl, [device.memsize]
|
2013-01-03 14:25:22 +01:00
|
|
|
jb @f
|
2012-02-23 22:18:16 +01:00
|
|
|
mov cl, [device.rx_start]
|
2013-01-03 14:25:22 +01:00
|
|
|
@@:
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp cl, ch
|
|
|
|
je .fail
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
movzx esi, ch ; we are using 256 byte pages
|
|
|
|
shl esi, 8 ; esi now holds the offset for current packet
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; Get packet header in eax
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
sub esp, 4 ; reserve 4 bytes on stack to put packet header in
|
|
|
|
mov edi, esp
|
2012-02-23 22:18:16 +01:00
|
|
|
mov cx, 4
|
2013-01-03 14:25:22 +01:00
|
|
|
call PIO_read
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov ecx, [esp] ; ecx now contains packet header
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; check if packet is ok
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
test ecx, RSTAT_PRX
|
|
|
|
jz .fail_3
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; calculate packet length in ecx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
shr ecx, 16
|
|
|
|
sub ecx, 4 ; CRC doesnt count as data byte
|
|
|
|
mov [esp + 4 + 4], ecx
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; check if packet size is ok
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
cmp ecx, ETH_ZLEN
|
|
|
|
jb .fail_3
|
|
|
|
cmp ecx, ETH_FRAME_LEN
|
|
|
|
ja .fail_3
|
|
|
|
|
|
|
|
; update stats
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 2,"Received %u bytes\n", ecx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
add dword[device.bytes_rx], ecx
|
|
|
|
adc dword[device.bytes_rx + 4], 0
|
|
|
|
inc [device.packets_rx]
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; update read and write pointers
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
add esi, 4
|
|
|
|
mov edi, [esp + 4]
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; now check if we can read all data at once (if we cross the end boundary, we need to wrap back to the beginning)
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
mov ah, [device.memsize]
|
|
|
|
sub eax, esi
|
|
|
|
cmp ecx, eax ; eax = number of bytes till end of buffer, ecx = bytes we need to read
|
|
|
|
jbe .no_wrap
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"WRAP!\n"
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; Read first part
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
sub ecx, eax
|
|
|
|
push ecx
|
|
|
|
mov ecx, eax
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
call PIO_read ; Read the data
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; update pointers
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
add edi, ecx
|
|
|
|
pop ecx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
movzx esi, [device.rx_start]
|
|
|
|
shl esi, 8
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; now read second part (or only part)
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.no_wrap:
|
|
|
|
call PIO_read ; Read the data
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; update boundary pointer
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
pop eax
|
|
|
|
mov al, ah
|
|
|
|
cmp al, [device.rx_start]
|
|
|
|
jne @f
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, [device.memsize]
|
2013-01-03 14:25:22 +01:00
|
|
|
@@:
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io P0_BOUND
|
|
|
|
dec al
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; now send the data to the kernel
|
|
|
|
|
2012-10-07 16:23:05 +02:00
|
|
|
jmp Eth_input
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.fail_3:
|
|
|
|
add esp, 4
|
|
|
|
.fail:
|
|
|
|
add esp, 8
|
|
|
|
.fail_2:
|
|
|
|
|
2012-08-25 19:56:09 +02:00
|
|
|
|
|
|
|
.no_rx:
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 2,"done\n"
|
|
|
|
|
|
|
|
set_io 0
|
|
|
|
set_io P0_ISR
|
|
|
|
mov al, 0xff
|
|
|
|
out dx, al
|
2012-08-25 19:56:09 +02:00
|
|
|
|
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Write MAC address ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
align 4
|
2012-02-23 22:18:16 +01:00
|
|
|
write_mac: ; in: mac on stack (6 bytes)
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"Writing MAC\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
mov al, CMD_PS1; + CMD_RD2 + CMD_STP
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P1_PAR0
|
|
|
|
mov esi, esp
|
|
|
|
mov cx, 6
|
2009-09-17 13:55:38 +02:00
|
|
|
@@:
|
2012-02-23 22:18:16 +01:00
|
|
|
lodsb
|
|
|
|
out dx, al
|
|
|
|
inc dx
|
|
|
|
loopw @r
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
add esp, 6
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
; Notice this procedure does not ret, but continues to read_mac instead.
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
|
|
|
;; Read MAC address ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
read_mac:
|
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"Reading MAC\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
xor esi, esi
|
2012-02-23 22:18:16 +01:00
|
|
|
mov cx, 16
|
2013-01-03 14:25:22 +01:00
|
|
|
sub esp, 16
|
|
|
|
mov edi, esp
|
|
|
|
call PIO_read
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
mov esi, esp
|
|
|
|
add esp, 16
|
2012-02-23 22:18:16 +01:00
|
|
|
lea edi, [device.mac]
|
|
|
|
mov ecx, 6
|
2009-09-17 13:55:38 +02:00
|
|
|
.loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
movsb
|
|
|
|
test [device.flags], FLAG_16BIT
|
|
|
|
jz .8bit
|
|
|
|
inc esi
|
2009-09-17 13:55:38 +02:00
|
|
|
.8bit:
|
2012-02-23 22:18:16 +01:00
|
|
|
loop .loop
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"MAC=%x-%x-%x-%x-%x-%x\n",\
|
|
|
|
[device.mac]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
;***************************************************************************
|
2013-01-03 14:25:22 +01:00
|
|
|
;
|
|
|
|
; PIO_read
|
2009-09-17 13:55:38 +02:00
|
|
|
;
|
|
|
|
; Description
|
|
|
|
; Read a frame from the ethernet card via Programmed I/O
|
2010-06-11 18:44:47 +02:00
|
|
|
; src in si
|
2009-09-17 13:55:38 +02:00
|
|
|
; cnt in cx
|
|
|
|
; dst in edi
|
|
|
|
;***************************************************************************
|
2013-01-03 14:25:22 +01:00
|
|
|
PIO_read:
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"PIO Read from %x to %x, %u bytes ", si, edi, cx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; start DMA
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
2013-01-03 14:25:22 +01:00
|
|
|
; set_io P0_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_RD2 + CMD_STA
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; set length of data we're interested in
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RBCR0
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, cl
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RBCR1
|
2013-01-03 14:25:22 +01:00
|
|
|
mov al, ch
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; set offset of what we want to read
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RSAR0
|
2013-01-03 14:25:22 +01:00
|
|
|
mov ax, si
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2013-01-03 14:25:22 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RSAR1
|
2013-01-03 14:25:22 +01:00
|
|
|
shr ax, 8
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
; start DMA read
|
|
|
|
set_io P0_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_RD0 + CMD_STA
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io NE_ASIC
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
test [device.flags], FLAG_16BIT
|
2013-01-03 14:25:22 +01:00
|
|
|
jz .8bits
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"(16-bit mode)\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
shr cx, 1 ; note that if the number was odd, carry flag will be set
|
2013-01-03 14:25:22 +01:00
|
|
|
pushf
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.16bits:
|
2012-02-23 22:18:16 +01:00
|
|
|
in ax, dx
|
|
|
|
stosw
|
2013-01-03 14:25:22 +01:00
|
|
|
loopw .16bits
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
inc cx
|
|
|
|
popf
|
2013-01-03 14:25:22 +01:00
|
|
|
jnc .done
|
|
|
|
jmp .8bits_
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.8bits:
|
|
|
|
DEBUGF 1,"(8-bit mode)\n"
|
|
|
|
|
|
|
|
.8bits_:
|
2012-02-23 22:18:16 +01:00
|
|
|
in al, dx
|
|
|
|
stosb
|
2013-01-03 14:25:22 +01:00
|
|
|
loopw .8bits_
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.done:
|
|
|
|
; set_io 0
|
|
|
|
; set_io P0_ISR
|
|
|
|
;
|
|
|
|
; .dmawait: ; Wait for Remote DMA Complete
|
|
|
|
; in al, dx
|
|
|
|
; test al, ISR_RDC
|
|
|
|
; jz .dmawait
|
2009-09-17 13:55:38 +02:00
|
|
|
; and al, not ISR_RDC
|
2013-01-03 14:25:22 +01:00
|
|
|
; out dx, al ; clear the bit
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;***************************************************************************
|
2013-01-03 14:25:22 +01:00
|
|
|
;
|
|
|
|
; PIO_write
|
2009-09-17 13:55:38 +02:00
|
|
|
;
|
|
|
|
; Description
|
|
|
|
; writes a frame to the ethernet card via Programmed I/O
|
2010-06-11 18:44:47 +02:00
|
|
|
; dst in di
|
2009-09-17 13:55:38 +02:00
|
|
|
; cnt in cx
|
|
|
|
; src in esi
|
|
|
|
;***************************************************************************
|
2013-01-03 14:25:22 +01:00
|
|
|
PIO_write:
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"Eth PIO Write from %x to %x, %u bytes ", esi, di, cx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
2013-01-03 14:25:22 +01:00
|
|
|
; set_io P0_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_RD2 + CMD_STA
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_ISR
|
|
|
|
mov al, ISR_RDC
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RBCR0
|
|
|
|
mov al, cl
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io P0_RBCR1
|
|
|
|
mov al, ch
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ax, di
|
|
|
|
set_io P0_RSAR0
|
|
|
|
out dx, al
|
|
|
|
shr ax, 8
|
|
|
|
set_io P0_RSAR1
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io P0_COMMAND
|
2012-02-23 22:18:16 +01:00
|
|
|
mov al, CMD_RD1 + CMD_STA
|
|
|
|
out dx, al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
set_io NE_ASIC
|
2012-02-23 22:18:16 +01:00
|
|
|
test [device.flags], FLAG_16BIT
|
2013-01-03 14:25:22 +01:00
|
|
|
jz .8_bit
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
DEBUGF 1,"(16-bit mode)\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
shr cx, 1 ; note that if the number was odd, carry flag will be set
|
|
|
|
pushf ; save the flags for later
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.16bit:
|
2012-02-23 22:18:16 +01:00
|
|
|
lodsw
|
|
|
|
out dx, ax
|
2013-01-03 14:25:22 +01:00
|
|
|
loopw .16bit
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
popf
|
2013-01-03 14:25:22 +01:00
|
|
|
jnc .done
|
2012-02-23 22:18:16 +01:00
|
|
|
inc cx
|
2013-01-03 14:25:22 +01:00
|
|
|
jmp .8_bit_
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.8_bit:
|
|
|
|
|
|
|
|
DEBUGF 1,"(8-bit mode)\n"
|
|
|
|
|
|
|
|
.8_bit_:
|
2012-02-23 22:18:16 +01:00
|
|
|
lodsb
|
|
|
|
out dx, al
|
2013-01-03 14:25:22 +01:00
|
|
|
loopw .8_bit_
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2013-01-03 14:25:22 +01:00
|
|
|
.done:
|
|
|
|
; set_io 0
|
|
|
|
; set_io P0_ISR
|
|
|
|
; .dmawait: ; Wait for Remote DMA Complete
|
|
|
|
; in al, dx
|
|
|
|
; test al, ISR_RDC
|
|
|
|
; jz .dmawait
|
2009-09-17 13:55:38 +02:00
|
|
|
; and al, not ISR_RDC
|
2013-01-03 14:25:22 +01:00
|
|
|
; out dx, al ; clear the bit
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;all initialized data place here
|
|
|
|
align 4
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
devices dd 0
|
|
|
|
version dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF)
|
|
|
|
my_service db 'RTL8029/ne2000',0 ;max 16 chars include zero
|
2009-09-25 23:09:41 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
device_1 db 'Realtek 8029',0
|
|
|
|
device_2 db 'Realtek 8019',0
|
|
|
|
device_3 db 'Realtek 8019AS',0
|
|
|
|
device_4 db 'ne2000',0
|
|
|
|
device_5 db 'DP8390',0
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
include_debug_strings
|
|
|
|
|
2009-09-25 23:09:41 +02:00
|
|
|
section '.data' data readable writable align 16 ;place all uninitialized data place here
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
device_list rd MAX_DEVICES
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|