A2osX/SYS/KERNEL.S.IO.txt

742 lines
14 KiB
Plaintext
Raw Normal View History

NEW
2018-11-17 17:17:13 +00:00
PREFIX
AUTO 4,1
2018-07-11 15:13:29 +00:00
*/--------------------------------------
* # open
* ## C
2018-10-04 15:30:14 +00:00
* `hFD open(const char *pathname, short int flags);`
2018-07-11 15:13:29 +00:00
* ## ASM
* **In:**
* `>PUSHB flags`
* `>LDYA pathname`
* `>SYSCALL open`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-07-11 15:13:29 +00:00
* A = hFD
2018-10-04 15:30:14 +00:00
* REG File created on ProDOS : T=TXT,X=$0000
2018-07-11 15:13:29 +00:00
*\--------------------------------------
2018-10-04 15:30:14 +00:00
K.Open.FLAGS .BS 1
K.Open.TYPE .BS 1
K.Open.AUXTYPE .BS 2
2019-02-28 16:45:33 +00:00
IO.hDev .BS 1
2019-01-04 13:17:31 +00:00
IO.hFD .BS 1
2019-02-28 16:45:33 +00:00
IO.hFILE .BS 1
2019-02-18 06:42:17 +00:00
IO.Counter .BS 2
2018-10-04 15:30:14 +00:00
*--------------------------------------
2018-11-17 17:17:13 +00:00
K.Open jsr PFT.YAToMLIPATH
>PULLB K.Open.FLAGS
2018-10-08 05:55:28 +00:00
2018-10-04 15:30:14 +00:00
lda #S.FI.T.TXT
sta K.Open.TYPE
stz K.Open.AUXTYPE
stz K.Open.AUXTYPE+1
2018-10-08 05:55:28 +00:00
2018-11-16 16:04:20 +00:00
IO.Open.I ldx #5 $/DEV/
2018-07-11 15:13:29 +00:00
cpx K.MLI.PATH
2018-10-05 14:58:38 +00:00
bcs IO.OPEN.REG
2018-07-11 15:13:29 +00:00
.1 lda K.MLI.PATH,x
cmp IO.DEVDIR,x
2018-10-05 14:58:38 +00:00
bne IO.OPEN.REG
2018-07-11 15:13:29 +00:00
dex
bne .1
2018-09-05 15:22:46 +00:00
*--------------------------------------
2018-11-19 07:43:00 +00:00
* /DEV/xxxxxx (CDEV,BDEV,LNK,DSOCK,SSOCK,PIPE)
2018-10-04 15:30:14 +00:00
*--------------------------------------
2018-10-05 14:58:38 +00:00
>LDYAI K.MLI.PATH+6 skip $/DEV/
2019-01-13 13:10:14 +00:00
2018-07-11 15:13:29 +00:00
jsr K.GetDevByName
2018-11-01 08:53:47 +00:00
bcc .7
2018-07-11 15:13:29 +00:00
2019-02-27 15:00:56 +00:00
ldx #2
2018-11-01 08:53:47 +00:00
2019-02-27 15:00:56 +00:00
.10 lda Nod.Table.hPath-2,x
2019-02-26 21:54:31 +00:00
beq .3
2018-11-01 08:53:47 +00:00
jsr K.GetMemPtr
>STYA ZPPtr1
ldy #0
.2 lda (ZPPtr1),y
iny
cmp K.MLI.PATH,y
2019-02-26 21:54:31 +00:00
bne .3
2018-11-01 08:53:47 +00:00
cmp #0 end of string ?
bne .2
2019-02-27 15:00:56 +00:00
lda Nod.Table.hFD-2,x return hFD
2019-02-26 21:54:31 +00:00
sta IO.hFD
jsr K.GetMemPtr
2019-02-28 16:45:33 +00:00
bra .71
2018-11-01 08:53:47 +00:00
2019-02-26 21:54:31 +00:00
.3 inx
2019-02-27 15:00:56 +00:00
cpx #K.NOD.MAX+2
2018-11-01 08:53:47 +00:00
bne .10
lda #MLI.E.NODEV
* sec
rts no OF found
2019-02-28 16:45:33 +00:00
.7 stx IO.hDev
.71 >STYA pFD
2018-07-11 15:13:29 +00:00
2018-10-04 15:30:14 +00:00
lda (pFD) #S.FD.T
tax
2018-11-01 08:53:47 +00:00
jmp (.8,x)
2018-10-04 15:30:14 +00:00
2018-11-01 08:53:47 +00:00
.8 .DA STDIO.IOERR REG
2018-10-04 15:30:14 +00:00
.DA STDIO.IOERR DIR
.DA IO.OPEN.CDEV
2019-01-13 13:10:14 +00:00
.DA IO.OPEN.BDEV
2018-10-04 15:30:14 +00:00
.DA STDIO.IOERR LNK
.DA IO.OPEN.DSOCK
.DA IO.OPEN.SSOCK
.DA IO.OPEN.PIPE
2019-02-20 16:07:43 +00:00
2018-10-04 15:30:14 +00:00
IO.OPEN.RTS rts
*--------------------------------------
IO.OPEN.REG >MLICALL MLIGETFILEINFO
2018-12-19 16:45:09 +00:00
bcc IO.OPEN.REG.E Already Exists
2018-10-04 15:30:14 +00:00
bit K.Open.FLAGS Create if not exists ?
2019-02-20 16:07:43 +00:00
bpl IO.OPEN.RTS No, return MLI error
2018-10-04 15:30:14 +00:00
2018-12-19 16:45:09 +00:00
ldx #2 Yes, Create...
2018-11-07 16:11:02 +00:00
.1 lda K.Open.TYPE,x
sta K.MLI.PARAMS+4,x File type,Aux type
dex
bpl .1
2018-10-04 15:30:14 +00:00
lda #S.FI.ST.STD
2018-12-19 16:45:09 +00:00
jsr IO.MLI.CREATE
2018-10-04 15:30:14 +00:00
bcs IO.OPEN.RTS
2018-12-19 16:45:09 +00:00
IO.OPEN.REG.E >LDYAI S.FD.REG
2018-10-04 15:30:14 +00:00
ldx #S.MEM.F.INIT0+S.MEM.F.FD
jsr MEM.GetMem.YAX
bcs IO.OPEN.RTS
>STYA pFD
2019-02-28 16:45:33 +00:00
stx IO.hFD
2018-10-04 15:30:14 +00:00
* ldy #S.FD.T Done by GetMem0
* lda #S.FD.T.REG
* sta (pFD),y
2019-01-30 16:23:00 +00:00
jsr IO.MLIOPEN
2019-02-28 16:45:33 +00:00
bcs IO.OPEN.ERR
2018-10-04 15:30:14 +00:00
lda K.Open.FLAGS
bit #O.WRONLY
beq .20 Write mode ?
and #O.APPEND Append ?
bne .11 yes, go to end of file
stz K.MLI.PARAMS+2
stz K.MLI.PARAMS+3
stz K.MLI.PARAMS+4
>MLICALL MLISETEOF no, reset size to 0
bra .21
.11 >MLICALL MLIGETEOF
2019-02-28 16:45:33 +00:00
bcs IO.OPEN.ERR
2018-10-04 15:30:14 +00:00
>MLICALL MLISETMARK
2019-02-28 16:45:33 +00:00
.21 bcs IO.OPEN.ERR
2018-10-04 15:30:14 +00:00
.20 lda K.Open.FLAGS
and #O.TEXT Text Mode ?
beq .8
lda #$FF
sta K.MLI.PARAMS+2
lda #C.CR
sta K.MLI.PARAMS+3
>MLICALL MLINEWLINE
2019-02-28 16:45:33 +00:00
bcs IO.OPEN.ERR
2018-10-04 15:30:14 +00:00
2019-02-28 16:45:33 +00:00
.8 lda IO.hFD
2018-10-04 15:30:14 +00:00
rts
2019-02-28 16:45:33 +00:00
IO.OPEN.ERR pha Save Error Code
lda IO.hFD
2018-11-07 16:11:02 +00:00
jsr K.Close
2018-10-04 15:30:14 +00:00
pla
sec
rts
*--------------------------------------
2019-01-13 13:10:14 +00:00
IO.OPEN.CDEV
2019-02-28 16:45:33 +00:00
IO.OPEN.BDEV jsr K.IOCTL.GetPDrv
2018-07-12 15:20:39 +00:00
ldx #IOCTL.OPEN
2019-02-28 16:45:33 +00:00
lda IO.hDev
2018-10-05 06:25:15 +00:00
jsr K.IOCTL.pDrvJmp
2018-09-05 15:22:46 +00:00
bcs .9
2018-12-03 06:59:30 +00:00
2019-02-28 16:45:33 +00:00
lda IO.hDev
2019-01-13 13:10:14 +00:00
2018-09-05 15:22:46 +00:00
.9 rts
*--------------------------------------
2018-10-04 15:30:14 +00:00
IO.OPEN.DSOCK
*--------------------------------------
2019-03-01 07:50:32 +00:00
IO.OPEN.SSOCK lda IO.hFD
clc
2019-02-26 21:54:31 +00:00
rts
2018-10-04 15:30:14 +00:00
*--------------------------------------
2019-02-26 16:50:42 +00:00
IO.OPEN.PIPE ldy #S.FD.PIPE.S
lda (pFD),y
inc
sta (pFD),y
2019-02-26 21:54:31 +00:00
lda IO.hFD
2018-10-04 15:30:14 +00:00
clc
rts
2018-12-19 16:45:09 +00:00
*--------------------------------------
IO.MLI.CREATE sta K.MLI.PARAMS+7 Storage Type
ldx #3
.1 lda DATELO,x
sta K.MLI.PARAMS+8,x Create Date/Time
dex
bpl .1
lda #S.FI.A.FULL
sta K.MLI.PARAMS+3 Access
>MLICALL MLICREATE
rts
2018-08-27 15:26:01 +00:00
*/--------------------------------------
* # close
* ## C
* `int close(hFD fd);`
* ## ASM
* **In:**
* `lda fd`
* `>SYSCALL close`
*\--------------------------------------
2018-11-19 16:15:16 +00:00
K.Close sta IO.hFD
2018-10-04 15:30:14 +00:00
jsr K.GetMemPtr
2018-07-11 15:13:29 +00:00
>STYA pFD
2019-01-25 12:43:50 +00:00
IO.Close.I lda (pFD) #S.FD.T
2018-07-11 15:13:29 +00:00
tax
jmp (.1,x)
.1 .DA IO.CLOSE.REG
2018-10-03 15:25:03 +00:00
.DA IO.CLOSE.DIR
2018-07-11 15:13:29 +00:00
.DA IO.CLOSE.CDEV
2018-10-04 15:30:14 +00:00
.DA IO.CLOSE.BDEV
2018-07-11 15:13:29 +00:00
.DA STDIO.IOERR LNK
2018-10-03 15:25:03 +00:00
.DA IO.CLOSE.DSOCK
2018-07-11 15:13:29 +00:00
.DA IO.CLOSE.SSOCK
2018-10-02 15:52:30 +00:00
.DA IO.CLOSE.PIPE
2018-07-10 15:33:13 +00:00
*--------------------------------------
2018-07-11 15:13:29 +00:00
IO.CLOSE.REG
2018-11-19 16:15:16 +00:00
IO.CLOSE.DIR ldy #S.FD.REG.REF
2018-10-03 15:25:03 +00:00
lda (pFD),y
beq .1
sta K.MLI.PARAMS+1
>MLICALL MLICLOSE
.1 ldy #S.FD.REG.IOBUF
2019-02-19 11:30:45 +00:00
bra IO.CLOSE.FD
2018-07-10 15:33:13 +00:00
*--------------------------------------
2018-07-11 15:13:29 +00:00
IO.CLOSE.CDEV
2018-10-04 15:30:14 +00:00
IO.CLOSE.BDEV
2018-07-11 15:13:29 +00:00
*--------------------------------------
2018-10-03 15:25:03 +00:00
IO.CLOSE.DSOCK
2019-02-26 07:00:37 +00:00
IO.CLOSE.SSOCK
clc
2018-07-18 15:30:42 +00:00
rts
2019-02-18 06:42:17 +00:00
*--------------------------------------
2019-02-26 07:00:37 +00:00
IO.CLOSE.PIPE ldy #S.FD.PIPE.S
2019-02-28 16:45:33 +00:00
2019-02-26 07:00:37 +00:00
lda (pFD),y
bmi .1 remote PS closed its end
lda #$80
sta (pFD),y
clc
rts
.1 jsr IO.CLOSE.NOD
2019-02-19 11:30:45 +00:00
ldy #S.FD.PIPE.hMem
IO.CLOSE.FD lda (pFD),y
beq .1
jsr K.FreeMem
.1 lda IO.hFD
jmp K.FreeMem
*--------------------------------------
2019-02-27 15:00:56 +00:00
IO.CLOSE.NOD ldx #2
2019-02-19 11:30:45 +00:00
lda IO.hFD
2019-02-27 15:00:56 +00:00
.1 cmp Nod.Table.hFD-2,x
2019-02-19 11:30:45 +00:00
bne .2
2019-02-27 15:00:56 +00:00
stz Nod.Table.hFD-2,x
2019-02-19 11:30:45 +00:00
2019-02-27 15:00:56 +00:00
lda Nod.Table.hPath-2,x
stz Nod.Table.hPath-2,x
2019-02-19 11:30:45 +00:00
jmp K.FreeMem
.2 inx
2019-02-27 15:00:56 +00:00
cpx #K.Nod.MAX+2
2019-02-19 11:30:45 +00:00
bne .1
2019-02-28 16:45:33 +00:00
lda #E.INVH
* sec
2019-02-19 11:30:45 +00:00
rts
2018-07-18 15:30:42 +00:00
*/--------------------------------------
2019-02-20 16:07:43 +00:00
* # read (BLOCKING)
2018-07-18 15:30:42 +00:00
* ## C
2018-08-27 15:26:01 +00:00
* `int read(hFD fd, void *buf, int count);`
* ## ASM
* **In:**
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>SYSCALL read`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-08-27 15:26:01 +00:00
* CC: Y,A = bytes read
* CS: A = EC
2018-07-18 15:30:42 +00:00
*\--------------------------------------
2018-11-19 16:15:16 +00:00
K.Read sta IO.hFD
2018-11-19 07:43:00 +00:00
jsr K.GetMemPtr
2018-08-08 15:13:37 +00:00
>STYA pFD
2018-07-19 15:33:55 +00:00
IO.Read.I lda (pFD) #S.FD.T
2018-07-18 15:30:42 +00:00
tax
jmp (.1,x)
.1 .DA IO.READ.REG
.DA STDIO.IOERR DIR
.DA IO.READ.CDEV
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
.DA IO.READ.SSOCK
2018-10-02 15:52:30 +00:00
.DA IO.READ.PIPE
2018-08-27 15:26:01 +00:00
*/--------------------------------------
2019-02-20 16:07:43 +00:00
* # write (BLOCKING)
2018-08-27 15:26:01 +00:00
* ## C
* `int write(hFD fd, const void *buf, int count);`
* ## ASM
* **In:**
* `>PUSHWI count`
* `>PUSHW buf`
* `lda fd`
* `>SYSCALL write`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-08-27 15:26:01 +00:00
* CC: Y,A = bytes written
* CS: A = EC
*\--------------------------------------
2018-11-19 16:15:16 +00:00
K.Write sta IO.hFD
2018-11-19 07:43:00 +00:00
jsr K.GetMemPtr
2018-08-08 15:13:37 +00:00
>STYA pFD
2018-07-19 15:33:55 +00:00
IO.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
2018-10-02 15:52:30 +00:00
.DA IO.WRITE.PIPE
2018-06-19 05:55:12 +00:00
*--------------------------------------
2018-08-08 15:13:37 +00:00
IO.READ.REG ldx #MLIREAD
.HS 2C BIT ABS
2018-07-24 16:00:24 +00:00
*--------------------------------------
2018-08-08 15:13:37 +00:00
IO.WRITE.REG ldx #MLIWRITE
2018-10-04 06:13:44 +00:00
2018-07-10 15:33:13 +00:00
ldy #S.FD.REG.REF
2018-07-24 16:00:24 +00:00
lda (pFD),y
2018-08-08 15:13:37 +00:00
sta K.MLI.PARAMS+1
2018-10-03 15:25:03 +00:00
>PULLW K.MLI.PARAMS+2
>PULLW K.MLI.PARAMS+4
2018-08-08 15:13:37 +00:00
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
jsr GP.MLICall
2018-11-08 14:23:06 +00:00
bcs .9
2018-09-06 15:36:44 +00:00
>LDYA K.MLI.PARAMS+6
2018-11-08 14:23:06 +00:00
.9 rts
2018-06-19 05:55:12 +00:00
*--------------------------------------
2019-02-22 13:34:06 +00:00
* (pStack)+2 count
* (pStack)+0 buf
*--------------------------------------
2018-07-24 16:00:24 +00:00
IO.READ.CDEV ldx #IOCTL.READ
.HS 2C BIT ABS
*--------------------------------------
IO.WRITE.CDEV ldx #IOCTL.WRITE
2019-02-22 16:08:37 +00:00
ldy #3
.1 lda (pStack),y
sta K.S.IOCTL+S.IOCTL.BUFPTR,y
dey
bpl .1
2018-10-03 15:25:03 +00:00
2018-09-06 15:36:44 +00:00
jsr K.IOCTL.GetPDRV
2018-06-19 05:55:12 +00:00
2018-07-13 14:38:24 +00:00
>LDYAI K.S.IOCTL
2018-07-24 16:00:24 +00:00
2019-02-22 16:08:37 +00:00
jsr K.IOCTL.pDrvJmp
bcc .8
tay CS, A=0 ?
bne .9 no, I/O error
rts BLOCKING I/O
.8 >LDYA K.S.IOCTL+S.IOCTL.BYTECNT
.9 >RET 4
2018-06-19 05:55:12 +00:00
*--------------------------------------
2018-10-08 15:41:00 +00:00
IO.WRITE.SSOCK ldy #S.FD.SSOCK.WRITE
2018-07-24 16:00:24 +00:00
.HS 2C BIT ABS
*--------------------------------------
2018-11-19 16:15:16 +00:00
IO.READ.SSOCK ldy #S.FD.SSOCK.READ
2018-07-24 16:00:24 +00:00
lda (pFD),y
tax Function Offset in LIB
2018-11-19 07:43:00 +00:00
ldy #S.FD.SSOCK.IOHANDLER
2018-07-24 16:00:24 +00:00
lda (pFD),y
2018-06-21 15:12:10 +00:00
jsr K.GetMemPtr
2018-11-19 16:15:16 +00:00
>STYA .1+1
2018-06-19 05:55:12 +00:00
2019-03-02 20:47:58 +00:00
lda IO.hFD
2018-11-19 16:15:16 +00:00
2019-03-02 20:47:58 +00:00
.1 jsr $FFFF SELF MODIFIED
bcs .9
phy
ply
bne .9
tax
bne .9
inc pStack CC, Y,A = 0
inc pStack
inc pStack
inc pStack keep buf/count on stack
sec BLOCKING I/O
.9 rts
2018-06-19 05:55:12 +00:00
*--------------------------------------
2019-02-22 13:34:06 +00:00
* (pStack)+2 count
* (pStack)+0 buf
*--------------------------------------
2019-02-26 07:00:37 +00:00
IO.READ.PIPE ldy #S.FD.PIPE.Used+1
2019-02-28 16:45:33 +00:00
2019-02-26 07:00:37 +00:00
lda (pFD),y Data ?
2019-02-22 13:34:06 +00:00
dey
ora (pFD),y
2019-02-26 07:00:37 +00:00
bne .10 yes...
2019-02-22 13:34:06 +00:00
2019-02-26 07:00:37 +00:00
ldy #S.FD.PIPE.S
lda (pFD),y
bpl .11
jmp IO.READ.PIPE.99 Remote PS closed the Pipe
.11 lda #0 BLOCKING I/O
2019-02-22 13:34:06 +00:00
sec
rts
.10 >PULLW .3+1 get buf
2019-02-28 16:45:33 +00:00
2019-02-22 13:34:06 +00:00
>PULLA get cnt lo
2019-02-18 06:42:17 +00:00
eor #$ff
sta IO.Counter
2019-02-22 13:34:06 +00:00
>PULLA get cnt hi
2019-02-18 06:42:17 +00:00
eor #$ff
sta IO.Counter+1
2018-10-02 15:52:30 +00:00
ldy #S.FD.PIPE.hMem
lda (pFD),y
jsr K.GetMemPtr
2019-02-15 16:38:17 +00:00
>STYA .2+1
2019-02-22 13:34:06 +00:00
ldy #S.FD.PIPE.Head
lda (pFD),y
sta .4+1
2019-02-23 22:01:58 +00:00
2019-02-22 13:34:06 +00:00
dey S.FD.PIPE.Tail
lda (pFD),y
tay
2019-02-15 16:38:17 +00:00
ldx #0
2019-02-18 06:42:17 +00:00
.1 inc IO.Counter
2019-02-22 13:34:06 +00:00
bne .2
2019-02-18 06:42:17 +00:00
inc IO.Counter+1
2019-02-23 22:01:58 +00:00
beq .5
2019-02-15 16:38:17 +00:00
2019-02-18 06:42:17 +00:00
.2 lda $ffff,y SELF MODIFIED
2019-02-15 16:38:17 +00:00
.3 sta $ffff,x SELF MODIFIED
inx
2019-02-23 22:01:58 +00:00
beq .8 moved $100 bytes
2019-02-22 13:34:06 +00:00
iny
.4 cpy #$ff SELF MODIFIED
2019-02-15 16:38:17 +00:00
bne .1
2019-02-23 22:01:58 +00:00
.5 clc
.HS B0 BCS
2019-02-18 06:42:17 +00:00
2019-02-23 22:01:58 +00:00
.8 sec
2019-02-22 13:34:06 +00:00
lda #0
2019-02-23 22:01:58 +00:00
rol
2019-02-22 13:34:06 +00:00
sta IO.Counter+1
stx IO.Counter
2019-02-15 16:38:17 +00:00
2019-02-22 13:34:06 +00:00
tya
ldy #S.FD.PIPE.Tail
sta (pFD),y
txa
ldy #S.FD.PIPE.Free
2018-07-24 16:00:24 +00:00
clc
2019-02-22 13:34:06 +00:00
adc (pFD),y
sta (pFD),y
iny
lda IO.Counter+1
adc (pFD),y
sta (pFD),y
ldy #S.FD.PIPE.Used
sec
lda (pFD),y
sbc IO.Counter
sta (pFD),y
iny
lda (pFD),y
sbc IO.Counter+1
sta (pFD),y
2018-10-02 15:52:30 +00:00
2019-02-22 13:34:06 +00:00
ldy IO.Counter
lda IO.Counter+1 Y,A = bytes read
clc
2018-10-02 15:52:30 +00:00
rts
2019-02-15 16:38:17 +00:00
2019-02-22 13:34:06 +00:00
IO.READ.PIPE.99 lda #MLI.E.EOF
2018-10-02 15:52:30 +00:00
sec
2019-02-22 13:34:06 +00:00
>RET 4
2018-07-24 16:00:24 +00:00
*--------------------------------------
2019-02-21 16:26:21 +00:00
* (pStack)+2 count
2019-02-22 13:34:06 +00:00
* (pStack)+0 buf
2019-02-21 16:26:21 +00:00
*--------------------------------------
2019-02-21 22:03:08 +00:00
IO.WRITE.PIPE ldy #S.FD.PIPE.S
lda (pFD),y
2019-02-26 07:00:37 +00:00
bmi IO.READ.PIPE.99 Remote PS closed the Pipe
2019-02-22 21:54:47 +00:00
2019-02-21 22:03:08 +00:00
sec
ldy #S.FD.PIPE.Free
lda (pFD),y
ldy #2
sbc (pStack),y
tax
ldy #S.FD.PIPE.Free+1
lda (pFD),y
ldy #3
sbc (pStack),y
bcc .9 not enough room in PIPE
ldy #S.FD.PIPE.Free+1
sta (pFD),y
dey
txa
sta (pFD),y store new Free
2019-02-22 13:34:06 +00:00
>PULLW .2+1 get buf
>PULLA get cnt lo
2019-02-21 22:03:08 +00:00
pha
2019-02-18 06:42:17 +00:00
eor #$ff
sta IO.Counter
2019-02-21 22:03:08 +00:00
pla
ldy #S.FD.PIPE.Used
2019-02-22 13:34:06 +00:00
clc
2019-02-21 22:03:08 +00:00
adc (pFD),y
sta (pFD),y
2019-02-22 13:34:06 +00:00
>PULLA get cnt hi
2019-02-21 22:03:08 +00:00
pha
2019-02-18 06:42:17 +00:00
eor #$ff
sta IO.Counter+1
2019-02-21 22:03:08 +00:00
pla
ldy #S.FD.PIPE.Used+1
adc (pFD),y
sta (pFD),y
2018-06-19 05:55:12 +00:00
2018-10-02 15:52:30 +00:00
ldy #S.FD.PIPE.hMem
2018-07-10 15:33:13 +00:00
lda (pFD),y
2018-06-21 15:12:10 +00:00
jsr K.GetMemPtr
2019-02-15 16:38:17 +00:00
>STYA .3+1
2018-06-19 05:55:12 +00:00
2019-02-22 13:34:06 +00:00
ldy #S.FD.PIPE.Head
lda (pFD),y
tay
2019-02-15 16:38:17 +00:00
ldx #0
2019-02-22 13:34:06 +00:00
.1 inc IO.Counter
bne .2
inc IO.Counter+1
beq .8
2019-02-15 16:38:17 +00:00
.2 lda $ffff,x SELF MODIFIED
2019-02-18 06:42:17 +00:00
.3 sta $ffff,y SELF MODIFIED
2019-02-15 16:38:17 +00:00
2019-02-22 13:34:06 +00:00
iny
2019-02-15 16:38:17 +00:00
inx
bne .1
2019-02-22 13:34:06 +00:00
sec moved $100 bytes
.HS 90 BCC
.8 clc
tya
ldy #S.FD.PIPE.Head
sta (pFD),y
txa
2019-02-18 06:42:17 +00:00
tay
lda #0 Y,A = bytes written
2019-02-22 13:34:06 +00:00
rol
* clc
rts
2018-06-19 05:55:12 +00:00
2019-02-21 22:03:08 +00:00
.9 lda #0 BLOCKING I/O
2018-10-02 15:52:30 +00:00
sec
rts
2018-07-11 15:13:29 +00:00
*/--------------------------------------
* # IOCTL
* ## C
2019-01-13 13:10:14 +00:00
* `int ioctl(short int DevID, int request, void * param );`
2018-07-11 15:13:29 +00:00
* ## ASM
* `PUSHWI param`
2018-07-19 15:33:55 +00:00
* `PUSHBI request`
2019-01-13 13:10:14 +00:00
* `lda hDEV`
2018-07-11 15:13:29 +00:00
* `>SYSCALL IOCTL`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-07-11 15:13:29 +00:00
* Y,A = ...
*\--------------------------------------
2019-01-13 13:10:14 +00:00
K.IOCTL tax
2019-02-27 15:00:56 +00:00
lda Dev.Table,x
2019-01-13 13:10:14 +00:00
beq K.IOCTL.9
2018-07-11 15:13:29 +00:00
2019-01-13 13:10:14 +00:00
sta pFD+1
2019-02-27 15:00:56 +00:00
lda Dev.Table-1,x
2019-01-13 13:10:14 +00:00
sta pFD
2018-08-08 15:13:37 +00:00
2018-09-07 14:12:42 +00:00
jsr K.IOCTL.GetPDrv
2018-09-06 15:36:44 +00:00
2018-07-19 15:33:55 +00:00
>PULLA
tax request
>PULLYA param
2018-10-24 15:36:45 +00:00
K.IOCTL.pDrvJmp jmp (pDrv)
2018-07-11 15:13:29 +00:00
2019-01-13 13:10:14 +00:00
K.IOCTL.9 sec
lda #MLI.E.NODEV
2018-08-08 15:13:37 +00:00
>RET 3
2018-09-06 15:36:44 +00:00
*--------------------------------------
K.IOCTL.GetPDrv ldy #S.FD.DEV.DRVPTR
lda (pFD),y
sta pDRV
iny
lda (pFD),y
sta pDRV+1
rts
2018-07-10 15:33:13 +00:00
*--------------------------------------
2019-01-30 16:23:00 +00:00
IO.MLIOPEN >LDYAI 1024 get a ProDOS IOBUF
ldx #S.MEM.F.ALIGN+S.MEM.F.NOMOVE
jsr MEM.GetMem.YAX
bcs .9
>STYA K.MLI.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
txa
ldy #S.FD.REG.IOBUF
sta (pFD),y
>MLICALL MLIOPEN
bcs .9
lda K.MLI.PARAMS+5 get ref_num
ldy #S.FD.REG.REF
sta (pFD),y
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
* clc
.9 rts
*--------------------------------------
2019-02-20 16:07:43 +00:00
IO.EOF tax
jmp (.1,x)
.1 .DA STDIO.IOERR REG
.DA STDIO.IOERR DIR
.DA IO.EOF.CDEV
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
.DA IO.EOF.SSOCK
.DA IO.EOF.PIPE
*--------------------------------------
IO.EOF.CDEV >LDYAI K.IOBuf
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
lda #S.IOCTL.STATCODE.GETRC
jsr K.GetDevStatus.I
bcs .9
lda K.IOBuf
ora K.IOBuf+1
.9 rts
*--------------------------------------
2019-03-02 20:47:58 +00:00
IO.EOF.SSOCK ldy #S.FD.SSOCK.EOF
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
*--------------------------------------
2019-03-01 14:36:20 +00:00
IO.EOF.PIPE
2019-02-20 16:07:43 +00:00
lda #MLI.E.IO
sec
rts
*--------------------------------------
2018-07-11 15:13:29 +00:00
IO.DEVDIR >PSTR "/DEV/"
*--------------------------------------
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/SYS/KERNEL.S.IO
LOAD USR/SRC/SYS/KERNEL.S
ASM