A2osX/SYS/KERNEL.S.STAT.txt

463 lines
9.1 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2019-04-19 05:42:43 +00:00
AUTO 3,1
2020-02-14 16:32:52 +00:00
*/--------------------------------------
* # ChTyp
* Change The type of a ProDOS File
* ## C
* `int chtyp(const char *filepath, short int filetype);`
* ## ASM
* `>PUSHW filepath`
* `>PUSHB filetype`
* `>SYSCALL chtyp`
* ## RETURN VALUE
*\--------------------------------------
2020-03-10 16:42:07 +00:00
K.ChTyp jsr PFT.CheckPath1
bcs .9
2020-02-14 16:32:52 +00:00
>MLICALL MLIGETFILEINFO
bcs .9
2020-03-10 16:42:07 +00:00
lda (pStack)
2020-02-14 16:32:52 +00:00
sta K.MLI.PARAMS+S.FI.T
>MLICALL MLISETFILEINFO
2020-03-10 16:42:07 +00:00
.9 >RET 3
2019-04-19 05:42:43 +00:00
*--------------------------------------
* # ChMod
* change permissions of a file
* ## C
* `int chmod(const char *pathname, int mode);`
* ## ASM
2020-02-14 07:21:56 +00:00
* `>PUSHW pathname`
2019-04-19 05:42:43 +00:00
* `>PUSHW mode`
* `>SYSCALL chmod`
2019-01-30 06:20:13 +00:00
* ## RETURN VALUE
2019-04-19 05:42:43 +00:00
*--------------------------------------
* only 777-555
*--------------------------------------
2020-02-14 07:21:56 +00:00
K.ChMod jsr PFT.CheckPath2
bcs K.ChMod.RET4
2019-01-30 06:20:13 +00:00
2020-03-10 16:42:07 +00:00
jsr STAT.PullPathAndMode
2020-02-14 07:21:56 +00:00
2019-04-19 05:42:43 +00:00
lda K.S.STAT+S.STAT.MODE+1
and /S.STAT.MODE.RU
beq .9
2020-03-10 16:42:07 +00:00
2019-04-19 05:42:43 +00:00
lda K.S.STAT+S.STAT.MODE
and #S.STAT.MODE.XO+S.STAT.MODE.RO+S.STAT.MODE.XG+S.STAT.MODE.RG+S.STAT.MODE.XU+S.STAT.MODE.RU
cmp #S.STAT.MODE.XO+S.STAT.MODE.RO+S.STAT.MODE.XG+S.STAT.MODE.RG+S.STAT.MODE.XU+S.STAT.MODE.RU
bne .9
2020-03-10 16:42:07 +00:00
2019-04-19 05:42:43 +00:00
>MLICALL MLIGETFILEINFO
bcs .90
2020-03-10 16:42:07 +00:00
2019-04-19 05:42:43 +00:00
lda K.MLI.PARAMS+S.FI.A
and #$3D not S.FI.A.RN+S.FI.A.D+S.FI.A.W
ora #S.FI.A.R
tax
lda K.S.STAT+S.STAT.MODE
tay
bit #S.STAT.MODE.WG
beq .1
txa
ora #S.FI.A.RN
tax
tya
2020-03-10 16:42:07 +00:00
2019-04-19 05:42:43 +00:00
.1 bit #S.STAT.MODE.WU
beq .2
2020-03-10 16:42:07 +00:00
2019-04-19 05:42:43 +00:00
txa
ora #S.FI.A.D
tax
tya
2020-03-10 16:42:07 +00:00
2019-04-19 05:42:43 +00:00
.2 bit #S.STAT.MODE.WO
beq .3
2020-03-10 16:42:07 +00:00
2019-04-19 05:42:43 +00:00
txa
ora #S.FI.A.W
tax
.3 stx K.MLI.PARAMS+S.FI.A
2019-01-30 06:20:13 +00:00
2019-04-19 05:42:43 +00:00
>MLICALL MLISETFILEINFO
2019-01-30 06:20:13 +00:00
rts
2020-03-10 16:42:07 +00:00
2019-04-19 05:42:43 +00:00
.9 lda #E.SYN
sec
.90 rts
2020-03-10 16:42:07 +00:00
2020-02-14 07:21:56 +00:00
K.ChMod.RET4 >RET 4 discard statbuf
*--------------------------------------
* # FStat
2018-10-04 15:30:14 +00:00
* Return information about a hFILE
2018-08-08 15:13:37 +00:00
* ## C
* `int fstat(short int hFILE, struct stat *statbuf);`
2018-07-20 11:51:08 +00:00
* ## ASM
2020-02-14 07:21:56 +00:00
* `>PUSHB hFILE`
2018-08-08 15:13:37 +00:00
* `>PUSHW statbuf`
* `>SYSCALL fstat`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
*--------------------------------------
2020-02-14 07:21:56 +00:00
K.FStat >PULLW K.Stat.Store.2+1
>PULLA
jsr PFT.CheckNodeA
bcs K.Stat.Store.RTS
2019-12-02 07:09:58 +00:00
2018-11-16 16:04:20 +00:00
tax
2019-02-27 15:00:56 +00:00
lda OF.Table.hPath-1,x
2018-10-04 15:30:14 +00:00
jsr K.GetMemPtr
2018-11-16 16:04:20 +00:00
jsr PFT.YAToMLIPATH
2019-12-02 07:09:58 +00:00
jsr SHARED.Stat.I
bcs K.Stat.Store.RTS
2018-11-16 16:04:20 +00:00
lda (pFD) #S.FD.T
2019-12-02 07:09:58 +00:00
bne K.Stat.Store
2018-11-16 16:04:20 +00:00
ldy #S.FD.REG.REF
lda (pFD),y
sta K.MLI.PARAMS+1
2018-11-07 16:11:02 +00:00
>MLICALL MLIGETEOF
2019-12-02 07:09:58 +00:00
bcs K.Stat.Store.RTS
2018-11-07 16:11:02 +00:00
ldx #2
2019-12-02 07:09:58 +00:00
2018-11-07 16:11:02 +00:00
.1 lda K.MLI.PARAMS+2,x
2019-12-02 07:09:58 +00:00
sta K.S.STAT+S.STAT.SIZE,x
2018-11-07 16:11:02 +00:00
dex
bpl .1
2019-12-02 07:09:58 +00:00
K.Stat.Store ldy #S.STAT-1
K.Stat.Store.1 lda K.S.STAT,y
K.Stat.Store.2 sta $ffff,y SELF MODIFIED
dey
bpl K.Stat.Store.1
2018-11-07 16:11:02 +00:00
* clc
2019-12-02 07:09:58 +00:00
K.Stat.Store.RTS
2018-11-07 16:11:02 +00:00
rts
*/--------------------------------------
* # Stat
* Return information about a file
2018-07-20 11:51:08 +00:00
* ## C
* `int stat(const char *pathname, struct stat *statbuf);`
* ## ASM
2020-02-14 07:21:56 +00:00
* `>PUSHW pathname`
2018-07-20 11:51:08 +00:00
* `>PUSHW statbuf`
* `>SYSCALL stat`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
*\--------------------------------------
2020-02-14 07:21:56 +00:00
K.Stat jsr PFT.CheckPath2
bcs K.ChMod.RET4 go discard statbuf
2019-04-19 05:42:43 +00:00
2019-12-02 07:09:58 +00:00
>PULLW K.Stat.Store.2+1
2019-04-19 05:42:43 +00:00
2020-02-14 07:21:56 +00:00
inc pStack
inc pStack
2019-12-02 07:09:58 +00:00
jsr SHARED.Stat.I
bcc K.Stat.Store
2019-04-19 05:42:43 +00:00
2019-04-15 05:40:13 +00:00
rts
*/-------------------------------------
2018-06-21 15:12:10 +00:00
* # MKDir
2018-09-20 15:33:05 +00:00
* create a directory
* ## C
* `int mkdir(const char *pathname, int mode);`
* ## ASM
2020-02-14 07:21:56 +00:00
* `>PUSHW pathname`
2018-09-20 15:33:05 +00:00
* `>PUSHW mode`
* `>SYSCALL mkdir`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-09-20 15:33:05 +00:00
* CC : success
* CS : error
* A = EC
*\-------------------------------------
2020-02-14 07:21:56 +00:00
K.MKDir jsr PFT.CheckPath2
2020-03-10 16:42:07 +00:00
bcs K.ChMod.RET4
2020-02-14 07:21:56 +00:00
2020-03-10 16:42:07 +00:00
jsr STAT.PullPathAndMode
2020-02-14 07:21:56 +00:00
2017-10-27 14:56:46 +00:00
lda #S.FI.T.DIR
2018-12-19 16:45:09 +00:00
sta K.MLI.PARAMS+4
stz K.MLI.PARAMS+5
stz K.MLI.PARAMS+6
2017-10-27 14:56:46 +00:00
lda #S.FI.ST.DIR
2020-03-10 16:42:07 +00:00
jmp IO.MLI.CREATE
*/--------------------------------------
2019-06-03 15:50:41 +00:00
* # MKFIFO
* return a pathname to a new FIFO
* ## C
2020-03-16 06:50:15 +00:00
* `hFILE mkfifo(const char *pathname, int mode);`
2019-06-03 15:50:41 +00:00
* ## ASM
2020-03-10 16:42:07 +00:00
* `>PUSHW pathname`
2019-06-03 15:50:41 +00:00
* `>PUSHW mode`
* `>SYSCALL mkfifo`
* ## RETURN VALUE
* CC = OK, CS = ERROR
2020-03-16 06:50:15 +00:00
* A = hFILE
2019-06-03 15:50:41 +00:00
*\--------------------------------------
2020-03-10 16:42:07 +00:00
K.MKFIFO jsr STAT.PullPathAndMode
2019-06-03 15:50:41 +00:00
>LDYAI 512
jsr K.pipe
2019-12-02 07:09:58 +00:00
bcs K.Stat.Store.RTS
2019-06-03 15:50:41 +00:00
2019-07-12 06:22:32 +00:00
ldy #0
2020-02-16 20:45:16 +00:00
.1 lda DEV.FIFO,y
2020-03-16 06:50:15 +00:00
sta (ZPPtr1),y fill pathname buffer
2019-07-12 06:22:32 +00:00
iny
cpy #9
bne .1
2019-06-04 15:49:58 +00:00
2019-07-12 14:51:57 +00:00
lda IO.hFD
2020-03-16 06:50:15 +00:00
jsr MATH32.AToHexAX
2019-07-12 06:22:32 +00:00
sta (ZPPtr1),y
txa
iny
sta (ZPPtr1),y
iny
lda #0
sta (ZPPtr1),y
bra K.MkNod.I
2019-06-03 15:50:41 +00:00
*/--------------------------------------
2018-06-21 15:12:10 +00:00
* # MkNod
2018-10-02 15:52:30 +00:00
* Create a special or ordinary file.
2018-09-20 15:33:05 +00:00
* (CDEV, BDEV, DSOCKS, SSOCK, PIPE)
* ## C
2018-10-03 15:25:03 +00:00
* `hFILE mknod(const char *pathname, int mode, hFD fd);`
2018-09-20 15:33:05 +00:00
* ## ASM
2020-03-10 16:42:07 +00:00
* `>PUSHW pathname`
2018-09-20 15:33:05 +00:00
* `>PUSHW mode`
2020-03-10 16:42:07 +00:00
* `>PUSHB fd`
2018-09-20 15:33:05 +00:00
* `>SYSCALL mknod`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-09-20 15:33:05 +00:00
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
2020-03-10 16:42:07 +00:00
K.MkNod >PULLB IO.hFD
jsr STAT.PullPathAndMode
2019-02-27 15:00:56 +00:00
K.MkNod.I ldx #2
2020-03-16 06:50:15 +00:00
2019-02-27 15:00:56 +00:00
.1 lda Nod.Table.hPath-2,x
2019-02-04 16:37:15 +00:00
beq .2
2020-03-16 06:50:15 +00:00
2019-02-04 16:37:15 +00:00
inx
2019-02-27 15:00:56 +00:00
cpx #K.Nod.MAX+2
2019-02-04 16:37:15 +00:00
bne .1
2020-03-16 06:50:15 +00:00
2019-02-04 16:37:15 +00:00
lda #E.OOH
2019-10-03 06:25:27 +00:00
* sec
2019-02-04 16:37:15 +00:00
rts
2020-03-16 06:50:15 +00:00
2019-02-04 16:37:15 +00:00
.2 stx .3+1 Store hFILE
2018-10-03 05:52:08 +00:00
>LDYA ZPPtr1
2020-03-16 06:50:15 +00:00
>SYSCALL2 StrDup
2019-02-04 16:37:15 +00:00
bcs .9
2020-03-16 06:50:15 +00:00
2019-02-04 16:37:15 +00:00
txa
2020-03-16 06:50:15 +00:00
2019-02-04 16:37:15 +00:00
.3 ldx #$ff SELF MODIFIED
2019-02-27 15:00:56 +00:00
sta Nod.Table.hPath-2,x
2019-07-12 14:51:57 +00:00
lda IO.hFD
2019-02-27 15:00:56 +00:00
sta Nod.Table.hFD-2,x
2019-02-04 16:37:15 +00:00
txa hNODE
2018-10-03 05:52:08 +00:00
clc
2019-02-04 16:37:15 +00:00
.9 rts
*/--------------------------------------
2019-02-04 16:37:15 +00:00
* # pipe
* ## C
2019-05-02 15:59:11 +00:00
* `hFD pipe(int size);`
2019-02-04 16:37:15 +00:00
* ## ASM
2019-05-02 15:59:11 +00:00
* `>LDYA size`
2019-02-04 16:37:15 +00:00
* `>SYSCALL pipe`
* ## RETURN VALUE
* CC = OK, CS = ERROR
* A = hFD
*\--------------------------------------
2019-06-03 15:50:41 +00:00
K.Pipe sta .1+1 SIZE HI
2020-02-16 20:45:16 +00:00
>SYSCALL2 NewStkObj
bcs .99
2020-02-16 20:45:16 +00:00
2019-06-03 15:50:41 +00:00
stx .8+1 save PIPE buffer
2020-02-16 20:45:16 +00:00
2019-07-12 14:51:57 +00:00
ldx #2
jsr IO.MkFD
bcs .9
2020-02-16 20:45:16 +00:00
2019-06-03 15:50:41 +00:00
.1 lda #$ff SELF MODIFIED
ldy #S.FD.PIPE.Free+1
2019-05-02 15:59:11 +00:00
sta (pFD),y
2019-06-03 15:50:41 +00:00
ldy #S.FD.PIPE.Size+1
2019-02-21 22:03:08 +00:00
sta (pFD),y
2020-03-16 06:50:15 +00:00
2019-02-26 16:50:42 +00:00
ldy #S.FD.PIPE.hMem
2020-03-16 06:50:15 +00:00
2019-06-03 15:50:41 +00:00
.8 lda #$ff Self Modified
2018-08-08 15:13:37 +00:00
sta (pFD),y
2019-05-03 13:08:12 +00:00
txa hFD
2019-02-15 16:38:17 +00:00
* clc
rts
2020-03-12 07:46:43 +00:00
.9 pha save error code
2019-06-03 15:50:41 +00:00
lda .8+1 get back PIPE buffer
2020-02-16 20:45:16 +00:00
>SYSCALL2 FreeStkObj
pla
sec
2019-12-02 16:47:53 +00:00
.99
K.Pipe.RTS rts
*--------------------------------------
2020-03-10 16:42:07 +00:00
STAT.PullPathAndMode
>PULLW K.S.STAT+S.STAT.MODE
>PULLW ZPPtr1 pathname
rts
*--------------------------------------
SHARED.Stat.I >MLICALL MLIGETFILEINFO
2019-12-02 16:47:53 +00:00
bcs K.Pipe.RTS
2020-03-10 16:42:07 +00:00
SHARED.GFI2Stat jsr SHARED.ClrStat
2019-12-02 16:47:53 +00:00
lda K.MLI.PARAMS+S.FI.A
2020-03-10 16:42:07 +00:00
jsr SHARED.Access2Mode
2019-12-02 16:47:53 +00:00
2020-02-16 20:45:16 +00:00
ldx #SHARED.GFI.Cnt
2019-12-02 16:47:53 +00:00
2020-02-16 20:45:16 +00:00
.3 ldy SHARED.GFI.Src-1,x
2019-12-02 16:47:53 +00:00
lda K.MLI.PARAMS,y
2020-02-16 20:45:16 +00:00
ldy SHARED.Stat.Dst-1,x
2019-12-02 16:47:53 +00:00
sta K.S.STAT,y
dex
bne .3
2020-02-16 20:45:16 +00:00
>LDYAI K.MLI.PARAMS+S.FI.CDATE
2020-03-10 16:42:07 +00:00
ldx #K.S.STAT+S.STAT.CTIME
2020-02-16 20:45:16 +00:00
jsr SHARED.PTime2StatYAX
2019-12-02 16:47:53 +00:00
2020-02-16 20:45:16 +00:00
>LDYAI K.MLI.PARAMS+S.FI.MDATE
2020-03-10 16:42:07 +00:00
ldx #K.S.STAT+S.STAT.MTIME
2020-02-16 20:45:16 +00:00
jmp SHARED.PTime2StatYAX
*--------------------------------------
2019-12-02 16:47:53 +00:00
SHARED.DirEnt2Stat
2020-02-16 20:45:16 +00:00
jsr SHARED.ClrStat
lda (ZPPtr3)
and #$F0
2020-02-29 14:06:28 +00:00
cmp #$D0 Vol Hdr, Dir Hdr or Dir ?
bcc .1
2019-12-02 16:47:53 +00:00
2020-02-16 20:45:16 +00:00
lda /S.STAT.MODE.DIR
sta K.S.STAT+S.STAT.MODE+1
.1 ldx #SHARED.DirEnt.Cnt
.2 ldy SHARED.DirEnt.Src-1,x
lda (ZPPtr3),y
ldy SHARED.Stat.Dst-1,x
sta K.S.STAT,y
dex
bne .2
ldy #$1E ProDOS Access
lda (ZPPtr3),y
2020-03-10 16:42:07 +00:00
jsr SHARED.Access2Mode
2020-02-16 20:45:16 +00:00
lda #$18 creation Date/time
2020-03-10 16:42:07 +00:00
ldx #K.S.STAT+S.STAT.CTIME
2020-02-16 20:45:16 +00:00
jsr SHARED.PTime2StatAX
lda #$21 mod Date/time
2020-03-10 16:42:07 +00:00
ldx #K.S.STAT+S.STAT.MTIME
2020-02-16 20:45:16 +00:00
jmp SHARED.PTime2StatAX
2019-12-02 16:47:53 +00:00
*--------------------------------------
SHARED.ClrStat ldx #S.STAT-1
.1 stz K.S.STAT,x
dex
bpl .1
2020-02-16 20:45:16 +00:00
lda CORE.FSID
sta K.S.STAT+S.STAT.FSID
2019-12-02 16:47:53 +00:00
rts
*--------------------------------------
2020-03-10 16:42:07 +00:00
SHARED.Mode2Access
clc
rts
*--------------------------------------
SHARED.Access2Mode
2019-12-02 16:47:53 +00:00
and #S.FI.A.FULL
cmp #S.FI.A.FULL
beq .7
tay
ldx #S.STAT.MODE.RO+S.STAT.MODE.RG+S.STAT.MODE.RU+S.STAT.MODE.XO+S.STAT.MODE.XG+S.STAT.MODE.XU
bit #S.FI.A.W
beq .1
txa
ora #S.STAT.MODE.WO
tax
tya
.1 asl D in C
bpl .2 RN in N
txa
ora #S.STAT.MODE.WG
tax
.2 txa
bcc .8
ora #S.STAT.MODE.WU
.HS 2C BIT ABS
.7 lda #S.STAT.MODE.FO+S.STAT.MODE.FG+S.STAT.MODE.FU rwxrwxrwx
.8 sta K.S.STAT+S.STAT.MODE
lda /S.STAT.MODE.RU ??????R??
ora K.S.STAT+S.STAT.MODE+1 preserve DIR
sta K.S.STAT+S.STAT.MODE+1
rts
*--------------------------------------
2020-02-16 20:45:16 +00:00
SHARED.PTime2StatAX
clc
adc ZPPtr3
tay
lda ZPPtr3+1
adc #0
SHARED.PTime2StatYAX
>PUSHYA
2020-03-10 16:42:07 +00:00
>PUSHB /K.S.STAT
2020-02-16 20:45:16 +00:00
txa
2020-03-10 16:42:07 +00:00
>PUSHA
2020-02-16 20:45:16 +00:00
>SYSCALL2 PTime2Time
rts
*--------------------------------------
SHARED.GFI.Src .DA #S.FI.T,#S.FI.AUXTYPE,#S.FI.AUXTYPE+1
2019-12-02 16:47:53 +00:00
.DA #S.FI.UBLKS,#S.FI.UBLKS+1
2020-02-16 20:45:16 +00:00
SHARED.GFI.Cnt .EQ *-SHARED.GFI.Src
*--------------------------------------
SHARED.DirEnt.Src
.HS 10.1f20.1314.151617
SHARED.DirEnt.Cnt .EQ *-SHARED.DirEnt.Src
*--------------------------------------
SHARED.Stat.Dst .DA #S.STAT.P.TYPE,#S.STAT.P.AUXTYPE,#S.STAT.P.AUXTYPE+1
2019-12-02 16:47:53 +00:00
.DA #S.STAT.BLOCKS,#S.STAT.BLOCKS+1
2020-02-16 20:45:16 +00:00
.DA #S.STAT.SIZE,#S.STAT.SIZE+1,#S.STAT.SIZE+2
*--------------------------------------
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/SYS/KERNEL.S.STAT
LOAD USR/SRC/SYS/KERNEL.S
ASM