A2osX/SYS/KERNEL.S.UNISTD.txt
burniouf 74acfeccd1 KERNEL & DRVs : lot of fixes around DEV.Open() , KCONFIG
SH : fiw for line wrap
ProDOS.FX : removed a strange bug inherited from 2.0.3 trashing FCBs
2023-11-26 14:17:41 +01:00

232 lines
4.3 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*/--------------------------------------
* # open
* ## C
* `hFD open(const char *pathname, short int flags);`
* ## ASM
* `>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 .2
.1 lda K.MLI.PATH,x
cmp UNISTD.DEV-1,x
bne .2
dex
bne .1
*--------------------------------------
* /dev/xxxxxx (CDEV,BDEV,DSOCK,SSOCK,PIPE)
*--------------------------------------
>LDYAI K.MLI.PATH+6 skip $/dev/
jsr K.GetDevByName
bcc .6
ldx #1
.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
.6 jsr DEV.GetPDrv
.7 lda (pFD) #S.FD.T
tax
jmp (.8-2,x)
.8
* .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
.9 rts
*/--------------------------------------
* # close
* ## C
* `int close(hFD fd);`
* ## ASM
* `lda fd`
* `>SYSCALL close`
*\--------------------------------------
K.Close jsr DEV.GetPFD
UNISTD.Close lda (pFD) #S.FD.T
tax
jmp (.1,x)
.1 .DA FS.CLOSE
.DA FS.CLOSE
.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
* `>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
* `>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
* `>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
* `>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 MLI.ACL
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 MLI.ACL
.9 >RET 4
*--------------------------------------
UNISTD.DEV .AS "/dev/"
*--------------------------------------
MAN
SAVE usr/src/sys/kernel.s.unistd
LOAD usr/src/sys/kernel.s
ASM