A2osX/SYS/KERNEL.S.FS.txt

382 lines
7.0 KiB
Plaintext
Raw Permalink Normal View History

2020-06-30 10:40:19 +00:00
NEW
AUTO 3,1
*--------------------------------------
2023-11-04 14:42:28 +00:00
FS.OPEN.REG >MLICALL MLI.GFINFO
2021-07-03 17:18:58 +00:00
bcs .10
2021-07-24 20:42:23 +00:00
2021-07-03 17:18:58 +00:00
lda IO.Open.TYPE Already Exists
beq .2
2021-07-24 20:42:23 +00:00
2021-07-03 17:18:58 +00:00
cmp K.MLI.PARAMS+S.FI.T
beq .2
2021-07-24 20:42:23 +00:00
2021-07-03 17:18:58 +00:00
lda #MLI.E.INCFF
sec
rts
.10 bit IO.Open.FLAGS Create if not exists ?
2020-08-19 19:39:43 +00:00
bpl .9 No, return MLI error
2020-06-30 14:30:14 +00:00
ldx #2 Yes, Create...
.1 lda IO.Open.TYPE,x
sta K.MLI.PARAMS+4,x File type,Aux type
dex
2020-06-30 10:40:19 +00:00
bpl .1
2020-06-30 14:30:14 +00:00
lda #S.FI.ST.STD
2023-10-18 05:41:12 +00:00
jsr FS.MLICREATE
2020-08-19 19:39:43 +00:00
bcs .9
2020-06-30 10:40:19 +00:00
2021-07-24 20:42:23 +00:00
.2 lda #S.FD.T.REG
2020-12-15 13:23:22 +00:00
jsr DEV.MkFD
2020-08-19 19:39:43 +00:00
bcs .9
2020-06-30 14:30:14 +00:00
2020-12-15 13:23:22 +00:00
jsr FS.MLIOPEN
2021-07-24 20:42:23 +00:00
bcs FS.OPEN.ERR
2020-06-30 14:30:14 +00:00
lda IO.Open.FLAGS
bit #O.WRONLY
2020-12-15 13:23:22 +00:00
beq .5 Write mode ?
2020-06-30 14:30:14 +00:00
and #O.APPEND Append ?
2020-12-15 13:23:22 +00:00
bne .3 yes, go to end of file
2020-06-30 14:30:14 +00:00
stz K.MLI.PARAMS+2
stz K.MLI.PARAMS+3
stz K.MLI.PARAMS+4
2023-11-04 14:42:28 +00:00
>MLICALL MLI.SETEOF no, reset size to 0
2020-12-15 13:23:22 +00:00
bra .4
2020-06-30 14:30:14 +00:00
2023-11-04 14:42:28 +00:00
.3 >MLICALL MLI.GETEOF
2021-07-24 20:42:23 +00:00
bcs FS.OPEN.ERR
2020-06-30 14:30:14 +00:00
2023-11-04 14:42:28 +00:00
>MLICALL MLI.SETMARK
2021-07-24 20:42:23 +00:00
.4 bcs FS.OPEN.ERR
2020-06-30 14:30:14 +00:00
2020-12-15 13:23:22 +00:00
.5 lda IO.Open.FLAGS
2020-06-30 14:30:14 +00:00
and #O.TEXT Text Mode ?
2021-07-24 20:42:23 +00:00
beq .8
2020-06-30 14:30:14 +00:00
lda #$FF
sta K.MLI.PARAMS+2
lda #C.CR
sta K.MLI.PARAMS+3
2023-11-04 14:42:28 +00:00
>MLICALL MLI.NEWLINE
2021-07-24 20:42:23 +00:00
bcs FS.OPEN.ERR
2020-12-15 13:23:22 +00:00
2021-07-24 20:42:23 +00:00
.8 lda IO.hFD
* clc
2020-12-15 13:23:22 +00:00
.9 rts
2020-06-30 14:30:14 +00:00
*--------------------------------------
2021-07-24 20:42:23 +00:00
FS.OPEN.ERR pha Save Error Code
jsr FS.MLICLOSE
2021-08-05 11:35:37 +00:00
2021-07-24 20:42:23 +00:00
pla
sec
rts
*--------------------------------------
FS.OPEN.DIR lda #S.FD.T.DIR
2020-12-15 13:23:22 +00:00
jsr DEV.MkFD
bcs .9
2020-06-30 14:30:14 +00:00
2020-12-15 13:23:22 +00:00
lda K.MLI.PATH+2
beq .8 "/"
2020-06-30 14:30:14 +00:00
2023-11-04 14:42:28 +00:00
>MLICALL MLI.GFINFO
2020-06-30 14:30:14 +00:00
bcs .9
2021-07-24 20:42:23 +00:00
2020-12-15 13:23:22 +00:00
lda K.MLI.PARAMS+S.FI.T
cmp #S.FI.T.DIR
bne .99
2021-07-24 20:42:23 +00:00
2020-12-15 13:23:22 +00:00
jsr FS.MLIOPEN
2021-07-24 20:42:23 +00:00
bcs FS.OPEN.ERR
.8 lda IO.hFD
* clc
2020-09-07 20:40:50 +00:00
rts
2021-07-24 20:42:23 +00:00
2020-12-15 13:23:22 +00:00
.99 lda #MLI.E.UNSUPST
sec
.9 rts
2020-06-30 14:30:14 +00:00
*--------------------------------------
2023-11-04 14:42:28 +00:00
FS.READ.REG ldx #MLI.READ
2020-12-15 13:23:22 +00:00
.HS 2C BIT ABS
*--------------------------------------
2023-11-04 14:42:28 +00:00
FS.WRITE.REG ldx #MLI.WRITE
2020-12-15 13:23:22 +00:00
ldy #S.FD.REG.REF
lda (pFD),y
sta K.MLI.PARAMS+1
>PULLW K.MLI.PARAMS+4
2021-05-14 20:58:20 +00:00
>PULLW K.MLI.PARAMS+2
2021-07-24 20:42:23 +00:00
2020-12-15 13:23:22 +00:00
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
jsr GP.MLICall
bcs .9
2021-05-14 20:58:20 +00:00
2020-12-15 13:23:22 +00:00
>LDYA K.MLI.PARAMS+6
2021-05-14 20:58:20 +00:00
.9 inc pStack
rts
2020-06-30 14:30:14 +00:00
*--------------------------------------
2023-11-04 14:42:28 +00:00
FS.EOF.REG >MLICALL MLI.GETMARK
2020-06-30 14:30:14 +00:00
bcs .9
2023-10-18 05:41:12 +00:00
2020-06-30 14:30:14 +00:00
ldy #2
2023-10-18 05:41:12 +00:00
2020-06-30 14:30:14 +00:00
.1 lda K.MLI.PARAMS+2,y
sta ACC32,y
dey
bpl .1
2023-11-04 14:42:28 +00:00
>MLICALL MLI.GETEOF
2020-06-30 14:30:14 +00:00
bcs .9
ldy #2
2023-10-18 05:41:12 +00:00
2020-06-30 14:30:14 +00:00
.2 lda K.MLI.PARAMS+2,y
eor ACC32,y
bne .8 FALSE
2023-10-18 05:41:12 +00:00
2020-06-30 14:30:14 +00:00
dey
bpl .2
2023-10-18 05:41:12 +00:00
2020-06-30 14:30:14 +00:00
lda #$ff TRUE
* clc
rts
.8 lda #0
* clc
.9 rts
*--------------------------------------
2023-10-18 05:41:12 +00:00
FS.CLOSE jsr FS.MLICLOSE
bcs FS.RTS
jmp DEV.FreeFD
*--------------------------------------
FS.MLICREATE sta K.MLI.PARAMS+7 Storage Type
2020-06-30 14:30:14 +00:00
ldx #3
2020-12-15 13:23:22 +00:00
2023-11-04 14:42:28 +00:00
.1 lda GP.DATE,x
2020-06-30 14:30:14 +00:00
sta K.MLI.PARAMS+8,x Create Date/Time
2020-06-30 10:40:19 +00:00
dex
2020-06-30 14:30:14 +00:00
bpl .1
2020-06-30 10:40:19 +00:00
2020-06-30 14:30:14 +00:00
lda #S.FI.A.FULL
sta K.MLI.PARAMS+3 Access
2023-11-04 14:42:28 +00:00
>MLICALL MLI.CREATE
2020-06-30 14:30:14 +00:00
rts
*--------------------------------------
2020-12-15 13:23:22 +00:00
FS.MLIOPEN >LDYAI 1024 get a ProDOS IOBUF
2020-06-30 14:30:14 +00:00
ldx #S.MEM.F.ALIGN
jsr MEM.GetMem.YAX
2023-10-18 05:41:12 +00:00
bcs FS.RTS
2020-06-30 14:30:14 +00:00
>STYA K.MLI.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
txa
ldy #S.FD.REG.IOBUF
sta (pFD),y
2023-11-04 14:42:28 +00:00
>MLICALL MLI.OPEN
2023-10-18 05:41:12 +00:00
bcs FS.RTS
2020-12-15 13:23:22 +00:00
2020-06-30 14:30:14 +00:00
lda K.MLI.PARAMS+5 get ref_num
ldy #S.FD.REG.REF
sta (pFD),y
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
* clc
2020-08-19 19:39:43 +00:00
2021-05-04 17:31:21 +00:00
FS.RTS rts
2020-08-18 19:56:50 +00:00
*--------------------------------------
FS.MLICLOSE ldy #S.FD.REG.REF
lda (pFD),y
beq .1
sta K.MLI.PARAMS+1
2023-11-04 14:42:28 +00:00
>MLICALL MLI.CLOSE
2023-10-18 05:41:12 +00:00
bcs FS.RTS
.1 ldy #S.FD.REG.IOBUF
lda (pFD),y
beq .8
jmp K.FreeMem
.8 clc
rts
*--------------------------------------
2020-11-19 15:34:02 +00:00
FS.Stat bit A2osX.FSID
2020-07-22 15:51:03 +00:00
bmi FS.Stat.FX
2020-12-15 13:23:22 +00:00
2023-11-04 14:42:28 +00:00
FS.Stat.203 >MLICALL MLI.GFINFO
2021-05-04 17:31:21 +00:00
bcs FS.RTS
2020-07-10 13:59:56 +00:00
2020-07-16 14:53:35 +00:00
jsr FS.ClrStat
2020-12-15 13:23:22 +00:00
2020-07-13 19:29:31 +00:00
lda K.MLI.PARAMS+S.FI.T
cmp #S.FI.T.DIR
bne .1
2020-12-15 13:23:22 +00:00
2020-07-13 19:29:31 +00:00
lda /S.STAT.MODE.DIR
sta K.S.STAT+S.STAT.MODE+1
2020-12-15 13:23:22 +00:00
2020-07-13 19:29:31 +00:00
.1 lda K.MLI.PARAMS+S.FI.A
2020-07-29 15:29:54 +00:00
sta K.S.STAT+S.STAT.P.ACCESS
2020-07-10 13:59:56 +00:00
2020-07-13 19:29:31 +00:00
ldx #FS.GFI.Cnt
2020-07-10 13:59:56 +00:00
2020-07-13 19:29:31 +00:00
.3 ldy FS.GFI.Src-1,x
2020-07-10 13:59:56 +00:00
lda K.MLI.PARAMS,y
2020-07-13 19:29:31 +00:00
ldy FS.Stat.Dst-1,x
2020-07-10 13:59:56 +00:00
sta K.S.STAT,y
dex
bne .3
2020-12-15 13:23:22 +00:00
2020-07-10 13:59:56 +00:00
>LDYAI K.MLI.PARAMS+S.FI.CDATE
ldx #K.S.STAT+S.STAT.CTIME
2020-08-19 19:39:43 +00:00
jsr FS.PTime2StatYAX
2020-07-10 13:59:56 +00:00
>LDYAI K.MLI.PARAMS+S.FI.MDATE
ldx #K.S.STAT+S.STAT.MTIME
2020-08-19 19:39:43 +00:00
jmp FS.PTime2StatYAX
2020-06-30 10:40:19 +00:00
*--------------------------------------
2023-11-04 14:42:28 +00:00
FS.Stat.FX >MLICALL MLI.GFINFOEX
2020-08-23 19:46:37 +00:00
bcc .1
2020-12-15 13:23:22 +00:00
2020-08-23 19:46:37 +00:00
cmp #MLI.E.BADCALL
beq FS.Stat.203 Apple WS CARD
rts
2020-12-15 13:23:22 +00:00
2020-08-23 19:46:37 +00:00
.1 >LDYAI K.MLI.PARAMS+3
2020-07-13 19:29:31 +00:00
>STYA ZPPtr3
*--------------------------------------
2020-07-16 14:53:35 +00:00
FS.DirEnt2Stat jsr FS.ClrStat
2020-06-30 10:40:19 +00:00
2021-04-08 20:30:18 +00:00
ldx #FS.DirEnt.Cnt
2020-06-30 10:40:19 +00:00
2021-04-08 20:30:18 +00:00
.1 ldy FS.DirEnt.Src-1,x
2020-06-30 10:40:19 +00:00
lda (ZPPtr3),y
2020-07-13 19:29:31 +00:00
ldy FS.Stat.Dst-1,x
2020-06-30 10:40:19 +00:00
sta K.S.STAT,y
dex
2021-04-08 20:30:18 +00:00
bne .1
2020-06-30 14:30:14 +00:00
2020-07-29 15:29:54 +00:00
ldy #S.FIEX.ACCESS
lda (ZPPtr3),y
sta K.S.STAT+S.STAT.P.ACCESS
2020-12-15 13:23:22 +00:00
2021-04-08 20:30:18 +00:00
lda (ZPPtr3)
and #$F0
cmp #$D0 Dir Hdr or Dir ?
bcc .3
cmp #$F0 Vol Hdr ?
bne .2
stz K.S.STAT+S.STAT.SIZE
ldy #S.FIEX.AUXTYPE
lda (ZPPtr3),y
sta K.S.STAT+S.STAT.BLOCKS
2021-07-24 20:42:23 +00:00
asl
2021-04-08 20:30:18 +00:00
sta K.S.STAT+S.STAT.SIZE+1
iny
lda (ZPPtr3),y
sta K.S.STAT+S.STAT.BLOCKS+1
2021-07-24 20:42:23 +00:00
rol
2021-04-08 20:30:18 +00:00
sta K.S.STAT+S.STAT.SIZE+2
2021-07-24 20:42:23 +00:00
2021-04-08 20:30:18 +00:00
lda #0
rol K.S.STAT+S.STAT.SIZE+3
.2 lda /S.STAT.MODE.DIR
tsb K.S.STAT+S.STAT.MODE+1
.3 ldy #S.FIEX.ACL
2020-06-30 10:40:19 +00:00
lda (ZPPtr3),y
2020-07-13 19:29:31 +00:00
cmp #$57
bne .7
2020-06-30 10:40:19 +00:00
2022-10-20 15:43:19 +00:00
iny
lda (ZPPtr3),y
bne .7
2020-07-13 19:29:31 +00:00
ldy #S.FIEX.ACL.UID
lda (ZPPtr3),y
sta K.S.STAT+S.STAT.UID
2020-06-30 10:40:19 +00:00
2020-07-13 19:29:31 +00:00
ldy #S.FIEX.ACL.GID
lda (ZPPtr3),y
sta K.S.STAT+S.STAT.GID
2020-12-15 13:23:22 +00:00
2020-07-13 19:29:31 +00:00
ldy #S.FIEX.ACL.MOD
lda (ZPPtr3),y
tsb K.S.STAT+S.STAT.MODE
iny
lda (ZPPtr3),y
tsb K.S.STAT+S.STAT.MODE+1
2020-12-15 13:23:22 +00:00
2020-07-13 19:29:31 +00:00
.7 lda #S.FIEX.CTIME
2020-06-30 10:40:19 +00:00
ldx #K.S.STAT+S.STAT.CTIME
2020-08-19 19:39:43 +00:00
jsr FS.PTime2StatAX
2020-06-30 10:40:19 +00:00
2020-07-13 19:29:31 +00:00
lda #S.FIEX.MTIME
2020-06-30 10:40:19 +00:00
ldx #K.S.STAT+S.STAT.MTIME
2021-04-08 20:30:18 +00:00
* jmp FS.PTime2StatAX
2020-06-30 10:40:19 +00:00
*--------------------------------------
2020-08-19 19:39:43 +00:00
FS.PTime2StatAX clc
2020-06-30 10:40:19 +00:00
adc ZPPtr3
tay
lda ZPPtr3+1
adc #0
2020-08-19 19:39:43 +00:00
FS.PTime2StatYAX
2020-06-30 10:40:19 +00:00
>PUSHYA
>PUSHB /K.S.STAT
txa
>PUSHA
>SYSCALL2 PTime2Time
2020-10-31 10:33:29 +00:00
clc ignore bad date error
2020-06-30 10:40:19 +00:00
rts
*--------------------------------------
2021-04-08 20:30:18 +00:00
FS.ClrStat ldx #S.STAT-1
.1 stz K.S.STAT,x
dex
bpl .1
lda A2osX.FSID
sta K.S.STAT+S.STAT.FSID
lda #2
sta K.S.STAT+S.STAT.BLKSIZE+1 = 512 bytes
2021-04-08 20:30:18 +00:00
rts
*--------------------------------------
2020-07-13 19:29:31 +00:00
FS.GFI.Src .DA #S.FI.T,#S.FI.AUXTYPE,#S.FI.AUXTYPE+1
2020-06-30 10:40:19 +00:00
.DA #S.FI.UBLKS,#S.FI.UBLKS+1
2020-07-13 19:29:31 +00:00
FS.GFI.Cnt .EQ *-FS.GFI.Src
2020-06-30 10:40:19 +00:00
*--------------------------------------
FS.DirEnt.Src .DA #S.FIEX.TYPE,#S.FIEX.AUXTYPE,#S.FIEX.AUXTYPE+1
2020-07-13 19:29:31 +00:00
.DA #S.FIEX.BLKUSED,#S.FIEX.BLKUSED+1
.DA #S.FIEX.EOF,#S.FIEX.EOF+1,#S.FIEX.EOF+2
FS.DirEnt.Cnt .EQ *-FS.DirEnt.Src
2020-06-30 10:40:19 +00:00
*--------------------------------------
2020-07-13 19:29:31 +00:00
FS.Stat.Dst .DA #S.STAT.P.TYPE,#S.STAT.P.AUXTYPE,#S.STAT.P.AUXTYPE+1
2020-06-30 10:40:19 +00:00
.DA #S.STAT.BLOCKS,#S.STAT.BLOCKS+1
.DA #S.STAT.SIZE,#S.STAT.SIZE+1,#S.STAT.SIZE+2
*--------------------------------------
MAN
SAVE usr/src/sys/kernel.s.fs
LOAD usr/src/sys/kernel.s
ASM