mirror of
https://github.com/A2osX/A2osX.git
synced 2024-10-31 23:09:33 +00:00
201 lines
4.0 KiB
Plaintext
201 lines
4.0 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*/--------------------------------------
|
||
* # open
|
||
* ## C
|
||
* `hFD open(const char *pathname, short int flags);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHW pathname`
|
||
* `>PUSHB flags`
|
||
* `>SYSCALL open`
|
||
* ## RETURN VALUE
|
||
* A = hFD
|
||
* REG File created on ProDOS : T=TXT,X=$0000
|
||
*\--------------------------------------
|
||
K.Open jsr PFT.CheckPath1
|
||
>PULLB IO.Open.FLAGS
|
||
|
||
lda #S.FI.T.TXT
|
||
sta IO.Open.TYPE
|
||
stz IO.Open.AUXTYPE
|
||
stz IO.Open.AUXTYPE+1
|
||
*--------------------------------------
|
||
UNISTD.Open ldx #5 /dev/
|
||
cpx K.MLI.PATH
|
||
bcs .8
|
||
|
||
.1 lda K.MLI.PATH,x
|
||
cmp IO.DEV-1,x
|
||
bne .8
|
||
|
||
dex
|
||
bne .1
|
||
*--------------------------------------
|
||
* /dev/xxxxxx (CDEV,BDEV,DSOCK,SSOCK,PIPE)
|
||
*--------------------------------------
|
||
>LDYAI K.MLI.PATH+6 skip $/dev/
|
||
|
||
jsr K.GetDevByName
|
||
bcs .9
|
||
|
||
lda (pFD) #S.FD.T
|
||
tax
|
||
jmp (.2-2,x)
|
||
.2
|
||
* .DA STDIO.IOERR REG
|
||
.DA STDIO.IOERR DIR
|
||
.DA DEV.OPEN
|
||
.DA DEV.OPEN
|
||
.DA STDIO.IOERR LNK
|
||
.DA SOCK.OPEN
|
||
.DA SOCK.OPEN
|
||
.DA PIPE.OPEN
|
||
|
||
.8 jmp FS.OPEN.REG
|
||
|
||
.9 rts
|
||
*/--------------------------------------
|
||
* # close
|
||
* ## C
|
||
* `int close(hFD fd);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `lda fd`
|
||
* `>SYSCALL close`
|
||
*\--------------------------------------
|
||
K.Close jsr DEV.GetPFD
|
||
|
||
UNISTD.Close lda (pFD) #S.FD.T
|
||
tax
|
||
jmp (.1,x)
|
||
|
||
.1 .DA FS.CLOSE.REGDIR
|
||
.DA FS.CLOSE.REGDIR
|
||
.DA DEV.CLOSE
|
||
.DA DEV.CLOSE
|
||
.DA STDIO.IOERR LNK
|
||
.DA SOCK.CLOSE
|
||
.DA SOCK.CLOSE
|
||
.DA PIPE.CLOSE
|
||
*/--------------------------------------
|
||
* # read
|
||
* ## C
|
||
* `int read(hFD fd, void *buf, int count);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHB fd`
|
||
* `>PUSHW buf`
|
||
* `>PUSHW count`
|
||
* `>SYSCALL read`
|
||
* ## RETURN VALUE
|
||
* CC: Y,A = bytes read
|
||
* CS: A = EC
|
||
*\--------------------------------------
|
||
K.Read ldy #4 hFD
|
||
lda (pStack),y
|
||
|
||
jsr DEV.GetPFD
|
||
|
||
UNISTD.Read lda (pFD) #S.FD.T
|
||
tax
|
||
jmp (.1,x)
|
||
|
||
.1 .DA FS.READ.REG
|
||
.DA STDIO.IOERR DIR
|
||
.DA DEV.READ
|
||
.DA STDIO.IOERR BDEV
|
||
.DA STDIO.IOERR LNK
|
||
.DA STDIO.IOERR DSOCK
|
||
.DA SOCK.READ
|
||
.DA PIPE.READ
|
||
*/--------------------------------------
|
||
* # write
|
||
* ## C
|
||
* `int write(hFD fd, const void *buf, int count);`
|
||
* ## ASM
|
||
* **In:**
|
||
* `>PUSHB fd`
|
||
* `>PUSHW buf`
|
||
* `>PUSHW count`
|
||
* `>SYSCALL write`
|
||
* ## RETURN VALUE
|
||
* CC: Y,A = bytes written
|
||
* CS: A = EC
|
||
*\--------------------------------------
|
||
K.Write ldy #4 hFD
|
||
lda (pStack),y
|
||
|
||
jsr DEV.GetPFD
|
||
|
||
UNISTD.Write lda (pFD) #S.FD.T
|
||
tax
|
||
jmp (.1,x)
|
||
|
||
.1 .DA FS.WRITE.REG
|
||
.DA STDIO.IOERR DIR
|
||
.DA DEV.WRITE
|
||
.DA STDIO.IOERR BDEV
|
||
.DA STDIO.IOERR LNK
|
||
.DA STDIO.IOERR DSOCK
|
||
.DA SOCK.WRITE
|
||
.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`
|
||
*\-------------------------------------
|
||
*K.LSeek
|
||
|
||
*/--------------------------------------
|
||
* # 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
|
||
*\--------------------------------------
|
||
K.ChOwn jsr PFT.CheckPath2
|
||
bcs .9
|
||
|
||
stz K.MLI.PARAMS+3+S.FIEX.ACL read mode
|
||
|
||
>MLICALL MLIACL
|
||
bcs .9
|
||
|
||
lda (pStack)
|
||
bmi .1
|
||
|
||
sta K.MLI.PARAMS+3+S.FIEX.ACL.GID
|
||
|
||
.1 ldy #1
|
||
lda (pStack),y
|
||
bmi .2
|
||
|
||
sta K.MLI.PARAMS+3+S.FIEX.ACL.UID
|
||
|
||
.2 lda #$57 write mode
|
||
sta K.MLI.PARAMS+3+S.FIEX.ACL
|
||
|
||
>MLICALL MLIACL
|
||
|
||
.9 >RET 4
|
||
*--------------------------------------
|
||
IO.DEV .AS "/dev/"
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/sys/kernel.s.unistd
|
||
LOAD usr/src/sys/kernel.s
|
||
ASM
|