2009-10-26 12:32:59 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2012-08-07 11:03:26 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
|
2009-10-26 12:32:59 +01:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; Ethernet driver for KolibriOS ;;
|
|
|
|
;; This is an adaptation of MenuetOS driver with minimal changes. ;;
|
|
|
|
;; Changes were made by CleverMouse. Original copyright follows. ;;
|
|
|
|
;; ;;
|
|
|
|
;; This driver is based on the SIS900 driver from ;;
|
|
|
|
;; the etherboot 5.0.6 project. The copyright statement is ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;; remaining parts Copyright 2004 Jason Delozier, ;;
|
|
|
|
;; cordata51@hotmail.com ;;
|
|
|
|
;; ;;
|
|
|
|
;; See file COPYING for details ;;
|
|
|
|
;; ;;
|
|
|
|
;; Updates: ;;
|
|
|
|
;; Revision Look up table and SIS635 Mac Address by Jarek Pelczar ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
format MS COFF
|
|
|
|
|
2012-08-07 11:59:58 +02:00
|
|
|
NUM_RX_DESC = 4 ;* Number of RX descriptors *
|
|
|
|
NUM_TX_DESC = 1 ;* Number of TX descriptors *
|
|
|
|
RX_BUFF_SZ = 1520 ;* Buffer size for each Rx buffer *
|
|
|
|
TX_BUFF_SZ = 1516 ;* Buffer size for each Tx buffer *
|
|
|
|
MAX_ETH_FRAME_SIZE = 1516
|
|
|
|
|
2012-07-09 13:31:56 +02:00
|
|
|
API_VERSION = 0x01000100
|
|
|
|
DRIVER_VERSION = 5
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-07-09 13:31:56 +02:00
|
|
|
MAX_DEVICES = 16
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-07-09 13:31:56 +02:00
|
|
|
DEBUG = 1
|
|
|
|
__DEBUG__ = 1
|
|
|
|
__DEBUG_LEVEL__ = 1
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
include 'proc32.inc'
|
|
|
|
include 'imports.inc'
|
|
|
|
include 'fdo.inc'
|
2010-07-12 01:13:12 +02:00
|
|
|
include 'netdrv.inc'
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
public START
|
|
|
|
public version
|
|
|
|
|
2010-07-15 20:54:19 +02:00
|
|
|
virtual at ebx
|
2012-02-23 22:18:16 +01:00
|
|
|
device:
|
2010-07-12 01:13:12 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ETH_DEVICE
|
2010-07-12 01:13:12 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
.io_addr dd ?
|
|
|
|
.pci_bus db ?
|
|
|
|
.pci_dev db ?
|
|
|
|
.irq_line db ?
|
|
|
|
.cur_rx db ?
|
|
|
|
.cur_tx db ?
|
|
|
|
.last_tx db ?
|
|
|
|
.pci_revision db ?
|
|
|
|
.table_entries db ?
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
dw ? ; align 4
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
.special_func dd ?
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
.txd rd (4 * NUM_TX_DESC)
|
|
|
|
.rxd rd (4 * NUM_RX_DESC)
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
.size = $ - device
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
end virtual
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
macro ee_delay {
|
|
|
|
push eax
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
in eax, dx
|
|
|
|
pop eax
|
2010-07-15 20:54:19 +02:00
|
|
|
}
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
section '.flat' code readable align 16
|
|
|
|
|
|
|
|
; Driver entry point - register our service when the driver is loading.
|
|
|
|
; TODO: add needed operations when unloading
|
|
|
|
START:
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp dword [esp+4], 1
|
|
|
|
jne .exit
|
|
|
|
stdcall RegService, my_service, service_proc
|
|
|
|
ret 4
|
2012-08-07 11:03:26 +02:00
|
|
|
.exit:
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret 4
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
; Service procedure for the driver - handle all I/O requests for the driver.
|
|
|
|
; Currently handled requests are: SRV_GETVERSION = 0 and SRV_HOOK = 1.
|
|
|
|
service_proc:
|
|
|
|
; 1. Get parameter from the stack: [esp+4] is the first parameter,
|
2009-11-08 19:00:01 +01:00
|
|
|
; pointer to IOCTL structure.
|
2012-02-23 22:18:16 +01:00
|
|
|
mov edx, [esp+4] ; edx -> IOCTL
|
2009-10-26 12:32:59 +01:00
|
|
|
; 2. Get request code and select a handler for the code.
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [IOCTL.io_code]
|
|
|
|
test eax, eax ; check for SRV_GETVERSION
|
|
|
|
jnz @f
|
2009-10-26 12:32:59 +01:00
|
|
|
; 3. This is SRV_GETVERSION request, no input, 4 bytes output, API_VERSION.
|
|
|
|
; 3a. Output size must be at least 4 bytes.
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [IOCTL.out_size], 4
|
|
|
|
jl .fail
|
2009-10-26 12:32:59 +01:00
|
|
|
; 3b. Write result to the output buffer.
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [IOCTL.output]
|
|
|
|
mov [eax], dword API_VERSION
|
2009-10-26 12:32:59 +01:00
|
|
|
; 3c. Return success.
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret 4
|
2012-08-07 11:03:26 +02:00
|
|
|
@@:
|
2012-02-23 22:18:16 +01:00
|
|
|
dec eax ; check for SRV_HOOK
|
|
|
|
jnz .fail
|
2009-10-26 12:32:59 +01:00
|
|
|
; 4. This is SRV_HOOK request, input defines the device to hook, no output.
|
|
|
|
; 4a. The driver works only with PCI devices,
|
2009-11-08 19:00:01 +01:00
|
|
|
; so input must be at least 3 bytes long.
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [IOCTL.inp_size], 3
|
|
|
|
jl .fail
|
2009-10-26 12:32:59 +01:00
|
|
|
; 4b. First byte of input is bus type, 1 stands for PCI.
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [IOCTL.input]
|
|
|
|
cmp byte [eax], 1
|
|
|
|
jne .fail
|
2009-10-26 12:32:59 +01:00
|
|
|
; 4c. Second and third bytes of the input define the device: bus and dev.
|
2009-11-08 19:00:01 +01:00
|
|
|
; Word in bx holds both bytes.
|
2012-02-23 22:18:16 +01:00
|
|
|
mov bx, [eax+1]
|
2009-10-26 12:32:59 +01:00
|
|
|
; 4d. Check if the device was already hooked,
|
2009-11-08 19:00:01 +01:00
|
|
|
; scan through the list of known devices.
|
2010-07-15 20:54:19 +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
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; mov eax, [IOCTL.input] ; get the pci bus and device numbers
|
2012-08-07 11:59:58 +02:00
|
|
|
mov ax, [eax+1] ;
|
2009-10-26 12:32:59 +01:00
|
|
|
.nextdevice:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ebx, [esi]
|
2012-08-07 11:59:58 +02: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-10-26 12:32:59 +01:00
|
|
|
; 4e. This device doesn't have its own eth_device structure yet, let's create one
|
|
|
|
.firstdevice:
|
|
|
|
; 4f. Check that we have place for new device.
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp [devices], MAX_DEVICES
|
|
|
|
jge .fail
|
2009-10-26 12:32:59 +01:00
|
|
|
; 4g. Allocate memory for device descriptor and receive+transmit buffers.
|
|
|
|
; 4h. Zero the structure.
|
2012-08-07 11:03:26 +02:00
|
|
|
allocate_and_clear ebx, device.size, .fail
|
2010-07-15 20:54:19 +02:00
|
|
|
; 4i. Save PCI coordinates
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [IOCTL.input]
|
2012-08-07 11:59:58 +02:00
|
|
|
mov cl, [eax+1]
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.pci_bus], cl
|
2012-08-07 11:59:58 +02:00
|
|
|
mov cl, [eax+2]
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.pci_dev], cl
|
2009-10-26 12:32:59 +01:00
|
|
|
; 4j. Fill in the direct call addresses into the struct.
|
2010-07-15 20:54:19 +02:00
|
|
|
; Note that get_MAC pointer is filled in initialization by probe.
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.reset], init
|
|
|
|
mov [device.transmit], transmit
|
2010-07-15 20:54:19 +02:00
|
|
|
; mov [device.get_MAC], read_mac
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.set_MAC], write_mac
|
|
|
|
mov [device.unload], unload
|
|
|
|
mov [device.name], my_service
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
; 4k. Now, it's time to find the base io addres of the PCI device
|
|
|
|
; TODO: implement check if bus and dev exist on this machine
|
|
|
|
|
2010-07-15 20:54:19 +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-07-15 20:54:19 +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-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
; 4m. Add new device to the list (required for int_handler).
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [devices]
|
|
|
|
mov [device_list+4*eax], ebx
|
|
|
|
inc [devices]
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
; 4m. Ok, the eth_device structure is ready, let's probe the device
|
2012-02-23 22:18:16 +01:00
|
|
|
call probe
|
|
|
|
test eax, eax
|
|
|
|
jnz .destroy
|
2009-10-26 12:32:59 +01:00
|
|
|
; 4n. If device was successfully initialized, register it for the kernel.
|
|
|
|
|
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
|
|
|
|
je .destroy
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret 4
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
; 5. 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
|
|
|
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
|
|
|
|
ret 4
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
; If an error occured, remove all allocated data and exit (returning -1 in eax)
|
|
|
|
|
|
|
|
.destroy:
|
2012-02-23 22:18:16 +01:00
|
|
|
dec [devices]
|
|
|
|
; todo: reset device into virgin state
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
.err:
|
2012-02-23 22:18:16 +01:00
|
|
|
stdcall KernelFree, ebx
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
.fail:
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret 4
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
|
|
|
|
;; ;;
|
|
|
|
;; Actual Hardware dependent code starts here ;;
|
|
|
|
;; ;;
|
|
|
|
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
|
|
|
|
|
|
|
|
unload:
|
2012-02-23 22:18:16 +01:00
|
|
|
; TODO: (in this particular order)
|
|
|
|
;
|
|
|
|
; - Stop the device
|
|
|
|
; - Detach int handler
|
|
|
|
; - Remove device from local list
|
|
|
|
; - call unregister function in kernel
|
|
|
|
; - Remove all allocated structures and buffers the card used
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax,-1
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
;********************************************************************
|
|
|
|
; Comments:
|
|
|
|
; Known to work with the following SIS900 ethernet cards:
|
|
|
|
; - Device ID: 0x0900 Vendor ID: 0x1039 Revision: 0x91
|
|
|
|
; - Device ID: 0x0900 Vendor ID: 0x1039 Revision: 0x90
|
|
|
|
;
|
|
|
|
; If your card is not listed, try it and let me know if it
|
|
|
|
; functions properly and it will be aded to the list. If not
|
|
|
|
; we may be able to add support for it.
|
|
|
|
;
|
|
|
|
; ToDo:
|
|
|
|
; - Enable MII interface for reading speed
|
|
|
|
; and duplex settings.
|
2010-07-15 20:54:19 +02:00
|
|
|
; - Update receive routine to support packet fragmentation.
|
2009-10-26 12:32:59 +01:00
|
|
|
; - Add additional support for other sis900 based cards
|
|
|
|
;
|
|
|
|
;********************************************************************
|
|
|
|
|
2012-07-09 13:31:56 +02:00
|
|
|
ETH_ALEN = 6 ; Size of Ethernet address
|
|
|
|
ETH_HLEN = 14 ; Size of ethernet header
|
|
|
|
ETH_ZLEN = 60 ; Minimum packet length
|
|
|
|
DSIZE = 0x00000fff
|
|
|
|
CRC_SIZE = 4
|
|
|
|
RFADDR_shift = 16
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Symbolic offsets to registers.
|
2012-07-09 13:31:56 +02:00
|
|
|
cr = 0x0 ; Command Register
|
|
|
|
cfg = 0x4 ; Configuration Register
|
|
|
|
mear = 0x8 ; EEPROM Access Register
|
|
|
|
ptscr = 0xc ; PCI Test Control Register
|
|
|
|
isr = 0x10 ; Interrupt Status Register
|
|
|
|
imr = 0x14 ; Interrupt Mask Register
|
|
|
|
ier = 0x18 ; Interrupt Enable Register
|
|
|
|
epar = 0x18 ; Enhanced PHY Access Register
|
|
|
|
txdp = 0x20 ; Transmit Descriptor Pointer Register
|
|
|
|
txcfg = 0x24 ; Transmit Configuration Register
|
|
|
|
rxdp = 0x30 ; Receive Descriptor Pointer Register
|
|
|
|
rxcfg = 0x34 ; Receive Configuration Register
|
|
|
|
flctrl = 0x38 ; Flow Control Register
|
|
|
|
rxlen = 0x3c ; Receive Packet Length Register
|
|
|
|
rfcr = 0x48 ; Receive Filter Control Register
|
|
|
|
rfdr = 0x4C ; Receive Filter Data Register
|
|
|
|
pmctrl = 0xB0 ; Power Management Control Register
|
|
|
|
pmer = 0xB4 ; Power Management Wake-up Event Register
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Command Register Bits
|
2012-07-09 13:31:56 +02:00
|
|
|
RELOAD = 0x00000400
|
|
|
|
ACCESSMODE = 0x00000200
|
|
|
|
RESET = 0x00000100
|
|
|
|
SWI = 0x00000080
|
|
|
|
RxRESET = 0x00000020
|
|
|
|
TxRESET = 0x00000010
|
|
|
|
RxDIS = 0x00000008
|
|
|
|
RxENA = 0x00000004
|
|
|
|
TxDIS = 0x00000002
|
|
|
|
TxENA = 0x00000001
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Configuration Register Bits
|
2012-07-09 13:31:56 +02:00
|
|
|
DESCRFMT = 0x00000100 ; 7016 specific
|
|
|
|
REQALG = 0x00000080
|
|
|
|
SB = 0x00000040
|
|
|
|
POW = 0x00000020
|
|
|
|
EXD = 0x00000010
|
|
|
|
PESEL = 0x00000008
|
|
|
|
LPM = 0x00000004
|
|
|
|
BEM = 0x00000001
|
|
|
|
RND_CNT = 0x00000400
|
|
|
|
FAIR_BACKOFF = 0x00000200
|
|
|
|
EDB_MASTER_EN = 0x00002000
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Eeprom Access Reigster Bits
|
2012-07-09 13:31:56 +02:00
|
|
|
MDC = 0x00000040
|
|
|
|
MDDIR = 0x00000020
|
|
|
|
MDIO = 0x00000010 ; 7016 specific
|
|
|
|
EECS = 0x00000008
|
|
|
|
EECLK = 0x00000004
|
|
|
|
EEDO = 0x00000002
|
|
|
|
EEDI = 0x00000001
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; TX Configuration Register Bits
|
2012-07-09 13:31:56 +02:00
|
|
|
ATP = 0x10000000 ;Automatic Transmit Padding
|
|
|
|
MLB = 0x20000000 ;Mac Loopback Enable
|
|
|
|
HBI = 0x40000000 ;HeartBeat Ignore (Req for full-dup)
|
|
|
|
CSI = 0x80000000 ;CarrierSenseIgnore (Req for full-du
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; RX Configuration Register Bits
|
2012-07-09 13:31:56 +02:00
|
|
|
AJAB = 0x08000000 ;
|
|
|
|
ATX = 0x10000000 ;Accept Transmit Packets
|
|
|
|
ARP = 0x40000000 ;accept runt packets (<64bytes)
|
|
|
|
AEP = 0x80000000 ;accept error packets
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Interrupt Reigster Bits
|
2012-07-09 13:31:56 +02:00
|
|
|
WKEVT = 0x10000000
|
|
|
|
TxPAUSEEND = 0x08000000
|
|
|
|
TxPAUSE = 0x04000000
|
|
|
|
TxRCMP = 0x02000000
|
|
|
|
RxRCMP = 0x01000000
|
|
|
|
DPERR = 0x00800000
|
|
|
|
SSERR = 0x00400000
|
|
|
|
RMABT = 0x00200000
|
|
|
|
RTABT = 0x00100000
|
|
|
|
RxSOVR = 0x00010000
|
|
|
|
HIBERR = 0x00008000
|
|
|
|
SWINT = 0x00001000
|
|
|
|
MIBINT = 0x00000800
|
|
|
|
TxURN = 0x00000400
|
|
|
|
TxIDLE = 0x00000200
|
|
|
|
TxERR = 0x00000100
|
|
|
|
TxDESC = 0x00000080
|
|
|
|
TxOK = 0x00000040
|
|
|
|
RxORN = 0x00000020
|
|
|
|
RxIDLE = 0x00000010
|
|
|
|
RxEARLY = 0x00000008
|
|
|
|
RxERR = 0x00000004
|
|
|
|
RxDESC = 0x00000002
|
|
|
|
RxOK = 0x00000001
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Interrupt Enable Register Bits
|
2012-07-09 13:31:56 +02:00
|
|
|
IE = RxOK + TxOK
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Revision ID
|
2012-07-09 13:31:56 +02:00
|
|
|
SIS900B_900_REV = 0x03
|
|
|
|
SIS630A_900_REV = 0x80
|
|
|
|
SIS630E_900_REV = 0x81
|
|
|
|
SIS630S_900_REV = 0x82
|
|
|
|
SIS630EA1_900_REV = 0x83
|
|
|
|
SIS630ET_900_REV = 0x84
|
|
|
|
SIS635A_900_REV = 0x90
|
|
|
|
SIS900_960_REV = 0x91
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Receive Filter Control Register Bits
|
2012-07-09 13:31:56 +02:00
|
|
|
RFEN = 0x80000000
|
|
|
|
RFAAB = 0x40000000
|
|
|
|
RFAAM = 0x20000000
|
|
|
|
RFAAP = 0x10000000
|
|
|
|
RFPromiscuous = 0x70000000
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Reveive Filter Data Mask
|
2012-07-09 13:31:56 +02:00
|
|
|
RFDAT = 0x0000FFFF
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Eeprom Address
|
2012-07-09 13:31:56 +02:00
|
|
|
EEPROMSignature = 0x00
|
|
|
|
EEPROMVendorID = 0x02
|
|
|
|
EEPROMDeviceID = 0x03
|
|
|
|
EEPROMMACAddr = 0x08
|
|
|
|
EEPROMChecksum = 0x0b
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
;The EEPROM commands include the alway-set leading bit.
|
2012-07-09 13:31:56 +02:00
|
|
|
EEread = 0x0180
|
|
|
|
EEwrite = 0x0140
|
|
|
|
EEerase = 0x01C0
|
|
|
|
EEwriteEnable = 0x0130
|
|
|
|
EEwriteDisable = 0x0100
|
|
|
|
EEeraseAll = 0x0120
|
|
|
|
EEwriteAll = 0x0110
|
|
|
|
EEaddrMask = 0x013F
|
|
|
|
EEcmdShift = 16
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
;For SiS962 or SiS963, request the eeprom software access
|
2012-07-09 13:31:56 +02:00
|
|
|
EEREQ = 0x00000400
|
|
|
|
EEDONE = 0x00000200
|
|
|
|
EEGNT = 0x00000100
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
;
|
|
|
|
; probe
|
|
|
|
;
|
|
|
|
; Searches for an ethernet card, enables it and clears the rx buffer
|
|
|
|
;
|
|
|
|
; TODO: probe mii transceivers
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
probe:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "Probe\n"
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx eax, [device.pci_bus]
|
|
|
|
movzx edx, [device.pci_dev]
|
|
|
|
stdcall PciWrite8, eax, edx, 0x40, 0 ; Wake Up Chip
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
make_bus_master [device.pci_bus], [device.pci_dev]
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Get Card Revision
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx eax, [device.pci_bus]
|
|
|
|
movzx edx, [device.pci_dev]
|
|
|
|
stdcall PciRead8, eax, edx, 0x08
|
|
|
|
mov [device.pci_revision], al ; save the revision for later use
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Look up through the specific_table
|
2012-02-23 22:18:16 +01:00
|
|
|
mov esi, specific_table
|
2010-07-15 20:54:19 +02:00
|
|
|
.loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp dword [esi], 0 ; Check if we reached end of the list
|
|
|
|
je .error
|
|
|
|
cmp al, [esi] ; Check if revision is OK
|
|
|
|
je .ok
|
|
|
|
add esi, 12 ; Advance to next entry
|
|
|
|
jmp .loop
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.error:
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1, "Device not supported!\n"
|
|
|
|
or eax, -1
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Find Get Mac Function
|
|
|
|
.ok:
|
2012-08-07 11:59:58 +02:00
|
|
|
mov eax, [esi + 4] ; Get pointer to "get MAC" function
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.get_MAC], eax
|
2012-08-07 11:59:58 +02:00
|
|
|
mov eax, [esi + 8] ; Get pointer to special initialization fn
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.special_func], eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Get MAC
|
2012-02-23 22:18:16 +01:00
|
|
|
call [device.get_MAC]
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Call special initialization fn if requested
|
|
|
|
|
2012-08-07 11:59:58 +02:00
|
|
|
cmp [device.special_func], 0
|
2012-02-23 22:18:16 +01:00
|
|
|
je @f
|
|
|
|
call [device.special_func]
|
2010-07-15 20:54:19 +02:00
|
|
|
@@:
|
|
|
|
|
|
|
|
; Set table entries
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.table_entries], 16
|
|
|
|
cmp [device.pci_revision], SIS635A_900_REV
|
|
|
|
jae @f
|
|
|
|
cmp [device.pci_revision], SIS900B_900_REV
|
|
|
|
je @f
|
|
|
|
mov [device.table_entries], 8
|
2010-07-15 20:54:19 +02:00
|
|
|
@@:
|
|
|
|
|
|
|
|
; TODO: Probe for mii transceiver
|
|
|
|
|
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; init
|
2009-10-26 12:32:59 +01:00
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; resets the ethernet controller chip and various
|
|
|
|
; data structures required for sending and receiving packets.
|
2009-10-26 12:32:59 +01:00
|
|
|
;
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
init:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "Init\n"
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-08-07 11:59:58 +02:00
|
|
|
call reset
|
|
|
|
jnz .ret
|
|
|
|
call init_rxfilter
|
|
|
|
call init_txd
|
|
|
|
call init_rxd
|
|
|
|
call set_rx_mode
|
|
|
|
call set_tx_mode
|
|
|
|
;call check_mode
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
; enable interrupts on packet receive
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
inc eax ; eax = 1 = RxOK
|
|
|
|
set_io 0
|
|
|
|
set_io imr
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
; globally enable interrupts
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io ier
|
|
|
|
out dx, eax ; eax is still 1
|
|
|
|
xor eax, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.mtu], 1514
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-08-07 11:59:58 +02:00
|
|
|
.ret:
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; reset
|
|
|
|
;
|
|
|
|
; disables interrupts and soft resets the controller chip
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
reset:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "reset\n"
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx eax, [device.irq_line]
|
|
|
|
stdcall AttachIntHandler, eax, int_handler, 0
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;--------------------------------------------
|
|
|
|
; Disable Interrupts and reset Receive Filter
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io ier
|
|
|
|
xor eax, eax
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io imr
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io rfcr
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-----------
|
|
|
|
; Reset Card
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io cr
|
|
|
|
in eax, dx ; Get current Command Register
|
|
|
|
or eax, RESET + RxRESET + TxRESET ; set flags
|
|
|
|
out dx, eax ; Write new Command Register
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;----------
|
|
|
|
; Wait loop
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io isr
|
|
|
|
mov ecx, 1000
|
2010-07-15 20:54:19 +02:00
|
|
|
.loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
dec ecx
|
|
|
|
jz .error
|
|
|
|
in eax, dx ; move interrup status to eax
|
2012-08-07 11:59:58 +02:00
|
|
|
test eax, 0x03000000 ; CHECKME
|
|
|
|
jz .loop
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;------------------------------------------------------
|
|
|
|
; Set Configuration Register depending on Card Revision
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io cfg
|
|
|
|
mov eax, PESEL ; Configuration Register Bit
|
|
|
|
cmp [device.pci_revision], SIS635A_900_REV
|
|
|
|
je .match
|
|
|
|
cmp [device.pci_revision], SIS900B_900_REV ; Check card revision
|
|
|
|
je .match
|
|
|
|
out dx, eax ; no revision match
|
|
|
|
jmp .done
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
.match: ; Revision match
|
|
|
|
or eax, RND_CNT ; Configuration Register Bit
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.done:
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.error:
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1, "Reset failed!\n"
|
|
|
|
or eax, -1
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; sis_init_rxfilter
|
2009-10-26 12:32:59 +01:00
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; sets receive filter address to our MAC address
|
2009-10-26 12:32:59 +01:00
|
|
|
;
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
init_rxfilter:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "Init RxFilter\n"
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;------------------------------------
|
|
|
|
; Get Receive Filter Control Register
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io rfcr
|
|
|
|
in eax, dx
|
|
|
|
push eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-----------------------------------------------
|
|
|
|
; disable packet filtering before setting filter
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
and eax, not RFEN
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;--------------------------------------
|
|
|
|
; load MAC addr to filter data register
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor ecx, ecx
|
|
|
|
RXINT_Mac_Write: ; high word of eax tells card which mac byte to write
|
|
|
|
mov eax, ecx
|
|
|
|
set_io 0
|
|
|
|
set_io rfcr
|
|
|
|
shl eax, 16 ;
|
|
|
|
out dx, eax ;
|
|
|
|
set_io rfdr
|
|
|
|
mov ax, word [device.mac+ecx*2] ; Get Mac ID word
|
|
|
|
out dx, ax ; Send Mac ID
|
|
|
|
inc cl ; send next word
|
|
|
|
cmp cl, 3 ; more to send?
|
|
|
|
jne RXINT_Mac_Write
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;------------------------
|
|
|
|
; enable packet filtering
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
pop eax ;old register value
|
|
|
|
set_io rfcr
|
|
|
|
or eax, RFEN ;enable filtering
|
|
|
|
out dx, eax ;set register
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
;
|
|
|
|
; init_txd
|
|
|
|
;
|
|
|
|
; initializes the Tx descriptor
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
init_txd:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "Init TxD\n"
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-------------------------
|
|
|
|
; initialize TX descriptor
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov dword [device.txd], 0 ; put link to next descriptor in link field
|
2012-08-07 11:59:58 +02:00
|
|
|
mov dword [device.txd + 4], 0 ; clear status field
|
|
|
|
mov dword [device.txd + 8], 0 ; ptr to buffer
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;----------------------------------
|
|
|
|
; load Transmit Descriptor Register
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
2012-08-07 11:59:58 +02:00
|
|
|
set_io txdp ; TX Descriptor Pointer
|
2012-02-23 22:18:16 +01:00
|
|
|
lea eax, [device.txd]
|
|
|
|
GetRealAddr
|
2012-08-07 11:59:58 +02:00
|
|
|
out dx, eax ; move the pointer
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
;
|
|
|
|
; init_rxd
|
|
|
|
;
|
|
|
|
; initializes the Rx descriptor ring
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
init_rxd:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "Init RxD\n"
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; init RX descriptors
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ecx, NUM_RX_DESC
|
|
|
|
lea esi, [device.rxd]
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.loop:
|
2012-08-07 11:59:58 +02:00
|
|
|
lea eax, [esi + 16] ; next ptr
|
2012-02-23 22:18:16 +01:00
|
|
|
GetRealAddr
|
2012-08-07 11:59:58 +02:00
|
|
|
mov dword [esi], eax
|
|
|
|
mov dword [esi + 4], RX_BUFF_SZ ; size
|
2012-02-23 22:18:16 +01:00
|
|
|
|
2012-08-07 11:59:58 +02:00
|
|
|
push ecx
|
2012-02-23 22:18:16 +01:00
|
|
|
stdcall KernelAlloc, RX_BUFF_SZ
|
2012-08-07 11:59:58 +02:00
|
|
|
pop ecx
|
2012-02-23 22:18:16 +01:00
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
2012-08-07 11:59:58 +02:00
|
|
|
mov dword [esi + 12], eax ; address
|
2012-02-23 22:18:16 +01:00
|
|
|
GetRealAddr
|
2012-08-07 11:59:58 +02:00
|
|
|
mov dword [esi + 8], eax ; real address
|
2012-02-23 22:18:16 +01:00
|
|
|
add esi, 16
|
2012-08-07 11:59:58 +02:00
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
2012-02-23 22:18:16 +01:00
|
|
|
|
|
|
|
lea eax, [device.rxd]
|
|
|
|
GetRealAddr
|
2012-08-07 11:59:58 +02:00
|
|
|
mov dword [esi - 16], eax ; correct last descriptor link ptr
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; And output ptr to first desc, to device
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io rxdp
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov [device.cur_rx], 0 ; Set curent rx discriptor to 0
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
.fail: ;;; TODO: abort instead!
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
;
|
|
|
|
; set_tx_mode
|
|
|
|
;
|
|
|
|
; sets the transmit mode to allow for full duplex
|
|
|
|
;
|
|
|
|
; If you are having problems transmitting packet try changing the
|
|
|
|
; Max DMA Burst, Possible settings are as follows:
|
|
|
|
;
|
|
|
|
; 0x00000000 = 512 bytes
|
|
|
|
; 0x00100000 = 4 bytes
|
|
|
|
; 0x00200000 = 8 bytes
|
|
|
|
; 0x00300000 = 16 bytes
|
|
|
|
; 0x00400000 = 32 bytes
|
|
|
|
; 0x00500000 = 64 bytes
|
|
|
|
; 0x00600000 = 128 bytes
|
|
|
|
; 0x00700000 = 256 bytes
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
set_tx_mode:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "set TX mode\n"
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io cr
|
|
|
|
in eax, dx ; Get current Command Register
|
|
|
|
or eax, TxENA ; Enable Receive
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io txcfg ; Transmit config Register offset
|
|
|
|
mov eax, ATP + HBI + CSI +0x00600120
|
|
|
|
; allow automatic padding
|
|
|
|
; allow heartbeat ignore
|
|
|
|
; allow carrier sense ignore
|
|
|
|
; Max DMA Burst (128 bytes)
|
|
|
|
; TX Fill Threshold
|
|
|
|
; TX Drain Threshold
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
;
|
|
|
|
; set_rx_mode
|
|
|
|
;
|
|
|
|
; sets the receive mode to accept all broadcast packets and packets
|
|
|
|
; with our MAC address, and reject all multicast packets. Also allows
|
|
|
|
; full-duplex
|
|
|
|
;
|
|
|
|
; If you are having problems receiving packet try changing the
|
|
|
|
; Max DMA Burst, Possible settings are as follows:
|
|
|
|
;
|
|
|
|
; 0x00000000 = 512 bytes
|
|
|
|
; 0x00100000 = 4 bytes
|
|
|
|
; 0x00200000 = 8 bytes
|
|
|
|
; 0x00300000 = 16 bytes
|
|
|
|
; 0x00400000 = 32 bytes
|
|
|
|
; 0x00500000 = 64 bytes
|
|
|
|
; 0x00600000 = 128 bytes
|
|
|
|
; 0x00700000 = 256 bytes
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
set_rx_mode:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "set RX mode\n"
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;----------------------------------------------
|
|
|
|
; update Multicast Hash Table in Receive Filter
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor cl, cl
|
2010-07-15 20:54:19 +02:00
|
|
|
.loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io rfcr ; Receive Filter Control Reg offset
|
|
|
|
mov eax, 4 ; determine table entry
|
|
|
|
add al, cl
|
|
|
|
shl eax, 16
|
|
|
|
out dx, eax ; tell card which entry to modify
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io rfdr ; Receive Filter Control Reg offset
|
|
|
|
mov eax, 0xffff ; entry value
|
|
|
|
out dx, ax ; write value to table in card
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
inc cl ; next entry
|
|
|
|
cmp cl, [device.table_entries]
|
|
|
|
jl .loop
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;------------------------------------
|
|
|
|
; Set Receive Filter Control Register
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io rfcr ; Receive Filter Control Register offset
|
|
|
|
mov eax, RFAAB + RFAAM + RFAAP + RFEN
|
|
|
|
; accecpt all broadcast packets
|
|
|
|
; accept all multicast packets
|
|
|
|
; Accept all packets
|
|
|
|
; enable receiver filter
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
;----------------
|
|
|
|
; Enable Receiver
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io cr
|
|
|
|
in eax, dx ; Get current Command Register
|
|
|
|
or eax, RxENA ; Enable Receive
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-------------------
|
|
|
|
; Configure Receiver
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io rxcfg ; Receive Config Register offset
|
|
|
|
mov eax, ATX + 0x00600002
|
|
|
|
; Accept Transmit Packets
|
|
|
|
; (Req for full-duplex and PMD Loopback)
|
|
|
|
; Max DMA Burst
|
|
|
|
; RX Drain Threshold, 8X8 bytes or 64bytes
|
2012-08-07 11:59:58 +02:00
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
;
|
|
|
|
; SIS960_get_mac_addr: - Get MAC address for SiS962 or SiS963 model
|
|
|
|
;
|
|
|
|
; SiS962 or SiS963 model, use EEPROM to store MAC address.
|
|
|
|
; EEPROM is shared by LAN and 1394.
|
|
|
|
; When access EEPROM, send EEREQ signal to hardware first, and wait for EEGNT.
|
|
|
|
; If EEGNT is ON, EEPROM is permitted to be accessed by LAN, otherwise is not.
|
|
|
|
; After MAC address is read from EEPROM, send
|
|
|
|
; EEDONE signal to refuse EEPROM access by LAN.
|
|
|
|
; The EEPROM map of SiS962 or SiS963 is different to SiS900.
|
|
|
|
; The signature field in SiS962 or SiS963 spec is meaningless.
|
|
|
|
;
|
|
|
|
; Return 0 is EAX = failure
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
2009-10-26 12:32:59 +01:00
|
|
|
SIS960_get_mac_addr:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "SIS960 - get mac: "
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-------------------------------
|
|
|
|
; Send Request for eeprom access
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io mear ; Eeprom access register
|
|
|
|
mov eax, EEREQ ; Request access to eeprom
|
|
|
|
out dx, eax ; Send request
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-----------------------------------------------------
|
|
|
|
; Loop 4000 times and if access not granted, error out
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ecx, 4000
|
2010-07-15 20:54:19 +02:00
|
|
|
.loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
in eax, dx ; get eeprom status
|
|
|
|
test eax, EEGNT ; see if eeprom access granted flag is set
|
|
|
|
jnz .got_access ; if it is, go access the eeprom
|
|
|
|
loop .loop ; else keep waiting
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1, "Access to EEprom failed!\n", 0
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io mear ; Eeprom access register
|
|
|
|
mov eax, EEDONE ; tell eeprom we are done
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax, -1 ; error
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.got_access:
|
|
|
|
|
|
|
|
;------------------------------------------
|
|
|
|
; EEprom access granted, read MAC from card
|
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
; zero based so 3-16 bit reads will take place
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ecx, 2
|
2010-07-15 20:54:19 +02:00
|
|
|
.read_loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, EEPROMMACAddr ; Base Mac Address
|
|
|
|
add eax, ecx ; Current Mac Byte Offset
|
|
|
|
push ecx
|
|
|
|
call read_eeprom ; try to read 16 bits
|
|
|
|
pop ecx
|
|
|
|
mov word [device.mac+ecx*2], ax ; save 16 bits to the MAC ID varible
|
|
|
|
dec ecx ; one less word to read
|
|
|
|
jns .read_loop ; if more read more
|
|
|
|
mov eax, 1 ; return non-zero indicating success
|
|
|
|
|
|
|
|
DEBUGF 2,"%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
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-------------------------------------
|
|
|
|
; Tell EEPROM We are Done Accessing It
|
|
|
|
|
|
|
|
.done:
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io mear ; Eeprom access register
|
|
|
|
mov eax, EEDONE ; tell eeprom we are done
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax ; ok
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
;
|
|
|
|
; get_mac_addr: - Get MAC address for stand alone SiS900 model
|
|
|
|
;
|
|
|
|
; Older SiS900 and friends, use EEPROM to store MAC address.
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
2011-11-08 18:24:46 +01:00
|
|
|
SIS900_get_mac_addr:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "SIS900 - get mac: "
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;------------------------------------
|
|
|
|
; check to see if we have sane EEPROM
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, EEPROMSignature ; Base Eeprom Signature
|
|
|
|
call read_eeprom ; try to read 16 bits
|
|
|
|
cmp ax, 0xffff
|
|
|
|
je .err
|
|
|
|
test ax, ax
|
|
|
|
je .err
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-----------
|
|
|
|
; Read MacID
|
|
|
|
|
|
|
|
; zero based so 3-16 bit reads will take place
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ecx, 2
|
2010-07-15 20:54:19 +02:00
|
|
|
.loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, EEPROMMACAddr ; Base Mac Address
|
|
|
|
add eax, ecx ; Current Mac Byte Offset
|
|
|
|
push ecx
|
|
|
|
call read_eeprom ; try to read 16 bits
|
|
|
|
pop ecx
|
|
|
|
mov word [device.mac+ecx*2], ax ; save 16 bits to the MAC ID storage
|
|
|
|
dec ecx ; one less word to read
|
|
|
|
jns .loop ; if more read more
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 2,"%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
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
.err:
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1, "Access to EEprom failed!\n", 0
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax, -1
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
;
|
|
|
|
; Get_Mac_SIS635_900_REV: - Get MAC address for model 635
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
2009-10-26 12:32:59 +01:00
|
|
|
Get_Mac_SIS635_900_REV:
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "SIS635 - get mac: "
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io rfcr
|
|
|
|
in eax, dx
|
|
|
|
mov edi, eax ; EDI=rfcrSave
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io cr
|
|
|
|
or eax, RELOAD
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-----------------------------------------------
|
|
|
|
; Disable packet filtering before setting filter
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io rfcr
|
|
|
|
mov eax, edi
|
|
|
|
and edi, not RFEN
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;---------------------------------
|
|
|
|
; Load MAC to filter data register
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ecx, 3
|
|
|
|
lea edi, [device.mac]
|
2010-07-15 20:54:19 +02:00
|
|
|
.loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io rfcr
|
|
|
|
mov eax, ecx
|
|
|
|
shl eax, RFADDR_shift
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io rfdr
|
|
|
|
in eax, dx
|
|
|
|
stosw
|
|
|
|
loop .loop
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;------------------------
|
|
|
|
; Enable packet filtering
|
|
|
|
|
|
|
|
; set_io rfcr
|
|
|
|
; mov eax, edi
|
|
|
|
; or eax, RFEN
|
|
|
|
; out dx, eax
|
|
|
|
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 2,"%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
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; read_eeprom
|
2009-10-26 12:32:59 +01:00
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; reads and returns a given location from EEPROM
|
2009-10-26 12:32:59 +01:00
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; IN: si = addr
|
|
|
|
; OUT: ax = data
|
2009-10-26 12:32:59 +01:00
|
|
|
;
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
|
|
|
read_eeprom:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io mear
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax ; start send
|
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax, EECLK
|
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;------------------------------------
|
|
|
|
; Send the read command
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
or esi, EEread
|
|
|
|
mov ecx, 1 shl 9
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.loop:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, EECS
|
|
|
|
test esi, ecx
|
|
|
|
jz @f
|
|
|
|
or eax, EEDI
|
2010-07-15 20:54:19 +02:00
|
|
|
@@:
|
2012-02-23 22:18:16 +01:00
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
or eax, EECLK
|
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
shr esi, 1
|
|
|
|
jnc .loop
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, EECS
|
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;------------------------
|
|
|
|
; Read 16-bits of data in
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor esi, esi
|
|
|
|
mov cx, 16
|
2010-07-15 20:54:19 +02:00
|
|
|
.loop2:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, EECS
|
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
|
|
|
|
|
|
|
or eax, EECLK
|
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
|
|
|
|
|
|
|
in eax, dx
|
|
|
|
shl esi, 1
|
|
|
|
test eax, EEDO
|
|
|
|
jz @f
|
|
|
|
inc esi
|
2010-07-15 20:54:19 +02:00
|
|
|
@@:
|
2012-02-23 22:18:16 +01:00
|
|
|
loop .loop2
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;----------------------------
|
|
|
|
; Terminate the EEPROM access
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, EECLK
|
|
|
|
out dx, eax
|
|
|
|
ee_delay
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx eax, si
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
align 4
|
2009-10-26 12:32:59 +01:00
|
|
|
write_mac:
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1,'Setting MAC is not supported for SIS900 card.\n'
|
|
|
|
add esp, 6
|
|
|
|
ret
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
;***************************************************************************
|
|
|
|
;
|
2010-07-15 20:54:19 +02:00
|
|
|
; int_handler
|
|
|
|
;
|
|
|
|
; handles received IRQs, which signal received packets
|
|
|
|
;
|
|
|
|
; Currently only supports one descriptor per packet, if packet is fragmented
|
|
|
|
; between multiple descriptors you will lose part of the packet
|
|
|
|
;
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
2009-10-26 12:32:59 +01:00
|
|
|
int_handler:
|
2012-08-07 11:59:58 +02:00
|
|
|
DEBUGF 1, "Int!\n"
|
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
; find pointer of device which made IRQ occur
|
2012-02-23 22:18:16 +01:00
|
|
|
mov esi, device_list
|
|
|
|
mov ecx, [devices]
|
|
|
|
test ecx, ecx
|
|
|
|
jz .nothing
|
2009-10-26 12:32:59 +01:00
|
|
|
.nextdevice:
|
2012-02-23 22:18:16 +01:00
|
|
|
mov ebx, [esi]
|
|
|
|
set_io 0
|
|
|
|
set_io isr
|
|
|
|
in eax, dx ; note that this clears all interrupts
|
|
|
|
test ax, IE
|
|
|
|
jnz .got_it
|
|
|
|
loop .nextdevice
|
2009-10-26 12:32:59 +01:00
|
|
|
.nothing:
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2009-10-26 12:32:59 +01:00
|
|
|
.got_it:
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
test ax, RxOK
|
|
|
|
jz .no_rx
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
push ax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-----------
|
|
|
|
; Get Status
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx eax, [device.cur_rx] ; find current discriptor
|
|
|
|
shl eax, 4 ; * 16
|
|
|
|
mov ecx, dword[device.rxd+eax+4] ; get receive status
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;-------------------------------------------
|
|
|
|
; Check RX_Status to see if packet is waiting
|
2012-02-23 22:18:16 +01:00
|
|
|
test ecx, 0x80000000
|
|
|
|
jnz .is_packet
|
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;----------------------------------------------
|
|
|
|
; There is a packet waiting check it for errors
|
|
|
|
.is_packet:
|
2012-02-23 22:18:16 +01:00
|
|
|
test ecx, 0x67C0000 ; see if there are any errors
|
|
|
|
jnz .error_status
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;---------------------
|
|
|
|
; Check size of packet
|
2012-02-23 22:18:16 +01:00
|
|
|
and ecx, DSIZE ; get packet size minus CRC
|
|
|
|
sub ecx, CRC_SIZE ; make sure packet contains data
|
|
|
|
jle .error_size
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; update statistics
|
2012-02-23 22:18:16 +01:00
|
|
|
inc dword [device.packets_rx]
|
|
|
|
add dword [device.bytes_rx], ecx
|
|
|
|
adc dword [device.bytes_rx+4], 0
|
|
|
|
|
|
|
|
push ebx
|
|
|
|
push .return
|
|
|
|
push ecx ; packet size
|
|
|
|
push [device.rxd+eax+12] ; packet ptr
|
|
|
|
DEBUGF 1, "Packet received OK\n"
|
|
|
|
jmp EthReceiver
|
2010-07-15 20:54:19 +02:00
|
|
|
.return:
|
2012-02-23 22:18:16 +01:00
|
|
|
pop ebx
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Reset status, allow ethernet card access to descriptor
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx ecx, [device.cur_rx]
|
|
|
|
shl ecx, 4 ; *16
|
|
|
|
mov ecx, [device.rxd+ecx]
|
|
|
|
stdcall KernelAlloc, RX_BUFF_SZ
|
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
mov dword [ecx+12], eax
|
|
|
|
GetRealAddr
|
|
|
|
mov dword [ecx+8], eax
|
|
|
|
mov dword [ecx+4], RX_BUFF_SZ
|
|
|
|
|
|
|
|
inc [device.cur_rx] ; get next descriptor
|
|
|
|
and [device.cur_rx], NUM_RX_DESC-1 ; only 4 descriptors 0-3
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; Enable Receiver
|
2012-02-23 22:18:16 +01:00
|
|
|
set_io 0
|
|
|
|
set_io cr ; Command Register offset
|
|
|
|
in eax, dx ; Get current Command Register
|
|
|
|
or eax, RxENA ; Enable Receiver
|
|
|
|
out dx, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
pop ax
|
|
|
|
jmp .no_rx
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.error_status:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1, "Packet error: %x\n", ecx
|
|
|
|
jmp .fail
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.error_size:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1, "Packet too large/small\n"
|
|
|
|
jmp .fail
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.no_rx:
|
2011-11-08 18:24:46 +01:00
|
|
|
;; test ax, TxOk
|
|
|
|
;; jz .no_tx
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
;;; TODO: free all unused buffers
|
2011-11-08 18:24:46 +01:00
|
|
|
;; stdcall KernelFree, eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
.no_tx:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
ret
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
|
2011-11-08 18:24:46 +01:00
|
|
|
.fail:
|
2012-02-23 22:18:16 +01:00
|
|
|
DEBUGF 1, "FAILED\n"
|
|
|
|
jmp $
|
|
|
|
ret
|
2011-11-08 18:24:46 +01:00
|
|
|
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
;***************************************************************************
|
|
|
|
; Function
|
|
|
|
; transmit
|
|
|
|
; Description
|
|
|
|
; Transmits a packet of data via the ethernet card
|
2009-11-08 19:00:01 +01:00
|
|
|
; buffer pointer in [esp+4]
|
|
|
|
; size of buffer in [esp+8]
|
2009-10-26 12:32:59 +01:00
|
|
|
; pointer to device structure in ebx
|
|
|
|
;
|
|
|
|
; only one transmit descriptor is used
|
|
|
|
;
|
|
|
|
;***************************************************************************
|
2010-07-15 20:54:19 +02:00
|
|
|
align 4
|
2009-10-26 12:32:59 +01:00
|
|
|
transmit:
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp dword [esp+8], MAX_ETH_FRAME_SIZE
|
|
|
|
ja .error
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
cmp dword [esp+8], 60
|
|
|
|
jb .error
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
movzx ecx, [device.cur_tx]
|
|
|
|
shl ecx, 4
|
|
|
|
mov ecx, [device.txd+ecx]
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
;; TODO: check if desc is empty (for example: check for eax, 0x6200000 at [ecx+4]
|
|
|
|
;;; or: count number of available descriptors
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [esp+4]
|
|
|
|
mov dword [ecx + 12], eax
|
|
|
|
GetRealAddr
|
|
|
|
mov dword [ecx + 8], eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
mov eax, [esp+8]
|
|
|
|
and eax, DSIZE
|
|
|
|
or eax, 0x80000000 ; card owns descriptor
|
|
|
|
mov dword [ecx + 4], eax
|
2010-07-15 20:54:19 +02:00
|
|
|
|
|
|
|
; update stats
|
2012-02-23 22:18:16 +01:00
|
|
|
inc [device.packets_tx]
|
|
|
|
add dword [device.bytes_tx], ecx
|
2012-08-07 11:59:58 +02:00
|
|
|
adc dword [device.bytes_tx + 4], 0
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2011-11-08 18:24:46 +01:00
|
|
|
.finish:
|
2012-02-23 22:18:16 +01:00
|
|
|
xor eax, eax
|
|
|
|
ret 8
|
2011-11-08 18:24:46 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
.error:
|
|
|
|
stdcall KernelFree, [esp+4]
|
|
|
|
or eax, -1
|
|
|
|
ret 8
|
2010-07-15 20:54:19 +02:00
|
|
|
|
2009-10-26 12:32:59 +01:00
|
|
|
|
|
|
|
; End of code
|
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
align 4 ; Place all initialised data here
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
devices dd 0
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2010-07-15 20:54:19 +02:00
|
|
|
specific_table:
|
2012-08-07 11:59:58 +02:00
|
|
|
; dd SIS630A_900_REV, Get_Mac_SIS630A_900_REV, 0
|
|
|
|
; dd SIS630E_900_REV, Get_Mac_SIS630E_900_REV, 0
|
|
|
|
dd SIS630S_900_REV, Get_Mac_SIS635_900_REV, 0
|
|
|
|
dd SIS630EA1_900_REV, Get_Mac_SIS635_900_REV, 0
|
|
|
|
dd SIS630ET_900_REV, Get_Mac_SIS635_900_REV, 0 ;SIS630ET_900_REV_SpecialFN
|
|
|
|
dd SIS635A_900_REV, Get_Mac_SIS635_900_REV, 0
|
|
|
|
dd SIS900_960_REV, SIS960_get_mac_addr, 0
|
|
|
|
dd SIS900B_900_REV, SIS900_get_mac_addr, 0
|
2012-02-23 22:18:16 +01:00
|
|
|
dd 0 ; end of list
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
version dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF)
|
|
|
|
my_service db 'SIS900',0 ; max 16 chars include zero
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
include_debug_strings ; All data wich FDO uses will be included here
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2010-07-15 20:54:19 +02:00
|
|
|
section '.data' data readable writable align 16; place all uninitialized data place here
|
2009-10-26 12:32:59 +01:00
|
|
|
|
2012-02-23 22:18:16 +01:00
|
|
|
device_list rd MAX_DEVICES ; This list contains all pointers to device structures the driver is handling
|
2009-10-26 12:32:59 +01:00
|
|
|
|