A2osX/SYS/KERNEL.S.IO.txt
2020-03-11 17:41:45 +01:00

202 lines
4.2 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
*--------------------------------------
IO.CLOSE.REG
IO.CLOSE.DIR ldy #S.FD.REG.REF
lda (pFD),y
beq .1
sta K.MLI.PARAMS+1
>MLICALL MLICLOSE
.1 ldy #S.FD.REG.IOBUF
lda (pFD),y
beq .2
jsr K.FreeMem
.2 lda IO.hFD
jmp K.FreeMem
*--------------------------------------
IO.READ.REG ldx #MLIREAD
.HS 2C BIT ABS
*--------------------------------------
IO.WRITE.REG ldx #MLIWRITE
ldy #S.FD.REG.REF
lda (pFD),y
sta K.MLI.PARAMS+1
>PULLW K.MLI.PARAMS+2
>PULLW K.MLI.PARAMS+4
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
jsr GP.MLICall
bcs .9
>LDYA K.MLI.PARAMS+6
.9
IO.WRITE.REG.RTS
rts
*--------------------------------------
IO.OPEN.CDEV
IO.OPEN.BDEV jsr SHARED.GetPDrv
ldx #IOCTL.OPEN
lda IO.hFD
jsr SHARED.pDrvJmp
bcs IO.WRITE.REG.RTS
lda IO.hFD
*--------------------------------------
IO.CLOSE.CDEV
IO.CLOSE.BDEV
clc
rts
*--------------------------------------
IO.READ.CDEV ldx #IOCTL.READ
.HS 2C BIT ABS
*--------------------------------------
IO.WRITE.CDEV ldx #IOCTL.WRITE
>PULLW K.S.IOCTL+S.IOCTL.BUFPTR
>PULLW K.S.IOCTL+S.IOCTL.BYTECNT
jsr SHARED.GetPDRV
>LDYAI K.S.IOCTL
jsr SHARED.pDrvJmp
bcs .9
>LDYA K.S.IOCTL+S.IOCTL.BYTECNT
.9 rts
*--------------------------------------
IO.OPEN.DSOCK
*--------------------------------------
IO.OPEN.SSOCK lda IO.hFD
clc
rts
*--------------------------------------
IO.CLOSE.DSOCK
IO.CLOSE.SSOCK
ldy #S.FD.SSOCK.CLOSE
.HS 2C BIT ABS
*--------------------------------------
IO.EOF.SSOCK ldy #S.FD.SSOCK.EOF
.HS 2C BIT ABS
*--------------------------------------
IO.READ.SSOCK ldy #S.FD.SSOCK.READ
.HS 2C BIT ABS
*--------------------------------------
IO.WRITE.SSOCK ldy #S.FD.SSOCK.WRITE
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
*--------------------------------------
IO.EOF.REG >MLICALL MLIGETMARK
bcs .9
ldy #2
.1 lda K.MLI.PARAMS+2,y
sta ACC32,y
dey
bpl .1
>MLICALL MLIGETEOF
bcs .9
ldy #2
.2 lda K.MLI.PARAMS+2,y
eor ACC32,y
bne .8 FALSE
dey
bpl .2
lda #$ff TRUE
* clc
rts
.8 lda #0
* clc
.9 rts
*--------------------------------------
IO.EOF.CDEV lda #S.IOCTL.STATCODE.EOF
jmp SHARED.GetDevStatus
*--------------------------------------
* 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
*--------------------------------------
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
*--------------------------------------
IO.MLI.OPEN >LDYAI 1024 get a ProDOS IOBUF
ldx #S.MEM.F.ALIGN
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
*--------------------------------------
IO.CLOSE.NOD ldx #2
lda IO.hFD
.1 cmp Nod.Table.hFD-2,x
bne .2
stz Nod.Table.hFD-2,x
lda Nod.Table.hPath-2,x
stz Nod.Table.hPath-2,x
jmp K.FreeMem
.2 inx
cpx #K.Nod.MAX+2
bne .1
lda #E.INVH
* sec
rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.IO
LOAD USR/SRC/SYS/KERNEL.S
ASM