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
.DA A2osX.BadCall .DA A2osX.BadCall
*-------------------------------------- *--------------------------------------
A2osX.DIIDrv.S >LDYAI A2osx.DIIStat A2osX.DIIDrv.S >LDYAI A2osx.DII.Stat
clc clc
rts rts
*-------------------------------------- *--------------------------------------
A2osX.DIIDrv.RW >STYA GO.DiskII.RW.1+1 A2osX.DIIDrv.RW >STYA GO.RW.SrcDst+1
jsr A2osX.Blk.GetCmdAndDevAX jsr A2osX.Blk.GetCmdAndDevAX
jmp GO.DiskII.RW 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 280
.DA #0 .DA #0
>PSTR "Disk II 5.25" >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
.DA #0,#9 .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 * A2osX.BlkDrv
* X = DEVMGR.cmd * X = DEVMGR.cmd
* Y,A = PTR to Params * Y,A = PTR to Params
@ -67,10 +110,10 @@ A2osX.BlkDrv.S jsr A2osX.Blk.GetCmdAndDev
jsr A2osX.BlkDrv.Go jsr A2osX.BlkDrv.Go
bcs .9 bcs .9
stx A2osx.BlkStat+S.DSTAT.SIZE stx A2osx.Blk.Stat+S.DSTAT.SIZE
sty A2osx.BlkStat+S.DSTAT.SIZE+1 sty A2osx.Blk.Stat+S.DSTAT.SIZE+1
>LDYAI A2osX.BlkStat >LDYAI A2osX.Blk.Stat
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
@ -128,7 +171,7 @@ A2osX.Blk.GetCmdAndDevAX
rts 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 .BS 3
>PSTR "ProDOS Block Dev" >PSTR "ProDOS Block Dev"
.DA #S.DSTAT.T.PRODOS .DA #S.DSTAT.T.PRODOS

View File

@ -142,18 +142,31 @@ GP.MLICall stx .1
jsr GO.A2osX jsr GO.A2osX
rts 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 stx $42
sta $43 sta $43
ldy #3 ldy #3
GO.DiskII.RW.1 lda $ffff,y Self Modified GO.RW.SrcDst lda $ffff,y Self Modified
sta $44,y sta $44,y
dey dey
bpl GO.DiskII.RW.1 bpl GO.RW.SrcDst
jsr $D000 GO.RW.Drv jsr $0000
cli cli
jsr GO.A2osX jsr GO.A2osX
rts rts

View File

@ -694,67 +694,101 @@ TClock.SIG .HS 0878282c58ff700538b00118b8087848
DevMgrInit >LDYAI MSG.DEV DevMgrInit >LDYAI MSG.DEV
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
stz ZPPtr1 lda DEVCNT
lda #$C1 sta DevMgrInit.DEVCNT
sta ZPPtr1+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 sta DEV.HEADER+S.DEV.BUSID
.1 lda #1 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 sta DEV.HEADER+S.DEV.DEVID
ldx #SmartPort.SIG-SmartPort.OFS-1 lda ZPPtr1+1
cmp #$D0 Disk II Driver is $D000
bne .2
.2 ldy SmartPort.OFS,x Check if there is a smartport firmware jsr DevMgrInit.DII
lda #A2osX.S.DII
bra .7 Go mark slot as USED
.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 lda (ZPPtr1),y
cmp SmartPort.SIG,x cmp SmartPort.SIG,x
bne .8 not a Disk Controller... bne .8 not a Disk Controller...
dex dex
bpl .2 bpl .5
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
ldy #7 ldy #7
lda (ZPPtr1),y lda (ZPPtr1),y
bne .4 $Cn07=00 : SmartPort bne .6 $Cn07=00 : SmartPort
jsr DevMgrInit.SP lda ZPPtr1 get $Cn
ldy #A2osX.S.SP 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 bra .7
.4 jsr DevMgrInit.BLK .6 jsr DevMgrInit.BLK
ldy #A2osX.S.BLK lda #A2osX.S.BLK
.7 lda ZPPtr1+1 .7 ldx DEV.HEADER+S.DEV.BUSID
and #$0f
tax
tya
sta A2osX.S,x sta A2osX.S,x
.8 inc DEV.HEADER+S.DEV.BUSID .8 dec DevMgrInit.DEVCNT
inc ZPPtr1+1 bpl .1
lda ZPPtr1+1
cmp #$C8
bne .1
clc clc
rts rts
DevMgrInit.DEVCNT
.BS 1
*-------------------------------------- *--------------------------------------
DevMgrInit.DII >LDYAI A2osX.DIIDrv DevMgrInit.DII >LDYAI A2osX.DIIDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP >STYA DEV.HEADER+S.DEV.DRV.JMP
jsr DevMgrInit.AddDev jmp DevMgrInit.AddDev
inc DEV.HEADER+S.DEV.DEVID *--------------------------------------
jsr DevMgrInit.AddDev DevMgrInit.RAM >DEBUG
rts >LDYAI A2osX.RamDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP
jmp DevMgrInit.AddDev
*-------------------------------------- *--------------------------------------
DevMgrInit.BLK ldy #$ff DevMgrInit.BLK ldy #$ff
lda (ZPPtr1),y lda (ZPPtr1),y
@ -764,51 +798,35 @@ DevMgrInit.BLK ldy #$ff
>LDYAI A2osX.BlkDrv >LDYAI A2osX.BlkDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP >STYA DEV.HEADER+S.DEV.DRV.JMP
jmp DevMgrInit.AddDev
jsr DevMgrInit.AddDev
inc DEV.HEADER+S.DEV.DEVID
jsr DevMgrInit.AddDev
rts
*-------------------------------------- *--------------------------------------
DevMgrInit.SP ldy #$ff DevMgrInit.SP ldy #$ff
lda (ZPPtr1),y lda (ZPPtr1),y
clc clc
adc #3 Compute smartport entry point adc #3 Compute smartport entry point
sta .1+1
sta .3+1 sta .3+1
sta DEV.HEADER+S.DEV.ROM.JMP sta DEV.HEADER+S.DEV.ROM.JMP
lda ZPPtr1+1 lda ZPPtr1+1
sta .1+2
sta .3+2 sta .3+2
sta DEV.HEADER+S.DEV.ROM.JMP+1 sta DEV.HEADER+S.DEV.ROM.JMP+1
>LDYAI A2osX.PrtDrv >LDYAI A2osX.PrtDrv
>STYA DEV.HEADER+S.DEV.DRV.JMP >STYA DEV.HEADER+S.DEV.DRV.JMP
.1 jsr $ffff Self Modified .2 lda DEV.HEADER+S.DEV.DEVID
.DA #0 Status
.DA SP.CTRL.STATUS
bcs .9
lda SP.CTRL.STATUS.DATA
beq .9 no device
.2 lda #1
sta SP.DEV.STATUS.DEVID sta SP.DEV.STATUS.DEVID
.3 jsr $ffff Self Modified .3 jsr $ffff Self Modified
.DA #0 Status .DA #0 Status
.DA SP.DEV.STATUS .DA SP.DEV.STATUS
bcs .7 bcs .9
lda SP.DEV.STATUS.DATA+S.DSTAT.S lda SP.DEV.STATUS.DATA+S.DSTAT.S
sta DEV.HEADER+S.DEV.S sta DEV.HEADER+S.DEV.S
jsr DevMgrInit.AddDev jsr DevMgrInit.AddDev
.7 inc SP.DEV.STATUS.DEVID
inc DEV.HEADER+S.DEV.DEVID
dec SP.CTRL.STATUS.DATA
bne .3
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
DevMgrInit.AddDev DevMgrInit.AddDev
@ -855,12 +873,6 @@ DEV.HEADER clc
SmartPort.OFS .HS 010305 SmartPort.OFS .HS 010305
SmartPort.SIG .HS 200003 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 .DA #3
SP.DEV.STATUS.DEVID SP.DEV.STATUS.DEVID
.BS 1 .BS 1

View File

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