A2osX/SYS/KERNEL.S.UNISTD.txt

240 lines
5.2 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
*--------------------------------------
2020-12-15 13:23:22 +00:00
UNISTD.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
2020-12-15 13:23:22 +00:00
cmp UNISTD.DEV-1,x
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
2019-07-27 20:51:39 +00:00
.DA IO.OPEN.CDEV
.DA IO.OPEN.BDEV
.DA STDIO.IOERR LNK
.DA IO.OPEN.DSOCK
.DA IO.OPEN.SSOCK
.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
UNISTD.Close lda (pFD) #S.FD.T
tax
jmp (.1,x)
2020-09-09 12:47:18 +00:00
.1 .DA FS.CLOSE.REG
.DA FS.CLOSE.DIR
2019-07-27 20:51:39 +00:00
.DA IO.CLOSE.CDEV
.DA IO.CLOSE.BDEV
.DA STDIO.IOERR LNK
.DA IO.CLOSE.DSOCK
.DA IO.CLOSE.SSOCK
.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
2019-07-27 20:51:39 +00:00
UNISTD.Read lda (pFD) #S.FD.T
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
UNISTD.Write lda (pFD) #S.FD.T
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
*--------------------------------------
2020-03-17 06:23:07 +00:00
IO.OPEN.CDEV
2020-12-15 13:23:22 +00:00
IO.OPEN.BDEV ldx #IOCTL.OPEN
lda IO.hDevNod
jsr DEV.pDrvJmp
2020-06-30 14:30:14 +00:00
bcs IO.WRITE.CDEV.RTS
2020-05-04 20:46:21 +00:00
*--------------------------------------
IO.OPEN.DSOCK
2020-12-15 13:23:22 +00:00
IO.OPEN.SSOCK lda IO.hDevNod
2020-03-17 06:23:07 +00:00
clc
rts
*--------------------------------------
2020-12-15 13:23:22 +00:00
IO.CLOSE.CDEV
IO.CLOSE.BDEV ldx #IOCTL.CLOSE
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
2020-03-17 06:23:07 +00:00
bcs .9
>LDYA K.S.IOCTL+S.IOCTL.BYTECNT
2020-06-30 14:30:14 +00:00
.9
IO.WRITE.CDEV.RTS
rts
2020-03-17 06:23:07 +00:00
*--------------------------------------
IO.CLOSE.DSOCK
2020-06-30 14:30:14 +00:00
IO.CLOSE.SSOCK
2020-03-17 06:23:07 +00:00
ldy #S.FD.SSOCK.CLOSE
.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
ldy #S.FD.SSOCK.IOHANDLER
lda (pFD),y
jsr K.GetMemPtr
>STYA .1+1
lda IO.hFD
.1 jmp $FFFF SELF MODIFIED
*--------------------------------------
IO.EOF.CDEV lda #S.IOCTL.STATCODE.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
bcs K.ChOwn.RET4
2020-07-18 14:04:21 +00:00
stz K.MLI.PARAMS+3+S.FIEX.ACL read mode
>MLICALL MLIACL
2020-07-10 13:59:56 +00:00
bcs K.ChOwn.RET4
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
K.ChOwn.RET4 >RET 4
2020-02-16 20:45:16 +00:00
*--------------------------------------
2020-12-15 13:23:22 +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