A2osX/SYS/KERNEL.S.FIO.txt

277 lines
5.3 KiB
Plaintext
Raw Permalink Normal View History

2015-03-14 21:48:35 +00:00
PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
2015-03-14 21:48:35 +00:00
INC 1
AUTO 6
*/--------------------------------------
* # FileSearch
2016-11-01 14:37:28 +00:00
* Search a file in the provided PATH list
* And return, if found, the full path to it.
* ## In:
* PUSHW = Ptr to Search Path (PSTR) %LIB%;/SYS/SLIB
* PUSHW = Ptr to File Name (PSTR)
* ## Out:
2016-11-01 14:37:28 +00:00
* CC : success
* Y,A = PSTR to FilePath (PSTR)
* X = hMem to FilePath
* CS : not found
*\--------------------------------------
2017-01-12 17:43:45 +00:00
K.FileSearch >PULLW ZPPtr4 ZPPtr1 trashed by ExpandPStrYA
>PULLYA Get Search list
>SYSCALL ExpandPStrYA Expand it (SYSCALL to BNK1)
bcs .99
2016-08-17 06:25:58 +00:00
stx .98+1
>STYA ZPPtr3 ZPPtr2 trashed by K.STAT !!! expanded search list ;
2015-06-03 18:30:57 +00:00
2016-09-21 15:20:37 +00:00
stz K.FileSearch.Index
2016-08-17 06:25:58 +00:00
.1 stz KrnBuf256 reset String
2016-08-17 06:25:58 +00:00
ldx #0
2016-06-07 06:10:18 +00:00
2016-09-21 15:20:37 +00:00
ldy K.FileSearch.Index
2016-06-07 06:10:18 +00:00
2016-08-17 06:25:58 +00:00
.2 tya
cmp (ZPPtr3) end of src string ?
2016-08-17 06:25:58 +00:00
beq .3 end of string, try it....
iny
2017-01-12 17:43:45 +00:00
lda (ZPPtr3),y
2016-08-17 06:25:58 +00:00
cmp #';'
beq .3
2016-08-17 06:25:58 +00:00
inx
sta KrnBuf256,x
2016-08-17 06:25:58 +00:00
bra .2
2016-08-17 06:25:58 +00:00
.3 txa
beq .98 String is empty....nothing to try
2016-09-21 15:20:37 +00:00
sty K.FileSearch.Index save current index
2015-06-03 18:30:57 +00:00
2016-08-17 06:25:58 +00:00
ldy #0
2016-06-07 06:10:18 +00:00
2016-08-17 06:25:58 +00:00
.4 iny
lda (ZPPtr4),y Append Fiename...
2016-08-17 06:25:58 +00:00
inx
sta KrnBuf256,x
2016-08-17 06:25:58 +00:00
tya
2017-01-12 17:43:45 +00:00
cmp (ZPPtr4)
2016-08-17 06:25:58 +00:00
bne .4
2015-06-03 18:30:57 +00:00
2016-09-26 16:00:52 +00:00
stx KrnBuf256 set string length
>PUSHWI K.S.STAT
2016-09-26 16:00:52 +00:00
>PUSHWI KrnBuf256
jsr K.STAT
2016-08-17 06:25:58 +00:00
bcs .1 Failed...retry next path...
2015-06-03 18:30:57 +00:00
jsr .98 Discard Expanded hSrch list
bra K.GetFullPathYA.NewStr
.98 lda #$ff SELF MODIFIED : Discard Expanded hSrch list
jsr K.FreeMemA
lda #MLI.ERR.FNOTFND
sec
.99 rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.FileSearch.Index .BS 1
*/--------------------------------------
* # GetFullPathYA
* ## In :
* Y,A = Filename (PSTR)
* ## Out :
2016-11-01 14:37:28 +00:00
* CC : success
* Y,A = FullPath (PSTR)
* X = hMem of FullPath
* CS : A = Error Code
*\--------------------------------------
2017-01-12 17:43:45 +00:00
K.GetFullPathYA >STYA ZPPtr3 Ptr1 & 2 used by StrCpy
lda (ZPPtr3)
beq K.GetFullPathYA.9
2016-08-17 06:25:58 +00:00
stz KrnBuf256
2016-08-17 06:25:58 +00:00
ldy #1
2017-01-12 17:43:45 +00:00
lda (ZPPtr3),y
2016-08-17 06:25:58 +00:00
cmp #'/' full path starting with '/'?
beq .1 yes, do not append to current prefix
ldy #S.PS.hPREFIX
lda (pPs),y
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
2016-08-17 06:25:58 +00:00
>PUSHYA
>PUSHWI KrnBuf256
>SYSCALL PStrCpy
2016-08-17 06:25:58 +00:00
2017-01-12 17:43:45 +00:00
.1 >PUSHW ZPPtr3
>PUSHWI KrnBuf256
>SYSCALL PStrCat
K.GetFullPathYA.NewStr
>LDYAI KrnBuf256
>SYSCALL NewPStrYA
rts
K.GetFullPathYA.9
sec
2016-08-17 06:25:58 +00:00
rts
*/--------------------------------------
* # LoadFile
* ## In:
* PUSHW = AUXTYPE (Handled by....
* PUSHB = TYPE ...
* PUSHB = MODE ...
2017-01-12 17:43:45 +00:00
* PUSHW = PATH ...FOpen)
* ## Out:
* Y,A = File Length
* X = hMem of Loaded File
*\--------------------------------------
K.LoadFile lda (pStack) read PTR.LO on top of stack
pha
ldy #1
lda (pStack),y read PTR.HI on top of stack
pha
>PUSHWI K.S.STAT
pla
ply
>PUSHYA
jsr K.Stat
bcs .10
lda K.S.STAT+S.STAT.SIZE+3
ora K.S.STAT+S.STAT.SIZE+2
bne .11
>LDYA K.S.STAT+S.STAT.SIZE push len
jsr K.GetMemYA
bcs .10
2016-09-21 15:20:37 +00:00
>STYA K.LoadFile.Mem
stx K.LoadFile.hMem
jsr K.FOpen
bcs .9
sta K.LoadFile.hFile
2016-09-21 15:20:37 +00:00
>PUSHW K.LoadFile.Mem
>PUSHW K.S.STAT+S.STAT.SIZE
2016-09-21 15:20:37 +00:00
>PUSHB K.LoadFile.hFile
2017-01-12 17:43:45 +00:00
jsr K.FRead
bcs .97
phy
pha Save Bytes read
jsr .99
2016-09-21 15:20:37 +00:00
pla
ply
2016-09-21 15:20:37 +00:00
ldx K.LoadFile.hMem
clc
2016-09-21 15:20:37 +00:00
.9 rts
.11 lda #SYSMGR.ERRFTB
.10 pha
>POP 6
pla
sec
rts
.97 pha
lda K.LoadFile.hMem
jsr K.FreeMemA
pla
2016-09-21 15:20:37 +00:00
.99 pha
2016-09-21 15:20:37 +00:00
lda K.LoadFile.hFile
jsr K.FCloseA
pla
sec
2016-09-21 15:20:37 +00:00
rts
*--------------------------------------
K.LoadFile.hFile .BS 1
K.LoadFile.hMem .BS 1
K.LoadFile.Mem .BS 2
*/--------------------------------------
* # SaveFile
* ## In:
* PUSHW = SrcPtr
* PUSHW = SrcLen
* PUSHW = AUXTYPE (Handled by....
* PUSHB = TYPE ...
* PUSHB = MODE ...
2017-01-12 17:43:45 +00:00
* PUSHW = PATH ...FOpen)
*\--------------------------------------
2017-01-12 17:43:45 +00:00
K.SaveFile jsr K.FOpen
bcs .9
sta .90+1
>PUSHA
2017-01-12 17:43:45 +00:00
jsr K.FWrite
bcs .99
jsr .99
clc
rts
.99 pha
.90 lda #$ff
jsr K.FCloseA
pla
sec
rts
.9 pha
>POP 4 Discard SrcPtr & SrcLen
pla
sec
rts
*/--------------------------------------
* # ChTyp
* ## In:
* PUSHB = TYPE
* PUSHW = PATH
*\--------------------------------------
K.ChTyp jsr PFT.CheckPathSTK
>PULLW K.MLI.PARAMS+1
>PULLB .1+1
>MLICALL MLIGETFILEINFO
bcs .9
.1 lda #$ff
sta K.MLI.PARAMS+S.FILEINFO.TYPE
>MLICALL MLISETFILEINFO
.9 rts
*/--------------------------------------
* # ChMod
* ## In:
* PUSHW = MODE
* PUSHW = PATH
*\--------------------------------------
K.ChMod
sec
rts
*/--------------------------------------
* # ChOwn
* ## In:
* PUSHW = UID
* PUSHW = PATH
*\--------------------------------------
K.ChOwn
sec
rts
*/--------------------------------------
* # ChGrp
* ## In:
* PUSHW = GID
* PUSHW = PATH
*\--------------------------------------
K.ChGrp
sec
rts
*--------------------------------------
2015-03-14 21:48:35 +00:00
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.FIO
LOAD /A2OSX.SRC/SYS/KERNEL.S
2015-03-14 21:48:35 +00:00
ASM