2016-01-16 22:04:22 +00:00
|
|
|
|
PR#3
|
|
|
|
|
PREFIX /A2OSX.SRC
|
2017-02-15 21:46:21 +00:00
|
|
|
|
LOMEM $900
|
2016-01-16 22:04:22 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
2017-01-31 16:40:37 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #SKT.New
|
2017-02-13 07:26:18 +00:00
|
|
|
|
* Create a new socket
|
2017-01-31 16:40:37 +00:00
|
|
|
|
* ##In :
|
|
|
|
|
* PUSHW = PTR to S.SOCKET template
|
|
|
|
|
* ##Out :
|
|
|
|
|
* YA = PTR to new S.SOCKET
|
|
|
|
|
* X = hSocket
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.New >PULLW ZPTmpPtr1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ldy #S.SOCKET.SRC.PORT+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
lda (ZPTmpPtr1),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
dey
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ora (ZPTmpPtr1),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
jsr GetDynPort
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sta (ZPTmpPtr1),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
txa
|
|
|
|
|
iny
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sta (ZPTmpPtr1),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-02-10 07:29:58 +00:00
|
|
|
|
.1 lda hSocketTable
|
|
|
|
|
>SYSCALL GetMemPtrA
|
2016-03-13 22:09:00 +00:00
|
|
|
|
>STYA ZPTmpPtr2
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-01-30 21:03:12 +00:00
|
|
|
|
lda #$ff
|
|
|
|
|
sta TmpOffset to keep track of any free slot
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ldx #0
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.2 lda (ZPTmpPtr2)
|
2017-01-30 21:03:12 +00:00
|
|
|
|
beq .4 empty!!!
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
cmp (ZPTmpPtr1)
|
2017-01-30 21:03:12 +00:00
|
|
|
|
bne .5 not same SKT type...try next
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ldy #S.SOCKET.SRC.ADDR
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.3 lda (ZPTmpPtr1),y
|
|
|
|
|
cmp (ZPTmpPtr2),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bne .5
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #S.SOCKET.DST.PORT+2
|
|
|
|
|
bne .3
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-01-30 21:03:12 +00:00
|
|
|
|
lda #ERR.SKT.BUSY same one!!!!! busy...
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2017-01-30 21:03:12 +00:00
|
|
|
|
.4 lda TmpOffset
|
|
|
|
|
bpl .5 already found an empty slot....
|
|
|
|
|
|
|
|
|
|
>LDYA ZPTmpPtr2 found one...
|
|
|
|
|
>STYA ZPTmpPtr3 save it!
|
2017-01-30 16:30:39 +00:00
|
|
|
|
stx TmpOffset
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.5 lda ZPTmpPtr2
|
2016-01-16 22:04:22 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.SOCKET
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sta ZPTmpPtr2
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bcc .6
|
2016-03-13 22:09:00 +00:00
|
|
|
|
inc ZPTmpPtr2+1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.6 inx
|
|
|
|
|
cpx #K.SKTTABLE.SIZE
|
|
|
|
|
bne .2
|
|
|
|
|
|
2017-01-30 21:03:12 +00:00
|
|
|
|
lda TmpOffset Did we found an empty slot ?
|
|
|
|
|
bmi .9
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
ldy #S.SOCKET.TEMPLATE-1
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.7 lda (ZPTmpPtr1),y
|
|
|
|
|
sta (ZPTmpPtr3),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .7
|
|
|
|
|
|
2017-02-10 07:29:58 +00:00
|
|
|
|
lda (ZPTmpPtr1)
|
|
|
|
|
cmp #S.SOCKET.SOCK.STREAM
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SO
|
|
|
|
|
lda (ZPTmpPtr1),y
|
|
|
|
|
and #S.SOCKET.SO.ACCEPTCONN
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
jsr SKT.New.TCP
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
.8 ldx TmpOffset
|
2016-03-13 22:09:00 +00:00
|
|
|
|
>LDYA ZPTmpPtr3
|
2016-01-16 22:04:22 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.9 lda #ERR.SKT.OOS
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sec
|
2017-02-10 07:29:58 +00:00
|
|
|
|
.99 rts
|
2016-01-16 22:04:22 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-10 07:29:58 +00:00
|
|
|
|
SKT.New.TCP ldy #S.SOCKET.SQ.INFREE
|
|
|
|
|
lda #K.TCP.WSIZE
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
iny
|
|
|
|
|
lda /K.TCP.WSIZE
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SQ.OUTFREE
|
|
|
|
|
lda #K.TCP.WSIZE
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
iny
|
|
|
|
|
lda /K.TCP.WSIZE
|
|
|
|
|
sta (ZPTmpPtr3),y
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
ldy #S.SOCKET.SQ.INUSED
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
iny
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SQ.OUTUSED
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
iny
|
|
|
|
|
sta (ZPTmpPtr3),y
|
2017-02-10 07:29:58 +00:00
|
|
|
|
|
2017-02-15 21:46:21 +00:00
|
|
|
|
ldx #3
|
|
|
|
|
ldy #S.SOCKET.SQ.SEQNUM+3
|
|
|
|
|
|
|
|
|
|
.2 lda A2osX.TIMER16,x
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
2017-02-10 07:29:58 +00:00
|
|
|
|
>PUSHW K.TCP.WSIZE
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>SYSCALL GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
txa
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.STREAM.hInMem
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
|
|
|
|
|
>PUSHW K.TCP.WSIZE
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>SYSCALL GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
txa
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.STREAM.hOutMem
|
|
|
|
|
sta (ZPTmpPtr3),y
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
2017-02-13 07:26:18 +00:00
|
|
|
|
*/--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* #SKT.CloseA
|
|
|
|
|
* Close socket
|
|
|
|
|
* ##In :
|
|
|
|
|
* A = hSocket
|
|
|
|
|
* ##Out :
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.CloseA cmp #K.SKTTABLE.SIZE
|
|
|
|
|
bcs SKT.GetA.9
|
|
|
|
|
|
|
|
|
|
jsr SKT.GetA.I
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
cmp #S.SOCKET.SOCK.DGRAM
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
cmp #S.SOCKET.SOCK.RAW
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SO
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
bit #S.SOCKET.SO.ACCEPTCONN
|
|
|
|
|
|
|
|
|
|
beq *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.8 lda #0
|
|
|
|
|
sta (ZPPtrSKT)
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #SKT.GetA
|
|
|
|
|
* Get Ptr to socket
|
|
|
|
|
* ##In :
|
|
|
|
|
* A = hSocket
|
|
|
|
|
* ##Out :
|
|
|
|
|
* Y,A = pS.SOCKET
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.GetA cmp #K.SKTTABLE.SIZE
|
|
|
|
|
bcs SKT.GetA.9
|
|
|
|
|
|
|
|
|
|
jsr SKT.GetA.I
|
|
|
|
|
|
|
|
|
|
bcs SKT.GetA.9
|
|
|
|
|
|
|
|
|
|
>LDYA ZPPtrSKT
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
SKT.GetA.I pha
|
|
|
|
|
lda hSocketTable
|
|
|
|
|
>SYSCALL GetMemPtrA
|
|
|
|
|
>STYA ZPPtrSKT
|
|
|
|
|
|
|
|
|
|
plx
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
.1 lda ZPPtrSKT
|
|
|
|
|
clc
|
|
|
|
|
adc #S.SOCKET
|
|
|
|
|
sta ZPPtrSKT
|
|
|
|
|
bcc .2
|
|
|
|
|
|
|
|
|
|
inc ZPPtrSKT+1
|
|
|
|
|
|
|
|
|
|
.2 dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.8 lda (ZPPtrSKT)
|
|
|
|
|
beq SKT.GetA.9
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
SKT.GetA.9 lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #SKT.GetTable
|
|
|
|
|
* Get socket table
|
|
|
|
|
* ##In :
|
|
|
|
|
* ##Out :
|
|
|
|
|
* Y,A = pS.SOCKET
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.GetTable lda hSocketTable
|
|
|
|
|
>SYSCALL GetMemPtrA
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
2017-02-13 07:26:18 +00:00
|
|
|
|
* #SKT.AcceptA
|
|
|
|
|
* Check for an incoming connection
|
|
|
|
|
* ##In :
|
|
|
|
|
* A = hListeningSocket
|
|
|
|
|
* ##Out :
|
|
|
|
|
* A = hSocket
|
|
|
|
|
*\--------------------------------------
|
2017-02-10 07:29:58 +00:00
|
|
|
|
SKT.AcceptA jsr SKT.GetA.I
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
ldy #S.SOCKET.SO
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
and #S.SOCKET.SO.ACCEPTCONN
|
2017-02-15 21:46:21 +00:00
|
|
|
|
beq .99
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
ldy #S.SOCKET.HQ.TAIL
|
2017-02-17 22:04:53 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ldy #S.SOCKET.HQ.HEAD
|
2016-03-13 22:09:00 +00:00
|
|
|
|
cmp (ZPPtrSKT),y Queue Empty
|
2017-02-17 22:04:53 +00:00
|
|
|
|
beq .9 CS
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-02-17 22:04:53 +00:00
|
|
|
|
pha save tail...
|
2016-03-13 22:09:00 +00:00
|
|
|
|
inc
|
2017-01-31 16:40:37 +00:00
|
|
|
|
cmp #S.SOCKET.HQ.MAX
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bne .1
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
lda #0
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-02-17 22:04:53 +00:00
|
|
|
|
.1 ldy #S.SOCKET.HQ.TAIL
|
|
|
|
|
sta (ZPPtrSKT),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
pla
|
|
|
|
|
clc
|
2017-01-31 16:40:37 +00:00
|
|
|
|
adc #S.SOCKET.HQ
|
2016-03-13 22:09:00 +00:00
|
|
|
|
tay
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
clc
|
2016-01-16 22:04:22 +00:00
|
|
|
|
rts
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.99 lda #ERR.SKT.BAD
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sec
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.9 rts
|
2017-02-13 07:26:18 +00:00
|
|
|
|
*/--------------------------------------
|
2017-02-15 21:46:21 +00:00
|
|
|
|
* #SKT.Write (DGRAM,STREAM,RAW)
|
2017-02-13 07:26:18 +00:00
|
|
|
|
* Send block of data
|
|
|
|
|
* ##In :
|
|
|
|
|
* PUSHB = hSocket
|
|
|
|
|
* PUSHW = pBuf
|
|
|
|
|
* PUSHW = len
|
|
|
|
|
* ##Out :
|
|
|
|
|
* A = hFrame
|
|
|
|
|
*\--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
SKT.Write >PULLW ZPDataInLen
|
2017-01-31 16:40:37 +00:00
|
|
|
|
>PULLW ZPDataInPtr
|
2017-02-10 16:49:14 +00:00
|
|
|
|
>PULLB hSocket
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
jsr SKT.GetA.I
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bcs .9
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
cmp #S.SOCKET.SOCK.DGRAM
|
2017-02-15 16:14:41 +00:00
|
|
|
|
beq SKT.Write.UDP
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
cmp #S.SOCKET.SOCK.STREAM
|
2017-01-30 16:30:39 +00:00
|
|
|
|
bne .1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
ldy #S.SOCKET.SO
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
and #S.SOCKET.SO.ACCEPTCONN
|
|
|
|
|
bne .99
|
2017-02-15 16:14:41 +00:00
|
|
|
|
jmp SKT.Write.TCP
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 cmp #S.SOCKET.SOCK.RAW
|
2017-01-30 16:30:39 +00:00
|
|
|
|
bne .99
|
2017-02-15 16:14:41 +00:00
|
|
|
|
jmp SKT.Write.RAW
|
2017-01-30 16:30:39 +00:00
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
.99 lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
SKT.Write.UDP ldx #S.IP.PROTOCOL.UDP
|
2017-02-13 07:26:18 +00:00
|
|
|
|
>LDYA ZPDataInLen
|
|
|
|
|
jsr FRM.NewIP
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
jsr SKT.SetFrameOutDstIP
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-02-16 16:26:11 +00:00
|
|
|
|
ldy #S.SOCKET.SRC.PORT
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
tax
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ldy #S.UDP.SRCPORT
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.DST.PORT
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
tax
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ldy #S.UDP.DSTPORT
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
jsr SKT.CopyDataInToOut
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
jmp FRM.SendIP
|
2017-01-31 16:40:37 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
SKT.Write.RAW ldy #S.SOCKET.RAW.PROTO
|
2017-02-13 07:26:18 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
tax
|
|
|
|
|
>LDYA ZPDataInLen
|
|
|
|
|
jsr FRM.NewIP
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr SKT.SetFrameOutDstIP
|
|
|
|
|
|
|
|
|
|
jsr SKT.CopyDataInToOut
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
jmp FRM.SendIP
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
SKT.Write.TCP ldy #S.SOCKET.TCP.STATUS
|
2017-02-08 06:52:30 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2017-02-15 16:14:41 +00:00
|
|
|
|
cmp #S.SOCKET.TCP.STATUS.ESTBLSH
|
|
|
|
|
bne .91
|
2017-02-06 17:04:03 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
jsr SKT.AddDataToSktOut
|
|
|
|
|
bcs .90
|
2017-02-09 16:24:19 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
jsr TCP.OUT try to push, ignore error....
|
2017-02-09 16:24:19 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.90 lda #0 no data transfered
|
2017-02-09 16:24:19 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
.91 lda #MLI.ERR.IO
|
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
2017-02-09 16:24:19 +00:00
|
|
|
|
*/--------------------------------------
|
2017-02-15 21:46:21 +00:00
|
|
|
|
* #SKT.ReadA (DGRAM,RAW)
|
2017-02-09 16:24:19 +00:00
|
|
|
|
* ##In :
|
|
|
|
|
* A = hSocket
|
|
|
|
|
* ##Out :
|
|
|
|
|
* A = hFrame
|
|
|
|
|
*\--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
SKT.ReadA jsr SKT.GetA.I
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
ldy #S.SOCKET.HQ.TAIL
|
2016-03-13 22:09:00 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2016-03-27 21:06:56 +00:00
|
|
|
|
tax
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
ldy #S.SOCKET.HQ.HEAD
|
2016-03-13 22:09:00 +00:00
|
|
|
|
cmp (ZPPtrSKT),y
|
|
|
|
|
beq .99
|
|
|
|
|
|
|
|
|
|
inc
|
2017-01-31 16:40:37 +00:00
|
|
|
|
cmp #S.SOCKET.HQ.MAX
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bne .1
|
|
|
|
|
lda #0
|
2016-03-27 21:06:56 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.1 ldy #S.SOCKET.HQ.TAIL
|
2016-03-27 21:06:56 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
txa
|
2016-03-13 22:09:00 +00:00
|
|
|
|
clc
|
2017-01-31 16:40:37 +00:00
|
|
|
|
adc #S.SOCKET.HQ
|
2016-03-13 22:09:00 +00:00
|
|
|
|
tay
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
clc
|
2016-01-16 22:04:22 +00:00
|
|
|
|
rts
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
.99 sec
|
|
|
|
|
.9 rts
|
2017-02-09 16:24:19 +00:00
|
|
|
|
*/--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* #SKT.PutC (STREAM)
|
|
|
|
|
* Write a Char To Stream
|
|
|
|
|
* ##In :
|
|
|
|
|
* PUSHB = hSocket
|
|
|
|
|
* PUSHB = Char
|
|
|
|
|
* ##Out :
|
|
|
|
|
* A = char
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.PutC sec
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #SKT.PutS (STREAM)
|
|
|
|
|
* Write Line in pBuf
|
|
|
|
|
* ##In :
|
|
|
|
|
* PUSHB = hSocket
|
|
|
|
|
* PUSHW = PSTR
|
|
|
|
|
* ##Out :
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.PutS
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
2017-02-10 16:49:14 +00:00
|
|
|
|
* #SKT.GetCA (STREAM)
|
|
|
|
|
* Read a Char From Stream in A
|
2017-02-10 07:29:58 +00:00
|
|
|
|
* ##In :
|
2017-02-10 16:49:14 +00:00
|
|
|
|
* A = hSocket
|
|
|
|
|
* ##Out :
|
|
|
|
|
* A = char
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.GetCA sec
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* #SKT.GetS (STREAM)
|
|
|
|
|
* Read a CR terminated Line in pBuf
|
|
|
|
|
* ##In :
|
|
|
|
|
* PUSHB = hSocket
|
|
|
|
|
* PUSHW = pBuf
|
|
|
|
|
* PUSHW = len
|
2017-02-10 07:29:58 +00:00
|
|
|
|
* ##Out :
|
|
|
|
|
* Y,A = bytes read
|
|
|
|
|
*\--------------------------------------
|
2017-02-10 16:49:14 +00:00
|
|
|
|
SKT.GetS sec
|
|
|
|
|
.HS 90 bcc
|
2017-02-10 07:29:58 +00:00
|
|
|
|
*/--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* #SKT.Read (STREAM)
|
2017-02-10 16:49:14 +00:00
|
|
|
|
* Read data in pBuf
|
2017-02-09 16:24:19 +00:00
|
|
|
|
* ##In :
|
2017-02-10 16:49:14 +00:00
|
|
|
|
* PUSHB = hSocket
|
|
|
|
|
* PUSHW = pBuf
|
|
|
|
|
* PUSHW = len
|
|
|
|
|
* ##Out :
|
|
|
|
|
* Y,A = bytes transfered
|
2017-02-09 16:24:19 +00:00
|
|
|
|
*\--------------------------------------
|
2017-02-15 16:14:41 +00:00
|
|
|
|
SKT.Read clc
|
|
|
|
|
ror bTextMode
|
|
|
|
|
>PULLW ZPDataOutLen
|
2017-02-10 16:49:14 +00:00
|
|
|
|
>PULLW ZPDataOutPtr
|
|
|
|
|
>PULLB hSocket
|
|
|
|
|
|
|
|
|
|
jsr SKT.GetA.I
|
|
|
|
|
bcs .99
|
|
|
|
|
cmp #S.SOCKET.SOCK.STREAM
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .90 bad skt
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SO
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
and #S.SOCKET.SO.ACCEPTCONN
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .90 Bad Skt
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.STATUS
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
cmp #S.SOCKET.TCP.STATUS.ESTBLSH
|
|
|
|
|
bne .91 IO err
|
|
|
|
|
|
|
|
|
|
jsr SKT.GetDataFromSktIn
|
|
|
|
|
bcs .99 No data...
|
|
|
|
|
|
|
|
|
|
>STYA TmpOffset
|
|
|
|
|
ldy #S.SOCKET.SQ.ACKNUM
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
clc
|
|
|
|
|
adc TmpOffset
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
adc TmpOffset+1
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
adc #0
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
adc #0
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.OPTIONS
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ora #S.TCP.OPTIONS.ACK
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
>LDYA TmpOffset
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.90 lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.91 lda #MLI.ERR.IO
|
2017-02-10 16:49:14 +00:00
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* PRIVATE
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* ZPPtrSKT -> actual socket
|
|
|
|
|
* A = hSocket or hFrame
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.AddToQueueA sta .2+1
|
|
|
|
|
ldy #S.SOCKET.HQ.HEAD
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
tax
|
|
|
|
|
inc
|
|
|
|
|
cmp #S.SOCKET.HQ.MAX
|
|
|
|
|
bne .1
|
|
|
|
|
lda #0
|
|
|
|
|
.1 ldy #S.SOCKET.HQ.TAIL
|
|
|
|
|
cmp (ZPPtrSKT),y
|
|
|
|
|
beq .9 Queue full!!
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.HQ.HEAD
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
txa
|
|
|
|
|
clc
|
|
|
|
|
adc #S.SOCKET.HQ
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.2 lda #$ff
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* From TCP.IN
|
2017-02-17 16:39:38 +00:00
|
|
|
|
* Src : A,X
|
|
|
|
|
* Dst : hOutMem/OUTTAIL
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.FreeDataFromSktOutAX
|
|
|
|
|
pha
|
|
|
|
|
ldy #S.SOCKET.SQ.OUTTAIL
|
|
|
|
|
clc
|
|
|
|
|
adc (ZPPtrSKT),y
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
adc (ZPPtrSKT),y
|
|
|
|
|
and /K.TCP.WSIZE-1
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
sta .1+1
|
|
|
|
|
stx .2+1
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SQ.OUTFREE
|
|
|
|
|
clc
|
|
|
|
|
adc (ZPPtrSKT),y
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
adc (ZPPtrSKT),y
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SQ.OUTUSED
|
|
|
|
|
sec
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
.1 sbc #$ff
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
adc (ZPPtrSKT),y
|
|
|
|
|
.2 sbc #$ff
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* From TCP.IN
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* Src : ZPDataInPtr/ZPDataInLen
|
|
|
|
|
* Dst : hInMem/INHEAD
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.AddDataToSktIn
|
2017-02-17 16:39:38 +00:00
|
|
|
|
jsr SKT.GetTCB
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldx ZPDataInLen
|
2017-02-17 16:39:38 +00:00
|
|
|
|
cpx SKT.TCBCache+S.SOCKET.SQ.INFREE
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataInLen+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sbc SKT.TCBCache+S.SOCKET.SQ.INFREE+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bcc .9 Not enough room in Q
|
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.STREAM.hInMem
|
2017-02-10 16:49:14 +00:00
|
|
|
|
>SYSCALL GetMemPtrA
|
|
|
|
|
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
clc
|
2017-02-17 16:39:38 +00:00
|
|
|
|
adc SKT.TCBCache+S.SOCKET.SQ.INHEAD
|
2017-02-10 16:49:14 +00:00
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
adc SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2+1 Make ZPTmpPtr2=base+Tail
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataInLen
|
|
|
|
|
eor #$FF
|
|
|
|
|
tax
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataInLen+1
|
|
|
|
|
eor #$FF
|
|
|
|
|
pha
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 inx
|
|
|
|
|
bne .2
|
|
|
|
|
pla
|
|
|
|
|
inc
|
2017-02-10 16:49:14 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.2 lda (ZPDataInPtr),y
|
|
|
|
|
sta (ZPTmpPtr2)
|
|
|
|
|
iny
|
|
|
|
|
bne .3
|
|
|
|
|
inc ZPDataInPtr+1
|
|
|
|
|
|
|
|
|
|
.3 inc ZPTmpPtr2
|
2017-02-10 16:49:14 +00:00
|
|
|
|
bne .4
|
2017-02-15 16:14:41 +00:00
|
|
|
|
inc ZPTmpPtr2+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
.4 inc SKT.TCBCache+S.SOCKET.SQ.INHEAD
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
inc SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
|
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
cmp /K.TCP.WSIZE
|
|
|
|
|
bne .1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
stz SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPTmpPtr1 Dst Ptr=Buffer Base
|
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
sta ZPTmpPtr2+1
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
.8 lda SKT.TCBCache+S.SOCKET.SQ.INFREE
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc ZPDataInLen
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.INFREE
|
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INFREE+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sbc ZPDataInLen+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.INFREE+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INUSED
|
2017-02-15 16:14:41 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPDataInLen
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.INUSED
|
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INUSED+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
adc ZPDataInLen+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.INUSED+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
jsr SKT.StoreTCB
|
2017-02-15 16:14:41 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* From SKT.SEND.TCP
|
|
|
|
|
* Src : ZPDataInPtr/ZPDataInLen
|
|
|
|
|
* Dst : hOutMem/OUTHEAD
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.AddDataToSktOut
|
2017-02-17 16:39:38 +00:00
|
|
|
|
jsr SKT.GetTCB
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
ldx ZPDataInLen
|
2017-02-17 16:39:38 +00:00
|
|
|
|
cpx SKT.TCBCache+S.SOCKET.SQ.OUTFREE
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataInLen+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sbc SKT.TCBCache+S.SOCKET.SQ.OUTFREE+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bcc .9 Not enough room in Q
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.STREAM.hOutMem
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>SYSCALL GetMemPtrA
|
|
|
|
|
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
clc
|
2017-02-17 16:39:38 +00:00
|
|
|
|
adc SKT.TCBCache+S.SOCKET.SQ.OUTHEAD
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
adc SKT.TCBCache+S.SOCKET.SQ.OUTHEAD+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2+1 Make ZPTmpPtr2=base+Tail
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataInLen
|
|
|
|
|
eor #$FF
|
|
|
|
|
tax
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataInLen+1
|
|
|
|
|
eor #$FF
|
|
|
|
|
pha
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 inx
|
|
|
|
|
bne .2
|
|
|
|
|
pla
|
|
|
|
|
inc
|
|
|
|
|
beq .8
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.2 lda (ZPDataInPtr),y
|
|
|
|
|
sta (ZPTmpPtr2)
|
|
|
|
|
iny
|
|
|
|
|
bne .3
|
|
|
|
|
inc ZPDataInPtr+1
|
|
|
|
|
|
|
|
|
|
.3 inc ZPTmpPtr2
|
|
|
|
|
bne .4
|
|
|
|
|
inc ZPTmpPtr2+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
.4 inc SKT.TCBCache+S.SOCKET.SQ.OUTHEAD
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
inc SKT.TCBCache+S.SOCKET.SQ.OUTHEAD+1
|
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.OUTHEAD+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
cmp /K.TCP.WSIZE
|
|
|
|
|
bne .1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
stz SKT.TCBCache+S.SOCKET.SQ.OUTHEAD+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPTmpPtr1 Dst Ptr=Buffer Base
|
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
sta ZPTmpPtr2+1
|
|
|
|
|
bra .1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
.8 lda SKT.TCBCache+S.SOCKET.SQ.OUTFREE
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc ZPDataInLen
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.OUTFREE
|
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.OUTFREE+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sbc ZPDataInLen+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.OUTFREE+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.OUTUSED
|
2017-02-15 16:14:41 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPDataInLen
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.OUTUSED
|
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.OUTUSED+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
adc ZPDataInLen+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.OUTUSED+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
jsr SKT.StoreTCB
|
2017-02-10 16:49:14 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* From TCP.OUT
|
|
|
|
|
* Src : hOutMem/OUTTAIL
|
|
|
|
|
* Dst : ZPDataOutPtr/ZPDataOutLen
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.GetDataFromSktOut
|
2017-02-17 16:39:38 +00:00
|
|
|
|
jsr SKT.GetTCB
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.STREAM.hOutMem
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>SYSCALL GetMemPtrA
|
|
|
|
|
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
clc
|
2017-02-17 16:39:38 +00:00
|
|
|
|
adc SKT.TCBCache+S.SOCKET.SQ.OUTTAIL
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
adc SKT.TCBCache+S.SOCKET.SQ.OUTTAIL+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataOutLen
|
|
|
|
|
eor #$FF
|
|
|
|
|
tax
|
2017-01-31 22:13:26 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataOutLen+1
|
|
|
|
|
eor #$FF
|
|
|
|
|
pha
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #0
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.1 inx
|
|
|
|
|
bne .2
|
|
|
|
|
pla
|
|
|
|
|
inc
|
2017-01-30 22:23:16 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.2 lda (ZPTmpPtr2)
|
|
|
|
|
sta (ZPDataOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
bne .3
|
|
|
|
|
inc ZPDataOutPtr+1
|
|
|
|
|
|
|
|
|
|
.3 inc ZPTmpPtr2
|
|
|
|
|
bne .4
|
|
|
|
|
inc ZPTmpPtr2+1
|
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
.4 inc SKT.TCBCache+S.SOCKET.SQ.OUTTAIL
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
inc SKT.TCBCache+S.SOCKET.SQ.OUTTAIL+1
|
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.OUTTAIL+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
cmp /K.TCP.WSIZE
|
|
|
|
|
bne .1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
stz SKT.TCBCache+S.SOCKET.SQ.OUTTAIL+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1 Dst Ptr=Buffer Base
|
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
sta ZPTmpPtr2+1
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-02-17 16:39:38 +00:00
|
|
|
|
* From SKT.Read
|
2017-02-15 16:14:41 +00:00
|
|
|
|
* In:
|
|
|
|
|
* Src : hInMem/INTAIL
|
|
|
|
|
* Dst : ZPDataOutPtr/ZPDataOutLen
|
|
|
|
|
* CS : Text Mode
|
|
|
|
|
* CC : Binary Mode
|
|
|
|
|
* Out:
|
|
|
|
|
* Y,A = bytes read
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.GetDataFromSktIn
|
|
|
|
|
ldy #S.SOCKET.STREAM.hInMem
|
2016-03-13 22:09:00 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>SYSCALL GetMemPtrA
|
|
|
|
|
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
|
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
jsr SKT.GetTCB
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
clc
|
2017-02-17 16:39:38 +00:00
|
|
|
|
adc SKT.TCBCache+S.SOCKET.SQ.INTAIL
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
adc SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataOutLen
|
|
|
|
|
eor #$FF
|
|
|
|
|
tax
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPDataOutLen+1
|
|
|
|
|
eor #$FF
|
|
|
|
|
pha
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
stz ZPTmpPtr3 Reset byte counter
|
|
|
|
|
stz ZPTmpPtr3+1
|
2017-02-10 07:29:58 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #0
|
2017-02-10 07:29:58 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.1 inx Check if room left in dest buffer
|
|
|
|
|
bne .2
|
|
|
|
|
pla
|
|
|
|
|
inc
|
|
|
|
|
beq .7
|
|
|
|
|
pha
|
2017-02-10 07:29:58 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
.2 lda SKT.TCBCache+S.SOCKET.SQ.INTAIL
|
|
|
|
|
eor SKT.TCBCache+S.SOCKET.SQ.INHEAD
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .3
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
|
|
|
|
|
eor SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
beq .8 no more data....
|
2017-01-31 16:40:37 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.3 lda (ZPTmpPtr2)
|
|
|
|
|
pha
|
2017-01-30 22:23:16 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
inc SKT.TCBCache+S.SOCKET.SQ.INTAIL
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .5
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
inc SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
|
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
cmp /K.TCP.WSIZE
|
|
|
|
|
bne .4
|
2017-02-10 07:29:58 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
stz SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
sta ZPTmpPtr2+1
|
|
|
|
|
bra .5
|
2017-02-10 07:29:58 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.4 inc ZPTmpPtr2
|
|
|
|
|
bne .4
|
|
|
|
|
inc ZPTmpPtr2+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.5 pla get back data....
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bit bTextMode do we need to check CR ?
|
|
|
|
|
bpl .6
|
|
|
|
|
|
|
|
|
|
cmp #13
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
.6 sta (ZPDataOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
bne .61
|
|
|
|
|
inc ZPDataOutPtr+1
|
|
|
|
|
|
|
|
|
|
.61 inc ZPTmpPtr3
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bne .1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
inc ZPTmpPtr3+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bra .1
|
2017-01-30 16:30:39 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.7 bit bTextMode here, bacause dst buf full....
|
|
|
|
|
bmi .9 ....and TextMode selected, NO ending CR found
|
|
|
|
|
|
|
|
|
|
.8 pla discard byte counter HI
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr3 Do we have transfered something?
|
|
|
|
|
eor ZPTmpPtr3+1
|
|
|
|
|
beq .9
|
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INFREE
|
2016-03-13 22:09:00 +00:00
|
|
|
|
clc
|
2017-02-15 16:14:41 +00:00
|
|
|
|
adc ZPTmpPtr3
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.INFREE
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INFREE+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
adc ZPTmpPtr3+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.INFREE+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INUSED
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc ZPTmpPtr3
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.INUSED
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
lda SKT.TCBCache+S.SOCKET.SQ.INUSED+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sbc ZPTmpPtr3+1
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache+S.SOCKET.SQ.INUSED+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-02-17 16:39:38 +00:00
|
|
|
|
jsr SKT.StoreTCB
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>LDYA ZPTmpPtr3
|
2016-03-13 22:09:00 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.9 lda #0 NO DATA
|
|
|
|
|
sec
|
2016-03-13 22:09:00 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-02-17 16:39:38 +00:00
|
|
|
|
SKT.GetTCB ldy #S.SOCKET-1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
.1 lda (ZPPtrSKT),y
|
2017-02-17 16:39:38 +00:00
|
|
|
|
sta SKT.TCBCache,y
|
2017-02-10 16:49:14 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-02-17 16:39:38 +00:00
|
|
|
|
SKT.StoreTCB ldy #S.SOCKET-1
|
|
|
|
|
.1 lda SKT.TCBCache,y
|
2017-02-10 16:49:14 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-01-31 16:40:37 +00:00
|
|
|
|
SKT.SetFrameOutDstIP
|
|
|
|
|
ldy #S.SOCKET.DST.ADDR
|
|
|
|
|
ldx #4
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPPtrSKT),y
|
|
|
|
|
pha
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
ldy #S.IP.DST+3
|
|
|
|
|
ldx #4
|
|
|
|
|
|
|
|
|
|
.2 pla
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.CopyDataInToOut
|
2017-02-13 07:26:18 +00:00
|
|
|
|
lda ZPDataInPtr+1
|
|
|
|
|
pha
|
|
|
|
|
lda ZPDataOutPtr+1
|
|
|
|
|
pha
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPDataInLen
|
|
|
|
|
eor #$ff
|
2017-02-13 07:26:18 +00:00
|
|
|
|
tax
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPDataInLen+1
|
|
|
|
|
eor #$ff
|
2017-02-13 07:26:18 +00:00
|
|
|
|
pha
|
2017-01-31 16:40:37 +00:00
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
.1 inx
|
2017-01-31 16:40:37 +00:00
|
|
|
|
bne .2
|
2017-02-13 07:26:18 +00:00
|
|
|
|
pla
|
|
|
|
|
inc
|
2017-01-31 16:40:37 +00:00
|
|
|
|
beq .9
|
2017-02-13 07:26:18 +00:00
|
|
|
|
pha
|
2017-01-31 16:40:37 +00:00
|
|
|
|
|
|
|
|
|
.2 lda (ZPDataInPtr),y
|
|
|
|
|
sta (ZPDataOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
bne .1
|
|
|
|
|
inc ZPDataInPtr+1
|
|
|
|
|
inc ZPDataOutPtr+1
|
|
|
|
|
bne .1
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
|
|
|
|
.9 pla
|
|
|
|
|
sta ZPDataOutPtr+1
|
|
|
|
|
pla
|
|
|
|
|
sta ZPDataInPtr+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
MAN
|
|
|
|
|
SAVE LIB/LIBTCPIP.S.SKT
|
|
|
|
|
LOAD LIB/LIBTCPIP.S
|
|
|
|
|
ASM
|