Kernel : Implementing new FILE API with Path Filtering #2, INIT2/INIT3 bug fixes

This commit is contained in:
Rémy GIBERT 2016-08-29 17:12:04 +02:00
parent 399646b8aa
commit 73425bb3dc
7 changed files with 173 additions and 81 deletions

View File

@ -281,6 +281,9 @@ SYS.FWRITE .EQ $E6
SYS.FFLUSH .EQ $E8 SYS.FFLUSH .EQ $E8
SYS.FSEEK .EQ $EA SYS.FSEEK .EQ $EA
SYS.FSEEK.SET .EQ $00
SYS.FSEEK.CUR .EQ $01
SYS.FSEEK.END .EQ $02
SYS.FTELL .EQ $EC SYS.FTELL .EQ $EC
SYS.FEOF .EQ $EE SYS.FEOF .EQ $EE

View File

@ -13,33 +13,29 @@ AUTO 6
* CS : A = EC * CS : A = EC
*-------------------------------------- *--------------------------------------
S.OPENDIRYA jsr S.PFTCHECKPATHYA S.OPENDIRYA jsr S.PFTCHECKPATHYA
* if we are here, we only have to deal with Local ProDOS path
clc clc
rts rts
*-------------------------------------- *--------------------------------------
* In : * In :
* Y,A = PTR to S.DIR * A = hDIR
* Out : * Out :
* CC : Y,A = PTR to S.DIRENT * CC : Y,A = PTR to S.DIRENT
* CS : A = EC * CS : A = EC
*-------------------------------------- *--------------------------------------
S.READDIRYA S.READDIRA jsr S.PFTCHECKDIRA
.8 clc clc
rts
.9 sec
rts rts
*-------------------------------------- *--------------------------------------
* In : * In :
* Y,A = PTR to S.DIR * A = hDIR
*-------------------------------------- *--------------------------------------
S.CLOSEDIRYA S.CLOSEDIRA jsr S.PFTCHECKDIRA
clc
rts rts
*-------------------------------------- *--------------------------------------
*-------------------------------------- *--------------------------------------

View File

@ -143,11 +143,7 @@ S.FCLOSEA.1 ldy #S.FILE.PRODOS.REF
*-------------------------------------- *--------------------------------------
S.FREAD jsr S.PFTCHECKFILESTK S.FREAD jsr S.PFTCHECKFILESTK
>PULLA >PULLA
jsr S.GetMemPtrA jsr FIL.SetupPrt1A
>STYA ZPQuickPtr1
ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
>PULLW MLICALL.PARAMS+4 >PULLW MLICALL.PARAMS+4
>PULLW MLICALL.PARAMS+2 >PULLW MLICALL.PARAMS+2
>MLICALL MLIREAD >MLICALL MLIREAD
@ -165,12 +161,7 @@ S.FREAD jsr S.PFTCHECKFILESTK
*-------------------------------------- *--------------------------------------
S.FWRITE jsr S.PFTCHECKFILESTK S.FWRITE jsr S.PFTCHECKFILESTK
>PULLA >PULLA
jsr S.GetMemPtrA jsr FIL.SetupPrt1A
>STYA ZPQuickPtr1
ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
>PULLB MLICALL.PARAMS+1
>PULLW MLICALL.PARAMS+4 >PULLW MLICALL.PARAMS+4
>PULLW MLICALL.PARAMS+2 >PULLW MLICALL.PARAMS+2
>MLICALL MLIWRITE >MLICALL MLIWRITE
@ -183,28 +174,123 @@ S.FWRITE jsr S.PFTCHECKFILESTK
* A = hFILE * A = hFILE
*-------------------------------------- *--------------------------------------
S.FFLUSHA jsr S.PFTCHECKFILEA S.FFLUSHA jsr S.PFTCHECKFILEA
jsr S.GetMemPtrA jsr FIL.SetupPrt1A
>STYA ZPQuickPtr1
ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
>MLICALL MLIFLUSH >MLICALL MLIFLUSH
rts rts
*-------------------------------------- *--------------------------------------
* S.FSEEK
* In :
* PULLB = hFILE
* PULLB = From
* PULLW = OffsetLo
* PULLW = OffsetHi
*-------------------------------------- *--------------------------------------
S.FSEEK S.FSEEK jsr S.PFTCHECKFILESTK
>PULLA
jsr FIL.SetupPrt1A
>PULLB S.FSEEK.FROM
>PULLW S.FSEEK.OFFSET
>PULLW S.FSEEK.OFFSET+2
lda S.FSEEK.FROM
beq .3
cmp #SYS.FSEEK.CUR
bne .1
>MLICALL MLIGETMARK
bcs .9
bcc .2
.1 cmp #SYS.FSEEK.END
bne .3
>MLICALL MLIGETEOF
bcs .9
.2 lda MLICALL.PARAMS+2
adc S.FSEEK.OFFSET
sta MLICALL.PARAMS+2
lda MLICALL.PARAMS+3
adc S.FSEEK.OFFSET+1
sta MLICALL.PARAMS+3
lda MLICALL.PARAMS+4
adc S.FSEEK.OFFSET+2
sta MLICALL.PARAMS+4
bcs .99 Offset out of range!
.3 >MLICALL MLISETMARK
.9 rts
.99 lda #SYSMGR.ERRFTB
sec
rts
*-------------------------------------- *--------------------------------------
S.FSEEK.FROM .BS 1
S.FSEEK.OFFSET .BS 4
*-------------------------------------- *--------------------------------------
S.FTELL * S.FTELLA
* In :
* A = hFILE
* Out :
* Y,A,X = Offset
*-------------------------------------- *--------------------------------------
S.FTELLA jsr S.PFTCHECKFILEA
S.FTELLA.1 jsr FIL.SetupPrt1A
>MLICALL MLIGETMARK
bcs .9
>LDYA MLICALL.PARAMS+2
ldx MLICALL.PARAMS+4
.9 rts
*-------------------------------------- *--------------------------------------
S.FEOF * S.FEOFA
* In :
* A = hFILE
* Out :
* CC :
* A=0 EOF
* A !=0 NOT EOF
* CS :
*-------------------------------------- *--------------------------------------
S.FEOFA jsr S.PFTCHECKFILEA
jsr FIL.SetupPrt1A
jsr S.FTELLA.1
bcs .9
>STYA S.FEOFA.MARK
stx S.FEOFA.MARK+2
>MLICALL MLIGETEOF
bcs .9
sec
lda MLICALL.PARAMS+2
sbc S.FEOFA.MARK
bne .8
lda MLICALL.PARAMS+3
sbc S.FEOFA.MARK+1
bne .8
lda MLICALL.PARAMS+4
sbc S.FEOFA.MARK+2
.8 clc
.9 rts
S.FEOFA.MARK .BS 3
*-------------------------------------- *--------------------------------------
S.REMOVE * S.REMOVEYA
*-------------------------------------- *--------------------------------------
S.REMOVEYA jsr S.PFTCHECKPATHYA
>STYA MLICALL.PARAMS+1
>MLICALL MLIDESTROY
rts
*-------------------------------------- *--------------------------------------
S.RENAME * S.RENAME
* In :
* PULLW = Old Name
* PULLW = New Name
*--------------------------------------
S.RENAME jsr S.PFTCHECKPATHYA
>PULLW MLICALL.PARAMS+1
>PULLW MLICALL.PARAMS+2
>MLICALL MLIRENAME
rts
*-------------------------------------- *--------------------------------------
S.MKDIRYA jsr S.PFTCHECKPATHYA S.MKDIRYA jsr S.PFTCHECKPATHYA
>STYA MLICALL.PARAMS+1 >STYA MLICALL.PARAMS+1
@ -217,6 +303,13 @@ S.MKDIRYA jsr S.PFTCHECKPATHYA
>MLICALL MLICREATE >MLICALL MLICREATE
rts rts
*-------------------------------------- *--------------------------------------
FIL.SetupPrt1A jsr S.GetMemPtrA
>STYA ZPQuickPtr1
ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
rts
*--------------------------------------
MAN MAN
SAVE SYS/KERNEL.S.FIL SAVE SYS/KERNEL.S.FIL
LOAD SYS/KERNEL.S LOAD SYS/KERNEL.S

View File

@ -8,18 +8,6 @@ AUTO 6
Kernel.Init2 >LDAXI MSG.Init2 Kernel.Init2 >LDAXI MSG.Init2
jsr PrintCStrAX jsr PrintCStrAX
sei
ldx #$FF init 6502 stack to highest
txs
sta SETALTZP
stx A2osX.SaveSM
stx A2osX.SaveSX
sta CLRALTZP Make MAIN ZP is enabled for X.PRINT.F
lda RROMBNK1 Make sure ROM is enabled for X.PRINT.F
cli
>LDAXI MSG.Relocate >LDAXI MSG.Relocate
jsr PrintCStrAX jsr PrintCStrAX
@ -32,8 +20,8 @@ Kernel.Init2 >LDAXI MSG.Init2
>STYA ZPQuickPtr2 >STYA ZPQuickPtr2
>LDYAI A2osX.BE00.SIZE^$FFFF >LDYAI A2osX.BE00.SIZE^$FFFF
>STYA ZPQuickPtr3 >STYA ZPQuickPtr3
jsr Kernel.Move jsr Kernel.Move
lda RRAMWRAMBNK2 lda RRAMWRAMBNK2
lda RRAMWRAMBNK2 lda RRAMWRAMBNK2
@ -43,7 +31,6 @@ Kernel.Init2 >LDAXI MSG.Init2
>STYA ZPQuickPtr2 >STYA ZPQuickPtr2
>LDYAI A2osX.D002.SIZE^$FFFF >LDYAI A2osX.D002.SIZE^$FFFF
>STYA ZPQuickPtr3 >STYA ZPQuickPtr3
jsr Kernel.Move jsr Kernel.Move
lda RRAMWRAMBNK1 lda RRAMWRAMBNK1
@ -55,7 +42,6 @@ Kernel.Init2 >LDAXI MSG.Init2
>STYA ZPQuickPtr2 >STYA ZPQuickPtr2
>LDYAI A2osX.D001.SIZE^$FFFF >LDYAI A2osX.D001.SIZE^$FFFF
>STYA ZPQuickPtr3 >STYA ZPQuickPtr3
jsr Kernel.Move jsr Kernel.Move
>LDYAI A2osX.E000 >LDYAI A2osX.E000
@ -64,7 +50,6 @@ Kernel.Init2 >LDAXI MSG.Init2
>STYA ZPQuickPtr2 >STYA ZPQuickPtr2
>LDYAI A2osX.E000.SIZE^$FFFF >LDYAI A2osX.E000.SIZE^$FFFF
>STYA ZPQuickPtr3 >STYA ZPQuickPtr3
jsr Kernel.Move jsr Kernel.Move
>LDYAI D.STACK.TOP >LDYAI D.STACK.TOP
@ -83,12 +68,10 @@ Kernel.Init2 >LDAXI MSG.Init2
jsr CPU.Init jsr CPU.Init
>LDAXI MSG.K.INIT >LDAXI MSG.Setup
jsr PrintCStrAX jsr PrintCStrAX
sta SETALTZP jsr GO.AUXLC
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
jsr S.IrqMgrInit jsr S.IrqMgrInit
bcs * bcs *
@ -103,21 +86,17 @@ Kernel.Init2 >LDAXI MSG.Init2
jsr S.TskMgrInit jsr S.TskMgrInit
bcs * bcs *
sta CLRALTZP Make sure MAIN ZP... jsr GO.MAINLC Make sure MAIN ZP...
lda RROMBNK1 ... & ROM is enabled for X.PRINT.F lda RROMBNK1 ... & ROM is enabled for X.PRINT.F
>LDAXI MSG.Init2.OK >LDAXI MSG.Init2.OK
jsr PrintCStrAX jsr PrintCStrAX
sta SETALTZP
lda RRAMWRAMBNK1
lda RRAMWRAMBNK1
rts rts
*-------------------------------------- *--------------------------------------
MSG.Init2 >CSTRING "A2osX[Stage2]:Init\n" MSG.Init2 >CSTRING "A2osX[Stage2]:Init\n"
MSG.Relocate >CSTRING "Relocating KERNEL...\n" MSG.Relocate >CSTRING "Relocating KERNEL...\n"
MSG.HZ >CSTRING "Kernel SYS Timer Set For %d0 hz Machine.\n" MSG.HZ >CSTRING "Kernel SYS Timer Set For %d0 hz Machine.\n"
MSG.K.INIT >CSTRING "Kernel Setup...\n" MSG.Setup >CSTRING "Kernel Setup...\n"
MSG.Init2.OK >CSTRING "A2osX[Stage2]:Complete.\n" MSG.Init2.OK >CSTRING "A2osX[Stage2]:Complete.\n"
*-------------------------------------- *--------------------------------------
CPU.Init >LDAXI MSG.CPU CPU.Init >LDAXI MSG.CPU
@ -130,7 +109,7 @@ CPU.Init >LDAXI MSG.CPU
lda MSG.CPUTYPEL,y lda MSG.CPUTYPEL,y
jsr PrintCStrAX jsr PrintCStrAX
CPU.Init.Speed lda MACHID lda MACHID
and #MACHID.TYPE and #MACHID.TYPE
cmp #MACHID.TYPE.IIc cmp #MACHID.TYPE.IIc
beq CPU.Init.Z80 beq CPU.Init.Z80

View File

@ -33,7 +33,7 @@ Kernel.Init3 ldx #DEVMGR.SELECT
>LDYAI TskMgr.Table >LDYAI TskMgr.Table
>STYA pPs >STYA pPs
jmp S.KernelRun rts
.9 >PUSHA .9 >PUSHA
>LDYAI MSG.StartupErr >LDYAI MSG.StartupErr

View File

@ -6,10 +6,8 @@ AUTO 6
.LIST OFF .LIST OFF
*-------------------------------------- *--------------------------------------
* In : * In :
* Y,A = PATH (PSTR) * PULLW/Y,A = PATH (PSTR)
* Out : * Out :
* CC :
* CS : A = EC
*-------------------------------------- *--------------------------------------
S.PFTCHECKPATHSTK S.PFTCHECKPATHSTK
lda (pStack) read PTR.LO on top of stack lda (pStack) read PTR.LO on top of stack
@ -63,34 +61,41 @@ S.PFTCHECKPATHYA
.9 >LDYA ZPQuickPtr1 restore passed params .9 >LDYA ZPQuickPtr1 restore passed params
ldx S.PFT.SYSCALL ldx S.PFT.SYSCALL
>LDYA ZPQuickPtr1
rts rts
*-------------------------------------- *--------------------------------------
* In : * In :
* PUSHB/A = hFILE * PULLB/A = hFILE/hDIR
* Out : * Out :
* CC : Y,A = PTR to S.DIRENT
* CS : A = EC
*-------------------------------------- *--------------------------------------
S.PFTCHECKFILESTK S.PFTCHECKFILESTK
lda (pStack) read hFILE on top of stack lda (pStack) read hFILE on top of stack
S.PFTCHECKFILEA S.PFTCHECKFILEA
S.PFTCHECKDIRA stx S.PFT.SYSCALL save #SYSCALL
sta S.PFT.hFILE
jsr S.GetMemPtrA X = unmidified jsr S.GetMemPtrA X = unmidified
>STYA ZPQuickPtr1
lda (ZPQuickPtr1)
beq .9 Handler is 0, back to kernel....
.8 clc jsr S.GetMemPtrA
rts >STYA .1+1
.9 sec lda S.PFT.SYSCALL getback #SYSCALL
sec
sbc #SYS.FOPEN-4 0=Lib.load, 2=Lib.Unload
tax
pla discard JSR return @
pla
lda S.PFT.hFILE restore passed params
.1 jmp $ffff
.9 lda S.PFT.hFILE
rts rts
*-------------------------------------- *--------------------------------------
* In : S.PFT.hFILE .BS 1
* hDIR
*--------------------------------------
S.PFTCHECKDIRA lda (pStack) read hDIR on top of stack
rts
*--------------------------------------
S.PFT.SYSCALL .BS 1 S.PFT.SYSCALL .BS 1
*-------------------------------------- *--------------------------------------
MAN MAN

View File

@ -19,15 +19,31 @@ ZPQuickPtr2 .EQ ZPKERNEL+2 (could be trashed by any JSR)
ZPQuickPtr3 .EQ ZPKERNEL+4 ZPQuickPtr3 .EQ ZPKERNEL+4
ZPQuickPtr4 .EQ ZPKERNEL+6 ZPQuickPtr4 .EQ ZPKERNEL+6
*-------------------------------------- *--------------------------------------
* Kernel Stage 2 * Kernel Init Stage 2
*-------------------------------------- *--------------------------------------
sei
ldx #$FF init 6502 stack to highest
txs
sta SETALTZP
stx A2osX.SaveSM
stx A2osX.SaveSX
sta CLRALTZP Make sure MAIN ZP is enabled for X.PRINT.F
lda RROMBNK1 Make sure ROM is enabled for X.PRINT.F
cli
jsr Kernel.Init2 jsr Kernel.Init2
>DEBUGOA >DEBUGOA
*-------------------------------------- *--------------------------------------
* Kernel Stage 3 * Kernel Init Stage 3
*-------------------------------------- *--------------------------------------
jsr GO.AUXLC
jsr Kernel.Init3 jsr Kernel.Init3
>DEBUGOA >DEBUGOA
*--------------------------------------
jmp S.KernelRun
*-------------------------------------- *--------------------------------------
.INB X.PRINTF.S .INB X.PRINTF.S
.INB SYS/KERNEL.S.INIT2 .INB SYS/KERNEL.S.INIT2