2018-06-08 14:42:11 +00:00
|
|
|
|
NEW
|
|
|
|
|
PREFIX /A2OSX.BUILD
|
|
|
|
|
AUTO 4,1
|
2018-07-11 15:13:29 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # open
|
|
|
|
|
* ## C
|
|
|
|
|
* `int open(const char *pathname, int flags);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHB flags`
|
|
|
|
|
* `>LDYA pathname`
|
|
|
|
|
* `>SYSCALL open`
|
|
|
|
|
* **Out:**
|
|
|
|
|
* A = hFD
|
|
|
|
|
* note : if file is created on ProDOS : T=TXT,X=$0000
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.Open jsr PFT.CheckPathYA check if not /mnt
|
|
|
|
|
|
|
|
|
|
K.Open.I jsr IO.SetMLIPathYA local pathname...
|
|
|
|
|
|
|
|
|
|
ldx #5 /DEV/
|
|
|
|
|
cpx K.MLI.PATH
|
2018-07-12 15:20:39 +00:00
|
|
|
|
bcs K.Open.REG
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
|
|
|
|
.1 lda K.MLI.PATH,x
|
|
|
|
|
cmp IO.DEVDIR,x
|
|
|
|
|
bne K.Open.REG
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
2018-07-12 15:20:39 +00:00
|
|
|
|
K.Open.DEV ldy #K.MLI.PATH+6 skip L/DEV/
|
|
|
|
|
lda /K.MLI.PATH+6
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
|
|
|
|
jsr K.GetDevByName
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA pFD
|
2018-07-12 15:20:39 +00:00
|
|
|
|
stx .8+1 DEVID
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
2018-07-12 15:20:39 +00:00
|
|
|
|
ldy #S.FD.DEV.DRVPTR
|
|
|
|
|
lda (pFD),y
|
|
|
|
|
sta .1+1
|
|
|
|
|
iny
|
|
|
|
|
lda (pFD),y
|
|
|
|
|
sta .1+2
|
|
|
|
|
|
|
|
|
|
>PULLA get flags
|
|
|
|
|
ldx #IOCTL.OPEN
|
|
|
|
|
.1 jsr $ffff SELF MODIFIED
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
.8 lda #$ff SELF MODIFIED
|
|
|
|
|
.99 rts
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
2018-07-12 15:20:39 +00:00
|
|
|
|
.9 >RET 1 discard flags
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
|
|
|
|
K.Open.REG >LDYAI K.MLI.PATH
|
|
|
|
|
>STYA K.MLI.PARAMS+1
|
|
|
|
|
|
2018-07-12 15:20:39 +00:00
|
|
|
|
lda (pStack)
|
|
|
|
|
* sta K.S.IOCTL
|
|
|
|
|
|
|
|
|
|
>RET 1
|
2018-06-08 14:42:11 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-11 15:13:29 +00:00
|
|
|
|
* int close(int fd);
|
2018-07-09 15:25:38 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-11 15:13:29 +00:00
|
|
|
|
K.Close jsr K.GetMemPtr
|
|
|
|
|
>STYA pFD
|
|
|
|
|
|
|
|
|
|
lda (pFD) #S.FD.T
|
|
|
|
|
tax
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
|
|
|
|
|
.1 .DA IO.CLOSE.REG
|
|
|
|
|
.DA STDIO.IOERR DIR
|
|
|
|
|
.DA IO.CLOSE.CDEV
|
|
|
|
|
.DA STDIO.IOERR BDEV
|
|
|
|
|
.DA STDIO.IOERR LNK
|
|
|
|
|
.DA STDIO.IOERR DSOCK
|
|
|
|
|
.DA IO.CLOSE.SSOCK
|
|
|
|
|
.DA IO.CLOSE.FIFO
|
2018-07-10 15:33:13 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-11 15:13:29 +00:00
|
|
|
|
IO.CLOSE.REG
|
2018-07-10 15:33:13 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-11 15:13:29 +00:00
|
|
|
|
IO.CLOSE.CDEV
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IO.CLOSE.SSOCK
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IO.CLOSE.FIFO
|
2018-07-10 15:33:13 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* int read(int fd, void *buf, size_t count);
|
2018-06-19 15:08:22 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-11 15:13:29 +00:00
|
|
|
|
K.Read
|
2018-07-10 15:33:13 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* int write(int fd, const void *buf, size_t count);
|
|
|
|
|
*--------------------------------------
|
2018-07-13 14:38:24 +00:00
|
|
|
|
K.Write jsr IO.SELECT
|
|
|
|
|
bcs K.Write.9
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
2018-07-13 14:38:24 +00:00
|
|
|
|
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
|
|
|
|
|
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
|
|
|
|
|
|
|
|
|
|
K.Write.I lda (pFD) #S.FD.T
|
2018-06-19 05:55:12 +00:00
|
|
|
|
tax
|
|
|
|
|
jmp (.1,x)
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
2018-06-19 15:08:22 +00:00
|
|
|
|
.1 .DA IO.WRITE.REG
|
2018-06-19 05:55:12 +00:00
|
|
|
|
.DA STDIO.IOERR DIR
|
2018-06-19 15:08:22 +00:00
|
|
|
|
.DA IO.WRITE.CDEV
|
2018-06-19 05:55:12 +00:00
|
|
|
|
.DA STDIO.IOERR BDEV
|
|
|
|
|
.DA STDIO.IOERR LNK
|
|
|
|
|
.DA STDIO.IOERR DSOCK
|
2018-06-19 15:08:22 +00:00
|
|
|
|
.DA IO.WRITE.SSOCK
|
|
|
|
|
.DA IO.WRITE.FIFO
|
2018-07-13 14:38:24 +00:00
|
|
|
|
K.Write.9 >RET 4
|
2018-06-19 05:55:12 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-19 15:08:22 +00:00
|
|
|
|
IO.WRITE.REG >PUSHW K.S.IOCTL+S.IOCTL.BUFPTR
|
|
|
|
|
>PUSHW K.S.IOCTL+S.IOCTL.BYTECNT
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.REG.REF
|
|
|
|
|
>PUSHB (pFD),y
|
2018-06-08 14:42:11 +00:00
|
|
|
|
|
2018-06-19 05:55:12 +00:00
|
|
|
|
jmp K.FWrite
|
|
|
|
|
*--------------------------------------
|
2018-07-10 15:33:13 +00:00
|
|
|
|
IO.WRITE.CDEV ldy #S.FD.DEV.DRVPTR
|
|
|
|
|
lda (pFD),y
|
2018-06-19 05:55:12 +00:00
|
|
|
|
sta .1+1
|
|
|
|
|
iny
|
2018-07-10 15:33:13 +00:00
|
|
|
|
lda (pFD),y
|
2018-06-19 05:55:12 +00:00
|
|
|
|
sta .1+2
|
|
|
|
|
|
2018-07-13 14:38:24 +00:00
|
|
|
|
>LDYAI K.S.IOCTL
|
2018-06-19 05:55:12 +00:00
|
|
|
|
ldx #IOCTL.WRITE
|
|
|
|
|
.1 jmp $ffff
|
|
|
|
|
*--------------------------------------
|
2018-07-10 15:33:13 +00:00
|
|
|
|
IO.WRITE.SSOCK lda (pFD) #S.FD.HANDLER
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemPtr
|
2018-06-19 05:55:12 +00:00
|
|
|
|
>STYA .1
|
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.SSOCK.HSKT
|
|
|
|
|
>PUSHB (pFD),y
|
2018-06-19 05:55:12 +00:00
|
|
|
|
>PUSHB K.IOBuf
|
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.SSOCK.WRITE
|
|
|
|
|
lda (pFD),y
|
2018-06-19 05:55:12 +00:00
|
|
|
|
tax Function Offset for write
|
|
|
|
|
.1 jmp $ffff
|
|
|
|
|
*--------------------------------------
|
2018-07-10 15:33:13 +00:00
|
|
|
|
IO.WRITE.FIFO ldy #S.FD.FIFO.S
|
|
|
|
|
lda (pFD),y
|
2018-06-19 05:55:12 +00:00
|
|
|
|
beq .9 Remote PS did not opened yet the pipe
|
2018-07-10 15:33:13 +00:00
|
|
|
|
cmp #S.FD.FIFO.S.Closed
|
2018-06-19 05:55:12 +00:00
|
|
|
|
beq .99 Remote PS closed the Pipe
|
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.FIFO.hMem
|
|
|
|
|
lda (pFD),y
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemPtr
|
2018-06-19 05:55:12 +00:00
|
|
|
|
>STYA .1+2
|
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.FIFO.Head
|
|
|
|
|
lda (pFD),y
|
2018-06-19 05:55:12 +00:00
|
|
|
|
inc
|
2018-07-10 15:33:13 +00:00
|
|
|
|
dey #S.FD.FIFO.Tail
|
|
|
|
|
cmp (pFD),y
|
2018-06-19 05:55:12 +00:00
|
|
|
|
beq .9 FIFO is full
|
|
|
|
|
iny
|
2018-07-10 15:33:13 +00:00
|
|
|
|
sta (pFD),y
|
2018-06-19 05:55:12 +00:00
|
|
|
|
tay
|
|
|
|
|
lda K.IOBuf
|
|
|
|
|
.1 sta $ffff,y
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 lda #MLI.E.VOLFULL
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
.99 lda #MLI.E.EOF
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2018-07-11 15:13:29 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # IOCTL
|
|
|
|
|
* ## C
|
|
|
|
|
* `int ioctl(int fd, unsigned long request, void * param );`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `PUSHWI param`
|
|
|
|
|
* `lda #request`
|
|
|
|
|
* `ldy fd`
|
|
|
|
|
* `>SYSCALL IOCTL`
|
|
|
|
|
* **Out:**
|
|
|
|
|
* Y,A = ...
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.IOCTL tax op
|
|
|
|
|
>PULLB .1+1 param LO
|
|
|
|
|
>PULLB .2+1 param HI
|
|
|
|
|
|
|
|
|
|
tya id
|
|
|
|
|
|
|
|
|
|
jsr K.GetDevByID
|
|
|
|
|
bcs K.IOCTL.9
|
|
|
|
|
|
|
|
|
|
>STYA pFD
|
|
|
|
|
|
|
|
|
|
.1 ldy #$ff SELF MODIFIED
|
|
|
|
|
.2 lda #$ff SELF MODIFIED
|
|
|
|
|
|
|
|
|
|
jmp (pFD) x = op
|
|
|
|
|
|
|
|
|
|
K.IOCTL.9 rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # pipe
|
|
|
|
|
* ## C
|
|
|
|
|
* `int pipe(int pipefd[2]);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
*\--------------------------------------
|
2018-07-12 15:20:39 +00:00
|
|
|
|
IO.SELECT cmp DevMgr.DevCnt
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
tax
|
|
|
|
|
|
|
|
|
|
ldy FD.Table.PTRLO,x
|
|
|
|
|
lda FD.Table.PTRHI,x
|
2018-07-10 15:33:13 +00:00
|
|
|
|
>STYA pFD
|
|
|
|
|
rts
|
2018-07-12 15:20:39 +00:00
|
|
|
|
|
|
|
|
|
.9 lda #MLI.E.NODEV
|
|
|
|
|
rts
|
2018-07-10 15:33:13 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-11 15:13:29 +00:00
|
|
|
|
IO.PullMLIPath >PULLYA
|
|
|
|
|
IO.SetMLIPathYA >STYA .1+1
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 lda $ffff,x Self Modified
|
|
|
|
|
beq .8
|
|
|
|
|
inx
|
|
|
|
|
sta K.MLI.PATH,x
|
|
|
|
|
cpx #MLI.MAXPATH
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.8 stx K.MLI.PATH
|
|
|
|
|
inx
|
|
|
|
|
stz K.MLI.PATH,x
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IO.DEVDIR >PSTR "/DEV/"
|
|
|
|
|
*--------------------------------------
|
2018-06-08 14:42:11 +00:00
|
|
|
|
MAN
|
|
|
|
|
SAVE /A2OSX.SRC/SYS/KERNEL.S.IO
|
|
|
|
|
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
|
|
|
|
ASM
|