Kernel 0.9.1 : DevMgr rewrite, starting with DEVCNT/DEVPTRS

This commit is contained in:
Rémy GIBERT 2017-11-07 17:28:34 +01:00
parent fe9635ccd5
commit ceadeca5f2
6 changed files with 189 additions and 109 deletions

Binary file not shown.

Binary file not shown.

View File

@ -25,15 +25,15 @@ A2osX.DIIDrv .DA A2osX.DIIDrv.S status
.DA A2osX.BadCall
.DA A2osX.BadCall
*--------------------------------------
A2osX.DIIDrv.S >LDYAI A2osx.DIIStat
A2osX.DIIDrv.S >LDYAI A2osx.DII.Stat
clc
rts
*--------------------------------------
A2osX.DIIDrv.RW >STYA GO.DiskII.RW.1+1
A2osX.DIIDrv.RW >STYA GO.RW.SrcDst+1
jsr A2osX.Blk.GetCmdAndDevAX
jmp GO.DiskII.RW
*--------------------------------------
A2osx.DIIStat .DA #S.DSTAT.S.BLOCK+S.DSTAT.S.WRITE+S.DSTAT.S.READ
A2osx.DII.Stat .DA #S.DSTAT.S.BLOCK+S.DSTAT.S.WRITE+S.DSTAT.S.READ
.DA 280
.DA #0
>PSTR "Disk II 5.25"
@ -42,6 +42,49 @@ A2osx.DIIStat .DA #S.DSTAT.S.BLOCK+S.DSTAT.S.WRITE+S.DSTAT.S.READ
.DA #0
.DA #0,#9
*--------------------------------------
* A2osX.RamDrv
* X = DEVMGR.cmd
* Y,A = PTR to Params
* pDev -> Dev Header AUX!!!
* $42 Command Number
* $43 Unit Number
* $44-$45 Buffer Pointer
* $46-$47 Block Number
*--------------------------------------
A2osX.RamDrv .DA A2osX.RamDrv.S status
.DA A2osX.RamDrv.RW Read
.DA A2osX.RamDrv.RW Write
.DA A2osX.BadCall Format
.DA A2osX.BadCall
.DA A2osX.BadCall
.DA A2osX.BadCall
.DA A2osX.BadCall
.DA A2osX.BadCall
.DA A2osX.BadCall
.DA A2osX.BadCall
*--------------------------------------
A2osX.RamDrv.S jsr A2osX.Blk.GetCmdAndDevAX
jsr GO.RamDrv.S
bcs .9
stx A2osx.RamDrv.Stat+S.DSTAT.SIZE
sty A2osx.RamDrv.Stat+S.DSTAT.SIZE+1
>LDYAI A2osX.RamDrv.Stat
clc
.9 rts
*--------------------------------------
A2osX.RamDrv.RW >STYA GO.RW.SrcDst+1
jsr A2osX.Blk.GetCmdAndDevAX
jmp GO.RamDrv.RW
*--------------------------------------
A2osx.RamDrv.Stat
.DA #S.DSTAT.S.BLOCK+S.DSTAT.S.WRITE+S.DSTAT.S.READ
.BS 3
>PSTR "ProDOS /RAM Disk"
.DA #S.DSTAT.T.RAM
.DA #0
.DA #0,#9
*--------------------------------------
* A2osX.BlkDrv
* X = DEVMGR.cmd
* Y,A = PTR to Params
@ -67,10 +110,10 @@ A2osX.BlkDrv.S jsr A2osX.Blk.GetCmdAndDev
jsr A2osX.BlkDrv.Go
bcs .9
stx A2osx.BlkStat+S.DSTAT.SIZE
sty A2osx.BlkStat+S.DSTAT.SIZE+1
stx A2osx.Blk.Stat+S.DSTAT.SIZE
sty A2osx.Blk.Stat+S.DSTAT.SIZE+1
>LDYAI A2osX.BlkStat
>LDYAI A2osX.Blk.Stat
clc
.9 rts
*--------------------------------------
@ -128,7 +171,7 @@ A2osX.Blk.GetCmdAndDevAX
rts
*--------------------------------------
A2osX.BlkStat .DA #S.DSTAT.S.BLOCK+S.DSTAT.S.WRITE+S.DSTAT.S.READ
A2osX.Blk.Stat .DA #S.DSTAT.S.BLOCK+S.DSTAT.S.WRITE+S.DSTAT.S.READ
.BS 3
>PSTR "ProDOS Block Dev"
.DA #S.DSTAT.T.PRODOS

View File

@ -142,18 +142,31 @@ GP.MLICall stx .1
jsr GO.A2osX
rts
*--------------------------------------
GO.DiskII.RW jsr GO.ProDOS
GO.RamDrv.S jsr GO.ProDOS
stx $42
sta $43
jsr $FF00
jsr GO.A2osX
rts
*--------------------------------------
GO.DiskII.RW ldy #$D0
.HS 2C bit abs
GO.RamDrv.RW ldy #$FF
sty GO.RW.Drv+2
jsr GO.ProDOS
stx $42
sta $43
ldy #3
GO.DiskII.RW.1 lda $ffff,y Self Modified
GO.RW.SrcDst lda $ffff,y Self Modified
sta $44,y
dey
bpl GO.DiskII.RW.1
bpl GO.RW.SrcDst
jsr $D000
GO.RW.Drv jsr $0000
cli
jsr GO.A2osX
rts

View File

@ -694,67 +694,101 @@ TClock.SIG .HS 0878282c58ff700538b00118b8087848
DevMgrInit >LDYAI MSG.DEV
>SYSCALL PrintF.YA
stz ZPPtr1
lda #$C1
sta ZPPtr1+1
lda #1
sta DEV.HEADER+S.DEV.BUSID
lda DEVCNT
sta DevMgrInit.DEVCNT
.1 lda #1
.1 ldx DevMgrInit.DEVCNT
lda DEVLST,x
asl
php Save Drive 1/2 in C
lsr 0SSSxxxx
lsr
lsr
lsr
lsr 00000SSS
sta DEV.HEADER+S.DEV.BUSID
asl 0000SSS0
tax
stz ZPPtr1
lda DEVPTRS+1,x
sta ZPPtr1+1
plp
lda #0
adc #1 Make DevID 1 or 2
sta DEV.HEADER+S.DEV.DEVID
ldx #SmartPort.SIG-SmartPort.OFS-1
lda ZPPtr1+1
cmp #$D0 Disk II Driver is $D000
bne .2
jsr DevMgrInit.DII
lda #A2osX.S.DII
bra .7 Go mark slot as USED
.2 ldy SmartPort.OFS,x Check if there is a smartport firmware
.2 cmp #$FF /RAM is always $FF00
bne .3
jsr DevMgrInit.RAM
bra .8
.3 and #$f
cmp #$C0
beq .4
jsr DevMgrInit.BLK Outside ROM space, ram loaded BLK dev
bra .8
.4 ldx #SmartPort.SIG-SmartPort.OFS-1
.5 ldy SmartPort.OFS,x Check if there is a smartport firmware
lda (ZPPtr1),y
cmp SmartPort.SIG,x
bne .8 not a Disk Controller...
dex
bpl .2
ldy #$ff
lda (ZPPtr1),y
bne .3 $0, Disk II, 16sect
jsr DevMgrInit.DII
ldy #A2osX.S.DII
bra .7
.3 inc
beq .7 $ff, Disk II 13 Sect, ignore
bpl .5
ldy #7
lda (ZPPtr1),y
bne .4 $Cn07=00 : SmartPort
bne .6 $Cn07=00 : SmartPort
jsr DevMgrInit.SP
ldy #A2osX.S.SP
lda ZPPtr1 get $Cn
and #$f get $0n
cmp DEV.HEADER+S.DEV.BUSID same as SSS ?
beq .51
inc DEV.HEADER+S.DEV.DEVID Remapped SP devices....
inc DEV.HEADER+S.DEV.DEVID Add 2 to DEVID (2 & 3)
.51 jsr DevMgrInit.SP
lda #A2osX.S.SP
bra .7
.4 jsr DevMgrInit.BLK
ldy #A2osX.S.BLK
.6 jsr DevMgrInit.BLK
lda #A2osX.S.BLK
.7 lda ZPPtr1+1
and #$0f
tax
tya
.7 ldx DEV.HEADER+S.DEV.BUSID
sta A2osX.S,x
.8 inc DEV.HEADER+S.DEV.BUSID
inc ZPPtr1+1
lda ZPPtr1+1
cmp #$C8
bne .1
.8 dec DevMgrInit.DEVCNT
bpl .1
clc
rts
DevMgrInit.DEVCNT
.BS 1
*--------------------------------------
DevMgrInit.DII >LDYAI A2osX.DIIDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP
jsr DevMgrInit.AddDev
inc DEV.HEADER+S.DEV.DEVID
jsr DevMgrInit.AddDev
rts
jmp DevMgrInit.AddDev
*--------------------------------------
DevMgrInit.RAM >DEBUG
>LDYAI A2osX.RamDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP
jmp DevMgrInit.AddDev
*--------------------------------------
DevMgrInit.BLK ldy #$ff
lda (ZPPtr1),y
@ -763,52 +797,36 @@ DevMgrInit.BLK ldy #$ff
sta DEV.HEADER+S.DEV.ROM.JMP+1
>LDYAI A2osX.BlkDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP
jsr DevMgrInit.AddDev
inc DEV.HEADER+S.DEV.DEVID
jsr DevMgrInit.AddDev
rts
>STYA DEV.HEADER+S.DEV.DRV.JMP
jmp DevMgrInit.AddDev
*--------------------------------------
DevMgrInit.SP ldy #$ff
lda (ZPPtr1),y
clc
adc #3 Compute smartport entry point
sta .1+1
sta .3+1
sta DEV.HEADER+S.DEV.ROM.JMP
lda ZPPtr1+1
sta .1+2
sta .3+2
sta DEV.HEADER+S.DEV.ROM.JMP+1
>LDYAI A2osX.PrtDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP
.1 jsr $ffff Self Modified
.DA #0 Status
.DA SP.CTRL.STATUS
bcs .9
lda SP.CTRL.STATUS.DATA
beq .9 no device
.2 lda #1
.2 lda DEV.HEADER+S.DEV.DEVID
sta SP.DEV.STATUS.DEVID
.3 jsr $ffff Self Modified
.DA #0 Status
.DA SP.DEV.STATUS
bcs .7
bcs .9
lda SP.DEV.STATUS.DATA+S.DSTAT.S
sta DEV.HEADER+S.DEV.S
jsr DevMgrInit.AddDev
.7 inc SP.DEV.STATUS.DEVID
inc DEV.HEADER+S.DEV.DEVID
dec SP.CTRL.STATUS.DATA
bne .3
.9 rts
*--------------------------------------
DevMgrInit.AddDev
@ -855,12 +873,6 @@ DEV.HEADER clc
SmartPort.OFS .HS 010305
SmartPort.SIG .HS 200003
*--------------------------------------
SP.CTRL.STATUS .DA #3
.DA #0
.DA SP.CTRL.STATUS.DATA
.DA #0
SP.CTRL.STATUS.DATA
.BS 8 DevCnt
SP.DEV.STATUS .DA #3
SP.DEV.STATUS.DEVID
.BS 1

View File

@ -16,7 +16,8 @@ AUTO 6
.INB /A2OSX.BUILD/INC/COM.6551.I
*--------------------------------------
TmpPtr1 .EQ $0
VS.CMD .EQ $C5 "E": Virtual Drive Command Envelope
ADT.CMD.VSD .EQ $C5 "E": Virtual Drive Command Envelope
ADT.CMD.PING .EQ $D9 "Y": PING
DRV.EntryPoint .EQ $BF41
*--------------------------------------
VSDRIVE.Init >LDAXI VSDRIVE.MSG0
@ -31,7 +32,8 @@ VSDRIVE.Init >LDAXI VSDRIVE.MSG0
bcs .99
stx DRV+2 DRV.Slotn0
sta .1+1 SlotCn
sta .1+1 Slot Cn
and #$0F
pha slot n
@ -117,16 +119,20 @@ SSC.Detect stz TmpPtr1
stz SSC.RESET,x
pha zzzzzzz...
pla
jsr VSDRIVE.Wait
lda #SSC.CTL.CLKEXT+SSC.CTL.B115200+SSC.CTL.8D+SSC.CTL.1S+SSC.CMD.NOP
sta SSC.CTL,x
jsr VSDRIVE.Wait
lda #SSC.CMD.RIRQDIS+SSC.CMD.TE+SSC.CMD.DTR
sta SSC.CMD,x
lda TmpPtr1+1
jsr VSDRIVE.Wait
lda TmpPtr1+1 A=Slot Cn, X=n0
clc
rts X=SlotN0, A=SlotCN
@ -139,15 +145,15 @@ SSC.Detect stz TmpPtr1
rts
*--------------------------------------
VSDRIVE.Ping ldx DRV+2 DRV.Slotn0
stz VSDRIVE.Ping.TO
stz VSDRIVE.Ping.TO+1
ldy #10
.1 lda SSC.STATUS,x
bit #SSC.STATUS.TDRE Ready for transmit?
bne .2
and #SSC.STATUS.TDRE Ready for transmit?
bne .20
jsr VSDRIVE.IncTimer Wait.......
bne .1
@ -155,37 +161,39 @@ VSDRIVE.Ping ldx DRV+2 DRV.Slotn0
bne .1
lda #1
.9 sec
rts Time Out.....
ldy #4 Five bytes to send
stz VSDRIVE.Ping.TO
stz VSDRIVE.Ping.TO+1
.2 lda VSDRIVE.Ping.CMD,y
.20 ldy #5 5 bytes to send
.2 lda VSDRIVE.CMDS-1,y
sta SSC.DATA,x
.3 lda SSC.STATUS,x
bit #SSC.STATUS.TDRE char transmitted?
bne .4
jsr VSDRIVE.Wait
.3 lda SSC.STATUS,x
and #SSC.STATUS.TDRE char transmitted?
bne .4
jsr VSDRIVE.IncTimer
bne .3
lda #2
bra .9
.4 dey
bpl .2 next byte
bne .2 next byte
lda #518^$ff
lda #521^$ffff 522 bytes to recieve
sta VSDRIVE.Ping.BC
lda /518^$ff
lda /521^$ffff
sta VSDRIVE.Ping.BC+1
stz VSDRIVE.Ping.TO
stz VSDRIVE.Ping.TO+1
ldy #20
.5 lda SSC.STATUS,x
and #SSC.STATUS.RDRF incoming char?
@ -193,15 +201,12 @@ VSDRIVE.Ping ldx DRV+2 DRV.Slotn0
jsr VSDRIVE.IncTimer
bne .5
dey
bne .5
lda #3
bra .9
.6 lda SSC.DATA,x
inc VSDRIVE.Ping.BC 518 bytes to recieve
inc VSDRIVE.Ping.BC
bne .5
inc VSDRIVE.Ping.BC+1
bne .5
@ -215,7 +220,15 @@ VSDRIVE.IncTimer
inc VSDRIVE.Ping.TO+1
.8 rts
*--------------------------------------
VSDRIVE.Ping.CMD .HS C4000001C5 C4=C5 eor 01 eor 00 eor 00
VSDRIVE.Wait lda #0
.1 dec
bne .1
rts
*--------------------------------------
VSDRIVE.CMDS .HS C6.00.00.03
.DA #ADT.CMD.VSD
* C6=C5 eor 03 eor 00 eor 00
VSDRIVE.Ping.TO .BS 2
VSDRIVE.Ping.BC .BS 2
*--------------------------------------
@ -358,16 +371,16 @@ DRV.Slotn0 ldx #$ff Self Modified
adc #2 CC from bcs
.2 sta DRV.CmdBuf.Cmd store cmd
eor #VS.CMD
eor #ADT.CMD.VSD
eor DRV.BLKNUM
eor DRV.BLKNUM+1
sta DRV.CmdBuf.Sum Compute & store CheckSum
lda DRV.BLKNUM
sta DRV.CmdBuf.BlkLo
sta DRV.CmdBuf.BlkL
lda DRV.BLKNUM+1
sta DRV.CmdBuf.BlkHi
sta DRV.CmdBuf.BlkH
* send CMD+CS
ldy #4 Send 5 bytes including Sum
@ -383,7 +396,6 @@ DRV.Slotn0 ldx #$ff Self Modified
sta $100,y
dey
bpl .5
*--------------------------------------
lda DRV.COMMAND
dec 1-1=0 if read
@ -394,7 +406,7 @@ DRV.Slotn0 ldx #$ff Self Modified
DRV.DO.CMD.R ldy #3 Read Back and check 4 bytes
.1 jsr DRV.SSCGet
eor DRV.CmdBuf.BlkHi,y
eor DRV.CmdBuf.BlkH,y
bne DRV.DO.CMD.ERR
dey
bpl .1
@ -516,10 +528,10 @@ DRV.READWRITE bit RRAMWRAMBNK1
rts
*--------------------------------------
DRV.CmdBuf.Sum .BS 1 Reverse order for dey
DRV.CmdBuf.BlkHi .BS 1
DRV.CmdBuf.BlkLo .BS 1
DRV.CmdBuf.BlkH .BS 1
DRV.CmdBuf.BlkL .BS 1
DRV.CmdBuf.Cmd .BS 1
DRV.CmdBuf.Env .DA #VS.CMD
DRV.CmdBuf.Env .DA #ADT.CMD.VSD
*--------------------------------------
.EP
*--------------------------------------