A2osX/SYS/KERNEL.S.UNISTD.txt

233 lines
5.0 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
* **In:**
* `>PUSHB flags`
* `>LDYA pathname`
* `>SYSCALL open`
* ## RETURN VALUE
* A = hFD
* REG File created on ProDOS : T=TXT,X=$0000
*\--------------------------------------
K.Open jsr PFT.YAToMLIPATH
>PULLB IO.Open.FLAGS
lda #S.FI.T.TXT
sta IO.Open.TYPE
stz IO.Open.AUXTYPE
stz IO.Open.AUXTYPE+1
*--------------------------------------
2021-05-04 17:31:21 +00:00
IO.Open ldx #5 /dev/
2020-06-30 14:30:14 +00:00
cpx K.MLI.PATH
2020-12-15 13:23:22 +00:00
bcs .8
2020-06-30 14:30:14 +00:00
.1 lda K.MLI.PATH,x
2021-05-04 17:31:21 +00:00
cmp IO.DEV-1,x
2020-12-15 13:23:22 +00:00
bne .8
2020-06-30 14:30:14 +00:00
dex
bne .1
*--------------------------------------
2020-03-16 06:50:15 +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
2020-12-15 13:23:22 +00:00
bcs .9
2020-06-30 14:30:14 +00:00
*--------------------------------------
2020-12-15 13:23:22 +00:00
stx IO.hDevNod pFD set by GetDevByName
2020-03-10 16:42:07 +00:00
2020-12-15 13:23:22 +00:00
lda (pFD) #S.FD.T
2019-07-27 20:51:39 +00:00
tax
2020-05-04 20:46:21 +00:00
2020-12-15 13:23:22 +00:00
jmp (.2-2,x)
.2
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-04 17:31:21 +00:00
.DA IO.OPEN.DEV
.DA IO.OPEN.DEV
2019-07-27 20:51:39 +00:00
.DA STDIO.IOERR LNK
2021-05-04 17:31:21 +00:00
.DA IO.OPEN.SOCK
.DA IO.OPEN.SOCK
2019-07-27 20:51:39 +00:00
.DA IO.OPEN.PIPE
2020-03-11 16:41:45 +00:00
2020-12-15 13:23:22 +00:00
.8 jmp FS.OPEN.REG
.9 rts
2019-07-27 20:51:39 +00:00
*/--------------------------------------
* # close
* ## C
* `int close(hFD fd);`
* ## ASM
* **In:**
* `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-04 17:31:21 +00:00
IO.Close lda (pFD) #S.FD.T
2019-07-27 20:51:39 +00:00
tax
jmp (.1,x)
2020-09-09 12:47:18 +00:00
.1 .DA FS.CLOSE.REG
.DA FS.CLOSE.DIR
2021-05-04 17:31:21 +00:00
.DA IO.CLOSE.DEV
.DA IO.CLOSE.DEV
2019-07-27 20:51:39 +00:00
.DA STDIO.IOERR LNK
2021-05-04 17:31:21 +00:00
.DA IO.CLOSE.SOCK
.DA IO.CLOSE.SOCK
2019-07-27 20:51:39 +00:00
.DA IO.CLOSE.PIPE
*/--------------------------------------
* # read
* ## C
* `int read(hFD fd, void *buf, int count);`
* ## ASM
* **In:**
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>SYSCALL read`
* ## RETURN VALUE
* CC: Y,A = bytes read
* CS: A = EC
*\--------------------------------------
2020-12-15 13:23:22 +00:00
K.Read jsr DEV.GetPFD
2020-02-16 20:45:16 +00:00
2021-05-04 17:31:21 +00:00
IO.Read lda (pFD) #S.FD.T
2019-07-27 20:51:39 +00:00
tax
jmp (.1,x)
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
.DA IO.READ.CDEV
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
.DA IO.READ.SSOCK
.DA IO.READ.PIPE
*/--------------------------------------
* # write
* ## C
* `int write(hFD fd, const void *buf, int count);`
* ## ASM
* **In:**
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>SYSCALL write`
* ## RETURN VALUE
* CC: Y,A = bytes written
* CS: A = EC
*\--------------------------------------
2020-12-15 13:23:22 +00:00
K.Write jsr DEV.GetPFD
2019-07-27 20:51:39 +00:00
2021-05-04 17:31:21 +00:00
IO.Write lda (pFD) #S.FD.T
2019-07-27 20:51:39 +00:00
tax
jmp (.1,x)
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
.DA IO.WRITE.CDEV
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
.DA IO.WRITE.SSOCK
.DA IO.WRITE.PIPE
*--------------------------------------
2021-05-04 17:31:21 +00:00
IO.OPEN.DEV ldx #IOCTL.OPEN
2020-12-15 13:23:22 +00:00
lda IO.hDevNod
jsr DEV.pDrvJmp
2021-05-04 17:31:21 +00:00
bcs IO.RTS
2020-05-04 20:46:21 +00:00
*--------------------------------------
2021-05-04 17:31:21 +00:00
IO.OPEN.SOCK lda IO.hDevNod
2020-03-17 06:23:07 +00:00
clc
rts
*--------------------------------------
2021-05-04 17:31:21 +00:00
IO.CLOSE.DEV ldx #IOCTL.CLOSE
2020-12-15 13:23:22 +00:00
lda IO.hDevNod
jmp DEV.pDrvJmp
*--------------------------------------
2020-03-17 06:23:07 +00:00
IO.READ.CDEV ldx #IOCTL.READ
.HS 2C BIT ABS
*--------------------------------------
IO.WRITE.CDEV ldx #IOCTL.WRITE
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
2020-12-15 13:23:22 +00:00
2020-03-17 06:23:07 +00:00
>LDYAI K.S.IOCTL
2020-12-15 13:23:22 +00:00
jsr DEV.pDrvJmp
2021-05-04 17:31:21 +00:00
bcs IO.RTS
2020-03-17 06:23:07 +00:00
>LDYA K.S.IOCTL+S.IOCTL.BYTECNT
2021-05-04 17:31:21 +00:00
IO.RTS rts
2020-03-17 06:23:07 +00:00
*--------------------------------------
2021-05-04 17:31:21 +00:00
IO.CLOSE.SOCK ldy #S.FD.SSOCK.CLOSE
2020-03-17 06:23:07 +00:00
.HS 2C BIT ABS
*--------------------------------------
IO.EOF.SSOCK ldy #S.FD.SSOCK.EOF
.HS 2C BIT ABS
*--------------------------------------
IO.READ.SSOCK ldy #S.FD.SSOCK.READ
.HS 2C BIT ABS
*--------------------------------------
IO.WRITE.SSOCK ldy #S.FD.SSOCK.WRITE
lda (pFD),y
tax Function Offset in LIB
2021-05-04 17:31:21 +00:00
ldy #S.FD.SSOCK.IOH
2020-03-17 06:23:07 +00:00
lda (pFD),y
jsr K.GetMemPtr
>STYA .1+1
lda IO.hFD
.1 jmp $FFFF SELF MODIFIED
*--------------------------------------
2021-05-04 17:31:21 +00:00
IO.EOF.CDEV lda #S.IOCTL.S.EOF
2020-12-15 13:23:22 +00:00
jmp DEV.GetDevStatus
2020-03-11 06:40:01 +00:00
*/--------------------------------------
* # ChOwn
* ## C
* `short int chown(const char *pathname, short int owner, short int group);`
* ## ASM
* **In:**
* `>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
2020-07-10 13:59:56 +00:00
2020-07-18 14:04:21 +00:00
stz K.MLI.PARAMS+3+S.FIEX.ACL read mode
>MLICALL MLIACL
2021-05-04 17:31:21 +00:00
bcs .9
2020-07-10 13:59:56 +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
2020-07-10 13:59:56 +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
2020-07-18 14:04:21 +00:00
>MLICALL MLIACL
2020-07-10 13:59:56 +00:00
2021-05-04 17:31:21 +00:00
.9 >RET 4
2020-02-16 20:45:16 +00:00
*--------------------------------------
2021-05-04 17:31:21 +00:00
IO.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