mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
8702d8c4e1
Bug Fix in SHELL, $?,$$....sysvars not printed at all Generalized use of new MemMgr API Call in all DRV,BIN,SBIN & LIB
455 lines
8.8 KiB
Plaintext
455 lines
8.8 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/DRV/UTHERNET.DRV
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||
.INB /A2OSX.BUILD/INC/MLI.ERR.I
|
||
.INB /A2OSX.BUILD/INC/NET.I
|
||
.INB /A2OSX.BUILD/INC/NET.8900A.I
|
||
.INB /A2OSX.BUILD/INC/LIBTCPIP.I
|
||
*--------------------------------------
|
||
ZPTmpPTR .EQ ZPDRV
|
||
Size .EQ ZPDRV+2
|
||
Counter .EQ ZPDRV+4
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp Dev.Detect cld,jmp abs=DRV
|
||
.DA #$61 6502,Level 1 (65c02)
|
||
.DA #1 DRV Layout Version 1
|
||
.DA 0
|
||
.DA CS.END-CS.START Code Length
|
||
.DA DEV.HEADER-CS.START Device Header Offset
|
||
.DA DRV.CS.START-CS.START Driver Code Offset
|
||
.DA DRV.CS.END-DRV.CS.START Drv Code Length
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
L.MSG.DETECT .DA MSG.DETECT
|
||
L.MSG.DETECT.OK .DA MSG.DETECT.OK
|
||
L.MSG.DETECT.KO .DA MSG.DETECT.KO
|
||
L.DEV.HEADER.NAME .DA DEV.HEADER.NAME
|
||
.DA 0 End Of Reloc Table
|
||
*--------------------------------------
|
||
Dev.Detect >STYA ARGS
|
||
>LDYA L.MSG.DETECT
|
||
>SYSCALL CPrintFYA
|
||
|
||
ldx #$70
|
||
ldy #7
|
||
|
||
.1 lda A2osX.SLOTS,y IO based detection, avoid scanning in Disk Controller IO!!!!
|
||
bne .2
|
||
|
||
lda /PP.ID
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.ID
|
||
sta PacketPagePTR,x
|
||
|
||
lda PacketPageDATA+1,x
|
||
cmp /DEVID
|
||
bne .2
|
||
|
||
lda PacketPageDATA,x
|
||
cmp #DEVID
|
||
beq .3
|
||
|
||
.2 dec DEV.HEADER.NAME+4
|
||
txa
|
||
sec
|
||
sbc #$10
|
||
tax
|
||
dey
|
||
bne .1
|
||
|
||
>LDYA L.MSG.DETECT.KO
|
||
>SYSCALL CPrintFYA
|
||
|
||
lda #MLI.ERR.NODEV
|
||
sec
|
||
rts
|
||
|
||
.3 stx DEVSLOTx0
|
||
lda #A2osX.SLOTS.NET
|
||
sta A2osX.SLOTS,y
|
||
|
||
lda /PP.REVISION Get Revision# of ths chip...
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.REVISION
|
||
sta PacketPagePTR,x
|
||
|
||
lda PacketPageDATA+1,x
|
||
sta DEVSTAT+S.DEVSTAT.VERSION+1 set Hardware version
|
||
lda PacketPageDATA,x
|
||
sta DEVSTAT+S.DEVSTAT.VERSION
|
||
|
||
>LDYA ARGS
|
||
>STYA ZPTmpPTR
|
||
lda (ZPTmpPTR)
|
||
bne .4
|
||
|
||
lda #$00
|
||
sta MAC
|
||
lda #$0E
|
||
sta MAC+1
|
||
lda #$3A
|
||
sta MAC+2
|
||
lda A2osX.RANDOM16
|
||
eor A2osX.TIMER16
|
||
sta MAC+3
|
||
eor A2osX.RANDOM16+1
|
||
sta MAC+4
|
||
eor A2osX.TIMER16+1
|
||
sta MAC+5
|
||
bra .8
|
||
|
||
.4 jsr DecodeMac
|
||
bcc .8
|
||
lda #DEVMGR.ERRICL
|
||
sec
|
||
rts
|
||
|
||
.8 >PUSHW L.DEV.HEADER.NAME
|
||
>LDYA L.MSG.DETECT.OK
|
||
>SYSCALL CPrintFYA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
.INB /A2OSX.SRC/DRV/X.NET.DRV.S
|
||
*--------------------------------------
|
||
CS.END
|
||
MSG.DETECT >CSTR "UtherNet/CS8900A Driver.\r\n"
|
||
MSG.DETECT.OK >CSTR "UtherNet/CS8900A Installed As Device : %S\r\n"
|
||
MSG.DETECT.KO >CSTR "Hardware Not Found.\r\n"
|
||
ARGS .BS 2
|
||
*--------------------------------------
|
||
* Device Header (16 Bytes)
|
||
*--------------------------------------
|
||
DEV.HEADER cld
|
||
jmp (DRV.CS.START,x)
|
||
.DA #0
|
||
.BS 6
|
||
DEV.HEADER.NAME >PSTR "ETH7" NAME
|
||
*--------------------------------------
|
||
* Driver Code
|
||
*--------------------------------------
|
||
DRV.CS.START .DA STATUS
|
||
.DA READBLOCK
|
||
.DA WRITEBLOCK
|
||
.DA A2osX.BADCALL
|
||
.DA A2osX.BADCALL
|
||
.DA A2osX.BADCALL
|
||
.DA OPEN
|
||
.DA CLOSE
|
||
.DA A2osX.BADCALL
|
||
.DA A2osX.BADCALL
|
||
L.DEVSTAT .DA DEVSTAT
|
||
.DA 0 end or relocation
|
||
*--------------------------------------
|
||
STATUS lda #S.DEVSTAT.NET.STATUS.10
|
||
sta LINK.STATUS
|
||
|
||
ldx DEVSLOTx0
|
||
|
||
lda /PP.LineST
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.LineST
|
||
sta PacketPagePTR,x
|
||
|
||
lda PacketPageDATA+1,x
|
||
lda PacketPageDATA,x
|
||
and #PP.LineST.LinkOK
|
||
beq .1
|
||
|
||
lda LINK.STATUS
|
||
ora #S.DEVSTAT.NET.STATUS.OK
|
||
sta LINK.STATUS
|
||
|
||
.1 lda /PP.TestCTL
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.TestCTL
|
||
sta PacketPagePTR,x
|
||
|
||
lda PacketPageDATA+1,x
|
||
ldy PacketPageDATA,x
|
||
and /PP.TestCTL.FDX
|
||
beq .2
|
||
|
||
lda LINK.STATUS
|
||
ora #S.DEVSTAT.NET.STATUS.FD
|
||
sta LINK.STATUS
|
||
|
||
.2 >LDYA L.DEVSTAT
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
READBLOCK php
|
||
sei
|
||
|
||
ldx DEVSLOTx0
|
||
|
||
lda /PP.RxEvent
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.RxEvent
|
||
sta PacketPagePTR,x
|
||
|
||
lda PacketPageDATA+1,x
|
||
ldy PacketPageDATA,x
|
||
and /PP.RxEvent.RxOK+PP.RxEvent.IA+PP.RxEvent.Brdcast+PP.RxEvent.Runt
|
||
bne .1
|
||
|
||
lda #ERR.DEV.NOFRAME
|
||
|
||
.9 plp
|
||
sec
|
||
rts
|
||
|
||
.1 lda RTDATA+1,x discard RxStatus
|
||
lda RTDATA,x
|
||
|
||
lda RTDATA+1,x
|
||
sta Size+1
|
||
|
||
lda RTDATA,x get RxLength
|
||
sta Size
|
||
clc
|
||
adc #2
|
||
tay
|
||
|
||
lda Size+1
|
||
adc #0
|
||
|
||
>SYSCALL GetMemYA
|
||
bcs .9
|
||
|
||
>STYA ZPTmpPTR
|
||
stx .8+1
|
||
sty .8+3
|
||
sta .8+5
|
||
|
||
lda Size
|
||
sta (ZPTmpPTR)
|
||
eor #$ff
|
||
sta Counter
|
||
ldy #1
|
||
lda Size+1
|
||
sta (ZPTmpPTR),y
|
||
eor #$ff
|
||
sta Counter+1
|
||
|
||
iny
|
||
|
||
ldx DEVSLOTx0
|
||
|
||
.2 inc Counter
|
||
bne .3
|
||
inc Counter+1
|
||
beq .8
|
||
|
||
.3 lda RTDATA,x
|
||
sta (ZPTmpPTR),y
|
||
iny
|
||
bne .4
|
||
inc ZPTmpPTR+1
|
||
|
||
.4 inc Counter
|
||
bne .5
|
||
inc Counter+1
|
||
beq .8
|
||
|
||
.5 lda RTDATA+1,x
|
||
sta (ZPTmpPTR),y
|
||
iny
|
||
bne .2
|
||
inc ZPTmpPTR+1
|
||
bne .2
|
||
|
||
.8 ldx #$ff hMem
|
||
ldy #$ff PtrLO
|
||
lda #$ff PtrHI
|
||
|
||
plp
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
WRITEBLOCK php
|
||
sei
|
||
>STYA ZPTmpPTR
|
||
|
||
ldx #5
|
||
ldy #S.ETH.SRCMAC+5
|
||
|
||
.10 lda MAC,x
|
||
sta (ZPTmpPTR),y
|
||
dey
|
||
dex
|
||
bpl .10
|
||
|
||
ldx DEVSLOTx0
|
||
|
||
lda /PP.TxCMD.LID+PP.TxCMD.TxStartFULL
|
||
sta TxCMD+1,x
|
||
lda #PP.TxCMD.LID+PP.TxCMD.TxStartFULL
|
||
sta TxCMD,x
|
||
|
||
ldy #1
|
||
lda (ZPTmpPTR),y
|
||
sta TxLength+1,x
|
||
eor #$ff
|
||
sta Counter+1
|
||
|
||
lda (ZPTmpPTR)
|
||
sta TxLength,x
|
||
eor #$ff
|
||
sta Counter
|
||
|
||
lda /PP.BusST
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.BusST
|
||
sta PacketPagePTR,x
|
||
|
||
ldy #16
|
||
|
||
.1 lda PacketPageDATA+1,x
|
||
and /PP.BusST.Rdy4TxNOW
|
||
bne WRITEBLOCK.1
|
||
|
||
lda PacketPageDATA,x
|
||
and #PP.BusST.TxBidErr
|
||
bne .9
|
||
|
||
dey
|
||
bne .1
|
||
|
||
.9 lda #ERR.DEV.NOBUFFER
|
||
plp
|
||
sec
|
||
rts
|
||
|
||
WRITEBLOCK.1 ldy #2
|
||
|
||
.1 inc Counter
|
||
bne .2
|
||
inc Counter+1
|
||
beq .8
|
||
|
||
.2 lda (ZPTmpPTR),y
|
||
sta RTDATA,x
|
||
iny
|
||
bne .3
|
||
inc ZPTmpPTR+1
|
||
|
||
.3 inc Counter
|
||
bne .4
|
||
inc Counter+1
|
||
beq .8
|
||
|
||
.4 lda (ZPTmpPTR),y
|
||
sta RTDATA+1,x
|
||
iny
|
||
bne .1
|
||
inc ZPTmpPTR+1
|
||
bne .1
|
||
|
||
.8 plp
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
OPEN jsr CLOSE
|
||
|
||
lda /PP.RxCTL
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.RxCTL
|
||
sta PacketPagePTR,x
|
||
|
||
lda /PP.RxCTL.LID+PP.RxCTL.RxOKA+PP.RxCTL.IA+PP.RxCTL.BroadcastA+PP.RxCTL.RuntA
|
||
sta PacketPageDATA+1,x
|
||
lda #PP.RxCTL.LID+PP.RxCTL.RxOKA+PP.RxCTL.IA+PP.RxCTL.BroadcastA+PP.RxCTL.RuntA
|
||
sta PacketPageDATA,x
|
||
|
||
lda /PP.MAC
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.MAC
|
||
sta PacketPagePTR,x
|
||
|
||
>LDYA MAC
|
||
>STYA PacketPageDATA,x
|
||
>LDYAI PP.MAC+2
|
||
>STYA PacketPagePTR,x
|
||
>LDYA MAC+2
|
||
>STYA PacketPageDATA,x
|
||
>LDYAI PP.MAC+4
|
||
>STYA PacketPagePTR,x
|
||
>LDYA MAC+4
|
||
>STYA PacketPageDATA,x
|
||
|
||
lda /PP.LineCTL
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.LineCTL
|
||
sta PacketPagePTR,x
|
||
|
||
lda /PP.LineCTL.LID+PP.LineCTL.SerRxOn+PP.LineCTL.SerTxOn+PP.LineCTL.10BaseT
|
||
sta PacketPageDATA+1,x
|
||
lda #PP.LineCTL.LID+PP.LineCTL.SerRxOn+PP.LineCTL.SerTxOn+PP.LineCTL.10BaseT
|
||
sta PacketPageDATA,x
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CLOSE ldx DEVSLOTx0
|
||
|
||
lda /PP.SelfCTL
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.SelfCTL
|
||
sta PacketPagePTR,x
|
||
|
||
lda /PP.SelfCTL.LID+PP.SelfCTL.RESET
|
||
sta PacketPageDATA+1,x
|
||
|
||
lda #PP.SelfCTL.LID+PP.SelfCTL.RESET
|
||
sta PacketPageDATA,x
|
||
|
||
lda /PP.SelfST
|
||
sta PacketPagePTR+1,x
|
||
lda #PP.SelfST
|
||
sta PacketPagePTR,x
|
||
|
||
ldy #0
|
||
|
||
.1 lda PacketPageDATA+1,x
|
||
lda PacketPageDATA,x
|
||
and #PP.SelfST.InitDone
|
||
|
||
bne .8
|
||
|
||
iny
|
||
bne .1
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
DRV.CS.END
|
||
DEVSLOTx0 .BS 1
|
||
*--------------------------------------
|
||
DEVSTAT .DA #0
|
||
.BS 3 size
|
||
>PSTR "Uthernet/CS8900A"
|
||
.DA #S.DEVSTAT.T.NET
|
||
.BS 1 Subtype
|
||
.BS 2 Version
|
||
*--------------------------------------
|
||
FLAGS .DA #0
|
||
LINK.STATUS .BS 1 OK/DUPLEX/SPEED
|
||
MAC .BS 6
|
||
MAN
|
||
SAVE /A2OSX.SRC/DRV/UTHERNET.DRV.S
|
||
ASM
|