A2osX/SYS/KERNEL.S.STAT.txt

322 lines
6.0 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 K.ChMod.RET3
2020-02-14 16:32:52 +00:00
>MLICALL MLIGETFILEINFO
bcs K.ChMod.RET3
2020-02-14 16:32:52 +00:00
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
bra K.SetAttr.I
2020-07-28 20:37:26 +00:00
*/--------------------------------------
2020-07-30 11:14:37 +00:00
* # SetAttr
2020-07-28 20:37:26 +00:00
* Change Attributes of a ProDOS File
* ## C
2020-07-30 11:14:37 +00:00
* `int setattr(const char *filepath, short int attributes);`
2020-07-28 20:37:26 +00:00
* ## ASM
* `>PUSHW filepath`
* `>PUSHB attributes`
2020-07-30 11:14:37 +00:00
* `>SYSCALL setattr`
2020-07-28 20:37:26 +00:00
* ## RETURN VALUE
*\--------------------------------------
2020-07-30 11:14:37 +00:00
K.SetAttr jsr PFT.CheckPath1
bcs K.ChMod.RET3
2020-07-28 20:37:26 +00:00
>MLICALL MLIGETFILEINFO
bcs K.ChMod.RET3
2020-07-28 20:37:26 +00:00
lda (pStack)
sta K.MLI.PARAMS+S.FI.A
K.SetAttr.I >MLICALL MLISETFILEINFO
bra K.ChMod.RET3
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
*--------------------------------------
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
2021-05-04 17:31:21 +00:00
jsr STAT.PM
2020-02-14 07:21:56 +00:00
2020-07-28 20:37:26 +00:00
stz K.MLI.PARAMS+3+S.FIEX.ACL read mode
2020-03-10 16:42:07 +00:00
2020-07-22 15:51:03 +00:00
>MLICALL MLIACL
bcs .9
>LDYA K.S.STAT+S.STAT.MODE
>STYA K.MLI.PARAMS+3+S.FIEX.ACL.MOD
lda #$57 write mode
sta K.MLI.PARAMS+3+S.FIEX.ACL
>MLICALL MLIACL
.9 rts
2020-03-10 16:42:07 +00:00
2020-08-19 19:39:43 +00:00
K.ChMod.RET4 inc pStack
2020-08-19 19:39:43 +00:00
K.ChMod.RET3 inc pStack
inc pStack
inc pStack
rts
*--------------------------------------
* # 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
*--------------------------------------
2021-07-24 20:42:23 +00:00
K.FStat ldy #2
jsr PFT.CheckNodeY
2020-08-19 19:39:43 +00:00
bcs K.ChMod.RET3
2019-12-02 07:09:58 +00:00
2020-08-19 19:39:43 +00:00
>PULLW K.Stat.Store.2+1
2020-12-15 13:23:22 +00:00
>PULLA
tax
2021-07-24 20:42:23 +00:00
lda hFDs.hName-1,x get path
2020-12-15 13:23:22 +00:00
jsr K.GetMemPtr
jsr PFT.YAToMLIPATH
jsr FS.Stat.203
2021-05-04 17:31:21 +00:00
bcs STAT.RTS
2020-12-15 13:23:22 +00:00
ldy #S.FD.REG.REF
lda (pFD),y
sta K.MLI.PARAMS+1
>MLICALL MLIGETEOF
2021-05-04 17:31:21 +00:00
bcs STAT.RTS
2019-12-02 07:09:58 +00:00
2020-12-15 13:23:22 +00:00
ldx #2
.1 lda K.MLI.PARAMS+2,x
sta K.S.STAT+S.STAT.SIZE,x
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
2021-05-04 17:31:21 +00:00
STAT.RTS 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
2020-07-10 13:59:56 +00:00
jsr FS.Stat
2019-12-02 07:09:58 +00:00
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
2021-05-04 17:31:21 +00:00
jsr STAT.PM
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-08-19 19:39:43 +00:00
jmp FS.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
*\--------------------------------------
2021-05-04 17:31:21 +00:00
K.MKFIFO jsr STAT.PM
2020-03-10 16:42:07 +00:00
2019-06-03 15:50:41 +00:00
>LDYAI 512
jsr K.pipe
2021-05-04 17:31:21 +00:00
bcs STAT.RTS
2019-06-03 15:50:41 +00:00
2019-07-12 06:22:32 +00:00
ldy #0
2021-07-24 20:42:23 +00:00
2020-12-15 13:23:22 +00:00
.1 lda STAT.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
2021-07-24 20:42:23 +00:00
cpy #9
2019-07-12 06:22:32 +00:00
bne .1
2019-06-04 15:49:58 +00:00
2019-07-12 14:51:57 +00:00
lda IO.hFD
2021-04-29 11:56:34 +00:00
jsr STDIO.A2HexAX
2019-07-12 06:22:32 +00:00
sta (ZPPtr1),y
txa
iny
sta (ZPPtr1),y
iny
lda #0
sta (ZPPtr1),y
2021-07-24 20:42:23 +00:00
lda ZPPtr1
clc
adc #5 skip /dev/
sta ZPPtr1
bcc K.MkNod.I
inc ZPPtr1+1
2019-07-12 06:22:32 +00:00
bra K.MkNod.I
2021-07-24 20:42:23 +00:00
*--------------------------------------
STAT.FIFO .AS "/dev/fifo"
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
2021-05-04 17:31:21 +00:00
jsr STAT.PM
2020-03-10 16:42:07 +00:00
2021-07-26 13:45:29 +00:00
K.MkNod.I lda IO.hFD
jsr DEV.GetFD
bcc .2
jsr DEV.GetFreeFD
bcs .9
lda IO.hFD
sta hFDs-1,x
2021-07-24 20:42:23 +00:00
.2 stx IO.hFILE
2020-12-15 13:23:22 +00:00
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
2021-07-24 20:42:23 +00:00
ldx IO.hFILE
sta hFDs.hName-1,x store path
2020-12-15 13:23:22 +00:00
2021-07-24 20:42:23 +00:00
txa hFILE
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
2021-07-24 20:42:23 +00:00
lda #S.FD.T.PIPE
2020-12-15 13:23:22 +00:00
jsr DEV.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
2021-07-24 20:42:23 +00:00
lda IO.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
2021-07-24 20:42:23 +00:00
.99 rts
2019-12-02 16:47:53 +00:00
*--------------------------------------
2021-05-04 17:31:21 +00:00
STAT.PM >PULLW K.S.STAT+S.STAT.MODE
2020-03-10 16:42:07 +00:00
>PULLW ZPPtr1 pathname
rts
*--------------------------------------
MAN
2020-05-28 21:13:52 +00:00
SAVE usr/src/sys/kernel.s.stat
LOAD usr/src/sys/kernel.s
ASM