mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 17:50:18 +00:00
283 lines
5.0 KiB
Plaintext
283 lines
5.0 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
*--------------------------------------
|
||
* # FStat
|
||
* Return information about a hfile
|
||
* ## C
|
||
* `int fstat(short int hFILE, struct stat *statbuf);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW statbuf`
|
||
* `lda hFILE`
|
||
* `>SYSCALL fstat`
|
||
* **Out:**
|
||
*--------------------------------------
|
||
K.FStat jsr PFT.CheckNodeA
|
||
jsr K.GetMemPtr
|
||
|
||
>STYA pFD
|
||
|
||
lda #S.FD.REG
|
||
clc
|
||
adc pFD
|
||
tay
|
||
lda /S.FD.REG
|
||
adc pFD+1
|
||
jsr K.Stat.I
|
||
bcs .9
|
||
|
||
ldy #S.FD.REG.REF
|
||
lda (pFD),y
|
||
sta K.MLI.PARAMS+1
|
||
>MLICALL MLIGETEOF
|
||
bcs .9
|
||
|
||
ldy #S.STAT.SIZE+3
|
||
lda #0
|
||
sta (ZPPtr1),y
|
||
|
||
ldx #2
|
||
|
||
.1 dey
|
||
lda K.MLI.PARAMS+2,x
|
||
sta (ZPPtr1),y
|
||
dex
|
||
bpl .1
|
||
|
||
.9 rts
|
||
*/--------------------------------------
|
||
* # Stat
|
||
* Return information about a file
|
||
* ## C
|
||
* `int stat(const char *pathname, struct stat *statbuf);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW statbuf`
|
||
* `>LDYA pathname`
|
||
* `>SYSCALL stat`
|
||
* **Out:**
|
||
*\--------------------------------------
|
||
K.Stat jsr PFT.CheckPathYA
|
||
K.Stat.I jsr STDIO.SetMLIPathYA
|
||
|
||
>PULLW ZPPtr1
|
||
|
||
>MLICALL MLIGETFILEINFO
|
||
bcs .9
|
||
|
||
ldx K.MLI.PARAMS+S.FI.A
|
||
|
||
lda #S.STAT.MODE.XO+S.STAT.MODE.WO+S.STAT.MODE.RO
|
||
cpx #S.FI.A.FULL
|
||
beq .2
|
||
|
||
lda #S.STAT.MODE.XO+S.STAT.MODE.RO
|
||
cpx #S.FI.A.R
|
||
beq .2
|
||
|
||
lda #0
|
||
|
||
.2 ldy #S.STAT.MODE
|
||
sta (ZPPtr1),y
|
||
|
||
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
|
||
sta (ZPPtr1),y
|
||
dex
|
||
bne .3
|
||
|
||
ldy #S.STAT.SIZE
|
||
lda #0
|
||
sta (ZPPtr1),y
|
||
|
||
iny
|
||
|
||
lda K.MLI.PARAMS+S.FI.UBLKS
|
||
asl
|
||
sta (ZPPtr1),y
|
||
|
||
iny
|
||
|
||
lda K.MLI.PARAMS+S.FI.UBLKS+1
|
||
rol
|
||
sta (ZPPtr1),y
|
||
|
||
iny
|
||
|
||
lda #0
|
||
rol
|
||
sta (ZPPtr1),y
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
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
|
||
*/-------------------------------------
|
||
* # MKDir
|
||
* create a directory
|
||
* ## C
|
||
* `int mkdir(const char *pathname, int mode);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW mode`
|
||
* `>LDYA pathname`
|
||
* `>SYSCALL mkdir`
|
||
* **Out:**
|
||
* CC : success
|
||
* CS : error
|
||
* A = EC
|
||
*\-------------------------------------
|
||
K.MKDir jsr PFT.CheckPathYA
|
||
jsr STDIO.SetMLIPathYA
|
||
|
||
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
|
||
*/--------------------------------------
|
||
* # MkNod
|
||
* return a hFile for a given file descriptor.
|
||
* (CDEV, BDEV, DSOCKS, SSOCK, PIPE)
|
||
* ## C
|
||
* `hFILE mknod(const char *pathname, int mode, hFD fd);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHB fd`
|
||
* `>PUSHW mode`
|
||
* `>LDYA pathname`
|
||
* `>SYSCALL mknod`
|
||
* **Out:**
|
||
* CC = OK, CS = ERROR
|
||
* A = hFILE
|
||
*\--------------------------------------
|
||
K.MkNod >STYA ZPPtr1 pathname
|
||
|
||
>PULLW K.S.STAT+S.STAT.MODE
|
||
>PULLB K.S.STAT+S.STAT.DEV
|
||
|
||
jsr K.GetMemPtr
|
||
bcs .99
|
||
|
||
>STYA pFD
|
||
|
||
ldx DevMgr.NodCnt
|
||
cpx #K.NOD.MAX
|
||
beq .98
|
||
|
||
.1 dex
|
||
bpl .
|
||
lda
|
||
|
||
lda (pFD) #S.FD.T
|
||
|
||
tax
|
||
jmp (.8,x)
|
||
|
||
.8 .DA STDIO.IOERR REG
|
||
.DA STDIO.IOERR DIR
|
||
.DA STAT.MKNOD.CDEV
|
||
.DA STAT.MKNOD.BDEV
|
||
.DA STDIO.IOERR LNK
|
||
.DA STAT.MKNOD.DSOCK
|
||
.DA STAT.MKNOD.SSOCK
|
||
.DA STDIO.IOERR FIFO
|
||
|
||
.98 lda #K.E.OOH
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
STAT.MKNOD.CDEV
|
||
STAT.MKNOD.BDEV
|
||
STAT.MKNOD.DSOCK
|
||
STAT.MKNOD.SSOCK
|
||
|
||
ldx #S.STAT
|
||
ldy #$ff
|
||
|
||
.1 inx
|
||
iny
|
||
lda (ZPPtr1),y
|
||
bne .1
|
||
|
||
txa
|
||
tay
|
||
lda #0
|
||
jsr K.GetMem
|
||
bcs .9
|
||
>STYA ZPPtr2
|
||
|
||
|
||
.9 rts
|
||
*/--------------------------------------
|
||
* # MKFIFO
|
||
* return a hFILE to a new FIFO
|
||
* ## C
|
||
* `hFILE mkfifo(const char *pathname, int mode);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW mode`
|
||
* `>LDYA pathname`
|
||
* `>SYSCALL mkfifo`
|
||
* **Out:**
|
||
* CC = OK, CS = ERROR
|
||
* A = hFILE
|
||
*\--------------------------------------
|
||
K.MKFIFO >LDYAI 256
|
||
jsr K.GetMem
|
||
bcs .99
|
||
|
||
stx .1+1 save FIFO buffer
|
||
|
||
>LDYAI S.FD.FIFO
|
||
jsr K.GetMem0
|
||
|
||
bcs .9
|
||
|
||
>STYA pFD
|
||
|
||
ldy #S.FD.T
|
||
lda #S.FD.T.FIFO
|
||
sta (pFD),y
|
||
|
||
iny S.FD.FIFO.hMem
|
||
.1 lda #$ff Self Modified
|
||
sta (pFD),y
|
||
txa
|
||
clc
|
||
rts
|
||
|
||
.9 pha save error code
|
||
lda .1+1 get back FIFO buffer
|
||
jsr K.FreeMem
|
||
pla
|
||
sec
|
||
|
||
.99 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/SYS/KERNEL.S.STAT
|
||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||
ASM
|