A2osX/SYS/KERNEL.S.IO.txt

883 lines
16 KiB
Plaintext
Raw Normal View History

NEW
2019-05-15 05:46:12 +00:00
AUTO 3,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
2019-07-11 15:51:24 +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
2019-07-11 15:51:24 +00:00
cmp IO.DEVDIR-1,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
2019-07-12 14:51:57 +00:00
IO.OPEN.REG.E ldx #0
jsr IO.MkFD
2018-10-04 15:30:14 +00:00
bcs IO.OPEN.RTS
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
*--------------------------------------
2019-02-26 16:50:42 +00:00
IO.OPEN.PIPE ldy #S.FD.PIPE.S
lda (pFD),y
inc
sta (pFD),y
2019-07-08 15:39:14 +00:00
*--------------------------------------
IO.OPEN.DSOCK
*--------------------------------------
IO.OPEN.SSOCK 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-06-10 13:52:20 +00:00
lda (pFD),y
beq .2
jsr K.FreeMem
.2 lda IO.hFD
jmp K.FreeMem
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
2019-05-08 19:41:46 +00:00
clc
rts
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
2019-05-08 19:41:46 +00:00
ldy #S.FD.SSOCK.CLOSE
lda (pFD),y
tax Function Offset in LIB
2019-02-26 07:00:37 +00:00
2019-05-08 19:41:46 +00:00
ldy #S.FD.SSOCK.IOHANDLER
lda (pFD),y
jsr K.GetMemPtr
>STYA .1+1
lda IO.hFD
2019-06-11 05:52:24 +00:00
.1 jmp $FFFF SELF MODIFIED
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
2019-06-10 13:52:20 +00:00
lda (pFD),y
beq .2
2019-02-19 11:30:45 +00:00
2019-06-10 13:52:20 +00:00
.DO AUXPIPE=1
2019-06-19 15:56:59 +00:00
ldx #SYS.FreeStkObj
jsr K.SYSCALL2.AUX
2019-06-10 13:52:20 +00:00
.ELSE
jsr K.FreeMem
.FIN
2019-02-19 11:30:45 +00:00
2019-06-10 13:52:20 +00:00
.2 lda IO.hFD
2019-02-19 11:30:45 +00:00
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-05-12 20:45:11 +00:00
* # read
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-05-12 20:45:11 +00:00
* # write
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
*--------------------------------------
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-05-12 20:45:11 +00:00
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
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
2019-05-12 20:45:11 +00:00
bcs .9
>LDYA K.S.IOCTL+S.IOCTL.BYTECNT
2019-02-22 16:08:37 +00:00
2019-05-12 20:45:11 +00:00
.9 rts
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
2019-05-12 20:45:11 +00:00
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-05-12 20:45:11 +00:00
.1 jmp $FFFF SELF MODIFIED
2019-02-22 13:34:06 +00:00
*--------------------------------------
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
2019-05-03 13:08:12 +00:00
jmp IO.READ.PIPE.EOF Remote PS closed the Pipe
2019-02-26 07:00:37 +00:00
2019-05-12 20:45:11 +00:00
.11 jmp IO.READ.PIPE.NODATA
2019-02-22 13:34:06 +00:00
.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-05-03 13:08:12 +00:00
pha
ldy #S.FD.PIPE.Used
cmp (pFD),y
>PULLA get cnt hi
tax
iny
sbc (pFD),y
2019-05-16 15:51:19 +00:00
pla A,X = cnt
bcc .12 cnt < Used
2019-05-03 13:08:12 +00:00
lda (pFD),y
tax
2019-05-16 15:51:19 +00:00
dey
lda (pFD),y A,X = Used
2019-05-03 13:08:12 +00:00
2019-05-16 15:51:19 +00:00
.12 sta .80+1
2019-05-03 13:08:12 +00:00
stx .81+1
2019-02-18 06:42:17 +00:00
eor #$ff
sta IO.Counter
2019-02-22 13:34:06 +00:00
2019-05-03 13:08:12 +00:00
txa
2019-02-18 06:42:17 +00:00
eor #$ff
sta IO.Counter+1
2018-10-02 15:52:30 +00:00
2019-05-23 15:38:32 +00:00
ldy #S.FD.PIPE.Free
clc
lda (pFD),y
adc .80+1
sta (pFD),y
iny
lda (pFD),y
adc .81+1
sta (pFD),y
iny #S.FD.PIPE.Used
sec
lda (pFD),y
sbc .80+1
sta (pFD),y
iny
lda (pFD),y
sbc .81+1
sta (pFD),y
2019-05-21 15:52:52 +00:00
ldy #S.FD.PIPE.Size+1
lda (pFD),y
sta .5+1 Page Count
2018-10-02 15:52:30 +00:00
ldy #S.FD.PIPE.hMem
lda (pFD),y
2019-06-19 15:56:59 +00:00
2019-05-23 15:38:32 +00:00
.DO AUXPIPE=1
2019-06-19 15:56:59 +00:00
ldx #SYS.GetStkObjPtr
jsr K.SYSCALL2.AUX
.ELSE
2018-10-02 15:52:30 +00:00
jsr K.GetMemPtr
2019-05-23 15:38:32 +00:00
.FIN
2019-02-15 16:38:17 +00:00
2019-05-03 13:08:12 +00:00
sty .2+1
2019-05-21 15:52:52 +00:00
sta .7+1 Pipe Buffer Base
2019-05-03 13:08:12 +00:00
ldy #S.FD.PIPE.Tail+1
2019-05-16 15:51:19 +00:00
clc
2019-05-03 13:08:12 +00:00
adc (pFD),y
sta .2+2
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
2019-05-23 15:38:32 +00:00
.13 .DO AUXPIPE=1
sta SETREADAUX
.FIN
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-05-03 15:16:51 +00:00
beq .8
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
2019-05-03 13:08:12 +00:00
2019-02-15 16:38:17 +00:00
inx
2019-05-03 13:08:12 +00:00
bne .4
2019-02-22 13:34:06 +00:00
2019-05-03 13:08:12 +00:00
inc .3+2
.4 iny
2019-02-15 16:38:17 +00:00
bne .1
2019-02-23 22:01:58 +00:00
2019-05-23 15:38:32 +00:00
.DO AUXPIPE=1
sta CLRREADAUX
.FIN
2019-05-03 13:08:12 +00:00
ldy #S.FD.PIPE.Tail+1
lda (pFD),y
inc
2019-05-21 15:52:52 +00:00
.5 cmp #$ff SELF MODIFIED
beq .6
2019-02-15 16:38:17 +00:00
2019-05-03 13:08:12 +00:00
sta (pFD),y
inc .2+2
ldy #0
2019-05-23 15:38:32 +00:00
bra .13
2019-05-03 13:08:12 +00:00
2019-05-21 15:52:52 +00:00
.6 lda #0
2019-05-03 13:08:12 +00:00
sta (pFD),y
2019-05-21 15:52:52 +00:00
.7 lda #$ff SELF MODIFIED
sta .2+2 Restore Pipe Buf base
2019-05-03 13:08:12 +00:00
ldy #0
2019-05-23 15:38:32 +00:00
bra .13
2019-05-03 13:08:12 +00:00
2019-05-23 15:38:32 +00:00
.8 .DO AUXPIPE=1
sta CLRREADAUX
.FIN
tya
2019-02-22 13:34:06 +00:00
ldy #S.FD.PIPE.Tail
sta (pFD),y
2019-05-03 13:08:12 +00:00
.80 ldy #$ff SELF MODIFIED
.81 lda #$ff Y,A = bytes read
2019-02-22 13:34:06 +00:00
clc
2018-10-02 15:52:30 +00:00
rts
2019-02-15 16:38:17 +00:00
2019-05-03 13:08:12 +00:00
IO.READ.PIPE.EOF
lda #MLI.E.EOF
2019-05-12 20:45:11 +00:00
.HS 2C BIT ABS
IO.READ.PIPE.NODATA
lda #E.NODATA
2018-10-02 15:52:30 +00:00
sec
2019-05-12 20:45:11 +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
2019-05-03 13:08:12 +00:00
bmi IO.READ.PIPE.EOF Remote PS closed the Pipe
2019-02-22 21:54:47 +00:00
2019-02-21 22:03:08 +00:00
ldy #S.FD.PIPE.Free
lda (pFD),y
ldy #2
2019-05-17 05:51:01 +00:00
sec
2019-02-21 22:03:08 +00:00
sbc (pStack),y
2019-05-17 05:51:01 +00:00
2019-02-21 22:03:08 +00:00
tax
2019-05-17 05:51:01 +00:00
2019-02-21 22:03:08 +00:00
ldy #S.FD.PIPE.Free+1
lda (pFD),y
ldy #3
sbc (pStack),y
2019-05-12 20:45:11 +00:00
bcc IO.READ.PIPE.NODATA not enough room in PIPE
2019-02-21 22:03:08 +00:00
ldy #S.FD.PIPE.Free+1
sta (pFD),y
dey
txa
sta (pFD),y store new Free
2019-05-23 15:38:32 +00:00
>PULLW .2+1 get dst buf
2019-05-12 20:45:11 +00:00
2019-02-22 13:34:06 +00:00
>PULLA get cnt lo
2019-05-03 13:08:12 +00:00
sta .80+1
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-05-03 13:08:12 +00:00
sta .81+1
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
2019-05-16 15:51:19 +00:00
iny #S.FD.PIPE.Used+1
2019-02-21 22:03:08 +00:00
adc (pFD),y
sta (pFD),y
2018-06-19 05:55:12 +00:00
2019-05-21 15:52:52 +00:00
ldy #S.FD.PIPE.Size+1
lda (pFD),y
sta .5+1 Page Count
2018-10-02 15:52:30 +00:00
ldy #S.FD.PIPE.hMem
2018-07-10 15:33:13 +00:00
lda (pFD),y
2019-05-23 15:38:32 +00:00
.DO AUXPIPE=1
2019-06-19 15:56:59 +00:00
ldx #SYS.GetStkObjPtr
jsr K.SYSCALL2.AUX
.ELSE
2019-05-23 15:38:32 +00:00
jsr K.GetMemPtr get src buf
.FIN
2018-06-19 05:55:12 +00:00
2019-05-03 13:08:12 +00:00
sty .3+1
2019-05-21 15:52:52 +00:00
sta .7+1 Pipe Buffer Base
2019-02-22 13:34:06 +00:00
2019-05-03 13:08:12 +00:00
ldy #S.FD.PIPE.Head+1
2019-05-03 15:16:51 +00:00
clc
2019-05-03 13:08:12 +00:00
adc (pFD),y
sta .3+2
dey
lda (pFD),y
tay S.FD.PIPE.Head
2019-05-23 15:38:32 +00:00
ldx #0
.10 .DO AUXPIPE=1
sta SETWRITEAUX
.FIN
2019-02-15 16:38:17 +00:00
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
inx
2019-05-03 13:08:12 +00:00
bne .4
inc .2+2
.4 iny
2019-02-15 16:38:17 +00:00
bne .1
2019-05-03 13:08:12 +00:00
2019-05-23 15:38:32 +00:00
.DO AUXPIPE=1
sta CLRWRITEAUX
.FIN
2019-05-03 13:08:12 +00:00
ldy #S.FD.PIPE.Head+1
lda (pFD),y
inc
2019-05-21 15:52:52 +00:00
.5 cmp #$ff SELF MODIFIED
beq .6
2019-05-03 13:08:12 +00:00
sta (pFD),y
inc .3+2
ldy #0
2019-05-23 15:38:32 +00:00
bra .10
2019-05-03 13:08:12 +00:00
2019-05-21 15:52:52 +00:00
.6 lda #0
2019-05-03 13:08:12 +00:00
sta (pFD),y
2019-05-21 15:52:52 +00:00
.7 lda #$ff SELF MODIFIED
2019-05-03 13:08:12 +00:00
sta .3+2
ldy #0
2019-05-23 15:38:32 +00:00
bra .10
.8 .DO AUXPIPE=1
sta CLRWRITEAUX
.FIN
2019-05-03 13:08:12 +00:00
2019-05-23 15:38:32 +00:00
tya
2019-02-22 13:34:06 +00:00
ldy #S.FD.PIPE.Head
2019-05-03 13:08:12 +00:00
sta (pFD),y
2019-02-22 13:34:06 +00:00
2019-05-03 13:08:12 +00:00
.80 ldy #$ff SELF MODIFIED
.81 lda #$ff SELF MODIFIED
clc Y,A = bytes written
2018-10-02 15:52:30 +00:00
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-05-02 09:52:32 +00:00
IO.EOF lda (pFD)
tax
2019-02-20 16:07:43 +00:00
jmp (.1,x)
2019-05-02 09:52:32 +00:00
.1 .DA IO.EOF.REG
2019-02-20 16:07:43 +00:00
.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
2019-05-02 09:52:32 +00:00
*--------------------------------------
.DUMMY
.OR ZPTMP
K.EOF.MARK .BS 3
.ED
*--------------------------------------
IO.EOF.REG >MLICALL MLIGETMARK
bcs IO.EOF.REG.RTS
ldy #2
.1 lda K.MLI.PARAMS+2,y
sta K.EOF.MARK,y
dey
bpl .1
>MLICALL MLIGETEOF
bcs IO.EOF.REG.RTS
ldy #2
.2 lda K.MLI.PARAMS+2,y
eor K.EOF.MARK,y
2019-05-14 16:04:16 +00:00
bne IO.EOF.FALSE
2019-05-02 09:52:32 +00:00
dey
bpl .2
2019-05-14 16:04:16 +00:00
IO.EOF.TRUE lda #$ff
2019-05-02 09:52:32 +00:00
* clc
IO.EOF.REG.RTS rts
2019-02-20 16:07:43 +00:00
*--------------------------------------
2019-05-16 15:51:19 +00:00
IO.EOF.CDEV lda #S.IOCTL.STATCODE.EOF
jmp K.GetDevStatus.I
2019-02-20 16:07:43 +00:00
*--------------------------------------
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-05-14 16:04:16 +00:00
IO.EOF.PIPE clc
ldy #S.FD.PIPE.Used
2019-05-02 15:59:11 +00:00
lda (pFD),y
iny
ora (pFD),y
2019-05-14 16:04:16 +00:00
beq IO.EOF.TRUE
2019-05-16 15:51:19 +00:00
IO.EOF.FALSE lda #0
* clc
rts
2019-02-20 16:07:43 +00:00
*--------------------------------------
2019-07-12 14:51:57 +00:00
* X = 0 > REG
* X = 1 > DIR
* X = 2 > PIPE
*--------------------------------------
IO.MkFD stx .8+1
ldy IO.MkFD.Y,x
lda #0
ldx #S.MEM.F.INIT0+S.MEM.F.FD
jsr MEM.GetMem.YAX
bcs .9
>STYA pFD
stx IO.hFD
.8 ldx #$ff SELF MODIFIED
lda IO.MkFD.T,x
sta (pFD) X = hFD, A = T
* clc
.9 rts
IO.MkFD.Y .DA #S.FD.REG,#S.FD.DIR,#S.FD.PIPE
IO.MkFD.T .DA #S.FD.T.REG,#S.FD.T.DIR,#S.FD.T.PIPE
*--------------------------------------
2019-05-03 13:08:12 +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-07-12 06:22:32 +00:00
IO.DEVDIR .EQ * "/DEV/"
2019-06-03 15:50:41 +00:00
*--------------------------------------
2019-06-04 15:49:58 +00:00
STAT.FIFO .AS "/DEV/FIFO"
2018-07-11 15:13:29 +00:00
*--------------------------------------
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/SYS/KERNEL.S.IO
LOAD USR/SRC/SYS/KERNEL.S
ASM