2019-07-27 20:51:39 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # open
|
|
|
|
|
* ## C
|
|
|
|
|
* `hFD open(const char *pathname, short int flags);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
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
|
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
|
2021-05-19 12:44:47 +00:00
|
|
|
|
|
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
|
2021-05-19 12:44:47 +00:00
|
|
|
|
|
|
|
|
|
>STYA pFD
|
|
|
|
|
|
|
|
|
|
stx IO.hDevNod
|
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-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
|
|
|
|
.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-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)
|
2020-09-09 12:47:18 +00:00
|
|
|
|
.1 .DA FS.CLOSE.REG
|
|
|
|
|
.DA FS.CLOSE.DIR
|
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
|
|
|
|
|
* **In:**
|
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-05-14 20:58:20 +00:00
|
|
|
|
K.Read ldy #4 hDev
|
|
|
|
|
lda (pStack),y
|
|
|
|
|
|
|
|
|
|
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)
|
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
|
|
|
|
|
* **In:**
|
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-05-14 20:58:20 +00:00
|
|
|
|
K.Write ldy #4 hDev
|
|
|
|
|
lda (pStack),y
|
|
|
|
|
|
|
|
|
|
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)
|
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
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>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
|
|
|
|
|
* **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
|