mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-22 16:31:07 +00:00
298 lines
4.8 KiB
Plaintext
298 lines
4.8 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*--------------------------------------
|
||
PIPE.SRCBUF .EQ ZPDRV
|
||
PIPE.DSTBUF .EQ ZPDRV+2
|
||
PIPE.CNT .EQ ZPDRV+4
|
||
PIPE.BASEH .EQ ZPDRV+6
|
||
PIPE.BUFH .EQ ZPDRV+7
|
||
PIPE.SIZEH .EQ ZPDRV+8
|
||
*--------------------------------------
|
||
IO.OPEN.PIPE ldy #S.FD.PIPE.S
|
||
lda (pFD),y
|
||
inc
|
||
sta (pFD),y
|
||
|
||
lda IO.hDevNod
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
IO.CLOSE.PIPE ldy #S.FD.PIPE.S
|
||
lda (pFD),y
|
||
bmi .1 remote PS closed its end
|
||
|
||
lda #$80
|
||
sta (pFD),y
|
||
clc
|
||
rts
|
||
|
||
.1 ldy #S.FD.PIPE.hMem
|
||
lda (pFD),y
|
||
beq .2
|
||
|
||
>SYSCALL2 FreeStkObj
|
||
|
||
.2 jmp DEV.Destroy
|
||
*--------------------------------------
|
||
* (pStack)+2 count
|
||
* (pStack)+0 buf
|
||
*--------------------------------------
|
||
IO.WRITE.PIPE ldy #S.FD.PIPE.S
|
||
lda (pFD),y
|
||
|
||
bpl .10
|
||
jmp IO.READ.PIPE.EOF Remote PS closed the Pipe
|
||
|
||
.10 ldy #S.FD.PIPE.Free
|
||
lda (pFD),y
|
||
ldy #2
|
||
cmp (pStack),y
|
||
|
||
ldy #S.FD.PIPE.Free+1
|
||
lda (pFD),y
|
||
ldy #3
|
||
sbc (pStack),y
|
||
bcc IO.READ.PIPE.NODATA not enough room in PIPE
|
||
|
||
>PULLW PIPE.SRCBUF
|
||
|
||
ldy #S.FD.PIPE.Head+1
|
||
jsr PIPE.GET.BUF
|
||
|
||
>STYA PIPE.DSTBUF
|
||
|
||
>PULLA get cnt lo
|
||
sta PIPE.CNT
|
||
eor #$ff
|
||
tax
|
||
|
||
>PULLA get cnt hi
|
||
sta PIPE.CNT+1
|
||
eor #$ff
|
||
pha
|
||
ldy #S.FD.PIPE.Head
|
||
lda (pFD),y
|
||
tay
|
||
|
||
sta SETWRITEAUX
|
||
|
||
.1 inx
|
||
bne .2
|
||
|
||
pla
|
||
inc
|
||
beq .8
|
||
|
||
pha
|
||
|
||
.2 lda (PIPE.SRCBUF)
|
||
sta (PIPE.DSTBUF),y
|
||
|
||
inc PIPE.SRCBUF
|
||
bne .4
|
||
|
||
inc PIPE.SRCBUF+1
|
||
.4 iny
|
||
bne .1
|
||
|
||
lda PIPE.BUFH
|
||
inc
|
||
cmp PIPE.SIZEH
|
||
beq .6
|
||
|
||
sta PIPE.BUFH
|
||
inc PIPE.DSTBUF+1
|
||
bra .1
|
||
|
||
.6 stz PIPE.BUFH
|
||
lda PIPE.BASEH Pipe Buffer Base
|
||
sta PIPE.DSTBUF+1
|
||
bra .1
|
||
|
||
.8 sta CLRWRITEAUX
|
||
|
||
tya
|
||
ldy #S.FD.PIPE.Head
|
||
sta (pFD),y
|
||
iny
|
||
lda PIPE.BUFH
|
||
sta (pFD),y
|
||
ldy #S.FD.PIPE.Free
|
||
jsr PIPE.SUB.CNT
|
||
|
||
iny #S.FD.PIPE.Used
|
||
|
||
jsr PIPE.ADD.CNT
|
||
jmp IO.READ.PIPE.EXIT
|
||
|
||
IO.READ.PIPE.EOF
|
||
lda #MLI.E.EOF
|
||
.HS 2C BIT ABS
|
||
IO.READ.PIPE.NODATA
|
||
lda #E.NODATA
|
||
sec
|
||
>RET 4
|
||
*--------------------------------------
|
||
IO.READ.PIPE ldy #S.FD.PIPE.Used+1
|
||
lda (pFD),y Data ?
|
||
dey
|
||
ora (pFD),y
|
||
bne .10 yes...
|
||
|
||
ldy #S.FD.PIPE.S
|
||
lda (pFD),y
|
||
bmi IO.READ.PIPE.EOF Remote PS closed the Pipe
|
||
bpl IO.READ.PIPE.NODATA
|
||
|
||
.10 >PULLW PIPE.DSTBUF get dest buf
|
||
|
||
ldy #S.FD.PIPE.Tail+1
|
||
jsr PIPE.GET.BUF
|
||
|
||
>STYA PIPE.SRCBUF
|
||
|
||
>PULLA get cnt lo
|
||
tax
|
||
ldy #S.FD.PIPE.Used
|
||
cmp (pFD),y
|
||
|
||
>PULLA get cnt hi
|
||
pha
|
||
iny #S.FD.PIPE.Used+1
|
||
sbc (pFD),y
|
||
pla
|
||
bcc .12 cnt < Used
|
||
|
||
dey
|
||
lda (pFD),y
|
||
tax
|
||
iny
|
||
lda (pFD),y X,A = Used
|
||
|
||
.12 stx PIPE.CNT
|
||
sta PIPE.CNT+1
|
||
|
||
eor #$ff
|
||
pha
|
||
txa
|
||
eor #$ff
|
||
tax
|
||
ldy #S.FD.PIPE.Tail
|
||
lda (pFD),y
|
||
tay
|
||
|
||
sta SETREADAUX
|
||
|
||
.1 inx
|
||
bne .2
|
||
|
||
pla
|
||
inc
|
||
beq .8
|
||
|
||
pha
|
||
|
||
.2 lda (PIPE.SRCBUF),y
|
||
sta (PIPE.DSTBUF)
|
||
|
||
inc PIPE.DSTBUF
|
||
bne .4
|
||
|
||
inc PIPE.DSTBUF+1
|
||
.4 iny
|
||
bne .1
|
||
|
||
lda PIPE.BUFH
|
||
inc
|
||
cmp PIPE.SIZEH
|
||
beq .6
|
||
|
||
sta PIPE.BUFH
|
||
inc PIPE.SRCBUF+1
|
||
bra .1
|
||
|
||
.6 stz PIPE.BUFH
|
||
lda PIPE.BASEH
|
||
sta PIPE.SRCBUF+1 Restore Pipe Buf base
|
||
bra .1
|
||
|
||
.8 sta CLRREADAUX
|
||
|
||
tya
|
||
ldy #S.FD.PIPE.Tail
|
||
sta (pFD),y
|
||
iny
|
||
lda PIPE.BUFH
|
||
sta (pFD),y
|
||
ldy #S.FD.PIPE.Free
|
||
jsr PIPE.ADD.CNT
|
||
|
||
iny #S.FD.PIPE.Used
|
||
|
||
jsr PIPE.SUB.CNT
|
||
IO.READ.PIPE.EXIT
|
||
>LDYA PIPE.CNT Y,A = bytes written
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
PIPE.GET.BUF lda (pFD),y
|
||
sta PIPE.BUFH
|
||
|
||
ldy #S.FD.PIPE.Size+1
|
||
lda (pFD),y
|
||
sta PIPE.SIZEH
|
||
|
||
ldy #S.FD.PIPE.hMem
|
||
lda (pFD),y
|
||
|
||
>SYSCALL2 GetStkObjPtr
|
||
|
||
sta PIPE.BASEH Pipe Buffer Base
|
||
* clc
|
||
adc PIPE.BUFH
|
||
rts
|
||
*--------------------------------------
|
||
PIPE.ADD.CNT clc
|
||
lda (pFD),y
|
||
adc PIPE.CNT
|
||
sta (pFD),y
|
||
|
||
iny
|
||
|
||
lda (pFD),y
|
||
adc PIPE.CNT+1
|
||
sta (pFD),y
|
||
rts
|
||
*--------------------------------------
|
||
PIPE.SUB.CNT sec
|
||
lda (pFD),y
|
||
sbc PIPE.CNT
|
||
sta (pFD),y
|
||
|
||
iny
|
||
|
||
lda (pFD),y
|
||
sbc PIPE.CNT+1
|
||
sta (pFD),y
|
||
rts
|
||
*--------------------------------------
|
||
IO.EOF.PIPE clc
|
||
ldy #S.FD.PIPE.Used
|
||
lda (pFD),y
|
||
iny
|
||
ora (pFD),y
|
||
beq .8
|
||
|
||
lda #0
|
||
* clc
|
||
rts
|
||
|
||
.8 dec lda #$ff
|
||
* clc
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/sys/kernel.s.pipe
|
||
LOAD usr/src/sys/kernel.s
|
||
ASM
|