forked from KolibriOS/kolibrios
Converted RTL8139 driver to PE format.
git-svn-id: svn://kolibrios.org@5045 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7dc01ee888
commit
5510d9a2d6
@ -135,7 +135,6 @@ FASM_PROGRAMS:=\
|
|||||||
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
||||||
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
||||||
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
||||||
drivers/rtl8139.obj:DRIVERS/RTL8139.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
|
||||||
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
||||||
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
||||||
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
||||||
@ -207,6 +206,7 @@ FASM_PROGRAMS_PESTRIP:=\
|
|||||||
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
||||||
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
||||||
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
||||||
|
drivers/rtl8139.sys:DRIVERS/RTL8139.SYS:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
||||||
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
||||||
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
||||||
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
||||||
|
@ -135,7 +135,6 @@ FASM_PROGRAMS:=\
|
|||||||
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
||||||
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
||||||
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
||||||
drivers/rtl8139.obj:DRIVERS/RTL8139.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
|
||||||
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
||||||
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
||||||
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
||||||
@ -207,6 +206,7 @@ FASM_PROGRAMS_PESTRIP:=\
|
|||||||
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
||||||
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
||||||
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
||||||
|
drivers/rtl8139.sys:DRIVERS/RTL8139.SYS:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
||||||
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
||||||
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
||||||
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
||||||
|
@ -135,7 +135,6 @@ FASM_PROGRAMS:=\
|
|||||||
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
||||||
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
||||||
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
||||||
drivers/rtl8139.obj:DRIVERS/RTL8139.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
|
||||||
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
||||||
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
||||||
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
||||||
@ -207,6 +206,7 @@ FASM_PROGRAMS_PESTRIP:=\
|
|||||||
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
||||||
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
||||||
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
||||||
|
drivers/rtl8139.sys:DRIVERS/RTL8139.SYS:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
||||||
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
||||||
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
||||||
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
||||||
|
@ -136,7 +136,6 @@ FASM_PROGRAMS:=\
|
|||||||
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
||||||
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
||||||
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
||||||
drivers/rtl8139.obj:DRIVERS/RTL8139.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
|
||||||
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
||||||
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
||||||
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
||||||
@ -207,6 +206,7 @@ FASM_PROGRAMS_PESTRIP:=\
|
|||||||
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
||||||
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
||||||
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
||||||
|
drivers/rtl8139.sys:DRIVERS/RTL8139.SYS:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
||||||
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
||||||
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
||||||
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
||||||
|
@ -135,7 +135,6 @@ FASM_PROGRAMS:=\
|
|||||||
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
drivers/vt823x.obj:DRIVERS/VT823X.OBJ:$(KERNEL)/drivers/vt823x.asm \
|
||||||
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
drivers/3c59x.obj:DRIVERS/3C59X.OBJ:$(REPOSITORY)/drivers/ethernet/3c59x.asm \
|
||||||
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
drivers/dec21x4x.obj:DRIVERS/DEC21X4X.OBJ:$(REPOSITORY)/drivers/ethernet/dec21x4x.asm \
|
||||||
drivers/rtl8139.obj:DRIVERS/RTL8139.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
|
||||||
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
drivers/rtl8169.obj:DRIVERS/RTL8169.OBJ:$(REPOSITORY)/drivers/ethernet/RTL8169.asm \
|
||||||
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
File|Managers/kfar:File|Managers/KFAR:$(PROGS)/fs/kfar/trunk/kfar.asm \
|
||||||
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
File|Managers/kfm:File|Managers/KFM:$(PROGS)/fs/kfm/trunk/kfm.asm \
|
||||||
@ -207,6 +206,7 @@ FASM_PROGRAMS_PESTRIP:=\
|
|||||||
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
drivers/r6040.sys:DRIVERS/R6040.SYS:$(REPOSITORY)/drivers/ethernet/R6040.asm \
|
||||||
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
drivers/rhine.sys:DRIVERS/RHINE.SYS:$(REPOSITORY)/drivers/ethernet/rhine.asm \
|
||||||
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
drivers/rtl8029.sys:DRIVERS/RTL8029.SYS:$(REPOSITORY)/drivers/ethernet/RTL8029.asm \
|
||||||
|
drivers/rtl8139.sys:DRIVERS/RTL8139.SYS:$(REPOSITORY)/drivers/ethernet/RTL8139.asm \
|
||||||
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
drivers/sis900.sys:DRIVERS/SIS900.SYS:$(REPOSITORY)/drivers/ethernet/sis900.asm \
|
||||||
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
drivers/uhci.sys:DRIVERS/UHCI.SYS:$(REPOSITORY)/drivers/usb/uhci.asm \
|
||||||
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
drivers/ohci.sys:DRIVERS/OHCI.SYS:$(REPOSITORY)/drivers/usb/ohci.asm \
|
||||||
|
@ -15,35 +15,33 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
format MS COFF
|
format PE DLL native
|
||||||
|
entry START
|
||||||
|
|
||||||
API_VERSION = 0x01000100
|
CURRENT_API = 0x0200
|
||||||
DRIVER_VERSION = 5
|
COMPATIBLE_API = 0x0100
|
||||||
|
API_VERSION = (COMPATIBLE_API shl 16) + CURRENT_API
|
||||||
|
|
||||||
MAX_DEVICES = 16
|
MAX_DEVICES = 16
|
||||||
|
|
||||||
RBLEN = 3 ; Receive buffer size: 0==8K 1==16k 2==32k 3==64k
|
RBLEN = 3 ; Receive buffer size: 0==8K 1==16k 2==32k 3==64k
|
||||||
|
|
||||||
TXRR = 8 ; total retries = 16+(TXRR*16)
|
TXRR = 8 ; total retries = 16+(TXRR*16)
|
||||||
TX_MXDMA = 6 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=2048
|
TX_MXDMA = 6 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=2048
|
||||||
ERTXTH = 8 ; in unit of 32 bytes e.g:(8*32)=256
|
ERTXTH = 8 ; in unit of 32 bytes e.g:(8*32)=256
|
||||||
RX_MXDMA = 7 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=unlimited
|
RX_MXDMA = 7 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=unlimited
|
||||||
RXFTH = 7 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=no threshold
|
RXFTH = 7 ; 0=16 1=32 2=64 3=128 4=256 5=512 6=1024 7=no threshold
|
||||||
|
|
||||||
DEBUG = 1
|
|
||||||
__DEBUG__ = 1
|
__DEBUG__ = 1
|
||||||
__DEBUG_LEVEL__ = 2 ; 1 = verbose, 2 = errors only
|
__DEBUG_LEVEL__ = 2 ; 1 = verbose, 2 = errors only
|
||||||
|
|
||||||
|
section '.flat' readable writable executable
|
||||||
|
|
||||||
|
include '../proc32.inc'
|
||||||
include '../struct.inc'
|
include '../struct.inc'
|
||||||
include '../macros.inc'
|
include '../macros.inc'
|
||||||
include '../proc32.inc'
|
|
||||||
include '../imports.inc'
|
|
||||||
include '../fdo.inc'
|
include '../fdo.inc'
|
||||||
include '../netdrv.inc'
|
include '../netdrv_pe.inc'
|
||||||
|
|
||||||
public START
|
|
||||||
public service_proc
|
|
||||||
public version
|
|
||||||
|
|
||||||
REG_IDR0 = 0x00
|
REG_IDR0 = 0x00
|
||||||
REG_MAR0 = 0x08 ; multicast filter register 0
|
REG_MAR0 = 0x08 ; multicast filter register 0
|
||||||
@ -137,7 +135,6 @@ public version
|
|||||||
(1 shl BIT_AM) ; Accept multicast packets
|
(1 shl BIT_AM) ; Accept multicast packets
|
||||||
|
|
||||||
RX_BUFFER_SIZE = (8192 shl RBLEN);+16+1500
|
RX_BUFFER_SIZE = (8192 shl RBLEN);+16+1500
|
||||||
MAX_ETH_FRAME_SIZE = 1514
|
|
||||||
NUM_TX_DESC = 4 ; not user selectable
|
NUM_TX_DESC = 4 ; not user selectable
|
||||||
|
|
||||||
EE_93C46_REG_ETH_ID = 7 ; MAC offset
|
EE_93C46_REG_ETH_ID = 7 ; MAC offset
|
||||||
@ -189,8 +186,6 @@ public version
|
|||||||
ISR_TIMEOUT or \
|
ISR_TIMEOUT or \
|
||||||
ISR_SERR
|
ISR_SERR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TSR_OWN = 1 shl 13
|
TSR_OWN = 1 shl 13
|
||||||
TSR_TUN = 1 shl 14
|
TSR_TUN = 1 shl 14
|
||||||
TSR_TOK = 1 shl 15
|
TSR_TOK = 1 shl 15
|
||||||
@ -201,33 +196,24 @@ public version
|
|||||||
TSR_CRS = 1 shl 31
|
TSR_CRS = 1 shl 31
|
||||||
|
|
||||||
|
|
||||||
virtual at ebx
|
struct device ETH_DEVICE
|
||||||
|
|
||||||
device:
|
io_addr dd ?
|
||||||
|
pci_bus dd ?
|
||||||
|
pci_dev dd ?
|
||||||
|
irq_line db ?
|
||||||
|
rb 3 ; align 4
|
||||||
|
|
||||||
ETH_DEVICE
|
rx_buffer dd ?
|
||||||
|
rx_data_offset dd ?
|
||||||
|
curr_tx_desc db ?
|
||||||
|
hw_ver_id db ?
|
||||||
|
rb 2 ; align 4
|
||||||
|
|
||||||
.rx_buffer dd ?
|
TX_DESC rd NUM_TX_DESC
|
||||||
|
|
||||||
.rx_data_offset dd ?
|
ends
|
||||||
.io_addr dd ?
|
|
||||||
|
|
||||||
.curr_tx_desc db ?
|
|
||||||
.pci_bus dd ?
|
|
||||||
.pci_dev dd ?
|
|
||||||
.irq_line db ?
|
|
||||||
.hw_ver_id db ?
|
|
||||||
|
|
||||||
db ? ; align 4
|
|
||||||
.TX_DESC rd NUM_TX_DESC
|
|
||||||
|
|
||||||
.size = $ - device
|
|
||||||
|
|
||||||
end virtual
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
section '.flat' code readable align 16
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
@ -236,20 +222,16 @@ section '.flat' code readable align 16
|
|||||||
;; (standard driver proc) ;;
|
;; (standard driver proc) ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
align 4
|
proc START c, reason:dword, cmdline:dword
|
||||||
proc START stdcall, state:dword
|
|
||||||
|
|
||||||
cmp [state], 1
|
cmp [reason], DRV_ENTRY
|
||||||
jne .exit
|
jne .fail
|
||||||
|
|
||||||
.entry:
|
DEBUGF 2,"Loading driver\n"
|
||||||
|
invoke RegService, my_service, service_proc
|
||||||
DEBUGF 2, "Loading driver\n"
|
|
||||||
stdcall RegService, my_service, service_proc
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
.exit:
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -263,7 +245,6 @@ endp
|
|||||||
;; (standard driver proc) ;;
|
;; (standard driver proc) ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
align 4
|
|
||||||
proc service_proc stdcall, ioctl:dword
|
proc service_proc stdcall, ioctl:dword
|
||||||
|
|
||||||
mov edx, [ioctl]
|
mov edx, [ioctl]
|
||||||
@ -304,9 +285,9 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
mov ax, [eax+1] ; get the pci bus and device numbers
|
mov ax, [eax+1] ; get the pci bus and device numbers
|
||||||
.nextdevice:
|
.nextdevice:
|
||||||
mov ebx, [esi]
|
mov ebx, [esi]
|
||||||
cmp al, byte[device.pci_bus]
|
cmp al, byte[ebx + device.pci_bus]
|
||||||
jne @f
|
jne @f
|
||||||
cmp ah, byte[device.pci_dev]
|
cmp ah, byte[ebx + device.pci_dev]
|
||||||
je .find_devicenum ; Device is already loaded, let's find it's device number
|
je .find_devicenum ; Device is already loaded, let's find it's device number
|
||||||
@@:
|
@@:
|
||||||
add esi, 4
|
add esi, 4
|
||||||
@ -318,40 +299,42 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
cmp [devices], MAX_DEVICES ; First check if the driver can handle one more card
|
cmp [devices], MAX_DEVICES ; First check if the driver can handle one more card
|
||||||
jae .fail
|
jae .fail
|
||||||
|
|
||||||
allocate_and_clear ebx, device.size, .fail ; Allocate the buffer for device structure
|
allocate_and_clear ebx, sizeof.device, .fail ; Allocate the buffer for device structure
|
||||||
|
|
||||||
; Fill in the direct call addresses into the struct
|
; Fill in the direct call addresses into the struct
|
||||||
|
|
||||||
mov [device.reset], reset
|
mov [ebx + device.reset], reset
|
||||||
mov [device.transmit], transmit
|
mov [ebx + device.transmit], transmit
|
||||||
mov [device.unload], unload
|
mov [ebx + device.unload], unload
|
||||||
mov [device.name], my_service
|
mov [ebx + device.name], my_service
|
||||||
|
|
||||||
; save the pci bus and device numbers
|
; save the pci bus and device numbers
|
||||||
|
|
||||||
mov eax, [edx + IOCTL.input]
|
mov eax, [edx + IOCTL.input]
|
||||||
movzx ecx, byte[eax+1]
|
movzx ecx, byte[eax+1]
|
||||||
mov [device.pci_bus], ecx
|
mov [ebx + device.pci_bus], ecx
|
||||||
movzx ecx, byte[eax+2]
|
movzx ecx, byte[eax+2]
|
||||||
mov [device.pci_dev], ecx
|
mov [ebx + device.pci_dev], ecx
|
||||||
|
|
||||||
; Now, it's time to find the base io addres of the PCI device
|
; Now, it's time to find the base io addres of the PCI device
|
||||||
|
|
||||||
PCI_find_io
|
stdcall PCI_find_io, [ebx + device.pci_bus], [ebx + device.pci_dev]
|
||||||
|
mov [ebx + device.io_addr], eax
|
||||||
|
|
||||||
; We've found the io address, find IRQ now
|
; We've found the io address, find IRQ now
|
||||||
|
|
||||||
PCI_find_irq
|
invoke PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.interrupt_line
|
||||||
|
mov [ebx + device.irq_line], al
|
||||||
|
|
||||||
DEBUGF 1, "Hooking into device, dev:%x, bus:%x, irq:%x, I/O addr:%x\n",\
|
DEBUGF 1, "Hooking into device, dev:%x, bus:%x, irq:%x, I/O addr:%x\n",\
|
||||||
[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
|
[ebx + device.pci_dev]:1,[ebx + device.pci_bus]:1,[ebx + device.irq_line]:1,[ebx + device.io_addr]:4
|
||||||
|
|
||||||
; Allocate the receive buffer
|
; Allocate the receive buffer
|
||||||
|
|
||||||
stdcall CreateRingBuffer, dword (RX_BUFFER_SIZE), dword PG_SW
|
invoke CreateRingBuffer, dword (RX_BUFFER_SIZE), dword PG_SW
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .err
|
jz .err
|
||||||
mov [device.rx_buffer], eax
|
mov [ebx + device.rx_buffer], eax
|
||||||
|
|
||||||
; Ok, the eth_device structure is ready, let's probe the device
|
; Ok, the eth_device structure is ready, let's probe the device
|
||||||
|
|
||||||
@ -367,8 +350,8 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jnz .destroy
|
jnz .destroy
|
||||||
|
|
||||||
mov [device.type], NET_TYPE_ETH
|
mov [ebx + device.type], NET_TYPE_ETH
|
||||||
call NetRegDev
|
invoke NetRegDev
|
||||||
|
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je .destroy
|
je .destroy
|
||||||
@ -379,7 +362,7 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
.find_devicenum:
|
.find_devicenum:
|
||||||
DEBUGF 1, "Trying to find device number of already registered device\n"
|
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
|
invoke NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx
|
||||||
; into a device number in edi
|
; into a device number in edi
|
||||||
mov eax, edi ; Application wants it in eax instead
|
mov eax, edi ; Application wants it in eax instead
|
||||||
DEBUGF 1, "Kernel says: %u\n", eax
|
DEBUGF 1, "Kernel says: %u\n", eax
|
||||||
@ -393,8 +376,8 @@ proc service_proc stdcall, ioctl:dword
|
|||||||
|
|
||||||
.err:
|
.err:
|
||||||
DEBUGF 2, "Error, removing all data !\n"
|
DEBUGF 2, "Error, removing all data !\n"
|
||||||
stdcall KernelFree, [device.rx_buffer]
|
invoke KernelFree, [ebx + device.rx_buffer]
|
||||||
stdcall KernelFree, ebx
|
invoke KernelFree, ebx
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
or eax, -1
|
or eax, -1
|
||||||
@ -435,11 +418,14 @@ align 4
|
|||||||
probe:
|
probe:
|
||||||
DEBUGF 1, "Probing\n"
|
DEBUGF 1, "Probing\n"
|
||||||
|
|
||||||
PCI_make_bus_master
|
; Make the device a bus master
|
||||||
|
invoke PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command
|
||||||
|
or al, PCI_CMD_MASTER
|
||||||
|
invoke PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax
|
||||||
|
|
||||||
; get chip version
|
; get chip version
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_TXCONFIG + 2
|
set_io [ebx + device.io_addr], REG_TXCONFIG + 2
|
||||||
in ax, dx
|
in ax, dx
|
||||||
shr ah, 2
|
shr ah, 2
|
||||||
shr ax, 6
|
shr ax, 6
|
||||||
@ -458,28 +444,28 @@ probe:
|
|||||||
cmp ecx, 8
|
cmp ecx, 8
|
||||||
ja .unknown
|
ja .unknown
|
||||||
|
|
||||||
mov [device.hw_ver_id], cl
|
mov [ebx + device.hw_ver_id], cl
|
||||||
|
|
||||||
mov ecx, [crosslist+ecx*4]
|
mov ecx, [crosslist+ecx*4]
|
||||||
mov [device.name], ecx
|
mov [ebx + device.name], ecx
|
||||||
|
|
||||||
DEBUGF 1, "Chip version: %s\n", ecx
|
DEBUGF 1, "Chip version: %s\n", ecx
|
||||||
|
|
||||||
; wake up the chip
|
; wake up the chip
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_HLTCLK
|
set_io [ebx + device.io_addr], REG_HLTCLK
|
||||||
mov al, 'R' ; run the clock
|
mov al, 'R' ; run the clock
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; unlock config and BMCR registers
|
; unlock config and BMCR registers
|
||||||
set_io REG_9346CR
|
set_io [ebx + device.io_addr], REG_9346CR
|
||||||
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
|
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; enable power management
|
; enable power management
|
||||||
set_io REG_CONFIG1
|
set_io [ebx + device.io_addr], REG_CONFIG1
|
||||||
in al, dx
|
in al, dx
|
||||||
cmp [device.hw_ver_id], IDX_RTL8139B
|
cmp [ebx + device.hw_ver_id], IDX_RTL8139B
|
||||||
jae .new_chip
|
jae .new_chip
|
||||||
; wake up older chips
|
; wake up older chips
|
||||||
and al, not ((1 shl BIT_SLEEP) or (1 shl BIT_PWRDWN))
|
and al, not ((1 shl BIT_SLEEP) or (1 shl BIT_PWRDWN))
|
||||||
@ -495,7 +481,7 @@ probe:
|
|||||||
and al, not (1 shl BIT_LWACT)
|
and al, not (1 shl BIT_LWACT)
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
set_io REG_CONFIG4
|
set_io [ebx + device.io_addr], REG_CONFIG4
|
||||||
in al, dx
|
in al, dx
|
||||||
and al, not (1 shl BIT_LWPTN)
|
and al, not (1 shl BIT_LWPTN)
|
||||||
out dx, al
|
out dx, al
|
||||||
@ -503,8 +489,8 @@ probe:
|
|||||||
; lock config and BMCR registers
|
; lock config and BMCR registers
|
||||||
.finish_wake_up:
|
.finish_wake_up:
|
||||||
xor al, al
|
xor al, al
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_9346CR
|
set_io [ebx + device.io_addr], REG_9346CR
|
||||||
out dx, al
|
out dx, al
|
||||||
DEBUGF 1, "probing done!\n"
|
DEBUGF 1, "probing done!\n"
|
||||||
|
|
||||||
@ -523,20 +509,20 @@ reset:
|
|||||||
DEBUGF 1, "Reset\n"
|
DEBUGF 1, "Reset\n"
|
||||||
|
|
||||||
; attach int handler
|
; attach int handler
|
||||||
movzx eax, [device.irq_line]
|
movzx eax, [ebx + device.irq_line]
|
||||||
DEBUGF 1, "Attaching int handler to irq %x\n", eax:1
|
DEBUGF 1, "Attaching int handler to irq %x\n", eax:1
|
||||||
stdcall AttachIntHandler, eax, int_handler, dword 0
|
invoke AttachIntHandler, eax, int_handler, ebx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
DEBUGF 2, "Could not attach int handler!\n"
|
DEBUGF 2, "Could not attach int handler!\n"
|
||||||
; or eax, -1
|
or eax, -1
|
||||||
; ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
; reset chip
|
; reset chip
|
||||||
DEBUGF 1, "Resetting chip\n"
|
DEBUGF 1, "Resetting chip\n"
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_COMMAND
|
set_io [ebx + device.io_addr], REG_COMMAND
|
||||||
mov al, 1 shl BIT_RST
|
mov al, 1 shl BIT_RST
|
||||||
out dx, al
|
out dx, al
|
||||||
mov cx, 1000 ; wait no longer for the reset
|
mov cx, 1000 ; wait no longer for the reset
|
||||||
@ -553,83 +539,83 @@ reset:
|
|||||||
call read_mac
|
call read_mac
|
||||||
|
|
||||||
; unlock config and BMCR registers
|
; unlock config and BMCR registers
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_9346CR
|
set_io [ebx + device.io_addr], REG_9346CR
|
||||||
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
|
mov al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; initialize multicast registers (no filtering)
|
; initialize multicast registers (no filtering)
|
||||||
mov eax, 0xffffffff
|
mov eax, 0xffffffff
|
||||||
set_io REG_MAR0
|
set_io [ebx + device.io_addr], REG_MAR0
|
||||||
out dx, eax
|
out dx, eax
|
||||||
set_io REG_MAR4
|
set_io [ebx + device.io_addr], REG_MAR4
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; enable Rx/Tx
|
; enable Rx/Tx
|
||||||
mov al, (1 shl BIT_RE) or (1 shl BIT_TE)
|
mov al, (1 shl BIT_RE) or (1 shl BIT_TE)
|
||||||
set_io REG_COMMAND
|
set_io [ebx + device.io_addr], REG_COMMAND
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; Rxbuffer size, unlimited dma burst, no wrapping, no rx threshold
|
; Rxbuffer size, unlimited dma burst, no wrapping, no rx threshold
|
||||||
; accept broadcast packets, accept physical match packets
|
; accept broadcast packets, accept physical match packets
|
||||||
mov eax, RX_CONFIG
|
mov eax, RX_CONFIG
|
||||||
set_io REG_RXCONFIG
|
set_io [ebx + device.io_addr], REG_RXCONFIG
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; 1024 bytes DMA burst, total retries = 16 + 8 * 16 = 144
|
; 1024 bytes DMA burst, total retries = 16 + 8 * 16 = 144
|
||||||
mov eax, (TX_MXDMA shl BIT_TX_MXDMA) or (TXRR shl BIT_TXRR) or BIT_IFG1 or BIT_IFG0
|
mov eax, (TX_MXDMA shl BIT_TX_MXDMA) or (TXRR shl BIT_TXRR) or BIT_IFG1 or BIT_IFG0
|
||||||
set_io REG_TXCONFIG
|
set_io [ebx + device.io_addr], REG_TXCONFIG
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; enable auto negotiation
|
; enable auto negotiation
|
||||||
set_io REG_BMCR
|
set_io [ebx + device.io_addr], REG_BMCR
|
||||||
in ax, dx
|
in ax, dx
|
||||||
or ax, (1 shl BIT_ANE)
|
or ax, (1 shl BIT_ANE)
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
; set auto negotiation advertisement
|
; set auto negotiation advertisement
|
||||||
set_io REG_ANAR
|
set_io [ebx + device.io_addr], REG_ANAR
|
||||||
in ax, dx
|
in ax, dx
|
||||||
or ax, (1 shl BIT_SELECTOR) or (1 shl BIT_10) or (1 shl BIT_10FD) or (1 shl BIT_TX) or (1 shl BIT_TXFD)
|
or ax, (1 shl BIT_SELECTOR) or (1 shl BIT_10) or (1 shl BIT_10FD) or (1 shl BIT_TX) or (1 shl BIT_TXFD)
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
; lock config and BMCR registers
|
; lock config and BMCR registers
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
set_io REG_9346CR
|
set_io [ebx + device.io_addr], REG_9346CR
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; init RX/TX pointers
|
; init RX/TX pointers
|
||||||
mov [device.rx_data_offset], eax
|
mov [ebx + device.rx_data_offset], eax
|
||||||
mov [device.curr_tx_desc], al
|
mov [ebx + device.curr_tx_desc], al
|
||||||
; set_io REG_CAPR
|
; set_io [ebx + device.io_addr], REG_CAPR
|
||||||
; out dx, ax
|
; out dx, ax
|
||||||
|
|
||||||
; clear packet/byte counters
|
; clear packet/byte counters
|
||||||
lea edi, [device.bytes_tx]
|
lea edi, [ebx + device.bytes_tx]
|
||||||
mov ecx, 6
|
mov ecx, 6
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
; clear missing packet counter
|
; clear missing packet counter
|
||||||
set_io REG_MPC
|
set_io [ebx + device.io_addr], REG_MPC
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; set RxBuffer address, init RX buffer offset
|
; set RxBuffer address, init RX buffer offset
|
||||||
mov eax, [device.rx_buffer]
|
mov eax, [ebx + device.rx_buffer]
|
||||||
mov dword[eax], 0 ; clear receive flags for first packet (really needed??)
|
mov dword[eax], 0 ; clear receive flags for first packet (really needed??)
|
||||||
DEBUGF 1, "RX buffer virtual addr=0x%x\n", eax
|
DEBUGF 1, "RX buffer virtual addr=0x%x\n", eax
|
||||||
GetRealAddr
|
invoke GetPhysAddr
|
||||||
DEBUGF 1, "RX buffer physical addr=0x%x\n", eax
|
DEBUGF 1, "RX buffer physical addr=0x%x\n", eax
|
||||||
set_io REG_RBSTART
|
set_io [ebx + device.io_addr], REG_RBSTART
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; enable interrupts
|
; enable interrupts
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_IMR
|
set_io [ebx + device.io_addr], REG_IMR
|
||||||
mov ax, INTERRUPT_MASK
|
mov ax, INTERRUPT_MASK
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
; Set the mtu, kernel will be able to send now
|
; Set the mtu, kernel will be able to send now
|
||||||
mov [device.mtu], 1514
|
mov [ebx + device.mtu], 1514
|
||||||
|
|
||||||
call cable
|
call cable
|
||||||
|
|
||||||
@ -647,24 +633,28 @@ reset:
|
|||||||
;; pointer to device structure in ebx ;;
|
;; pointer to device structure in ebx ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
align 4
|
|
||||||
transmit:
|
proc transmit stdcall bufferptr, buffersize
|
||||||
DEBUGF 1, "Transmitting packet, buffer:%x, size:%u\n", [esp+4], [esp+8]
|
|
||||||
mov eax, [esp+4]
|
pushf
|
||||||
DEBUGF 1, "To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
|
cli
|
||||||
|
|
||||||
|
DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize]
|
||||||
|
mov eax, [bufferptr]
|
||||||
|
DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
|
||||||
[eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
|
[eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
|
||||||
[eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
|
[eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
|
||||||
[eax+13]:2,[eax+12]:2
|
[eax+13]:2,[eax+12]:2
|
||||||
|
|
||||||
cmp dword [esp+8], MAX_ETH_FRAME_SIZE
|
cmp [buffersize], 1514
|
||||||
ja .fail
|
ja .fail
|
||||||
cmp dword [esp+8], 60
|
cmp [buffersize], 60
|
||||||
jb .fail
|
jb .fail
|
||||||
|
|
||||||
; check if we own the current discriptor
|
; check if we own the current discriptor
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_TSD0
|
set_io [ebx + device.io_addr], REG_TSD0
|
||||||
movzx ecx, [device.curr_tx_desc]
|
movzx ecx, [ebx + device.curr_tx_desc]
|
||||||
shl ecx, 2
|
shl ecx, 2
|
||||||
add edx, ecx
|
add edx, ecx
|
||||||
in eax, dx
|
in eax, dx
|
||||||
@ -673,38 +663,39 @@ transmit:
|
|||||||
|
|
||||||
.send_packet:
|
.send_packet:
|
||||||
; get next descriptor
|
; get next descriptor
|
||||||
inc [device.curr_tx_desc]
|
inc [ebx + device.curr_tx_desc]
|
||||||
and [device.curr_tx_desc], NUM_TX_DESC-1
|
and [ebx + device.curr_tx_desc], NUM_TX_DESC-1
|
||||||
|
|
||||||
; Update stats
|
; Update stats
|
||||||
inc [device.packets_tx]
|
inc [ebx + device.packets_tx]
|
||||||
mov eax, [esp+8]
|
mov eax, [buffersize]
|
||||||
add dword [device.bytes_tx], eax
|
add dword [ebx + device.bytes_tx], eax
|
||||||
adc dword [device.bytes_tx+4], 0
|
adc dword [ebx + device.bytes_tx+4], 0
|
||||||
|
|
||||||
; Set the buffer address
|
; Set the buffer address
|
||||||
set_io REG_TSAD0
|
set_io [ebx + device.io_addr], REG_TSAD0
|
||||||
mov eax, [esp+4]
|
mov eax, [bufferptr]
|
||||||
mov [device.TX_DESC+ecx], eax
|
mov [ebx + device.TX_DESC+ecx], eax
|
||||||
GetRealAddr
|
invoke GetPhysAddr
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; And the size of the buffer
|
; And the size of the buffer
|
||||||
set_io REG_TSD0
|
set_io [ebx + device.io_addr], REG_TSD0
|
||||||
mov eax, [esp+8]
|
mov eax, [buffersize]
|
||||||
or eax, (ERTXTH shl BIT_ERTXTH) ; Early threshold
|
or eax, (ERTXTH shl BIT_ERTXTH) ; Early threshold
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
DEBUGF 1, "Packet Sent!\n"
|
DEBUGF 1, "Packet Sent!\n"
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret 8
|
popf
|
||||||
|
ret
|
||||||
|
|
||||||
.wait_to_send:
|
.wait_to_send:
|
||||||
DEBUGF 1, "Waiting for timeout\n"
|
DEBUGF 1, "Waiting for timeout\n"
|
||||||
|
|
||||||
push edx
|
push edx
|
||||||
mov esi, 30
|
mov esi, 30
|
||||||
stdcall Sleep
|
invoke Sleep
|
||||||
pop edx
|
pop edx
|
||||||
|
|
||||||
in ax, dx
|
in ax, dx
|
||||||
@ -719,9 +710,12 @@ transmit:
|
|||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
DEBUGF 2, "transmit failed!\n"
|
DEBUGF 2, "transmit failed!\n"
|
||||||
stdcall KernelFree, [esp+4]
|
invoke KernelFree, [bufferptr]
|
||||||
|
popf
|
||||||
or eax, -1
|
or eax, -1
|
||||||
ret 8
|
ret
|
||||||
|
|
||||||
|
endp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -748,8 +742,8 @@ int_handler:
|
|||||||
.nextdevice:
|
.nextdevice:
|
||||||
mov ebx, [esi]
|
mov ebx, [esi]
|
||||||
|
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_ISR
|
set_io [ebx + device.io_addr], REG_ISR
|
||||||
in ax, dx ; Get interrupt status
|
in ax, dx ; Get interrupt status
|
||||||
out dx, ax ; send it back to ACK
|
out dx, ax ; send it back to ACK
|
||||||
test ax, ax
|
test ax, ax
|
||||||
@ -776,16 +770,16 @@ int_handler:
|
|||||||
push ax
|
push ax
|
||||||
|
|
||||||
.receive:
|
.receive:
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_COMMAND
|
set_io [ebx + device.io_addr], REG_COMMAND
|
||||||
in al, dx
|
in al, dx
|
||||||
test al, BUFE ; test if RX buffer is empty
|
test al, BUFE ; test if RX buffer is empty
|
||||||
jnz .finish
|
jnz .finish
|
||||||
|
|
||||||
DEBUGF 1, "RX:\n"
|
DEBUGF 1, "RX:\n"
|
||||||
|
|
||||||
mov eax, [device.rx_buffer]
|
mov eax, [ebx + device.rx_buffer]
|
||||||
add eax, [device.rx_data_offset]
|
add eax, [ebx + device.rx_data_offset]
|
||||||
test byte [eax], (1 shl BIT_ROK) ; check if packet is ok
|
test byte [eax], (1 shl BIT_ROK) ; check if packet is ok
|
||||||
jz .reset_rx
|
jz .reset_rx
|
||||||
|
|
||||||
@ -794,14 +788,14 @@ int_handler:
|
|||||||
sub cx, 4 ; don't copy CRC
|
sub cx, 4 ; don't copy CRC
|
||||||
|
|
||||||
; Update stats
|
; Update stats
|
||||||
add dword [device.bytes_rx], ecx
|
add dword [ebx + device.bytes_rx], ecx
|
||||||
adc dword [device.bytes_rx + 4], 0
|
adc dword [ebx + device.bytes_rx + 4], 0
|
||||||
inc [device.packets_rx]
|
inc [ebx + device.packets_rx]
|
||||||
|
|
||||||
DEBUGF 1, "Received %u bytes\n", ecx
|
DEBUGF 1, "Received %u bytes\n", ecx
|
||||||
|
|
||||||
push ebx eax ecx
|
push ebx eax ecx
|
||||||
stdcall KernelAlloc, ecx ; Allocate a buffer to put packet into
|
invoke KernelAlloc, ecx ; Allocate a buffer to put packet into
|
||||||
pop ecx
|
pop ecx
|
||||||
test eax, eax ; Test if we allocated succesfully
|
test eax, eax ; Test if we allocated succesfully
|
||||||
jz .abort
|
jz .abort
|
||||||
@ -827,13 +821,13 @@ int_handler:
|
|||||||
rep movsd
|
rep movsd
|
||||||
.nd:
|
.nd:
|
||||||
|
|
||||||
jmp Eth_input ; Send it to kernel
|
jmp [Eth_input] ; Send it to kernel
|
||||||
|
|
||||||
.abort:
|
.abort:
|
||||||
pop eax ebx
|
pop eax ebx
|
||||||
; update eth_data_start_offset
|
; update eth_data_start_offset
|
||||||
movzx eax, word [eax+2] ; packet length
|
movzx eax, word [eax+2] ; packet length
|
||||||
add eax, [device.rx_data_offset]
|
add eax, [ebx + device.rx_data_offset]
|
||||||
add eax, 4+3 ; packet header is 4 bytes long + dword alignment
|
add eax, 4+3 ; packet header is 4 bytes long + dword alignment
|
||||||
and eax, not 3 ; dword alignment
|
and eax, not 3 ; dword alignment
|
||||||
|
|
||||||
@ -842,11 +836,11 @@ int_handler:
|
|||||||
DEBUGF 1, "Wrapping\n"
|
DEBUGF 1, "Wrapping\n"
|
||||||
sub eax, RX_BUFFER_SIZE
|
sub eax, RX_BUFFER_SIZE
|
||||||
.no_wrap:
|
.no_wrap:
|
||||||
mov [device.rx_data_offset], eax
|
mov [ebx + device.rx_data_offset], eax
|
||||||
DEBUGF 1, "New RX ptr: %d\n", eax
|
DEBUGF 1, "New RX ptr: %d\n", eax
|
||||||
|
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_CAPR ; update 'Current Address of Packet Read register'
|
set_io [ebx + device.io_addr], REG_CAPR ; update 'Current Address of Packet Read register'
|
||||||
sub eax, 0x10 ; value 0x10 is a constant for CAPR
|
sub eax, 0x10 ; value 0x10 is a constant for CAPR
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
@ -889,15 +883,15 @@ int_handler:
|
|||||||
push ax
|
push ax
|
||||||
mov ecx, (NUM_TX_DESC-1)*4
|
mov ecx, (NUM_TX_DESC-1)*4
|
||||||
.txdescloop:
|
.txdescloop:
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_TSD0
|
set_io [ebx + device.io_addr], REG_TSD0
|
||||||
add edx, ecx
|
add edx, ecx
|
||||||
in eax, dx
|
in eax, dx
|
||||||
|
|
||||||
test eax, TSR_OWN ; DMA operation completed
|
test eax, TSR_OWN ; DMA operation completed
|
||||||
jz .notthisone
|
jz .notthisone
|
||||||
|
|
||||||
cmp [device.TX_DESC+ecx], 0
|
cmp [ebx + device.TX_DESC+ecx], 0
|
||||||
je .notthisone
|
je .notthisone
|
||||||
|
|
||||||
DEBUGF 1, "TSD: 0x%x\n", eax
|
DEBUGF 1, "TSD: 0x%x\n", eax
|
||||||
@ -927,11 +921,11 @@ int_handler:
|
|||||||
DEBUGF 1, "TX: Transmit OK!\n"
|
DEBUGF 1, "TX: Transmit OK!\n"
|
||||||
|
|
||||||
.no_tok:
|
.no_tok:
|
||||||
DEBUGF 1, "free transmit buffer 0x%x\n", [device.TX_DESC+ecx]:8
|
DEBUGF 1, "free transmit buffer 0x%x\n", [ebx + device.TX_DESC+ecx]:8
|
||||||
push ecx ebx
|
push ecx ebx
|
||||||
stdcall KernelFree, [device.TX_DESC+ecx]
|
invoke KernelFree, [ebx + device.TX_DESC+ecx]
|
||||||
pop ebx ecx
|
pop ebx ecx
|
||||||
mov [device.TX_DESC+ecx], 0
|
mov [ebx + device.TX_DESC+ecx], 0
|
||||||
|
|
||||||
.notthisone:
|
.notthisone:
|
||||||
sub ecx, 4
|
sub ecx, 4
|
||||||
@ -947,8 +941,8 @@ int_handler:
|
|||||||
push ax
|
push ax
|
||||||
DEBUGF 2, "RX:buffer overflow!\n"
|
DEBUGF 2, "RX:buffer overflow!\n"
|
||||||
|
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_ISR
|
set_io [ebx + device.io_addr], REG_ISR
|
||||||
mov ax, ISR_FIFOOVW or ISR_RXOVW
|
mov ax, ISR_FIFOOVW or ISR_RXOVW
|
||||||
out dx, ax
|
out dx, ax
|
||||||
pop ax
|
pop ax
|
||||||
@ -972,8 +966,8 @@ int_handler:
|
|||||||
push ax
|
push ax
|
||||||
DEBUGF 2, "RX fifo overflow!\n"
|
DEBUGF 2, "RX fifo overflow!\n"
|
||||||
|
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_ISR
|
set_io [ebx + device.io_addr], REG_ISR
|
||||||
mov ax, ISR_FIFOOVW or ISR_RXOVW
|
mov ax, ISR_FIFOOVW or ISR_RXOVW
|
||||||
out dx, ax
|
out dx, ax
|
||||||
pop ax
|
pop ax
|
||||||
@ -1008,8 +1002,8 @@ align 4
|
|||||||
cable:
|
cable:
|
||||||
DEBUGF 1, "Checking link status:\n"
|
DEBUGF 1, "Checking link status:\n"
|
||||||
|
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_MSR
|
set_io [ebx + device.io_addr], REG_MSR
|
||||||
in al, dx
|
in al, dx
|
||||||
|
|
||||||
test al, 1 shl 2 ; 0 = link ok 1 = link fail
|
test al, 1 shl 2 ; 0 = link ok 1 = link fail
|
||||||
@ -1019,22 +1013,22 @@ cable:
|
|||||||
jnz .10mbps
|
jnz .10mbps
|
||||||
|
|
||||||
.100mbps:
|
.100mbps:
|
||||||
mov [device.state], ETH_LINK_100M
|
mov [ebx + device.state], ETH_LINK_100M
|
||||||
call NetLinkChanged
|
invoke NetLinkChanged
|
||||||
DEBUGF 2, "link changed to 100 mbit\n"
|
DEBUGF 2, "link changed to 100 mbit\n"
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.10mbps:
|
.10mbps:
|
||||||
mov [device.state], ETH_LINK_10M
|
mov [ebx + device.state], ETH_LINK_10M
|
||||||
call NetLinkChanged
|
invoke NetLinkChanged
|
||||||
DEBUGF 2, "link changed to 10 mbit\n"
|
DEBUGF 2, "link changed to 10 mbit\n"
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.notconnected:
|
.notconnected:
|
||||||
mov [device.state], ETH_LINK_DOWN
|
mov [ebx + device.state], ETH_LINK_DOWN
|
||||||
call NetLinkChanged
|
invoke NetLinkChanged
|
||||||
DEBUGF 2, "no link\n"
|
DEBUGF 2, "no link\n"
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@ -1053,36 +1047,36 @@ write_mac: ; in: mac pushed onto stack (as 3 words)
|
|||||||
DEBUGF 1, "Writing MAC\n"
|
DEBUGF 1, "Writing MAC\n"
|
||||||
|
|
||||||
; disable all in command registers
|
; disable all in command registers
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
set_io REG_9346CR
|
set_io [ebx + device.io_addr], REG_9346CR
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
set_io REG_IMR
|
set_io [ebx + device.io_addr], REG_IMR
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
set_io REG_ISR
|
set_io [ebx + device.io_addr], REG_ISR
|
||||||
mov eax, -1
|
mov eax, -1
|
||||||
out dx, ax
|
out dx, ax
|
||||||
|
|
||||||
; enable writing
|
; enable writing
|
||||||
set_io REG_9346CR
|
set_io [ebx + device.io_addr], REG_9346CR
|
||||||
mov eax, REG_9346CR_WE
|
mov eax, REG_9346CR_WE
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
; write the mac ...
|
; write the mac ...
|
||||||
set_io REG_IDR0
|
set_io [ebx + device.io_addr], REG_IDR0
|
||||||
pop eax
|
pop eax
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
set_io REG_IDR0+4
|
set_io [ebx + device.io_addr], REG_IDR0+4
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
pop ax
|
pop ax
|
||||||
out dx, eax
|
out dx, eax
|
||||||
|
|
||||||
; disable writing
|
; disable writing
|
||||||
set_io REG_9346CR
|
set_io [ebx + device.io_addr], REG_9346CR
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
out dx, al
|
out dx, al
|
||||||
|
|
||||||
@ -1100,8 +1094,8 @@ write_mac: ; in: mac pushed onto stack (as 3 words)
|
|||||||
read_mac:
|
read_mac:
|
||||||
DEBUGF 1, "Reading MAC:\n"
|
DEBUGF 1, "Reading MAC:\n"
|
||||||
|
|
||||||
set_io 0
|
set_io [ebx + device.io_addr], 0
|
||||||
lea edi, [device.mac]
|
lea edi, [ebx + device.mac]
|
||||||
in eax, dx
|
in eax, dx
|
||||||
stosd
|
stosd
|
||||||
add edx, 4
|
add edx, 4
|
||||||
@ -1115,11 +1109,11 @@ read_mac:
|
|||||||
|
|
||||||
; End of code
|
; End of code
|
||||||
|
|
||||||
section '.data' data readable writable align 16 ; place all uninitialized data place here
|
data fixups
|
||||||
align 4 ; Place all initialised data here
|
end data
|
||||||
|
|
||||||
|
include '../peimport.inc'
|
||||||
|
|
||||||
devices dd 0
|
|
||||||
version dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF)
|
|
||||||
my_service db 'RTL8139',0 ; max 16 chars include zero
|
my_service db 'RTL8139',0 ; max 16 chars include zero
|
||||||
|
|
||||||
device_1 db 'Realtek 8139',0
|
device_1 db 'Realtek 8139',0
|
||||||
@ -1158,5 +1152,7 @@ HW_VER_ARRAY_SIZE = $-hw_ver_array
|
|||||||
|
|
||||||
include_debug_strings ; All data wich FDO uses will be included here
|
include_debug_strings ; All data wich FDO uses will be included here
|
||||||
|
|
||||||
|
align 4
|
||||||
|
devices dd 0
|
||||||
device_list rd MAX_DEVICES ; This list contains all pointers to device structures the driver is handling
|
device_list rd MAX_DEVICES ; This list contains all pointers to device structures the driver is handling
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user