A2osX/SYS/KERNEL.S.STAT.txt

222 lines
4.1 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
PREFIX /A2OSX.BUILD
2017-12-22 21:24:30 +00:00
AUTO 4,1
*--------------------------------------
* # FStat
* Return information about a hfile
2018-07-20 11:51:08 +00:00
* ## ASM
* `int fstat(int fd, struct stat *statbuf);`
* ## ASM
2018-06-18 08:44:02 +00:00
* **In:**
* PUSHW = PTR to S.STAT buffer
* PUSHB = hFile
2018-06-18 08:44:02 +00:00
* **Out:**
*--------------------------------------
*jsr PFT.CheckNodeSTK
*/--------------------------------------
* # Stat
* Return information about a file
2018-07-20 11:51:08 +00:00
* ## C
* `int stat(const char *pathname, struct stat *statbuf);`
* ## ASM
2018-06-18 08:44:02 +00:00
* **In:**
2018-07-20 11:51:08 +00:00
* `>PUSHW statbuf`
* `>LDYA pathname`
* `>SYSCALL stat`
2018-06-18 08:44:02 +00:00
* **Out:**
*\--------------------------------------
2018-07-20 11:51:08 +00:00
K.Stat jsr PFT.CheckPathYA
jsr STDIO.SetMLIPathYA
>PULLW K.Stat.StoreY+1
2018-07-20 11:51:08 +00:00
>MLICALL MLIGETFILEINFO
bcs .9
2017-10-27 14:56:46 +00:00
ldx K.MLI.PARAMS+S.FI.A
lda #S.STAT.MODE.XO+S.STAT.MODE.WO+S.STAT.MODE.RO
2017-10-27 14:56:46 +00:00
cpx #S.FI.A.FULL
beq .2
lda #S.STAT.MODE.XO+S.STAT.MODE.RO
2017-10-27 14:56:46 +00:00
cpx #S.FI.A.R
beq .2
lda #0
.2 ldy #S.STAT.MODE
jsr K.Stat.StoreY
ldx #K.Stat.DST-K.Stat.SRC
.3 ldy K.Stat.SRC-1,x
lda K.MLI.PARAMS,y
ldy K.Stat.DST-1,x
jsr K.Stat.StoreY
dex
bne .3
ldy #S.STAT.SIZE
lda #0
jsr K.Stat.StoreY
iny
2017-10-27 14:56:46 +00:00
lda K.MLI.PARAMS+S.FI.UBLKS
asl
jsr K.Stat.StoreY
iny
2017-10-27 14:56:46 +00:00
lda K.MLI.PARAMS+S.FI.UBLKS+1
rol
jsr K.Stat.StoreY
iny
lda #0
rol
jsr K.Stat.StoreY
clc
.9 rts
K.Stat.StoreY sta $ffff,y
rts
*--------------------------------------
2017-10-27 14:56:46 +00:00
K.Stat.SRC .DA #S.FI.T
.DA #S.FI.AUXTYPE,#S.FI.AUXTYPE+1
.DA #S.FI.UBLKS,#S.FI.UBLKS+1
K.Stat.DST .DA #S.STAT.P.TYPE
.DA #S.STAT.P.AUXTYPE,#S.STAT.P.AUXTYPE+1
.DA #S.STAT.BLOCKS,#S.STAT.BLOCKS+1
*/-------------------------------------
2018-06-21 15:12:10 +00:00
* # MKDir
2018-06-14 15:31:36 +00:00
* **In:**
* Y,A = DIR name
2018-06-14 15:31:36 +00:00
* **Out:**
* CC : success
* CS : error
* A = EC
*\-------------------------------------
2018-06-21 15:12:10 +00:00
K.MKDir jsr PFT.CheckPathYA
jsr STDIO.SetMLIPathYA
2017-10-27 14:56:46 +00:00
lda #S.FI.A.FULL
sta K.MLI.PARAMS+S.FI.A
lda #S.FI.T.DIR
sta K.MLI.PARAMS+S.FI.T
lda #S.FI.ST.DIR
sta K.MLI.PARAMS+S.FI.ST
* jsr DATETIME
ldx #3
.1 lda DATELO,x
sta K.MLI.PARAMS+8,x
dex
bpl .1
>MLICALL MLICREATE
rts
*/--------------------------------------
2018-06-21 15:12:10 +00:00
* # MkNod
2018-06-28 15:26:34 +00:00
* int mknod(const char *pathname, mode_t mode, dev_t dev);
* return a hFile for a given Device Name
2018-06-14 15:31:36 +00:00
* **In:**
* Y,A=DevName
2018-06-14 15:31:36 +00:00
* **Out:**
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
2018-07-09 15:25:38 +00:00
K.MkNod jsr K.GetDevByName Y,A=NAME
bcs .9
2018-01-15 06:50:44 +00:00
>STYA .1+1
stx .2+1
2018-07-10 15:33:13 +00:00
ldy #S.FD.T
2018-07-11 15:13:29 +00:00
lda (pFD),y
2018-07-10 15:33:13 +00:00
cmp #S.FD.T.CDEV
bne .99
txa Pass DEV.ID to OPEN
2018-06-22 14:59:24 +00:00
ldx #IOCTL.OPEN
2018-01-15 06:50:44 +00:00
.1 jsr $FFFF SELF MODIFIED
bcs .9
2018-07-10 15:33:13 +00:00
>LDYAI S.FD.DEV
2018-06-21 15:12:10 +00:00
jsr K.GetMem0
bcs .9
2018-07-10 15:33:13 +00:00
>STYA ZPPtr3 Ptr3=S.FD
2018-07-10 15:33:13 +00:00
ldy #S.FD.T
lda #S.FD.T.CDEV
sta (ZPPtr3),y
2018-07-10 15:33:13 +00:00
ldy #S.FD.DEV.DEVID
2018-01-15 06:50:44 +00:00
.2 lda #$ff Self Modified
sta (ZPPtr3),y
2018-07-10 15:33:13 +00:00
ldy #S.FD.DEV.DRVPTR
2018-01-15 06:50:44 +00:00
lda .1+1
sta (ZPPtr3),y
iny
2018-01-15 06:50:44 +00:00
lda .1+2
sta (ZPPtr3),y
txa
clc
.9 rts
.99 lda #MLI.E.IO
sec
rts
*/--------------------------------------
* # MKFIFO
2018-06-28 15:26:34 +00:00
* int mkfifo(const char *pathname, mode_t mode);
* return a hFILE to a new FIFO
2018-06-14 15:31:36 +00:00
* **In:**
* **Out:**
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
K.MKFIFO >LDYAI 256
2018-06-21 15:12:10 +00:00
jsr K.GetMem
bcs .99
stx .1+1 save FIFO buffer
2018-07-10 15:33:13 +00:00
>LDYAI S.FD.FIFO
2018-06-21 15:12:10 +00:00
jsr K.GetMem0
bcs .9
>STYA ZPPtr1
2018-07-10 15:33:13 +00:00
ldy #S.FD.T
lda #S.FD.T.FIFO
sta (ZPPtr1),y
2018-07-10 15:33:13 +00:00
iny S.FD.FIFO.hMem
.1 lda #$ff Self Modified
sta (ZPPtr1),y
txa
clc
rts
.9 pha save error code
lda .1+1 get back FIFO buffer
2018-06-22 06:24:35 +00:00
jsr K.FreeMem
pla
sec
.99 rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.STAT
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM