StupidOS/kernel/dev/at/ne2k.inc

123 lines
2 KiB
PHP
Raw Normal View History

2024-07-14 16:48:36 +00:00
;; File: ne2k.inc
;;
;; Usefull links:
2024-07-15 13:58:43 +00:00
;; - <datasheet at https://web.archive.org/web/20010612150713/http://www.national.com/ds/DP/DP8390D.pdf>
2024-07-14 16:48:36 +00:00
NE2K_IOBASE = 0x300
2024-07-22 15:31:24 +00:00
NE2K_ASIC = NE2K_IOBASE + 0x10
NE2K_NIC = NE2K_IOBASE + 0x00
NE2K_RESET = 0xF
2024-07-14 16:48:36 +00:00
2024-07-15 13:58:43 +00:00
; PAGE 0
2024-07-22 15:31:24 +00:00
DP8390D_CR = 0x0
DP8390D_CR_PS1 = 0x80
DP8390D_CR_PS0 = 0x40
DP8390D_CR_RD2 = 0x20
DP8390D_CR_RD1 = 0x10
DP8390D_CR_RD0 = 0x08
DP8390D_CR_TXP = 0x04
DP8390D_CR_STA = 0x02
DP8390D_CR_STP = 0x01
DP8390D_CLDA0 = 0x1
DP8390D_CLDA1 = 0x2
DP8390D_BNRY = 0x3
DP8390D_TSR = 0x4
DP8390D_NCR = 0x5
DP8390D_FIFO = 0x6
DP8390D_ISR = 0x7
DP8390D_CRDA0 = 0x8
DP8390D_CRDA1 = 0x9
DP8390D_RSR = 0xC
DP8390D_CNTR0 = 0xD
DP8390D_CNTR1 = 0xE
DP8390D_CNTR2 = 0xF
DP8390D_PSTART = 0x1
DP8390D_PSTOP = 0x2
DP8390D_TPSR = 0x4
DP8390D_TBCR0 = 0x5
DP8390D_TBCR1 = 0x6
DP8390D_RSAR0 = 0x8
DP8390D_RSAR1 = 0x9
DP8390D_RBCR0 = 0xA
DP8390D_RBCR1 = 0xB
DP8390D_RCR = 0xC
DP8390D_TCR = 0xD
DP8390D_DCR = 0xE
DP8390D_IMR = 0xF
2024-07-15 13:58:43 +00:00
; PAGE 1
2024-07-22 15:31:24 +00:00
DP8390D_PAR0 = 0x1
DP8390D_PAR1 = 0x2
DP8390D_PAR2 = 0x3
DP8390D_PAR3 = 0x4
DP8390D_PAR4 = 0x5
DP8390D_PAR5 = 0x6
DP8390D_CURR = 0x7
DP8390D_MAR0 = 0x8
DP8390D_MAR1 = 0x9
DP8390D_MAR2 = 0xA
DP8390D_MAR3 = 0xB
DP8390D_MAR4 = 0xC
DP8390D_MAR5 = 0xD
DP8390D_MAR6 = 0xE
DP8390D_MAR7 = 0xF
2024-07-15 13:58:43 +00:00
ne2k_init:
2024-07-21 16:14:38 +00:00
call ne2k_probe
or eax, eax
jnz @f
mov esi, szMsgNe2kfound
call klog
2024-07-22 15:31:24 +00:00
@@:
ret
ne2k_probe:
mov dx, NE2K_ASIC + NE2K_RESET
2024-07-15 13:58:43 +00:00
in al, dx
out dx, al
2024-07-22 15:31:24 +00:00
mov ecx, 5000
@@:
dec ecx
or ecx, ecx
jnz @b
2024-07-15 13:58:43 +00:00
2024-07-22 15:31:24 +00:00
mov dx, NE2K_NIC + DP8390D_CR
mov al, DP8390D_CR_RD2 or DP8390D_CR_STP
out dx, al
mov ecx, 5000
@@:
dec ecx
or ecx, ecx
jnz @b
2024-07-15 13:58:43 +00:00
2024-07-22 15:31:24 +00:00
mov dx, NE2K_NIC + DP8390D_CR
2024-07-21 16:14:38 +00:00
in al, dx
2024-07-22 15:31:24 +00:00
and al, (DP8390D_CR_RD2 or DP8390D_CR_TXP or DP8390D_CR_STA or DP8390D_CR_STP)
cmp al, (DP8390D_CR_RD2 or DP8390D_CR_STP)
2024-07-21 16:14:38 +00:00
jne @f
2024-07-22 15:31:24 +00:00
2024-07-21 16:14:38 +00:00
xor eax, eax
@@:
2024-07-14 16:48:36 +00:00
ret
2024-07-14 20:39:48 +00:00
ne2k_irq:
2024-07-22 21:43:35 +00:00
pusha
mov esi, szMsgNe2kIRQ
call klog
popa
2024-07-14 20:39:48 +00:00
iret
2024-07-19 07:53:03 +00:00
ne2k_device:
db 'ne2k', 0, 0, 0, 0
dd ne2k_init
2024-07-21 16:14:38 +00:00
szMsgNe2kfound db "NE2K: found", 0
2024-07-22 21:43:35 +00:00
szMsgNe2kIRQ db "NE2K: IRQ", 0