A2osX/SYS/KERNEL.S.UNISTD.txt

232 lines
4.3 KiB
Plaintext
Raw Normal View History

2019-07-27 20:51:39 +00:00
NEW
AUTO 3,1
*/--------------------------------------
* # open
* ## C
* `hFD open(const char *pathname, short int flags);`
* ## ASM
2021-05-14 20:58:20 +00:00
* `>PUSHW pathname`
2019-07-27 20:51:39 +00:00
* `>PUSHB flags`
* `>SYSCALL open`
* ## RETURN VALUE
* A = hFD
* REG File created on ProDOS : T=TXT,X=$0000
*\--------------------------------------
2021-05-14 20:58:20 +00:00
K.Open jsr PFT.CheckPath1
2019-07-27 20:51:39 +00:00
>PULLB IO.Open.FLAGS
lda #S.FI.T.TXT
sta IO.Open.TYPE
stz IO.Open.AUXTYPE
stz IO.Open.AUXTYPE+1
*--------------------------------------
2021-05-19 12:44:47 +00:00
UNISTD.Open ldx #5 /dev/
2020-06-30 14:30:14 +00:00
cpx K.MLI.PATH
2023-10-18 05:41:12 +00:00
bcs .2
2020-06-30 14:30:14 +00:00
.1 lda K.MLI.PATH,x
2023-10-18 05:41:12 +00:00
cmp UNISTD.DEV-1,x
bne .2
2021-05-19 12:44:47 +00:00
2020-06-30 14:30:14 +00:00
dex
bne .1
*--------------------------------------
2021-07-24 20:42:23 +00:00
* /dev/xxxxxx (CDEV,BDEV,DSOCK,SSOCK,PIPE)
2020-06-30 14:30:14 +00:00
*--------------------------------------
2020-12-15 13:23:22 +00:00
>LDYAI K.MLI.PATH+6 skip $/dev/
2019-07-27 20:51:39 +00:00
2020-03-13 16:10:36 +00:00
jsr K.GetDevByName
2023-10-18 05:41:12 +00:00
bcc .6
ldx #1
2023-10-18 05:41:12 +00:00
.3 lda FILEs.hFD-1,x
beq .5
lda FILEs.hName-1,x
beq .5
jsr K.GetMemPtr
>STYA ZPPtr1
ldy #$ff
.4 iny
lda K.Buf256,y
cmp (ZPPtr1),y
bne .5
cmp #0
bne .4
stx IO.hFILE
lda FILEs.hFD-1,x
jsr DEV.GetPFD
bra .7
.5 inx
cpx #K.FILE.MAX+1
bcc .3
lda #MLI.E.NODEV
* sec
rts
.2 jmp FS.OPEN.REG
2023-10-18 05:41:12 +00:00
.6 jsr DEV.GetPDrv
2021-05-19 12:44:47 +00:00
2023-10-18 05:41:12 +00:00
.7 lda (pFD) #S.FD.T
2019-07-27 20:51:39 +00:00
tax
2023-10-18 05:41:12 +00:00
jmp (.8-2,x)
.8
2019-07-29 15:38:55 +00:00
* .DA STDIO.IOERR REG
2020-03-16 06:50:15 +00:00
.DA STDIO.IOERR DIR
2021-05-19 12:44:47 +00:00
.DA DEV.OPEN
.DA DEV.OPEN
2019-07-27 20:51:39 +00:00
.DA STDIO.IOERR LNK
2021-05-19 12:44:47 +00:00
.DA SOCK.OPEN
.DA SOCK.OPEN
2021-05-14 20:58:20 +00:00
.DA PIPE.OPEN
2020-03-11 16:41:45 +00:00
2020-12-15 13:23:22 +00:00
.9 rts
2019-07-27 20:51:39 +00:00
*/--------------------------------------
* # close
* ## C
* `int close(hFD fd);`
* ## ASM
* `lda fd`
* `>SYSCALL close`
*\--------------------------------------
2020-12-15 13:23:22 +00:00
K.Close jsr DEV.GetPFD
2019-07-27 20:51:39 +00:00
2021-05-19 12:44:47 +00:00
UNISTD.Close lda (pFD) #S.FD.T
2019-07-27 20:51:39 +00:00
tax
jmp (.1,x)
2021-07-24 20:42:23 +00:00
2023-10-18 05:41:12 +00:00
.1 .DA FS.CLOSE
.DA FS.CLOSE
2021-05-19 12:44:47 +00:00
.DA DEV.CLOSE
.DA DEV.CLOSE
2019-07-27 20:51:39 +00:00
.DA STDIO.IOERR LNK
2021-05-19 12:44:47 +00:00
.DA SOCK.CLOSE
.DA SOCK.CLOSE
2021-05-14 20:58:20 +00:00
.DA PIPE.CLOSE
2019-07-27 20:51:39 +00:00
*/--------------------------------------
* # read
* ## C
* `int read(hFD fd, void *buf, int count);`
* ## ASM
2021-05-14 20:58:20 +00:00
* `>PUSHB fd`
2019-07-27 20:51:39 +00:00
* `>PUSHW buf`
2021-05-14 20:58:20 +00:00
* `>PUSHW count`
2019-07-27 20:51:39 +00:00
* `>SYSCALL read`
* ## RETURN VALUE
* CC: Y,A = bytes read
* CS: A = EC
*\--------------------------------------
2021-07-24 20:42:23 +00:00
K.Read ldy #4 hFD
2021-05-14 20:58:20 +00:00
lda (pStack),y
2023-10-18 05:41:12 +00:00
2021-05-14 20:58:20 +00:00
jsr DEV.GetPFD
2020-02-16 20:45:16 +00:00
2021-05-14 20:58:20 +00:00
UNISTD.Read lda (pFD) #S.FD.T
2019-07-27 20:51:39 +00:00
tax
jmp (.1,x)
2021-07-24 20:42:23 +00:00
2020-12-15 13:23:22 +00:00
.1 .DA FS.READ.REG
2019-07-27 20:51:39 +00:00
.DA STDIO.IOERR DIR
2021-05-19 12:44:47 +00:00
.DA DEV.READ
2019-07-27 20:51:39 +00:00
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
2021-05-19 12:44:47 +00:00
.DA SOCK.READ
2021-05-14 20:58:20 +00:00
.DA PIPE.READ
2019-07-27 20:51:39 +00:00
*/--------------------------------------
* # write
* ## C
* `int write(hFD fd, const void *buf, int count);`
* ## ASM
2021-05-14 20:58:20 +00:00
* `>PUSHB fd`
2019-07-27 20:51:39 +00:00
* `>PUSHW buf`
2021-05-14 20:58:20 +00:00
* `>PUSHW count`
2019-07-27 20:51:39 +00:00
* `>SYSCALL write`
* ## RETURN VALUE
* CC: Y,A = bytes written
* CS: A = EC
*\--------------------------------------
2021-07-24 20:42:23 +00:00
K.Write ldy #4 hFD
2021-05-14 20:58:20 +00:00
lda (pStack),y
2021-07-24 20:42:23 +00:00
2021-05-14 20:58:20 +00:00
jsr DEV.GetPFD
2019-07-27 20:51:39 +00:00
2021-05-14 20:58:20 +00:00
UNISTD.Write lda (pFD) #S.FD.T
2019-07-27 20:51:39 +00:00
tax
jmp (.1,x)
2021-07-24 20:42:23 +00:00
2020-12-15 13:23:22 +00:00
.1 .DA FS.WRITE.REG
2019-07-27 20:51:39 +00:00
.DA STDIO.IOERR DIR
2021-05-19 12:44:47 +00:00
.DA DEV.WRITE
2019-07-27 20:51:39 +00:00
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
2021-05-19 12:44:47 +00:00
.DA SOCK.WRITE
2021-05-14 20:58:20 +00:00
.DA PIPE.WRITE
*/-------------------------------------
* # LSeek
* Set the file-position indicator for hFD
* ## C
* `int lseek( short int hFD, long offset, short int whence );`
* ## ASM
* `>PUSHB hFD`
* `>PUSHL offset`
* `>PUSHB whence`
* `>SYSCALL fseek`
*\-------------------------------------
2021-05-19 12:44:47 +00:00
*K.LSeek
2021-05-14 20:58:20 +00:00
2020-03-11 06:40:01 +00:00
*/--------------------------------------
* # ChOwn
* ## C
* `short int chown(const char *pathname, short int owner, short int group);`
* ## ASM
* `>PUSHW pathname`
* `>PUSHB owner`
* `>PUSHB group`
* `>SYSCALL chown`
* ## RETURN VALUE
*\--------------------------------------
2020-07-10 13:59:56 +00:00
K.ChOwn jsr PFT.CheckPath2
2021-05-04 17:31:21 +00:00
bcs .9
2023-10-18 05:41:12 +00:00
2020-07-18 14:04:21 +00:00
stz K.MLI.PARAMS+3+S.FIEX.ACL read mode
2023-10-18 05:41:12 +00:00
2023-11-04 14:42:28 +00:00
>MLICALL MLI.ACL
2021-05-04 17:31:21 +00:00
bcs .9
2023-10-18 05:41:12 +00:00
2020-07-18 14:18:10 +00:00
lda (pStack)
bmi .1
sta K.MLI.PARAMS+3+S.FIEX.ACL.GID
2020-07-28 20:37:26 +00:00
.1 ldy #1
2020-07-18 14:18:10 +00:00
lda (pStack),y
bmi .2
sta K.MLI.PARAMS+3+S.FIEX.ACL.UID
2023-10-18 05:41:12 +00:00
2020-07-18 14:18:10 +00:00
.2 lda #$57 write mode
2020-07-16 14:53:35 +00:00
sta K.MLI.PARAMS+3+S.FIEX.ACL
2023-11-04 14:42:28 +00:00
>MLICALL MLI.ACL
2023-10-18 05:41:12 +00:00
.9 >RET 4
2020-02-16 20:45:16 +00:00
*--------------------------------------
2023-10-18 05:41:12 +00:00
UNISTD.DEV .AS "/dev/"
2020-06-30 14:30:14 +00:00
*--------------------------------------
2019-07-27 20:51:39 +00:00
MAN
2020-12-15 13:23:22 +00:00
SAVE usr/src/sys/kernel.s.unistd
LOAD usr/src/sys/kernel.s
2019-07-27 20:51:39 +00:00
ASM