A2osX/SYS/KERNEL.S.STAT.txt

438 lines
7.8 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
2019-05-02 15:59:11 +00:00
*/--------------------------------------
* # 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
2019-04-19 05:42:43 +00:00
*--------------------------------------
* # ChMod
* change permissions of a file
* ## C
* `int chmod(const char *pathname, int mode);`
* ## ASM
2019-01-30 06:20:13 +00:00
* **In:**
2019-04-19 05:42:43 +00:00
* `>PUSHW mode`
* `>LDYA pathname`
* `>SYSCALL chmod`
2019-01-30 06:20:13 +00:00
* ## RETURN VALUE
2019-04-19 05:42:43 +00:00
*--------------------------------------
* only 777-555
*--------------------------------------
K.ChMod jsr PFT.CheckPathYA
bcs .99
2019-01-30 06:20:13 +00:00
2019-04-19 05:42:43 +00:00
>PULLW K.S.STAT+S.STAT.MODE
2019-01-30 06:20:13 +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
2019-01-30 06:20:13 +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
2019-01-30 06:20:13 +00:00
2019-04-19 05:42:43 +00:00
>MLICALL MLIGETFILEINFO
bcs .90
2019-01-30 06:20:13 +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
2019-01-30 06:20:13 +00:00
2019-04-19 05:42:43 +00:00
lda K.S.STAT+S.STAT.MODE
tay
bit #S.STAT.MODE.WG
beq .1
txa
ora #S.FI.A.RN
tax
2019-01-30 06:20:13 +00:00
2019-04-19 05:42:43 +00:00
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
2019-01-30 06:20:13 +00:00
2019-04-19 05:42:43 +00:00
>MLICALL MLISETFILEINFO
clc
2019-01-30 06:20:13 +00:00
rts
2019-04-19 05:42:43 +00:00
.9 lda #E.SYN
sec
.90 rts
.99 >RET 2
*--------------------------------------
* # 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
2018-06-18 08:44:02 +00:00
* **In:**
2018-08-08 15:13:37 +00:00
* `>PUSHW statbuf`
* `lda hFILE`
* `>SYSCALL fstat`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
*--------------------------------------
2018-08-08 15:13:37 +00:00
K.FStat jsr PFT.CheckNodeA
2018-11-16 16:04:20 +00:00
bcs K.FStat.9
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
jsr K.Stat.I
2018-11-07 16:11:02 +00:00
bcs K.Stat.9
2018-11-16 16:04:20 +00:00
lda (pFD) #S.FD.T
bne K.Stat.BLK2SIZE
2018-11-07 16:11:02 +00:00
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
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
2018-08-08 15:13:37 +00:00
2018-11-16 16:04:20 +00:00
K.FStat.9 >RET 2 discard statbuf
*/--------------------------------------
* # 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-10-11 15:23:06 +00:00
* ## RETURN VALUE
*\--------------------------------------
2018-07-20 11:51:08 +00:00
K.Stat jsr PFT.CheckPathYA
2018-11-16 16:04:20 +00:00
bcs K.FStat.9 go discard statbuf
2018-11-07 16:11:02 +00:00
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
2018-11-16 16:04:20 +00:00
K.Stat.I >PULLW ZPPtr1 Get StatBuf
2018-07-20 11:51:08 +00:00
>MLICALL MLIGETFILEINFO
bcs .9
2019-04-15 05:40:13 +00:00
lda K.MLI.PARAMS+S.FI.A
jsr STAT.Access2Mode
2019-04-15 05:40:13 +00:00
.2 phy
2019-04-19 05:42:43 +00:00
ldy #S.STAT.MODE
2018-09-06 15:36:44 +00:00
sta (ZPPtr1),y
2019-04-19 05:42:43 +00:00
iny
2019-04-15 05:40:13 +00:00
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
2018-09-06 15:36:44 +00:00
sta (ZPPtr1),y
dex
bne .3
clc
.9 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
2019-04-15 05:40:13 +00:00
*--------------------------------------
STAT.Access2Mode
and #S.FI.A.FULL
cmp #S.FI.A.FULL
2019-04-19 05:42:43 +00:00
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??
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
2018-06-14 15:31:36 +00:00
* **In:**
2018-09-20 15:33:05 +00:00
* `>PUSHW mode`
* `>LDYA pathname`
* `>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
*\-------------------------------------
2018-11-16 16:04:20 +00:00
K.MKDir jsr PFT.CheckPathYA
2018-12-19 16:45:09 +00:00
bcs K.Stat.9
2018-11-10 14:30:09 +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
2018-12-19 16:45:09 +00:00
jmp IO.MLI.CREATE
*/--------------------------------------
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
2018-06-14 15:31:36 +00:00
* **In:**
2018-09-20 15:33:05 +00:00
* `>PUSHB fd`
* `>PUSHW mode`
* `>LDYA pathname`
* `>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
*\--------------------------------------
2018-09-20 15:33:05 +00:00
K.MkNod >STYA ZPPtr1 pathname
2018-09-20 15:33:05 +00:00
>PULLW K.S.STAT+S.STAT.MODE
>PULLB K.S.STAT+S.STAT.DEV
2019-02-04 16:37:15 +00:00
2019-02-27 15:00:56 +00:00
K.MkNod.I ldx #2
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
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
lda #E.OOH
* sec
rts
.2 stx .3+1 Store hFILE
2018-10-03 05:52:08 +00:00
>LDYA ZPPtr1
2019-05-04 21:13:50 +00:00
ldx #SYS.StrDup
jsr K.SYSCALL.GoB
2019-02-04 16:37:15 +00:00
bcs .9
txa
2018-10-03 05:52:08 +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-02-04 16:37:15 +00:00
lda K.S.STAT+S.STAT.DEV
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-09-20 15:33:05 +00:00
2018-10-03 05:52:08 +00:00
clc
2019-02-04 16:37:15 +00:00
.9 rts
*/--------------------------------------
* # MKFIFO
* return a hFILE to a new FIFO
2018-09-20 15:33:05 +00:00
* ## C
2019-02-15 16:38:17 +00:00
* `hFILE mkfifo();`
2018-09-20 15:33:05 +00:00
* ## ASM
2018-06-14 15:31:36 +00:00
* **In:**
2018-09-20 15:33:05 +00:00
* `>SYSCALL mkfifo`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-09-20 15:33:05 +00:00
* CC = OK, CS = ERROR
* A = hFILE
*\--------------------------------------
2019-02-15 16:38:17 +00:00
K.MKFIFO
* jsr K.pipe
* bcs .9
2019-02-28 16:45:33 +00:00
* sta IO.hFD
2019-02-15 16:38:17 +00:00
* stz K.S.STAT+S.STAT.MODE
* stz K.S.STAT+S.STAT.MODE+1
* >LDYA STAT.PipeFn
* >STYA ZPPtr1
* jsr K.MkNod.I
* bcc .9
2019-02-28 16:45:33 +00:00
* jmp IO.OPEN.ERR
2019-02-15 16:38:17 +00:00
sec
2019-02-04 16:37:15 +00:00
rts
*/--------------------------------------
* # 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-05-02 15:59:11 +00:00
K.Pipe >STYA ZPPtr1
2019-05-03 13:08:12 +00:00
* jsr K.NewStkObj Buffer in AUX mem
jsr K.GetMem
bcs .99
2018-10-02 15:52:30 +00:00
stx .1+1 save PIPE buffer
2018-10-02 15:52:30 +00:00
>LDYAI S.FD.PIPE
2019-01-11 16:06:05 +00:00
ldx #S.MEM.F.INIT0+S.MEM.F.FD
jsr MEM.GetMem.YAX
bcs .9
2018-08-08 15:13:37 +00:00
>STYA pFD
2018-10-02 15:52:30 +00:00
lda #S.FD.T.PIPE
2019-02-18 06:42:17 +00:00
sta (pFD)
2019-02-21 22:03:08 +00:00
ldy #S.FD.PIPE.Free
2019-05-02 15:59:11 +00:00
lda ZPPtr1
2019-02-21 22:03:08 +00:00
sta (pFD),y
iny
2019-05-02 15:59:11 +00:00
lda ZPPtr1+1
sta (pFD),y
ldy #S.FD.PIPE.Size
lda ZPPtr1
sta (pFD),y
iny
lda ZPPtr1+1
2019-02-21 22:03:08 +00:00
sta (pFD),y
2019-02-23 22:01:58 +00:00
2019-02-26 16:50:42 +00:00
ldy #S.FD.PIPE.hMem
.1 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
.9 pha save error code
2018-10-02 15:52:30 +00:00
lda .1+1 get back PIPE buffer
2018-06-22 06:24:35 +00:00
jsr K.FreeMem
pla
sec
.99 rts
*--------------------------------------
2019-02-15 16:38:17 +00:00
*STAT.PipeFn .AZ "/DEV/PIPE00"
*--------------------------------------
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/SYS/KERNEL.S.STAT
LOAD USR/SRC/SYS/KERNEL.S
ASM