mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 17:50:18 +00:00
Kernel : Implementing new FILE API with Path Filtering
This commit is contained in:
parent
5251ba0527
commit
92c1b3cb49
@ -269,6 +269,12 @@ SYS.DecOutYA .EQ $DE
|
||||
*SYS.FPUTS .EQ $F6
|
||||
*--------------------------------------
|
||||
SYS.FOPEN .EQ $E0
|
||||
SYS.FOPEN.R .EQ $01 Open For Read
|
||||
SYS.FOPEN.W .EQ $02 Open For Write
|
||||
SYS.FOPEN.A .EQ $04 Append
|
||||
SYS.FOPEN.T .EQ $08 Open/Append in Text mode
|
||||
SYS.FOPEN.X .EQ $80 Create if not exists
|
||||
|
||||
SYS.FCLOSE .EQ $E2
|
||||
SYS.FREAD .EQ $E4
|
||||
SYS.FWRITE .EQ $E6
|
||||
@ -284,7 +290,7 @@ SYS.OPENDIRYA .EQ $F4
|
||||
SYS.READDIRYA .EQ $F6
|
||||
|
||||
SYS.CLOSEDIRYA .EQ $F8
|
||||
SYS.MKDIR .EQ $FA
|
||||
SYS.MKDIRYA .EQ $FA
|
||||
SYS.MKNOD .EQ $FC
|
||||
SYS.MKFIFO .EQ $FE
|
||||
*--------------------------------------
|
||||
@ -544,7 +550,10 @@ S.FILE.TYPE.LNK .EQ 5
|
||||
S.FILE.TYPE.SOCK .EQ 6
|
||||
S.FILE.TYPE.FIFO .EQ 7
|
||||
|
||||
S.FILE.DATA .EQ 16 64 byte opaque data (for NFSv3)
|
||||
S.FILE.PRODOS.REF .EQ 2
|
||||
S.FILE.PRODOS.IOBUF .EQ 3
|
||||
*
|
||||
S.FILE.PRODOS .EQ 4
|
||||
*
|
||||
* no S.FILE,Variable size
|
||||
*--------------------------------------
|
||||
@ -552,18 +561,21 @@ S.FILE.DATA .EQ 16 64 byte opaque data (for NFSv3)
|
||||
*--------------------------------------
|
||||
S.DIR.HANDLER .EQ 0
|
||||
S.DIR.INO .EQ 1
|
||||
S.DIR.PATH .EQ 2
|
||||
*
|
||||
S.DIR.PATH .EQ 2 PSTR
|
||||
* no S.DIR
|
||||
*--------------------------------------
|
||||
* S.DIRENT for ReadDir
|
||||
*--------------------------------------
|
||||
S.DIRENT
|
||||
S.DIRENT.STAT .EQ 0
|
||||
S.DIRENT.NAME .EQ S.STAT
|
||||
S.DIRENT
|
||||
S.DIRENT.NAME .EQ S.STAT PSTR
|
||||
* no S.DIRENT,Variable size
|
||||
*--------------------------------------
|
||||
S.PFILTER
|
||||
S.PFT.PATH .EQ 0
|
||||
S.PFT.HANDLER .EQ 23
|
||||
S.PFT.DATA .EQ 24 8 bytes OPAQUE data for handler
|
||||
*
|
||||
S.PFT .EQ 32
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE INC/A2OSX.I
|
||||
|
167
SYS/KERNEL.S.FIL.txt
Normal file
167
SYS/KERNEL.S.FIL.txt
Normal file
@ -0,0 +1,167 @@
|
||||
PR#3
|
||||
PREFIX /A2OSX.SRC
|
||||
NEW
|
||||
INC 1
|
||||
AUTO 6
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
* For All SYS.xxxx calls, X = #SYSCall
|
||||
* Must be kept in X before calling
|
||||
* S.PFTCheckPathXX
|
||||
*--------------------------------------
|
||||
* S.FOPEN
|
||||
* In :
|
||||
* PULLW = PATH (PSTR)
|
||||
* PULLB = MODE
|
||||
* Out :
|
||||
* CC : A = hFILE
|
||||
* CS : A = EC
|
||||
*--------------------------------------
|
||||
S.FOPEN jsr S.PFTCHECKPATHSTK
|
||||
>PULLW MLICALL.PARAMS+1
|
||||
>PULLB S.FOPEN.MODE
|
||||
|
||||
>PUSHWI S.FILE.PRODOS
|
||||
>PUSHBI S.MEM.F.INIT0
|
||||
jsr S.GetMem
|
||||
bcs .99
|
||||
>STYA ZPQuickPtr1
|
||||
stx hFILE
|
||||
|
||||
>PUSHWI 1024 get a ProDOS IOBUF
|
||||
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
|
||||
jsr S.GetMem
|
||||
bcs .99
|
||||
|
||||
>STYA MLICALL.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
|
||||
txa
|
||||
ldy #S.FILE.PRODOS.IOBUF
|
||||
sta (ZPQuickPtr1),y
|
||||
|
||||
>MLICALL MLIOPEN
|
||||
bcc .1 Failed...
|
||||
bit S.FOPEN.MODE Create if not exists?
|
||||
bpl .98 no....error
|
||||
|
||||
|
||||
.1 lda MLICALL.PARAMS+5 get ref_num
|
||||
ldy #S.FILE.PRODOS.REF
|
||||
sta (ZPQuickPtr1),y
|
||||
|
||||
lda S.FOPEN.MODE
|
||||
bit #SYS.FOPEN.A
|
||||
beq .1
|
||||
|
||||
|
||||
|
||||
|
||||
.1
|
||||
lda hFILE
|
||||
clc
|
||||
rts CC
|
||||
|
||||
.98 pha save MLI error
|
||||
jsr S.FCLOSEA.1
|
||||
pla get back MLI error
|
||||
sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
S.FOPEN.MODE .BS 1
|
||||
hFILE .BS 1
|
||||
*--------------------------------------
|
||||
* S.FCLOSEA
|
||||
* In :
|
||||
* A = hFILE
|
||||
*--------------------------------------
|
||||
S.FCLOSEA jsr S.PFTCHECKFILEA
|
||||
jsr S.GetMemPtrA
|
||||
>STYA ZPQuickPtr1
|
||||
|
||||
S.FCLOSEA.1 ldy #S.FILE.PRODOS.REF
|
||||
lda (ZPQuickPtr1),y
|
||||
beq .1
|
||||
sta MLICALL.PARAMS+1
|
||||
>MLICALL MLICLOSE
|
||||
|
||||
.1 ldy #S.FILE.PRODOS.IOBUF
|
||||
lda (ZPQuickPtr1),y
|
||||
beq .2
|
||||
jsr S.FreeMemA
|
||||
|
||||
.2 lda hFILE
|
||||
jsr S.FreeMemA
|
||||
rts
|
||||
*--------------------------------------
|
||||
* S.FREAD
|
||||
* In :
|
||||
* PULLB = hFILE
|
||||
* PULLW = Bytes To Read
|
||||
* PULLW = Dest Ptr
|
||||
* Out :
|
||||
* Y,A = Bytes Read
|
||||
*--------------------------------------
|
||||
S.FREAD jsr S.PFTCHECKFILESTK
|
||||
>PULLB MLICALL.PARAMS+1
|
||||
>PULLW MLICALL.PARAMS+4
|
||||
>PULLW MLICALL.PARAMS+2
|
||||
>MLICALL MLIREAD
|
||||
bcs .9
|
||||
>LDYA MLICALL.PARAMS+6
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
* S.FWRITE
|
||||
* In :
|
||||
* PULLB = hFILE
|
||||
* PULLW = Bytes To Write
|
||||
* PULLW = Src Ptr
|
||||
* Out :
|
||||
* Y,A = Bytes Written
|
||||
*--------------------------------------
|
||||
S.FWRITE jsr S.PFTCHECKFILESTK
|
||||
>PULLB MLICALL.PARAMS+1
|
||||
>PULLW MLICALL.PARAMS+4
|
||||
>PULLW MLICALL.PARAMS+2
|
||||
>MLICALL MLIWRITE
|
||||
bcs .9
|
||||
>LDYA MLICALL.PARAMS+6
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
* S.FFLUSHA
|
||||
* In :
|
||||
* A = hFILE
|
||||
*--------------------------------------
|
||||
S.FFLUSHA jsr S.PFTCHECKFILEA
|
||||
sta MLICALL.PARAMS+1
|
||||
>MLICALL MLIFLUSH
|
||||
rts
|
||||
*--------------------------------------
|
||||
*--------------------------------------
|
||||
S.FSEEK
|
||||
*--------------------------------------
|
||||
*--------------------------------------
|
||||
S.FTELL
|
||||
*--------------------------------------
|
||||
*--------------------------------------
|
||||
S.FEOF
|
||||
*--------------------------------------
|
||||
*--------------------------------------
|
||||
S.REMOVE
|
||||
*--------------------------------------
|
||||
*--------------------------------------
|
||||
S.RENAME
|
||||
*--------------------------------------
|
||||
S.MKDIRYA jsr S.PFTCHECKPATHYA
|
||||
>STYA MLICALL.PARAMS+1
|
||||
lda #$C3
|
||||
sta MLICALL.PARAMS+3 Access
|
||||
lda #$0F
|
||||
sta MLICALL.PARAMS+4 type=Directory
|
||||
lda #$0D Storage=Linked List
|
||||
sta MLICALL.PARAMS+7
|
||||
>MLICALL MLICREATE
|
||||
rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE SYS/KERNEL.S.FIL
|
||||
LOAD SYS/KERNEL.S
|
||||
ASM
|
@ -11,8 +11,14 @@ AUTO 6
|
||||
* CC :
|
||||
* CS : A = EC
|
||||
*--------------------------------------
|
||||
S.PFTCHECKPATHSTK
|
||||
lda (pStack) read PTR.LO on top of stack
|
||||
pha
|
||||
ldy #1
|
||||
lda (pStack),y read PTR.HI on top of stack
|
||||
ply
|
||||
S.PFTCHECKPATHYA
|
||||
phx save #SYSCALL
|
||||
stx S.PFT.SYSCALL save #SYSCALL
|
||||
>STYA ZPQuickPtr1
|
||||
|
||||
>LDYA FltMgr.Table
|
||||
@ -31,15 +37,16 @@ S.PFTCHECKPATHYA
|
||||
dey
|
||||
bne .2
|
||||
|
||||
lda (ZPQuickPtr2) get len again
|
||||
tay
|
||||
iny
|
||||
ldy #S.S.PFT.HANDLER
|
||||
lda (ZPQuickPtr2),y get hLib
|
||||
jsr S.GetMemPtrA
|
||||
>STYA .3+1
|
||||
|
||||
pla getback #SYSCALL
|
||||
|
||||
lda S.PFT.SYSCALL getback #SYSCALL
|
||||
sec
|
||||
sbc #SYS.FOPEN-4 0=Lib.load, 2=Lib.Unload
|
||||
tax
|
||||
|
||||
pla discard JSR return @
|
||||
pla
|
||||
|
||||
@ -50,21 +57,24 @@ S.PFTCHECKPATHYA
|
||||
.8 lda ZPQuickPtr2
|
||||
clc
|
||||
adc (ZPQuickPtr2) Add STR len
|
||||
adc #2 skip hMem & XOffset
|
||||
adc #S.PFT
|
||||
sta ZPQuickPtr2
|
||||
bcc .1 always
|
||||
bcc .1
|
||||
|
||||
|
||||
.9 plx restore X from Stack
|
||||
.9 >LDYA ZPQuickPtr1 restore passed params
|
||||
ldx S.PFT.SYSCALL
|
||||
rts
|
||||
*--------------------------------------
|
||||
* In :
|
||||
* Y,A = PTR to S.DIR
|
||||
* PUSHB/A = hFILE
|
||||
* Out :
|
||||
* CC : Y,A = PTR to S.DIRENT
|
||||
* CS : A = EC
|
||||
*--------------------------------------
|
||||
S.PFTCHECKFILEYA
|
||||
S.PFTCHECKFILESTK
|
||||
lda (pStack) read hFILE on top of stack
|
||||
S.PFTCHECKFILEA
|
||||
jsr GetMemPtrA X = unmidified
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
@ -73,14 +83,14 @@ S.PFTCHECKFILEYA
|
||||
rts
|
||||
*--------------------------------------
|
||||
* In :
|
||||
* Y,A = PTR to S.FILE
|
||||
* hDIR
|
||||
*--------------------------------------
|
||||
S.PFTCHECKDIRYA
|
||||
S.PFTCHECKDIRA lda (pStack) read hDIR on top of stack
|
||||
|
||||
rts
|
||||
|
||||
*--------------------------------------
|
||||
|
||||
S.PFT.SYSCALL .BS 1
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE SYS/KERNEL.S.PFT
|
||||
|
Loading…
Reference in New Issue
Block a user