mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-03 12:06:05 +00:00
442 lines
7.9 KiB
Plaintext
442 lines
7.9 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*/--------------------------------------
|
||
* # GetMemStat
|
||
* **In:**
|
||
* Y,A = Ptr to 24 bytes buffer
|
||
* ## RETURN VALUE
|
||
* Buffer filled with memory stats
|
||
*\--------------------------------------
|
||
K.GetMemStat >STYA ZPPtr1
|
||
|
||
ldy #23
|
||
ldx #7
|
||
|
||
.1 lda DevMgr.Stat,x
|
||
sta (ZPPtr1),y
|
||
dey
|
||
dex
|
||
bpl .1
|
||
|
||
sta SETREADAUX
|
||
|
||
jsr .2
|
||
|
||
sta CLRREADAUX
|
||
|
||
.2 ldx #7
|
||
|
||
.3 lda Mem.Table,x
|
||
sta (ZPPtr1),y
|
||
dey
|
||
dex
|
||
bpl .3
|
||
|
||
rts
|
||
*--------------------------------------
|
||
* # ChMod
|
||
* change permissions of a file
|
||
* ## C
|
||
* `int chmod(const char *pathname, int mode);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW mode`
|
||
* `>LDYA pathname`
|
||
* `>SYSCALL chmod`
|
||
* ## RETURN VALUE
|
||
*--------------------------------------
|
||
* only 777-555
|
||
*--------------------------------------
|
||
K.ChMod jsr PFT.CheckPathYA
|
||
bcs .99
|
||
|
||
>PULLW K.S.STAT+S.STAT.MODE
|
||
|
||
lda K.S.STAT+S.STAT.MODE+1
|
||
and /S.STAT.MODE.RU
|
||
beq .9
|
||
|
||
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
|
||
|
||
>MLICALL MLIGETFILEINFO
|
||
bcs .90
|
||
|
||
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
|
||
.1 bit #S.STAT.MODE.WU
|
||
beq .2
|
||
|
||
txa
|
||
ora #S.FI.A.D
|
||
tax
|
||
|
||
tya
|
||
.2 bit #S.STAT.MODE.WO
|
||
beq .3
|
||
|
||
txa
|
||
ora #S.FI.A.W
|
||
tax
|
||
|
||
.3 stx K.MLI.PARAMS+S.FI.A
|
||
|
||
>MLICALL MLISETFILEINFO
|
||
rts
|
||
|
||
.9 lda #E.SYN
|
||
sec
|
||
.90 rts
|
||
|
||
.99 >RET 2
|
||
*--------------------------------------
|
||
* # FStat
|
||
* Return information about a hFILE
|
||
* ## C
|
||
* `int fstat(short int hFILE, struct stat *statbuf);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW statbuf`
|
||
* `lda hFILE`
|
||
* `>SYSCALL fstat`
|
||
* ## RETURN VALUE
|
||
*--------------------------------------
|
||
K.FStat jsr PFT.CheckNodeA
|
||
bcs K.FStat.9
|
||
|
||
tax
|
||
lda OF.Table.hPath-1,x
|
||
jsr K.GetMemPtr
|
||
|
||
jsr PFT.YAToMLIPATH
|
||
|
||
jsr K.Stat.I
|
||
bcs K.Stat.9
|
||
|
||
lda (pFD) #S.FD.T
|
||
bne K.Stat.BLK2SIZE
|
||
|
||
ldy #S.FD.REG.REF
|
||
lda (pFD),y
|
||
sta K.MLI.PARAMS+1
|
||
|
||
>MLICALL MLIGETEOF
|
||
bcs K.Stat.BLK2SIZE
|
||
|
||
ldy #S.STAT.SIZE+3
|
||
lda #0
|
||
sta (ZPPtr1),y
|
||
|
||
ldx #2
|
||
|
||
.1 lda K.MLI.PARAMS+2,x
|
||
dey
|
||
sta (ZPPtr1),y
|
||
dex
|
||
bpl .1
|
||
|
||
* clc
|
||
rts
|
||
|
||
K.FStat.9 >RET 2 discard statbuf
|
||
*/--------------------------------------
|
||
* # Stat
|
||
* Return information about a file
|
||
* ## C
|
||
* `int stat(const char *pathname, struct stat *statbuf);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW statbuf`
|
||
* `>LDYA pathname`
|
||
* `>SYSCALL stat`
|
||
* ## RETURN VALUE
|
||
*\--------------------------------------
|
||
K.Stat jsr PFT.CheckPathYA
|
||
bcs K.FStat.9 go discard statbuf
|
||
|
||
jsr K.Stat.I
|
||
bcs K.Stat.9
|
||
K.Stat.BLK2SIZE
|
||
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
|
||
K.Stat.9 rts
|
||
|
||
K.Stat.I >PULLW ZPPtr1 Get StatBuf
|
||
|
||
>MLICALL MLIGETFILEINFO
|
||
bcs .9
|
||
|
||
lda K.MLI.PARAMS+S.FI.A
|
||
jsr STAT.Access2Mode
|
||
|
||
.2 phy
|
||
ldy #S.STAT.MODE
|
||
sta (ZPPtr1),y
|
||
iny
|
||
pla
|
||
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
|
||
|
||
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
|
||
*--------------------------------------
|
||
STAT.Access2Mode
|
||
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 ldy /S.STAT.MODE.RU ??????R??
|
||
|
||
STAT.Access2Mode.RTS
|
||
rts
|
||
*/-------------------------------------
|
||
* # MKDir
|
||
* create a directory
|
||
* ## C
|
||
* `int mkdir(const char *pathname, int mode);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW mode`
|
||
* `>LDYA pathname`
|
||
* `>SYSCALL mkdir`
|
||
* ## RETURN VALUE
|
||
* CC : success
|
||
* CS : error
|
||
* A = EC
|
||
*\-------------------------------------
|
||
K.MKDir jsr PFT.CheckPathYA
|
||
bcs STAT.Access2Mode.RTS
|
||
|
||
lda #S.FI.T.DIR
|
||
sta K.MLI.PARAMS+4
|
||
stz K.MLI.PARAMS+5
|
||
stz K.MLI.PARAMS+6
|
||
lda #S.FI.ST.DIR
|
||
jmp IO.MLI.CREATE
|
||
*/--------------------------------------
|
||
* # MKFIFO
|
||
* return a pathname to a new FIFO
|
||
* ## C
|
||
* `int mkfifo( char *pathname, int mode );`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW mode`
|
||
* `>LDYA pathname`
|
||
* `>SYSCALL mkfifo`
|
||
* ## RETURN VALUE
|
||
* CC = OK, CS = ERROR
|
||
* A = hFD
|
||
*\--------------------------------------
|
||
K.MKFIFO >STYA ZPPtr1 pathname buffer
|
||
>PULLW K.S.STAT+S.STAT.MODE
|
||
|
||
>LDYAI 512
|
||
jsr K.pipe
|
||
bcs STAT.Access2Mode.RTS
|
||
|
||
ldy #0
|
||
|
||
.1 lda STAT.FIFO,y
|
||
sta (ZPPtr1),y
|
||
iny
|
||
cpy #9
|
||
bne .1
|
||
|
||
lda IO.hFD
|
||
jsr MATH.AToHexAX
|
||
|
||
sta (ZPPtr1),y
|
||
txa
|
||
iny
|
||
sta (ZPPtr1),y
|
||
iny
|
||
lda #0
|
||
sta (ZPPtr1),y
|
||
|
||
bra K.MkNod.I
|
||
*/--------------------------------------
|
||
* # MkNod
|
||
* Create a special or ordinary file.
|
||
* (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`
|
||
* ## RETURN VALUE
|
||
* CC = OK, CS = ERROR
|
||
* A = hFILE
|
||
*\--------------------------------------
|
||
K.MkNod >STYA ZPPtr1 pathname
|
||
|
||
>PULLW K.S.STAT+S.STAT.MODE
|
||
>PULLB IO.hFD
|
||
|
||
K.MkNod.I ldx #2
|
||
|
||
.1 lda Nod.Table.hPath-2,x
|
||
beq .2
|
||
|
||
inx
|
||
cpx #K.Nod.MAX+2
|
||
bne .1
|
||
|
||
lda #E.OOH
|
||
* sec
|
||
rts
|
||
|
||
.2 stx .3+1 Store hFILE
|
||
|
||
>LDYA ZPPtr1
|
||
ldx #SYS.StrDup
|
||
jsr K.SYSCALL2.BANK
|
||
bcs .9
|
||
txa
|
||
|
||
.3 ldx #$ff SELF MODIFIED
|
||
sta Nod.Table.hPath-2,x
|
||
lda IO.hFD
|
||
sta Nod.Table.hFD-2,x
|
||
|
||
txa hNODE
|
||
|
||
clc
|
||
.9 rts
|
||
*/--------------------------------------
|
||
* # pipe
|
||
* ## C
|
||
* `hFD pipe(int size);`
|
||
* ## ASM
|
||
* `>LDYA size`
|
||
* `>SYSCALL pipe`
|
||
* ## RETURN VALUE
|
||
* CC = OK, CS = ERROR
|
||
* A = hFD
|
||
*\--------------------------------------
|
||
K.Pipe sta .1+1 SIZE HI
|
||
|
||
.DO AUXPIPE=1
|
||
ldx #SYS.NewStkObj
|
||
jsr K.SYSCALL2.AUX Buffer in AUX mem
|
||
.ELSE
|
||
jsr K.GetMem
|
||
.FIN
|
||
bcs .99
|
||
|
||
stx .8+1 save PIPE buffer
|
||
|
||
ldx #2
|
||
jsr IO.MkFD
|
||
bcs .9
|
||
|
||
.1 lda #$ff SELF MODIFIED
|
||
ldy #S.FD.PIPE.Free+1
|
||
sta (pFD),y
|
||
|
||
ldy #S.FD.PIPE.Size+1
|
||
sta (pFD),y
|
||
|
||
ldy #S.FD.PIPE.hMem
|
||
.8 lda #$ff Self Modified
|
||
sta (pFD),y
|
||
txa hFD
|
||
* clc
|
||
rts
|
||
|
||
.9 pha save error code
|
||
lda .8+1 get back PIPE buffer
|
||
.DO AUXPIPE=1
|
||
ldx #SYS.FreeStkObj
|
||
jsr K.SYSCALL2.AUX
|
||
.ELSE
|
||
jsr K.FreeMem
|
||
.FIN
|
||
pla
|
||
sec
|
||
|
||
.99 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/SYS/KERNEL.S.STAT
|
||
LOAD USR/SRC/SYS/KERNEL.S
|
||
ASM
|