A2osX/SYS/KERNEL.S.PIPE.txt

298 lines
4.8 KiB
Plaintext
Raw Normal View History

2019-07-27 20:51:39 +00:00
NEW
AUTO 3,1
*--------------------------------------
2020-12-15 13:23:22 +00:00
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
2019-07-27 20:51:39 +00:00
*--------------------------------------
IO.OPEN.PIPE ldy #S.FD.PIPE.S
lda (pFD),y
inc
sta (pFD),y
2020-12-15 13:23:22 +00:00
lda IO.hDevNod
2019-07-27 20:51:39 +00:00
clc
2019-10-03 06:25:27 +00:00
rts
2019-07-27 20:51:39 +00:00
*--------------------------------------
IO.CLOSE.PIPE ldy #S.FD.PIPE.S
lda (pFD),y
bmi .1 remote PS closed its end
2020-12-15 13:23:22 +00:00
2019-07-27 20:51:39 +00:00
lda #$80
sta (pFD),y
clc
rts
2020-12-15 13:23:22 +00:00
.1 ldy #S.FD.PIPE.hMem
2019-07-27 20:51:39 +00:00
lda (pFD),y
beq .2
2020-02-16 20:45:16 +00:00
>SYSCALL2 FreeStkObj
2020-12-15 13:23:22 +00:00
.2 jmp DEV.Destroy
2019-07-27 20:51:39 +00:00
*--------------------------------------
* (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
2020-12-15 13:23:22 +00:00
>PULLW PIPE.SRCBUF
2019-07-27 20:51:39 +00:00
ldy #S.FD.PIPE.Head+1
2020-12-15 13:23:22 +00:00
jsr PIPE.GET.BUF
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
>STYA PIPE.DSTBUF
2020-03-12 07:46:43 +00:00
2019-07-27 20:51:39 +00:00
>PULLA get cnt lo
2020-12-15 13:23:22 +00:00
sta PIPE.CNT
2019-07-27 20:51:39 +00:00
eor #$ff
tax
>PULLA get cnt hi
2020-12-15 13:23:22 +00:00
sta PIPE.CNT+1
2019-07-27 20:51:39 +00:00
eor #$ff
pha
ldy #S.FD.PIPE.Head
lda (pFD),y
tay
sta SETWRITEAUX
2020-02-16 20:45:16 +00:00
2019-07-27 20:51:39 +00:00
.1 inx
bne .2
pla
inc
beq .8
2020-03-12 07:46:43 +00:00
2019-07-27 20:51:39 +00:00
pha
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
.2 lda (PIPE.SRCBUF)
sta (PIPE.DSTBUF),y
2019-07-27 20:51:39 +00:00
2020-12-15 13:23:22 +00:00
inc PIPE.SRCBUF
2019-07-27 20:51:39 +00:00
bne .4
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
inc PIPE.SRCBUF+1
2019-07-27 20:51:39 +00:00
.4 iny
bne .1
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
lda PIPE.BUFH
2019-07-27 20:51:39 +00:00
inc
2020-12-15 13:23:22 +00:00
cmp PIPE.SIZEH
2019-07-27 20:51:39 +00:00
beq .6
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
sta PIPE.BUFH
inc PIPE.DSTBUF+1
2019-07-27 20:51:39 +00:00
bra .1
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
.6 stz PIPE.BUFH
lda PIPE.BASEH Pipe Buffer Base
sta PIPE.DSTBUF+1
2019-07-27 20:51:39 +00:00
bra .1
2020-02-16 20:45:16 +00:00
.8 sta CLRWRITEAUX
2019-07-27 20:51:39 +00:00
tya
ldy #S.FD.PIPE.Head
sta (pFD),y
iny
2020-12-15 13:23:22 +00:00
lda PIPE.BUFH
2019-07-27 20:51:39 +00:00
sta (pFD),y
ldy #S.FD.PIPE.Free
2020-12-15 13:23:22 +00:00
jsr PIPE.SUB.CNT
2019-07-27 20:51:39 +00:00
iny #S.FD.PIPE.Used
2020-12-15 13:23:22 +00:00
jsr PIPE.ADD.CNT
2019-07-27 20:51:39 +00:00
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...
2020-03-12 07:46:43 +00:00
2019-07-27 20:51:39 +00:00
ldy #S.FD.PIPE.S
lda (pFD),y
bmi IO.READ.PIPE.EOF Remote PS closed the Pipe
bpl IO.READ.PIPE.NODATA
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
.10 >PULLW PIPE.DSTBUF get dest buf
2019-07-27 20:51:39 +00:00
ldy #S.FD.PIPE.Tail+1
2020-12-15 13:23:22 +00:00
jsr PIPE.GET.BUF
2019-07-27 20:51:39 +00:00
2020-12-15 13:23:22 +00:00
>STYA PIPE.SRCBUF
2019-07-27 20:51:39 +00:00
>PULLA get cnt lo
tax
ldy #S.FD.PIPE.Used
cmp (pFD),y
2020-03-12 07:46:43 +00:00
2019-07-27 20:51:39 +00:00
>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
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
.12 stx PIPE.CNT
sta PIPE.CNT+1
2019-07-27 20:51:39 +00:00
eor #$ff
pha
txa
eor #$ff
tax
ldy #S.FD.PIPE.Tail
lda (pFD),y
tay
2020-02-16 20:45:16 +00:00
2019-07-27 20:51:39 +00:00
sta SETREADAUX
.1 inx
bne .2
2020-03-12 07:46:43 +00:00
2019-07-27 20:51:39 +00:00
pla
inc
beq .8
2020-03-12 07:46:43 +00:00
2019-07-27 20:51:39 +00:00
pha
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
.2 lda (PIPE.SRCBUF),y
sta (PIPE.DSTBUF)
2019-07-27 20:51:39 +00:00
2020-12-15 13:23:22 +00:00
inc PIPE.DSTBUF
2019-07-27 20:51:39 +00:00
bne .4
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
inc PIPE.DSTBUF+1
2019-07-27 20:51:39 +00:00
.4 iny
bne .1
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
lda PIPE.BUFH
2019-07-27 20:51:39 +00:00
inc
2020-12-15 13:23:22 +00:00
cmp PIPE.SIZEH
2019-07-27 20:51:39 +00:00
beq .6
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
sta PIPE.BUFH
inc PIPE.SRCBUF+1
2019-07-27 20:51:39 +00:00
bra .1
2020-03-12 07:46:43 +00:00
2020-12-15 13:23:22 +00:00
.6 stz PIPE.BUFH
lda PIPE.BASEH
sta PIPE.SRCBUF+1 Restore Pipe Buf base
2019-07-27 20:51:39 +00:00
bra .1
2020-02-16 20:45:16 +00:00
.8 sta CLRREADAUX
2019-07-27 20:51:39 +00:00
tya
ldy #S.FD.PIPE.Tail
sta (pFD),y
iny
2020-12-15 13:23:22 +00:00
lda PIPE.BUFH
2019-07-27 20:51:39 +00:00
sta (pFD),y
ldy #S.FD.PIPE.Free
2020-12-15 13:23:22 +00:00
jsr PIPE.ADD.CNT
2019-07-27 20:51:39 +00:00
iny #S.FD.PIPE.Used
2020-12-15 13:23:22 +00:00
jsr PIPE.SUB.CNT
2019-10-03 06:25:27 +00:00
IO.READ.PIPE.EXIT
2020-12-15 13:23:22 +00:00
>LDYA PIPE.CNT Y,A = bytes written
2019-07-27 20:51:39 +00:00
clc
rts
*--------------------------------------
2020-12-15 13:23:22 +00:00
PIPE.GET.BUF lda (pFD),y
sta PIPE.BUFH
2019-07-27 20:51:39 +00:00
ldy #S.FD.PIPE.Size+1
lda (pFD),y
2020-12-15 13:23:22 +00:00
sta PIPE.SIZEH
2019-07-27 20:51:39 +00:00
ldy #S.FD.PIPE.hMem
lda (pFD),y
2020-02-16 20:45:16 +00:00
>SYSCALL2 GetStkObjPtr
2019-07-27 20:51:39 +00:00
2020-12-15 13:23:22 +00:00
sta PIPE.BASEH Pipe Buffer Base
2019-07-27 20:51:39 +00:00
* clc
2020-12-15 13:23:22 +00:00
adc PIPE.BUFH
2019-07-27 20:51:39 +00:00
rts
*--------------------------------------
2020-12-15 13:23:22 +00:00
PIPE.ADD.CNT clc
2019-07-27 20:51:39 +00:00
lda (pFD),y
2020-12-15 13:23:22 +00:00
adc PIPE.CNT
2019-07-27 20:51:39 +00:00
sta (pFD),y
2020-12-15 13:23:22 +00:00
2019-07-27 20:51:39 +00:00
iny
lda (pFD),y
2020-12-15 13:23:22 +00:00
adc PIPE.CNT+1
2019-07-27 20:51:39 +00:00
sta (pFD),y
rts
*--------------------------------------
2020-12-15 13:23:22 +00:00
PIPE.SUB.CNT sec
2019-07-27 20:51:39 +00:00
lda (pFD),y
2020-12-15 13:23:22 +00:00
sbc PIPE.CNT
2019-07-27 20:51:39 +00:00
sta (pFD),y
2020-12-15 13:23:22 +00:00
2019-07-27 20:51:39 +00:00
iny
2020-12-15 13:23:22 +00:00
2019-07-27 20:51:39 +00:00
lda (pFD),y
2020-12-15 13:23:22 +00:00
sbc PIPE.CNT+1
2019-07-27 20:51:39 +00:00
sta (pFD),y
rts
*--------------------------------------
IO.EOF.PIPE clc
ldy #S.FD.PIPE.Used
lda (pFD),y
iny
ora (pFD),y
beq .8
2020-12-15 13:23:22 +00:00
2019-07-27 20:51:39 +00:00
lda #0
* clc
rts
2020-12-15 13:23:22 +00:00
.8 dec lda #$ff
2019-07-27 20:51:39 +00:00
* clc
rts
*--------------------------------------
MAN
2020-12-15 13:23:22 +00:00
SAVE usr/src/sys/kernel.s.pipe
LOAD usr/src/sys/kernel.s
2019-07-27 20:51:39 +00:00
ASM