Kernel version 0.8 : Migrating CMDs to new CIO/DIR/TIME API

This commit is contained in:
Rémy GIBERT 2016-10-18 17:56:06 +02:00
parent 617c1e6344
commit e702d711fc
6 changed files with 170 additions and 58 deletions

Binary file not shown.

Binary file not shown.

View File

@ -43,20 +43,62 @@ L.TIME.Mod .DA TIME.Mod
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT >SYSCALL SYS.GetArgC CS.INIT >SYSCALL SYS.GetArgC
cmp #1 sta ArgCount
bne .1
.1 dec ArgCount
beq .8
lda ArgCount
>SYSCALL SYS.GetArgA
>STYA ZPPtr1
lda (ZPPtr1)
cmp #2
bcc .7
ldy #1
lda (ZPPtr1),y
cmp #'-'
bne .7
iny
lda (ZPPtr1),y
cmp #'R'
bne .90
ldy bRecurse
lda #$80
sta (pData),y
bra .1
.7 >LDYA ZPPtr1
jsr CS.INIT.OPENDIR
bcc .1
bcs .99
.8 ldy #hDIR
lda (pData),y
bne .80
ldy #S.PS.hPREFIX ldy #S.PS.hPREFIX
lda (pPs),y lda (pPs),y
>SYSCALL SYS.GetMemPtrA >SYSCALL SYS.GetMemPtrA
>SYSCALL SYS.OPENDIRYA >SYSCALL SYS.OPENDIRYA
bcc .8 A=hDir bcs .99
.99 rts
.1 lda #1
>SYSCALL SYS.GetArgA
>SYSCALL SYS.GetFullPathYA ldy #hDIR
sta (pData),y
.80 lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
rts
.90 lda #SYSMGR.ERRSYN
.99 sec
rts
*--------------------------------------
CS.INIT.OPENDIR >SYSCALL SYS.GetFullPathYA
bcs .99 bcs .99
stx hFullPath stx hFullPath
>STYA ZPPtr1 >STYA ZPPtr1
@ -105,25 +147,20 @@ CS.INIT >SYSCALL SYS.GetArgC
.7 >LDYA ZPPtr1 .7 >LDYA ZPPtr1
>SYSCALL SYS.OPENDIRYA >SYSCALL SYS.OPENDIRYA
bcs .9 bcs .9
ldy #hDIR A=hDir
jsr .9 Cleanup
.8 ldy #hDIR A=hDir
sta (pData),y sta (pData),y
lda (pPs) jsr .9 Cleanup
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc clc
rts .99 rts
.9 pha .9 pha
lda hFullPath lda hFullPath
>SYSCALL SYS.FreeMemA >SYSCALL SYS.FreeMemA
pla pla
sec sec
rts rts
*-------------------------------------- *--------------------------------------
CS.RUN ldy #bCANCEL CS.RUN ldy #bCANCEL
lda (pData),y lda (pData),y
@ -220,6 +257,13 @@ CS.RUN.DEV ldy #S.STAT.PRODOS.DEVBLOCKS+1
*-------------------------------------- *--------------------------------------
CS.RUN.DIR jsr CS.RUN.PUSHDATES CS.RUN.DIR jsr CS.RUN.PUSHDATES
ldy #S.STAT.MODE+1
lda (ZPPtr2),y
>PUSHA
dey
lda (ZPPtr2),y
>PUSHA File Mode
>PUSHW ZPPtr1 >PUSHW ZPPtr1
>LDYA L.MSG.DIR >LDYA L.MSG.DIR
>SYSCALL SYS.PrintFYA >SYSCALL SYS.PrintFYA
@ -235,6 +279,13 @@ CS.RUN.FILE jsr CS.RUN.PUSHDATES
adc #0 adc #0
>PUSHYA File Size >PUSHYA File Size
ldy #S.STAT.MODE+1
lda (ZPPtr2),y
>PUSHA
dey
lda (ZPPtr2),y
>PUSHA File Mode
ldy #S.STAT.PRODOS.AUXTYPE+1 ldy #S.STAT.PRODOS.AUXTYPE+1
lda (ZPPtr2),y lda (ZPPtr2),y
>PUSHA >PUSHA
@ -333,10 +384,10 @@ CS.QUIT ldy #hDIR
FileType2PSTR ldy #0 FileType2PSTR ldy #0
.1 cmp PRODOS.FT.HEX,y .1 cmp PRODOS.FT.HEX,y
beq .3 beq .2
.2 iny iny
cpy #PRODOS.FT.TXT-PRODOS.FT.TXT cpy #PRODOS.FT.TXT-PRODOS.FT.HEX
bne .1 bne .1
pha pha
@ -354,7 +405,7 @@ FileType2PSTR ldy #0
lda HEXDIGIT,x lda HEXDIGIT,x
sta PRODOS.FT.DFLT+3 sta PRODOS.FT.DFLT+3
.3 tya .2 tya
asl asl
asl CC asl CC
adc L.PRODOS.FT.TXT adc L.PRODOS.FT.TXT
@ -364,9 +415,14 @@ FileType2PSTR ldy #0
rts rts
*-------------------------------------- *--------------------------------------
CS.END CS.END
*--------------------------------------
hFullPath .BS 1
STAT .BS S.STAT
ArgCount .BS 1
*--------------------------------------
MSG.DEV >CSTRING "%15S S%d,D%d Blocks Used:%5D,Total:%5D\n" MSG.DEV >CSTRING "%15S S%d,D%d Blocks Used:%5D,Total:%5D\n"
MSG.DIR >CSTRING "/%15S <dir> %S %S\n" MSG.DIR >CSTRING "/%15S <dir> %a %S %S\n"
MSG.FILE >CSTRING "%15S %S $%H %10u %S %S\n" MSG.FILE >CSTRING "%15S %S $%H %a %10u %S %S\n"
*-------------------------------------- *--------------------------------------
PRODOS.FT.HEX .HS 0406FAFCFDE2FF PRODOS.FT.HEX .HS 0406FAFCFDE2FF
PRODOS.FT.TXT >PSTRING "TXT" PRODOS.FT.TXT >PSTRING "TXT"
@ -381,8 +437,6 @@ TIME.Format >PSTRING "%d-%b-%y %H:%M"
TIME.Create .BS 20 TIME.Create .BS 20
TIME.Mod .BS 20 TIME.Mod .BS 20
HEXDIGIT .AS '0123456789ABCDEF' HEXDIGIT .AS '0123456789ABCDEF'
hFullPath .BS 1
STAT .BS S.STAT
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
.OR 0 .OR 0
@ -392,6 +446,7 @@ hDIR .BS 1
hFilter .BS 1 hFilter .BS 1
bSTOP .BS 1 bSTOP .BS 1
bCANCEL .BS 1 bCANCEL .BS 1
bRecurse .BS 1
DS.END DS.END
.ED .ED
*-------------------------------------- *--------------------------------------

View File

@ -439,9 +439,18 @@ S.STAT.MODE.RG .EQ $0020
S.STAT.MODE.XU .EQ $0040 S.STAT.MODE.XU .EQ $0040
S.STAT.MODE.WU .EQ $0080 S.STAT.MODE.WU .EQ $0080
S.STAT.MODE.RU .EQ $0100 S.STAT.MODE.RU .EQ $0100
S.STAT.MODE.SST .EQ $0200 *S.STAT.MODE.SST .EQ $0200
S.STAT.MODE.SGID .EQ $0400 *S.STAT.MODE.SGID .EQ $0400
S.STAT.MODE.SUID .EQ $0800 *S.STAT.MODE.SUID .EQ $0800
S.STAT.MODE.REG .EQ $0000
S.STAT.MODE.FIFO .EQ $1000
S.STAT.MODE.CHR .EQ $2000
S.STAT.MODE.BLK .EQ $2000
S.STAT.MODE.DIR .EQ $4000
S.STAT.MODE.LNK .EQ $5000
S.STAT.MODE.SOCK .EQ $6000
S.STAT.DEV .EQ 2 WORD S.STAT.DEV .EQ 2 WORD
S.STAT.UID .EQ 4 WORD S.STAT.UID .EQ 4 WORD
S.STAT.GID .EQ 6 WORD S.STAT.GID .EQ 6 WORD

View File

@ -230,6 +230,35 @@ PrintFJMP .DA PrintF.A
.DA PrintF.S,PrintF.SS .DA PrintF.S,PrintF.SS
*-------------------------------------- *--------------------------------------
PrintF.A >PULLW HEXBUF PrintF.A >PULLW HEXBUF
lda HEXBUF+1
lsr
lsr
lsr
lsr
tax
lda TYPES,x
jsr K.COutA
ldx #0
.1 lda #'-'
lsr HEXBUF
bcc .2
lda ACCESS,x
.2 jsr K.COutA
inx
cpx #8
bne .1
.3 lda #'-'
lsr HEXBUF+1
bcc .4
lda ACCESS,x
.4 jsr K.COutA
rts rts
*-------------------------------------- *--------------------------------------
PrintF.BB >PULLYA PrintF.BB >PULLYA
@ -593,7 +622,8 @@ DEC2HEX stz HEXBUF
* pla * pla
*.99 rts *.99 rts
*-------------------------------------- *--------------------------------------
*ACCESS .AS "drwxrwxrwx" TYPES .AS "-pcbdls"
ACCESS .AS "rwxrwxrwx"
HEXBUF .BS 4 32 bits max HEXBUF .BS 4 32 bits max
BCDBUF .BS 5 5, enough to handle 10 digits (32bits) BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
ASCBUF .BS 12 LEN + sign + 10 digits ($FFFFFFFF=4.294.967.295) ASCBUF .BS 12 LEN + sign + 10 digits ($FFFFFFFF=4.294.967.295)

View File

@ -107,18 +107,13 @@ K.READDIRA jsr PFT.CheckDirA
*-------------------------------------- *--------------------------------------
K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
>PUSHWI 256 Get a 256 bytes buffer for ONLINE call... >LDYAI KrnBuf256
>PUSHBI 0
jsr K.GetMem
bcs .99
stx K.READDIRA.hMem
>STYA MLICALL.PARAMS+2 >STYA MLICALL.PARAMS+2
>STYA ZPQuickPtr2 For PASS #1 & #2 >STYA ZPQuickPtr2
>MLICALL MLIONLINE >MLICALL MLIONLINE
bcc .10 bcc .10
.98 jsr K.READDIRA.CLN
sec sec
.99 rts .99 rts
* pass #1 compute BufSize..... * pass #1 compute BufSize.....
@ -151,7 +146,7 @@ K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
* pass #2 Fill Buffer... * pass #2 Fill Buffer...
jsr K.READDIRA.GetBuf jsr K.READDIRA.GetBuf
bcs .98 bcs .99
.3 lda (ZPQuickPtr2) .3 lda (ZPQuickPtr2)
and #$0F and #$0F
@ -185,23 +180,23 @@ K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
lda #0 lda #0
rol rol
inc inc
sta KrnBuf256+S.STAT.PRODOS.DRIVE sta KrnSTAT+S.STAT.PRODOS.DRIVE
pla pla
lsr CC lsr CC
lsr lsr
lsr lsr
lsr lsr
lsr lsr
sta KrnBuf256+S.STAT.PRODOS.SLOT sta KrnSTAT+S.STAT.PRODOS.SLOT
>MLICALL MLIGETFILEINFO >MLICALL MLIGETFILEINFO
sta KrnBuf256+S.STAT.PRODOS.DEVSTATUS sta KrnSTAT+S.STAT.PRODOS.DEVSTATUS
bcs .80 bcs .80
>LDYA MLICALL.PARAMS+5 AUXTYPE=TOTAL BLOCKS >LDYA MLICALL.PARAMS+5 AUXTYPE=TOTAL BLOCKS
>STYA KrnBuf256+S.STAT.PRODOS.DEVBLOCKS >STYA KrnSTAT+S.STAT.PRODOS.DEVBLOCKS
>LDYA MLICALL.PARAMS+8 >LDYA MLICALL.PARAMS+8
>STYA KrnBuf256+S.STAT.BLOCKS >STYA KrnSTAT+S.STAT.BLOCKS
.80 jsr K.READDIRA.ADDSTAT .80 jsr K.READDIRA.ADDSTAT
@ -221,9 +216,7 @@ K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
ldy #S.DIR.F ldy #S.DIR.F
lda #S.DIR.F.NOMORE lda #S.DIR.F.NOMORE
sta (ZPQuickPtr1),y sta (ZPQuickPtr1),y
jsr K.READDIRA.CLN Discard ONLINE BUFFER
lda K.READDIRA.hDIRENT lda K.READDIRA.hDIRENT
tax tax
jmp K.GetMemPtrA jmp K.GetMemPtrA
@ -453,36 +446,61 @@ K.READDIRA.ADD..
* ldy #$25 total_blocks * ldy #$25 total_blocks
* lda (ZPQuickPtr3),y * lda (ZPQuickPtr3),y
* sta KrnBuf256+S.STAT.BLOCKS * sta KrnSTAT+S.STAT.BLOCKS
* iny * iny
* lda (ZPQuickPtr3),y * lda (ZPQuickPtr3),y
* sta KrnBuf256+S.STAT.BLOCKS+1 * sta KrnSTAT+S.STAT.BLOCKS+1
*-------------------------------------- *--------------------------------------
K.READDIRA.ADDD lda #$0F K.READDIRA.ADDD lda #$0F
sta KrnBuf256+S.STAT.PRODOS.TYPE sta KrnSTAT+S.STAT.PRODOS.TYPE
bra K.READDIRA.ADDSTAT lda /S.STAT.MODE.DIR
sta KrnSTAT+S.STAT.MODE+1
bra K.READDIRA.AddAccess
*-------------------------------------- *--------------------------------------
K.READDIRA.ADDF ldx #ADDF.DST-ADDF.SRC K.READDIRA.ADDF lda /S.STAT.MODE.REG
sta KrnSTAT+S.STAT.MODE+1
ldx #ADDF.DST-ADDF.SRC
.1 ldy ADDF.SRC-1,x .1 ldy ADDF.SRC-1,x
lda (ZPQuickPtr3),y lda (ZPQuickPtr3),y
ldy ADDF.DST-1,x ldy ADDF.DST-1,x
sta KrnBuf256,y sta KrnSTAT,y
dex dex
bpl .1 bpl .1
*--------------------------------------
>PUSHWI KrnBuf256+S.STAT.CTIME K.READDIRA.AddAccess
ldy #$1E ProDOS Access
lda (ZPQuickPtr3),y
ldx #0
bit #$01 ProDOS R
beq .2
ldx #S.STAT.MODE.RO
.2 bit #$C2 ProDOS D,Rn,W
beq .3
txa
ora #S.STAT.MODE.XO+S.STAT.MODE.WO
.HS 89 bit imm to skip txa
.3 txa
sta KrnSTAT+S.STAT.MODE
*--------------------------------------
K.READDIRA.AddTime
>PUSHWI KrnSTAT+S.STAT.CTIME
lda #$18 creation Date/time lda #$18 creation Date/time
jsr K.READDIRA.ConvertTime jsr K.READDIRA.ConvertTime
>PUSHWI KrnBuf256+S.STAT.MTIME >PUSHWI KrnSTAT+S.STAT.MTIME
lda #$21 mod Date/time lda #$21 mod Date/time
jsr K.READDIRA.ConvertTime jsr K.READDIRA.ConvertTime
*-------------------------------------- *--------------------------------------
K.READDIRA.AddStat K.READDIRA.AddStat
ldy #S.STAT-1 ldy #S.STAT-1
.1 lda KrnBuf256,y .1 lda KrnSTAT,y
sta (ZPQuickPtr4),y sta (ZPQuickPtr4),y
dey dey
bpl .1 bpl .1
@ -498,7 +516,7 @@ K.READDIRA.AddStat
K.READDIRA.ClrStat K.READDIRA.ClrStat
ldx #S.STAT-1 ldx #S.STAT-1
.1 stz KrnBuf256,x .1 stz KrnSTAT,x
dex dex
bpl .1 bpl .1
rts rts