2018-06-08 14:42:11 +00:00
|
|
|
|
NEW
|
2018-11-17 17:17:13 +00:00
|
|
|
|
PREFIX
|
2018-06-08 14:42:11 +00:00
|
|
|
|
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-01-04 13:17:31 +00:00
|
|
|
|
IO.hFD .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
|
|
|
|
|
2018-11-01 08:53:47 +00:00
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.10 lda Nod.Table.hPath,x
|
|
|
|
|
beq .6
|
|
|
|
|
jsr K.GetMemPtr
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPPtr1),y
|
|
|
|
|
iny
|
|
|
|
|
cmp K.MLI.PATH,y
|
|
|
|
|
bne .6
|
|
|
|
|
cmp #0 end of string ?
|
|
|
|
|
bne .2
|
|
|
|
|
|
2018-11-19 07:43:00 +00:00
|
|
|
|
lda Nod.Table.hFD,x return hFD
|
2018-11-01 08:53:47 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.6 inx
|
|
|
|
|
cpx #K.NOD.MAX
|
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
lda #MLI.E.NODEV
|
|
|
|
|
* sec
|
|
|
|
|
rts no OF found
|
|
|
|
|
|
|
|
|
|
.7 >STYA pFD
|
2018-11-19 07:43:00 +00:00
|
|
|
|
phx DEVID
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
2018-10-04 15:30:14 +00:00
|
|
|
|
lda (pFD) #S.FD.T
|
|
|
|
|
tax
|
2018-11-19 07:43:00 +00:00
|
|
|
|
pla hFILE
|
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
|
|
|
|
|
stx .8+1 save hFD
|
|
|
|
|
|
|
|
|
|
* 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
|
2018-10-04 15:30:14 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>MLICALL MLISETMARK
|
|
|
|
|
.21 bcs .9
|
|
|
|
|
|
|
|
|
|
.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
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-11-07 16:11:02 +00:00
|
|
|
|
.8 lda #$ff SELF MODIFIED
|
2018-10-04 15:30:14 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2018-11-07 16:11:02 +00:00
|
|
|
|
.9 pha Save Error Code
|
2018-10-04 15:30:14 +00:00
|
|
|
|
lda .8+1
|
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
|
|
|
|
|
IO.OPEN.BDEV sta .1+1 A=DEVID
|
2018-10-05 06:25:15 +00:00
|
|
|
|
pha
|
|
|
|
|
jsr K.IOCTL.GetPDrv
|
2018-07-12 15:20:39 +00:00
|
|
|
|
|
|
|
|
|
ldx #IOCTL.OPEN
|
2018-10-05 06:25:15 +00:00
|
|
|
|
pla pass A=DEVID To Driver
|
|
|
|
|
jsr K.IOCTL.pDrvJmp
|
2018-09-05 15:22:46 +00:00
|
|
|
|
bcs .9
|
2018-12-03 06:59:30 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
.1 lda #$ff SELF MODIFIED
|
|
|
|
|
|
2018-09-05 15:22:46 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2018-10-04 15:30:14 +00:00
|
|
|
|
IO.OPEN.DSOCK
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IO.OPEN.SSOCK
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IO.OPEN.PIPE
|
|
|
|
|
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-18 06:42:17 +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-19 11:30:45 +00:00
|
|
|
|
IO.CLOSE.PIPE jsr IO.CLOSE.NOD
|
|
|
|
|
|
|
|
|
|
ldy #S.FD.PIPE.hMem
|
|
|
|
|
|
|
|
|
|
IO.CLOSE.FD lda (pFD),y
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
jsr K.FreeMem
|
|
|
|
|
|
|
|
|
|
.1 lda IO.hFD
|
|
|
|
|
jmp K.FreeMem
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IO.CLOSE.NOD ldx #0
|
|
|
|
|
|
|
|
|
|
lda IO.hFD
|
|
|
|
|
|
|
|
|
|
.1 lda Nod.Table.hFD,x
|
|
|
|
|
cmp IO.hFD
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
stz Nod.Table.hFD,x
|
|
|
|
|
|
|
|
|
|
lda Nod.Table.hPath,x
|
|
|
|
|
stz Nod.Table.hPath,x
|
|
|
|
|
jmp K.FreeMem
|
|
|
|
|
|
|
|
|
|
.2 inx
|
|
|
|
|
cpx #K.Nod.MAX
|
|
|
|
|
bne .1
|
|
|
|
|
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
|
|
|
|
|
2018-11-19 16:15:16 +00:00
|
|
|
|
lda IO.hFD
|
|
|
|
|
|
|
|
|
|
.1 jmp $FFFF SELF MODIFIED
|
2018-06-19 05:55:12 +00:00
|
|
|
|
*--------------------------------------
|
2019-02-22 13:34:06 +00:00
|
|
|
|
* (pStack)+2 count
|
|
|
|
|
* (pStack)+0 buf
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IO.READ.PIPE ldy #S.FD.PIPE.S
|
|
|
|
|
lda (pFD),y
|
|
|
|
|
bne .11
|
|
|
|
|
jmp IO.READ.PIPE.99 Remote PS closed the Pipe
|
2019-02-23 22:01:58 +00:00
|
|
|
|
|
2019-02-22 13:34:06 +00:00
|
|
|
|
.11 ldy #S.FD.PIPE.Used+1
|
2019-02-22 21:54:47 +00:00
|
|
|
|
|
2019-02-22 13:34:06 +00:00
|
|
|
|
lda (pFD),y
|
|
|
|
|
dey
|
|
|
|
|
ora (pFD),y
|
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
* lda #0 BLOCKING I/O
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.10 >PULLW .3+1 get buf
|
|
|
|
|
|
|
|
|
|
>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-23 22:01:58 +00:00
|
|
|
|
* >DEBUG
|
|
|
|
|
|
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-22 13:34:06 +00:00
|
|
|
|
beq 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
|
2019-02-23 22:01:58 +00:00
|
|
|
|
|
|
|
|
|
* >DEBUG
|
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
|
|
|
|
|
lda Dev.Table+1,x
|
|
|
|
|
beq K.IOCTL.9
|
2018-07-11 15:13:29 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
sta pFD+1
|
|
|
|
|
lda Dev.Table,x
|
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
IO.EOF.SSOCK
|
2019-02-21 16:26:21 +00:00
|
|
|
|
lda #MLI.E.IO
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2019-02-20 16:07:43 +00:00
|
|
|
|
*--------------------------------------
|
2019-02-23 22:01:58 +00:00
|
|
|
|
IO.EOF.PIPE >DEBUG
|
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/"
|
|
|
|
|
*--------------------------------------
|
2018-06-08 14:42:11 +00:00
|
|
|
|
MAN
|
2018-11-17 17:17:13 +00:00
|
|
|
|
SAVE USR/SRC/SYS/KERNEL.S.IO
|
|
|
|
|
LOAD USR/SRC/SYS/KERNEL.S
|
2018-06-08 14:42:11 +00:00
|
|
|
|
ASM
|