2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-12-22 21:24:30 +00:00
|
|
|
|
AUTO 4,1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.LIST OFF
|
2017-01-31 16:40:37 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Socket
|
2018-09-26 15:36:32 +00:00
|
|
|
|
* Create a new socket
|
|
|
|
|
* ## C
|
2018-09-28 15:24:44 +00:00
|
|
|
|
* `hFD socket(short int type, short int protocol);`
|
2018-09-26 15:36:32 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
2018-09-28 15:24:44 +00:00
|
|
|
|
* `>PUSHB protocol`
|
2018-09-26 15:36:32 +00:00
|
|
|
|
* `lda type`
|
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.socket`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-09-26 15:36:32 +00:00
|
|
|
|
* CC: A = hSOCKET
|
|
|
|
|
* CS: A = EC
|
|
|
|
|
*\--------------------------------------
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.Socket tax type (RAW,DGRAM,SEQPACKET,STREAM)
|
2018-09-28 15:24:44 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
>PULLA get protocol (RAW)
|
2018-09-28 05:58:24 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.Socket.I jmp (J.SKT.Socket,x)
|
2018-09-28 05:58:24 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.Socket.RAW ldy #S.SOCKET socket.size
|
|
|
|
|
bra SKT.Socket.DSOCK
|
2018-09-28 05:58:24 +00:00
|
|
|
|
SKT.Socket.DGRAM
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.IP.PROTOCOL.UDP
|
2018-10-01 15:52:58 +00:00
|
|
|
|
ldy #S.SOCKET socket.size
|
|
|
|
|
bra SKT.Socket.DSOCK
|
2018-09-28 05:58:24 +00:00
|
|
|
|
SKT.Socket.SEQPACKET
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.IP.PROTOCOL.TCP
|
2018-10-01 15:52:58 +00:00
|
|
|
|
ldy #S.SOCKET.TCP socket.size
|
2018-09-28 15:24:44 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.Socket.DSOCK
|
|
|
|
|
stx FD.DSOCK+S.SOCKET.T save type
|
|
|
|
|
sta FD.DSOCK+S.SOCKET.PROTO ICMP,UDP,TCP
|
|
|
|
|
lda #0 Y = socket.size
|
2018-09-28 15:24:44 +00:00
|
|
|
|
>SYSCALL GetMem0
|
2018-10-08 15:41:00 +00:00
|
|
|
|
bcs .9
|
2018-10-01 15:52:58 +00:00
|
|
|
|
>STYA ZPTmpPtr1
|
|
|
|
|
stx FD.DSOCK+S.FD.DSOCK.HSKT
|
|
|
|
|
|
|
|
|
|
jsr SKT.Socket.FindFree
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
ldy #FD.DSOCK.SIZE-1
|
2018-09-28 15:24:44 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
.1 lda FD.DSOCK,y
|
|
|
|
|
sta (ZPTmpPtr1),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
SKT.Socket.STREAM
|
|
|
|
|
lda #S.IP.PROTOCOL.TCP
|
|
|
|
|
ldy #S.SOCKET.TCP
|
|
|
|
|
|
|
|
|
|
stx FD.SSOCK+S.SOCKET.T save type
|
|
|
|
|
sta FD.SSOCK+S.SOCKET.PROTO ICMP,UDP,TCP
|
|
|
|
|
lda #0 Y = socket.size
|
|
|
|
|
>SYSCALL GetMem0
|
2018-10-08 15:41:00 +00:00
|
|
|
|
bcs .9
|
2018-10-01 15:52:58 +00:00
|
|
|
|
>STYA ZPTmpPtr1
|
|
|
|
|
stx FD.SSOCK+S.FD.SSOCK.HSKT
|
|
|
|
|
|
|
|
|
|
jsr SKT.Socket.FindFree
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
ldy #FD.SSOCK.SIZE-1
|
|
|
|
|
|
|
|
|
|
.1 lda FD.SSOCK,y
|
|
|
|
|
sta (ZPTmpPtr1),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
SKT.Socket.FindFree
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda SKT.TABLE,y
|
|
|
|
|
beq .2
|
|
|
|
|
iny
|
|
|
|
|
cpy #K.SKTTABLE.SIZE
|
|
|
|
|
bne .1
|
2018-09-28 05:58:24 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
txa
|
|
|
|
|
>SYSCALL freemem
|
|
|
|
|
lda #K.E.OOH
|
|
|
|
|
sec
|
2018-10-01 15:52:58 +00:00
|
|
|
|
rts
|
2018-09-28 15:24:44 +00:00
|
|
|
|
|
|
|
|
|
.2 txa x = hFD
|
|
|
|
|
sta SKT.TABLE,y
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2018-09-26 15:36:32 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Bind
|
2018-09-28 15:24:44 +00:00
|
|
|
|
* bind a name to a socket
|
2018-09-26 15:36:32 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int bind(hFD fd, const struct sockaddr *addr);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHW addr`
|
|
|
|
|
* `lda fd`
|
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.socket`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-09-26 15:36:32 +00:00
|
|
|
|
* CC: A = hSOCKET
|
|
|
|
|
* CS: A = EC
|
|
|
|
|
*\--------------------------------------
|
2018-09-28 15:24:44 +00:00
|
|
|
|
SKT.bind >SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-01 05:48:42 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
jsr SKT.PullLocAddr
|
2018-09-28 15:24:44 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
lda SKT.LOC.ADDR+S.SOCKADDR.PORT
|
|
|
|
|
bne .1
|
2018-10-10 15:39:22 +00:00
|
|
|
|
ldx SKT.LOC.ADDR+S.SOCKADDR.PORT+1
|
2018-10-01 05:48:42 +00:00
|
|
|
|
bne .1
|
2018-09-28 15:24:44 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
jsr GetDynPort
|
2018-09-28 15:24:44 +00:00
|
|
|
|
|
2018-10-10 15:39:22 +00:00
|
|
|
|
sta SKT.LOC.ADDR+S.SOCKADDR.PORT
|
|
|
|
|
stx SKT.LOC.ADDR+S.SOCKADDR.PORT+1
|
2018-09-28 15:24:44 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
.1 jsr SKT.FindMatchingLoc
|
2018-09-28 15:24:44 +00:00
|
|
|
|
bcc .9
|
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
jsr SKT.SetLocAddr
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
.9 lda #ERR.SKT.BUSY
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2018-09-26 15:36:32 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Connect
|
2018-09-28 15:24:44 +00:00
|
|
|
|
* Iinitiate a connection on a socket
|
2018-09-26 15:36:32 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int connect(hFD fd, const struct sockaddr *addr);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHW addr`
|
|
|
|
|
* `lda fd`
|
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.socket`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-09-26 15:36:32 +00:00
|
|
|
|
* CC: A = hSOCKET
|
|
|
|
|
* CS: A = EC
|
|
|
|
|
*\--------------------------------------
|
2018-09-27 15:34:38 +00:00
|
|
|
|
SKT.connect >SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
jsr SKT.PullRemAddr
|
2018-09-27 15:34:38 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.T
|
2018-10-01 05:48:42 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-27 15:34:38 +00:00
|
|
|
|
tax
|
|
|
|
|
jmp (J.SKT.connect,x)
|
2018-10-01 05:48:42 +00:00
|
|
|
|
|
2018-09-27 15:34:38 +00:00
|
|
|
|
SKT.connect.RAW
|
|
|
|
|
SKT.connect.DGRAM
|
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
jsr SKT.SetRemAddr
|
2018-09-27 15:34:38 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
SKT.connect.STREAM
|
|
|
|
|
>LDYAI K.TCP.WSIZE
|
|
|
|
|
>SYSCALL getmem
|
|
|
|
|
bcs SKT.connect.99
|
|
|
|
|
txa
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.SQ.hInMem
|
|
|
|
|
sta (ZPPtrSKT),y
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
>LDYAI K.TCP.WSIZE
|
|
|
|
|
>SYSCALL getmem
|
|
|
|
|
bcs SKT.connect.99
|
2016-01-16 22:04:22 +00:00
|
|
|
|
txa
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.SQ.hOutMem
|
|
|
|
|
sta (ZPPtrSKT),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
SKT.connect.SEQPACKET
|
|
|
|
|
ldy #S.SOCKET.TCP.S
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
bne SKT.connect.9
|
|
|
|
|
|
|
|
|
|
jsr SKT.SetRemAddr
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
lda #K.TCP.WSIZE
|
|
|
|
|
ldy #S.SOCKET.TCP.INFREE
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
ldy #S.SOCKET.TCP.OUTFREE
|
|
|
|
|
sta (ZPPtrSKT),y
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
lda /K.TCP.WSIZE
|
|
|
|
|
ldy #S.SOCKET.TCP.INFREE
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
ldy #S.SOCKET.TCP.OUTFREE
|
|
|
|
|
sta (ZPPtrSKT),y
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.OUTNEXTSEQ
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
.2 lda A2osX.TIMER16-S.SOCKET.TCP.OUTNEXTSEQ,y
|
|
|
|
|
sta (ZPPtrSKT),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2018-10-01 05:48:42 +00:00
|
|
|
|
cpy #S.SOCKET.TCP.OUTNEXTSEQ+4
|
|
|
|
|
bne .2
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
lda #S.TCP.OPTIONS.SYN
|
|
|
|
|
jsr TCP.OUT.SendOptA Send SYN
|
|
|
|
|
bcs .9
|
2017-01-30 21:03:12 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.S
|
|
|
|
|
lda #S.SOCKET.TCP.S.SYNSENT
|
|
|
|
|
sta (ZPPtrSKT),y
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
clc
|
2018-10-01 05:48:42 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
SKT.connect.9 lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
|
|
|
|
SKT.connect.99 rts
|
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Listen
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* Listen for connections on a socket
|
|
|
|
|
* ## C
|
|
|
|
|
* `int listen(hFD fd);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `lda fd`
|
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.listen`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* CS: A = EC
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.listen >SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.T
|
|
|
|
|
lda (ZPPtrSKT),y
|
2018-10-01 15:52:58 +00:00
|
|
|
|
cmp #S.SOCKET.T.SEQPACKET+1
|
2018-10-01 05:48:42 +00:00
|
|
|
|
bcc .9
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.TCP.S
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
bne .9
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
lda #S.SOCKET.TCP.S.LISTEN
|
|
|
|
|
sta (ZPPtrSKT),y
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.O
|
|
|
|
|
lda #S.SOCKET.O.ACCEPTCONN
|
2018-08-29 15:01:02 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
2018-09-27 06:00:22 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
.9 lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Accept
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* Accept a connection on a socket
|
|
|
|
|
* ## C
|
|
|
|
|
* `hFD Accept(hFD fd);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `lda fd`
|
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.accept`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* A = hSocket
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.Accept >SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.O
|
2018-09-25 15:31:35 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
and #S.SOCKET.O.ACCEPTCONN
|
2018-10-01 05:48:42 +00:00
|
|
|
|
beq .99
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.HQ.TAIL
|
2018-09-27 06:00:22 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.HQ.HEAD
|
|
|
|
|
cmp (ZPPtrSKT),y Queue Empty
|
|
|
|
|
beq .9 CS
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
pha save tail...
|
|
|
|
|
inc
|
|
|
|
|
cmp #S.SOCKET.HQ.MAX
|
|
|
|
|
bne .1
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
lda #0
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
.1 ldy #S.SOCKET.HQ.TAIL
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
pla
|
|
|
|
|
clc
|
|
|
|
|
adc #S.SOCKET.HQ
|
|
|
|
|
tay
|
|
|
|
|
lda (ZPPtrSKT),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
.99 lda #ERR.SKT.BAD
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sec
|
2018-10-01 05:48:42 +00:00
|
|
|
|
.9 rts
|
2017-02-13 07:26:18 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Shutdown
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* Close socket
|
|
|
|
|
* ## C
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* `int shutdown(int fd);`
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `lda fd`
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.shutdown`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*\--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
SKT.shutdown >SYSCALL GetMemPtr
|
2018-10-01 05:48:42 +00:00
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
cmp #S.SOCKET.T.STREAM
|
2018-06-18 06:22:50 +00:00
|
|
|
|
beq .10 TCP
|
2018-09-28 15:24:44 +00:00
|
|
|
|
cmp #S.SOCKET.T.RAW+1
|
|
|
|
|
bcs .9 no #S.SOCKET.T.DGRAM, nor #S.SOCKET.T.RAW
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
.1 ldy #S.SOCKET.HQ.TAIL
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ldy #S.SOCKET.HQ.HEAD
|
|
|
|
|
cmp (ZPPtrSKT),y
|
2018-06-18 06:22:50 +00:00
|
|
|
|
beq .8 No frame in Queue, close..
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
pha save tail...
|
2017-03-10 16:35:54 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.SOCKET.HQ
|
|
|
|
|
tax
|
|
|
|
|
pla
|
2018-01-16 07:32:11 +00:00
|
|
|
|
inc
|
2017-03-10 16:35:54 +00:00
|
|
|
|
cmp #S.SOCKET.HQ.MAX
|
|
|
|
|
beq .2
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
lda #0
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
.2 ldy #S.SOCKET.HQ.TAIL
|
2017-03-10 16:35:54 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2017-03-10 16:35:54 +00:00
|
|
|
|
txa
|
2018-01-16 07:32:11 +00:00
|
|
|
|
tay
|
|
|
|
|
lda (ZPPtrSKT),y
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2017-03-10 16:35:54 +00:00
|
|
|
|
bra .1
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.8 lda #0
|
|
|
|
|
sta (ZPPtrSKT)
|
|
|
|
|
clc
|
2017-03-10 16:35:54 +00:00
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
.9 lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
.10 ldy #S.SOCKET.O
|
2018-06-18 06:22:50 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
bit #S.SOCKET.O.ACCEPTCONN
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
bne * TO DO: Listening socket
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.S
|
2018-09-13 15:29:02 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
cmp #S.SOCKET.TCP.S.CLWAIT
|
2018-09-13 15:29:02 +00:00
|
|
|
|
bne .11
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
lda #S.SOCKET.TCP.S.LASTACK
|
2018-09-13 15:29:02 +00:00
|
|
|
|
bra .12
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
.11 lda #S.SOCKET.TCP.S.FINWT1
|
2018-09-13 15:29:02 +00:00
|
|
|
|
.12 sta (ZPPtrSKT),y
|
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.O
|
2018-06-18 06:22:50 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-13 06:22:07 +00:00
|
|
|
|
ora #S.TCP.OPTIONS.FIN+S.TCP.OPTIONS.ACK
|
2018-06-18 06:22:50 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
2018-09-13 15:29:02 +00:00
|
|
|
|
jmp TCP.OUT Try to push FIN/ACK
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Read (STREAM)
|
2018-09-11 21:15:15 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int skt.read(hFD fd, void *buf, int count);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHWI count`
|
|
|
|
|
* `>PUSHW buf`
|
|
|
|
|
* `lda fd`
|
2018-09-17 15:42:38 +00:00
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.skt.read`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-09-11 21:15:15 +00:00
|
|
|
|
* CC: Y,A = bytes read
|
|
|
|
|
* CS: A = EC
|
2018-08-29 15:01:02 +00:00
|
|
|
|
*\--------------------------------------
|
2018-10-01 05:48:42 +00:00
|
|
|
|
SKT.Read >SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-04 15:29:15 +00:00
|
|
|
|
>PULLW ZPDataInPtr !!!DataOut trashed when sending ACK in TCP.OUT
|
2018-09-11 21:15:15 +00:00
|
|
|
|
>PULLW ZPDataInLen !!!use DataInPtr/Len
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.T
|
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
cmp #S.SOCKET.T.STREAM
|
2018-08-29 15:01:02 +00:00
|
|
|
|
bne .90 bad skt
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.O
|
2018-08-29 15:01:02 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
and #S.SOCKET.O.ACCEPTCONN
|
2018-08-29 15:01:02 +00:00
|
|
|
|
bne .90 Bad Skt
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.S
|
2018-08-29 15:01:02 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
cmp #S.SOCKET.TCP.S.ESTBLSH
|
2018-08-29 15:01:02 +00:00
|
|
|
|
bcc .92 Not yet established...no data
|
2018-09-28 15:24:44 +00:00
|
|
|
|
cmp #S.SOCKET.TCP.S.FINWT2
|
2018-09-06 07:45:50 +00:00
|
|
|
|
bcs .91 closing...IO err
|
2018-08-29 15:01:02 +00:00
|
|
|
|
|
|
|
|
|
jsr SKT.GetDataFromSktIn
|
|
|
|
|
rts if CS, No data...
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-08-29 15:01:02 +00:00
|
|
|
|
.90 lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-08-29 15:01:02 +00:00
|
|
|
|
.91 lda #MLI.E.IO
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.92 lda #0
|
|
|
|
|
sec
|
|
|
|
|
.99 rts
|
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Write (STREAM)
|
2018-09-11 21:15:15 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int skt.write(hFD fd, const void *buf, int count);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHWI count`
|
|
|
|
|
* `>PUSHW buf`
|
|
|
|
|
* `lda fd`
|
2018-09-17 15:42:38 +00:00
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.skt.write`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-09-11 21:15:15 +00:00
|
|
|
|
* CC: Y,A = bytes written
|
|
|
|
|
* CS: A = EC
|
2017-02-13 07:26:18 +00:00
|
|
|
|
*\--------------------------------------
|
2018-10-01 05:48:42 +00:00
|
|
|
|
SKT.Write >SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
>PULLW ZPDataInPtr
|
2018-09-11 21:15:15 +00:00
|
|
|
|
>PULLW ZPDataInLen
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.T
|
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
cmp #S.SOCKET.T.STREAM
|
2017-03-23 16:41:36 +00:00
|
|
|
|
bne .99
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.O
|
2017-02-13 07:26:18 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
and #S.SOCKET.O.ACCEPTCONN
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bne .99
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.S
|
2017-02-08 06:52:30 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-09-28 15:24:44 +00:00
|
|
|
|
cmp #S.SOCKET.TCP.S.ESTBLSH
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .91
|
2017-02-06 17:04:03 +00:00
|
|
|
|
|
2017-03-24 16:27:44 +00:00
|
|
|
|
jsr SKT.AddDataToSktOut will call SKT.GetTCB
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bcs .90
|
2017-02-09 16:24:19 +00:00
|
|
|
|
|
2017-03-24 16:27:44 +00:00
|
|
|
|
jsr TCP.OUT.I SKT.GetTCB called, try to push, ignore error....
|
2017-02-09 16:24:19 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.90 lda #0 no data transfered
|
2017-02-09 16:24:19 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2017-10-26 16:01:54 +00:00
|
|
|
|
.91 lda #MLI.E.IO
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sec
|
2018-08-29 15:01:02 +00:00
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-08-29 15:01:02 +00:00
|
|
|
|
.99 lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
2018-10-01 15:52:58 +00:00
|
|
|
|
rts
|
2017-02-09 16:24:19 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Recv (RAW,DGRAM,SEQPACKET)
|
|
|
|
|
* # RecvFrom (RAW,DGRAM,SEQPACKET)
|
2018-10-08 15:41:00 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `hMem recv(hFD fd);`
|
|
|
|
|
* `hMem recvfrom(hFD fd, struct sockaddr *addr);`
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHW addr` (RecvFrom)
|
|
|
|
|
* `lda fd`
|
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.skt.Recv`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* CC: A = hMem
|
|
|
|
|
* CS: A = EC
|
2017-02-09 16:24:19 +00:00
|
|
|
|
*\--------------------------------------
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.RecvFrom sec
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
SKT.Recv clc
|
|
|
|
|
php
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
2018-10-01 05:48:42 +00:00
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
ldy #S.SOCKET.T
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
cmp #S.SOCKET.T.STREAM
|
|
|
|
|
beq .99
|
|
|
|
|
|
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
|
2018-10-09 15:47:06 +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
|
2018-10-01 15:52:58 +00:00
|
|
|
|
beq .90
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
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
|
|
|
|
|
lda #0
|
2018-10-09 15:47:06 +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
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2016-03-27 21:06:56 +00:00
|
|
|
|
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
|
2018-10-01 15:52:58 +00:00
|
|
|
|
plp
|
|
|
|
|
bcc .9
|
|
|
|
|
pha
|
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPFrameInPtr
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
>PULLW ZPTmpPtr1 addr
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.SRC
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPFrameInPtr),y
|
|
|
|
|
sta SA.REMOTE+S.SOCKADDR.ADDR-S.IP.SRC,y
|
|
|
|
|
iny
|
|
|
|
|
cpy #S.IP.SRC+4
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
ldy #S.IP.PROTOCOL
|
|
|
|
|
lda (ZPFrameInPtr),y
|
|
|
|
|
cmp #S.IP.PROTOCOL.ICMP
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
ldy #S.ICMP.IDENTIFIER
|
|
|
|
|
bra .7
|
|
|
|
|
|
|
|
|
|
.3 cmp #S.IP.PROTOCOL.TCP
|
|
|
|
|
beq .6
|
|
|
|
|
cmp #S.IP.PROTOCOL.UDP
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
.6 ldy #S.TCPUDP.SRCPORT
|
|
|
|
|
|
|
|
|
|
.7 lda (ZPFrameInPtr),y
|
|
|
|
|
sta SA.REMOTE+S.SOCKADDR+1
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPFrameInPtr),y
|
|
|
|
|
sta SA.REMOTE+S.SOCKADDR
|
|
|
|
|
|
|
|
|
|
.8 lda #S.SOCKADDR-1
|
|
|
|
|
|
|
|
|
|
.80 lda SA.REMOTE,y
|
|
|
|
|
sta (ZPTmpPtr1),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .80
|
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
pla
|
|
|
|
|
clc
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.9 rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
.99 plp
|
|
|
|
|
lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
.90 plp
|
|
|
|
|
lda #0 no data
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2017-02-09 16:24:19 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # Send (RAW,DGRAM,SEQPACKET)
|
|
|
|
|
* # SendTo (RAW,DGRAM,SEQPACKET)
|
2018-09-17 15:42:38 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int skt.send(hFD fd, const void *buf, int count);`
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* `int skt.sendto(hFD fd, const void *buf, int count, const struct sockaddr *addr);`
|
2018-09-17 15:42:38 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* `>PUSHW addr` (SendTo)
|
2018-09-17 15:42:38 +00:00
|
|
|
|
* `>PUSHWI count`
|
|
|
|
|
* `>PUSHW buf`
|
|
|
|
|
* `lda fd`
|
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.skt.send`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-09-17 15:42:38 +00:00
|
|
|
|
* CC: Y,A = bytes written
|
|
|
|
|
* CS: A = EC
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*\--------------------------------------
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.SendTo sec
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
SKT.Send clc
|
|
|
|
|
php
|
|
|
|
|
>SYSCALL GetMemPtr
|
2018-10-01 05:48:42 +00:00
|
|
|
|
>STYA ZPPtrSKT
|
2018-10-01 15:52:58 +00:00
|
|
|
|
plp
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
bcc .1
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
jsr SKT.PullRemAddr
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
.1 >PULLW ZPDataInPtr
|
2018-09-17 15:42:38 +00:00
|
|
|
|
>PULLW ZPDataInLen
|
2017-03-07 16:40:32 +00:00
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.T
|
|
|
|
|
lda (ZPPtrSKT),y
|
2018-10-01 15:52:58 +00:00
|
|
|
|
tax
|
|
|
|
|
jmp (J.SKT.send,x)
|
2018-08-29 15:01:02 +00:00
|
|
|
|
*--------------------------------------
|
2018-10-08 15:41:00 +00:00
|
|
|
|
SKT.Send.RAW ldy #S.SOCKET.PROTO
|
2018-08-29 15:01:02 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2017-03-15 06:58:13 +00:00
|
|
|
|
|
2018-08-29 15:01:02 +00:00
|
|
|
|
tax
|
|
|
|
|
>LDYA ZPDataInLen
|
|
|
|
|
jsr FRM.NewIP
|
2018-09-17 15:42:38 +00:00
|
|
|
|
bcs SKT.Send.9
|
2018-08-29 15:01:02 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
bra SKT.Send.DGRAM.8
|
2018-08-29 15:01:02 +00:00
|
|
|
|
*--------------------------------------
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.Send.DGRAM ldx #S.IP.PROTOCOL.UDP
|
2018-08-29 15:01:02 +00:00
|
|
|
|
>LDYA ZPDataInLen
|
|
|
|
|
jsr FRM.NewIP
|
2018-09-17 15:42:38 +00:00
|
|
|
|
bcs SKT.Send.9
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2018-09-17 15:42:38 +00:00
|
|
|
|
jsr SKT.SetFrameOutTCPUDPPorts
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.Send.DGRAM.8
|
|
|
|
|
|
|
|
|
|
jsr SKT.SetFrameOutDstIP
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2018-08-29 15:01:02 +00:00
|
|
|
|
jsr SKT.CopyDataInToOut
|
2017-03-21 21:54:59 +00:00
|
|
|
|
|
2018-08-29 15:01:02 +00:00
|
|
|
|
jmp FRM.SendIP
|
2018-10-01 15:52:58 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.Send.STREAM lda #ERR.SKT.BAD
|
|
|
|
|
sec
|
2018-10-08 15:41:00 +00:00
|
|
|
|
SKT.Send.9 rts
|
2018-10-01 15:52:58 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.Send.SEQPACKET
|
|
|
|
|
bra *
|
2018-10-01 05:48:42 +00:00
|
|
|
|
*/--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* # GetTable
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* Get socket table
|
|
|
|
|
* ## C
|
2018-10-10 15:39:22 +00:00
|
|
|
|
* `void * gettable();`
|
2018-10-01 05:48:42 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>LIBCALL hLIBTCPIP,LIBTCPIP.skt.GetTable`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-10-01 05:48:42 +00:00
|
|
|
|
*\--------------------------------------
|
|
|
|
|
SKT.GetTable >LDYA L.SKT.Table
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* PRIVATE
|
2018-10-01 05:48:42 +00:00
|
|
|
|
*--------------------------------------
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.PullLocAddr >PULLW ZPTmpPtr1
|
2018-10-01 05:48:42 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.SOCKADDR-1
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPTmpPtr1),y
|
|
|
|
|
sta SKT.LOC.ADDR,y
|
|
|
|
|
dey
|
2018-10-10 15:39:22 +00:00
|
|
|
|
bpl .1
|
2018-10-01 05:48:42 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-10-01 15:52:58 +00:00
|
|
|
|
SKT.PullRemAddr >PULLW ZPTmpPtr1
|
2018-10-01 05:48:42 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.SOCKADDR-1
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPTmpPtr1),y
|
|
|
|
|
sta SKT.REM.ADDR,y
|
|
|
|
|
dey
|
2018-10-10 15:39:22 +00:00
|
|
|
|
bpl .1
|
2018-10-01 05:48:42 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
SKT.SetLocAddr ldy #S.SOCKET.LOC.ADDR
|
2018-10-01 05:48:42 +00:00
|
|
|
|
|
2018-10-10 15:39:22 +00:00
|
|
|
|
.1 lda SKT.LOC.ADDR+S.SOCKADDR.ADDR-S.SOCKET.LOC.ADDR,y
|
2018-10-01 05:48:42 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
2018-10-10 15:39:22 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #S.SOCKET.LOC.PORT+2
|
2018-10-01 05:48:42 +00:00
|
|
|
|
bne .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-10-10 15:39:22 +00:00
|
|
|
|
SKT.SetRemAddr ldy #S.SOCKET.REM.ADDR
|
2018-10-01 05:48:42 +00:00
|
|
|
|
|
2018-10-10 15:39:22 +00:00
|
|
|
|
.1 lda SKT.REM.ADDR+S.SOCKADDR.ADDR-S.SOCKET.REM.ADDR,y
|
2018-10-01 05:48:42 +00:00
|
|
|
|
sta (ZPPtrSKT),y
|
2018-10-10 15:39:22 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #S.SOCKET.REM.PORT+2
|
2018-10-01 05:48:42 +00:00
|
|
|
|
bne .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.FindMatchingLocRem
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 lda SKT.TABLE,x
|
|
|
|
|
beq .8
|
|
|
|
|
|
2018-10-09 15:47:06 +00:00
|
|
|
|
phx
|
2018-10-01 05:48:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPTmpPtr1
|
2018-10-09 15:47:06 +00:00
|
|
|
|
plx
|
2018-10-01 05:48:42 +00:00
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPTmpPtr1),y
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.LOC.PORT This Socket is bound to 0.0.0.0,check only LOC port
|
|
|
|
|
|
|
|
|
|
.3 lda (ZPTmpPtr1),y
|
|
|
|
|
|
2018-10-10 15:39:22 +00:00
|
|
|
|
.4 cmp SKT.LOC.ADDR+S.SOCKADDR.ADDR-S.SOCKET.LOC.ADDR,y
|
2018-10-01 05:48:42 +00:00
|
|
|
|
bne .8
|
|
|
|
|
iny
|
|
|
|
|
cpy #S.SOCKET.REM.ADDR
|
|
|
|
|
bne .3
|
|
|
|
|
|
2018-10-10 15:39:22 +00:00
|
|
|
|
lda SKT.REM.ADDR+S.SOCKADDR.ADDR
|
2018-10-01 05:48:42 +00:00
|
|
|
|
cmp #$ff FF.FF.FF.FF, Broadcast ?
|
|
|
|
|
bne .5
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.O
|
|
|
|
|
lda (ZPTmpPtr1),y
|
|
|
|
|
and #S.SOCKET.O.BROADCAST
|
|
|
|
|
beq .9 this socket does not accept broadcast
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.REM.PORT Boradcast, check port only
|
|
|
|
|
|
|
|
|
|
.5 lda (ZPTmpPtr1),y
|
2018-10-10 15:39:22 +00:00
|
|
|
|
cmp SKT.REM.ADDR+S.SOCKADDR.ADDR-S.SOCKET.REM.ADDR,y
|
2018-10-01 05:48:42 +00:00
|
|
|
|
bne .9 wrong remote host, exit....
|
|
|
|
|
iny
|
|
|
|
|
cpy #S.SOCKET.REM.PORT+2
|
|
|
|
|
bne .5
|
|
|
|
|
|
|
|
|
|
>LDYA ZPTmpPtr1 x = SKT.TABLE index
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 inx
|
|
|
|
|
cpx #K.SKTTABLE.SIZE
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.FindMatchingLoc
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.LOC.PORT+1
|
|
|
|
|
phy
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 lda SKT.TABLE,x
|
|
|
|
|
beq .7
|
|
|
|
|
|
2018-10-09 15:47:06 +00:00
|
|
|
|
phx
|
2018-10-01 05:48:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPTmpPtr1
|
2018-10-09 15:47:06 +00:00
|
|
|
|
plx
|
2018-10-01 05:48:42 +00:00
|
|
|
|
|
|
|
|
|
ply
|
|
|
|
|
phy
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPTmpPtr1),y
|
2018-10-10 15:39:22 +00:00
|
|
|
|
cmp SKT.LOC.ADDR+S.SOCKADDR.ADDR-S.SOCKET.LOC.ADDR,y
|
2018-10-01 05:48:42 +00:00
|
|
|
|
bne .7
|
|
|
|
|
dey
|
|
|
|
|
cpy #S.SOCKET.LOC.ADDR-1
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
ply
|
|
|
|
|
|
|
|
|
|
>LDYA ZPTmpPtr1 x = SKT.TABLE index
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.7 inx
|
|
|
|
|
cpx #K.SKTTABLE.SIZE
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
ply
|
|
|
|
|
|
|
|
|
|
* sec
|
|
|
|
|
|
|
|
|
|
.9 rts
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* 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
|
2018-06-18 06:22:50 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
.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
|
|
|
|
|
* Src : ZPDataInPtr/ZPDataInLen
|
|
|
|
|
* Dst : hInMem/INHEAD
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.AddDataToSktIn
|
2018-10-08 15:41:00 +00:00
|
|
|
|
ldx SKT.TmpCache+S.SOCKET.TCP.INFREE
|
2017-03-15 06:58:13 +00:00
|
|
|
|
cpx ZPDataInLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INFREE+1
|
2017-03-15 06:58:13 +00:00
|
|
|
|
sbc ZPDataInLen+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bcc .9 Not enough room in Q
|
|
|
|
|
|
2017-04-10 06:07:14 +00:00
|
|
|
|
ldy #S.TCP.SEQNUM+3
|
2017-03-27 06:28:25 +00:00
|
|
|
|
ldx #3
|
|
|
|
|
|
|
|
|
|
.10 lda (ZPFrameInPtr),y
|
2018-10-08 15:41:00 +00:00
|
|
|
|
eor SKT.TmpCache+S.SOCKET.TCP.INLASTSEQNUM,x
|
2017-03-27 06:28:25 +00:00
|
|
|
|
bne .9
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .10
|
|
|
|
|
|
2017-03-09 16:38:27 +00:00
|
|
|
|
ldy #S.SOCKET.SQ.hInMem
|
|
|
|
|
lda (ZPPtrSKT),y
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
2017-02-10 16:49:14 +00:00
|
|
|
|
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
clc
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.INHEAD
|
2017-02-10 16:49:14 +00:00
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.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-03-24 07:31:30 +00:00
|
|
|
|
pha
|
|
|
|
|
|
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
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.4 inc SKT.TmpCache+S.SOCKET.TCP.INHEAD
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.INHEAD+1
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INHEAD+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
cmp /K.TCP.WSIZE
|
|
|
|
|
bne .1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
stz SKT.TmpCache+S.SOCKET.TCP.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
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.8 lda SKT.TmpCache+S.SOCKET.TCP.INFREE
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc ZPDataInLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INFREE
|
2017-03-19 21:47:54 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INFREE+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sbc ZPDataInLen+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INFREE+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INUSED
|
2017-02-15 16:14:41 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPDataInLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INUSED
|
2017-03-19 21:47:54 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INUSED+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
adc ZPDataInLen+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INUSED+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-03-27 06:28:25 +00:00
|
|
|
|
clc
|
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INLASTSEQNUM+3
|
2017-03-27 06:28:25 +00:00
|
|
|
|
adc ZPDataInLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INLASTSEQNUM+3
|
2017-03-27 06:28:25 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INLASTSEQNUM+2
|
2017-03-27 06:28:25 +00:00
|
|
|
|
adc ZPDataInLen+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INLASTSEQNUM+2
|
2017-03-27 06:28:25 +00:00
|
|
|
|
bcc .80
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.INLASTSEQNUM+1
|
2017-03-27 06:28:25 +00:00
|
|
|
|
bne .80
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.INLASTSEQNUM
|
2017-03-27 06:28:25 +00:00
|
|
|
|
|
2017-04-10 06:07:14 +00:00
|
|
|
|
.80 clc
|
|
|
|
|
rts
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-22 16:39:01 +00:00
|
|
|
|
* From SKT.Read
|
|
|
|
|
* In:
|
|
|
|
|
* Src : hInMem/INTAIL
|
|
|
|
|
* Dst : ZPDataOutPtr/ZPDataOutLen
|
|
|
|
|
* Out:
|
|
|
|
|
* Y,A = bytes read
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-22 16:39:01 +00:00
|
|
|
|
SKT.GetDataFromSktIn
|
2017-03-24 16:27:44 +00:00
|
|
|
|
jsr SKT.GetTCB
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INUSED
|
|
|
|
|
ora SKT.TmpCache+S.SOCKET.TCP.INUSED+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bne .10
|
|
|
|
|
sec
|
2017-04-06 06:31:50 +00:00
|
|
|
|
rts A=0,NO DATA
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
.10 ldy #S.SOCKET.SQ.hInMem
|
2017-03-09 16:38:27 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
clc
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.INTAIL
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.INTAIL+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sta ZPTmpPtr2+1
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2018-09-04 15:29:15 +00:00
|
|
|
|
lda ZPDataInLen
|
2017-02-15 16:14:41 +00:00
|
|
|
|
eor #$FF
|
|
|
|
|
tax
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2018-09-04 15:29:15 +00:00
|
|
|
|
lda ZPDataInLen+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
eor #$FF
|
|
|
|
|
pha
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
stz ZPTmpPtr3 Reset byte counter
|
|
|
|
|
stz ZPTmpPtr3+1
|
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #0
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
.1 inx Check if room left in dest buffer
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .2
|
|
|
|
|
pla
|
|
|
|
|
inc
|
|
|
|
|
beq .8
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
2017-03-16 07:32:24 +00:00
|
|
|
|
pha
|
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.2 lda SKT.TmpCache+S.SOCKET.TCP.INTAIL
|
|
|
|
|
eor SKT.TmpCache+S.SOCKET.TCP.INHEAD
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .3
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INTAIL+1
|
|
|
|
|
eor SKT.TmpCache+S.SOCKET.TCP.INHEAD+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
beq .7 no more data....
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
.3 lda (ZPTmpPtr2)
|
|
|
|
|
pha
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.INTAIL
|
2018-09-03 11:27:11 +00:00
|
|
|
|
bne .4
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.INTAIL+1
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INTAIL+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
cmp /K.TCP.WSIZE
|
|
|
|
|
bne .4
|
2017-03-09 16:38:27 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
stz SKT.TmpCache+S.SOCKET.TCP.INTAIL+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
sta ZPTmpPtr2+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bra .5
|
2017-02-10 16:49:14 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
.4 inc ZPTmpPtr2
|
|
|
|
|
bne .5
|
|
|
|
|
inc ZPTmpPtr2+1
|
2017-01-31 22:13:26 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
.5 pla get back data....
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2018-09-04 15:29:15 +00:00
|
|
|
|
.6 sta (ZPDataInPtr),y
|
2017-02-15 16:14:41 +00:00
|
|
|
|
iny
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bne .61
|
2018-09-04 15:29:15 +00:00
|
|
|
|
inc ZPDataInPtr+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
.61 inc ZPTmpPtr3
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
inc ZPTmpPtr3+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
bra .1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
.7 pla discard byte counter HI
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2018-08-29 15:01:02 +00:00
|
|
|
|
.8 lda ZPTmpPtr3 Do we have transfered something?
|
2017-03-29 06:33:26 +00:00
|
|
|
|
ora ZPTmpPtr3+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
beq .9
|
2017-03-13 15:34:56 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INFREE
|
2017-03-22 16:39:01 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPTmpPtr3
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INFREE
|
2017-03-19 21:47:54 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INFREE+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
adc ZPTmpPtr3+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INFREE+1
|
2017-03-13 15:34:56 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INUSED
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc ZPTmpPtr3
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INUSED
|
2017-03-19 21:47:54 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.INUSED+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sbc ZPTmpPtr3+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.INUSED+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTACKNUM+3
|
2017-04-10 06:07:14 +00:00
|
|
|
|
clc
|
2017-03-22 16:39:01 +00:00
|
|
|
|
adc ZPTmpPtr3
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTACKNUM+3
|
2017-03-13 15:34:56 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTACKNUM+2
|
2017-03-22 16:39:01 +00:00
|
|
|
|
adc ZPTmpPtr3+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTACKNUM+2
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
bcc .80
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.OUTACKNUM+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bne .80
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.OUTACKNUM
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
.80 jsr SKT.StoreTCB
|
|
|
|
|
|
2018-09-28 15:24:44 +00:00
|
|
|
|
ldy #S.SOCKET.TCP.O
|
2017-03-22 16:39:01 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ora #S.TCP.OPTIONS.ACK
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
|
2017-04-04 20:40:25 +00:00
|
|
|
|
jsr TCP.OUT.I SKT.GetTCB already called, Try to ACK read DATA
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
>LDYA ZPTmpPtr3
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2018-09-11 21:15:15 +00:00
|
|
|
|
.9
|
|
|
|
|
* lda #0 NO DATA
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sec
|
2017-03-10 16:35:54 +00:00
|
|
|
|
rts
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-22 16:39:01 +00:00
|
|
|
|
* From SKT.Write.TCP
|
|
|
|
|
* Src : ZPDataInPtr/ZPDataInLen
|
|
|
|
|
* Dst : hOutMem/OUTHEAD
|
2017-02-15 16:14:41 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-22 16:39:01 +00:00
|
|
|
|
SKT.AddDataToSktOut
|
|
|
|
|
jsr SKT.GetTCB
|
2018-10-08 15:41:00 +00:00
|
|
|
|
ldx SKT.TmpCache+S.SOCKET.TCP.OUTFREE
|
2017-03-23 07:32:11 +00:00
|
|
|
|
cpx ZPDataInLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTFREE+1
|
2017-03-23 07:32:11 +00:00
|
|
|
|
sbc ZPDataInLen+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bcc .9 Not enough room in Q
|
|
|
|
|
|
|
|
|
|
ldy #S.SOCKET.SQ.hOutMem
|
2016-03-13 22:09:00 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
2017-02-15 16:14:41 +00:00
|
|
|
|
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1
|
|
|
|
|
clc
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.OUTHEAD
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
|
|
|
|
|
lda ZPTmpPtr1+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.OUTHEAD+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sta ZPTmpPtr2+1 Make ZPTmpPtr2=base+Tail
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
lda ZPDataInLen
|
2017-02-15 16:14:41 +00:00
|
|
|
|
eor #$FF
|
|
|
|
|
tax
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
lda ZPDataInLen+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
eor #$FF
|
|
|
|
|
pha
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
ldy #0
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
.1 inx
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bne .2
|
|
|
|
|
pla
|
|
|
|
|
inc
|
2017-03-15 07:30:01 +00:00
|
|
|
|
beq .8
|
2017-01-31 16:40:37 +00:00
|
|
|
|
|
2017-02-15 16:14:41 +00:00
|
|
|
|
pha
|
2017-01-30 22:23:16 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
.2 lda (ZPDataInPtr),y
|
|
|
|
|
sta (ZPTmpPtr2)
|
|
|
|
|
iny
|
|
|
|
|
bne .3
|
|
|
|
|
inc ZPDataInPtr+1
|
|
|
|
|
|
|
|
|
|
.3 inc ZPTmpPtr2
|
|
|
|
|
bne .4
|
|
|
|
|
inc ZPTmpPtr2+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.4 inc SKT.TmpCache+S.SOCKET.TCP.OUTHEAD
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bne .1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.OUTHEAD+1
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTHEAD+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
cmp /K.TCP.WSIZE
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bne .1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
stz SKT.TmpCache+S.SOCKET.TCP.OUTHEAD+1
|
2017-02-10 07:29:58 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
lda ZPTmpPtr1 Dst Ptr=Buffer Base
|
2017-02-15 16:14:41 +00:00
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
sta ZPTmpPtr2+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2017-02-10 07:29:58 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.8 lda SKT.TmpCache+S.SOCKET.TCP.OUTFREE
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc ZPDataInLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTFREE
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTFREE+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sbc ZPDataInLen+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTFREE+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTUSED
|
2017-03-22 16:39:01 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPDataInLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTUSED
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTUSED+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
adc ZPDataInLen+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTUSED+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTTOSEND
|
2017-04-04 20:40:25 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPDataInLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTTOSEND
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTTOSEND+1
|
2017-04-04 20:40:25 +00:00
|
|
|
|
adc ZPDataInLen+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTTOSEND+1
|
2017-04-04 20:40:25 +00:00
|
|
|
|
jsr SKT.StoreTCB
|
2017-04-06 06:31:50 +00:00
|
|
|
|
rts
|
2017-03-22 16:39:01 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* From TCP.OUT
|
|
|
|
|
* Src : hOutMem/OUTTAIL
|
|
|
|
|
* Dst : ZPDataOutPtr/ZPDataOutLen
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.GetDataFromSktOut
|
|
|
|
|
ldy #S.SOCKET.SQ.hOutMem
|
|
|
|
|
lda (ZPPtrSKT),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
2017-03-22 16:39:01 +00:00
|
|
|
|
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
|
|
|
|
|
|
2017-04-04 20:40:25 +00:00
|
|
|
|
lda ZPTmpPtr1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
clc
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.OUTTAILNEXT
|
2017-04-04 20:40:25 +00:00
|
|
|
|
sta ZPTmpPtr2 Make ZPTmpPtr2=base+nexttail
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
2017-04-04 20:40:25 +00:00
|
|
|
|
lda ZPTmpPtr1+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.OUTTAILNEXT+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sta ZPTmpPtr2+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
lda ZPDataOutLen
|
|
|
|
|
eor #$FF
|
|
|
|
|
tax
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
lda ZPDataOutLen+1
|
|
|
|
|
eor #$FF
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 inx
|
|
|
|
|
bne .2
|
|
|
|
|
pla
|
|
|
|
|
inc
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPTmpPtr2)
|
|
|
|
|
sta (ZPDataOutPtr),y
|
2017-02-15 16:14:41 +00:00
|
|
|
|
iny
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bne .3
|
2017-02-15 16:14:41 +00:00
|
|
|
|
inc ZPDataOutPtr+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
.3 inc ZPTmpPtr2
|
|
|
|
|
bne .4
|
|
|
|
|
inc ZPTmpPtr2+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.4 inc SKT.TmpCache+S.SOCKET.TCP.OUTTAILNEXT
|
2016-03-13 22:09:00 +00:00
|
|
|
|
bne .1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
inc SKT.TmpCache+S.SOCKET.TCP.OUTTAILNEXT+1
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTTAILNEXT+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
cmp /K.TCP.WSIZE
|
|
|
|
|
bne .1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
stz SKT.TmpCache+S.SOCKET.TCP.OUTTAILNEXT+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
lda ZPTmpPtr1 Dst Ptr=Buffer Base
|
|
|
|
|
sta ZPTmpPtr2
|
|
|
|
|
lda ZPTmpPtr1+1
|
|
|
|
|
sta ZPTmpPtr2+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
bra .1
|
2017-03-15 07:30:01 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.8 lda SKT.TmpCache+S.SOCKET.TCP.OUTTOSEND
|
2017-04-04 20:40:25 +00:00
|
|
|
|
sec
|
|
|
|
|
sbc ZPDataOutLen
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTTOSEND
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTTOSEND+1
|
2017-04-04 20:40:25 +00:00
|
|
|
|
sbc ZPDataOutLen+1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTTOSEND+1
|
2017-04-04 20:40:25 +00:00
|
|
|
|
|
|
|
|
|
clc
|
2017-03-22 16:39:01 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* From TCP.IN
|
|
|
|
|
* Src : A,X
|
|
|
|
|
* Dst : hOutMem/OUTTAIL
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SKT.AckDataToSktOut
|
2017-04-10 06:07:14 +00:00
|
|
|
|
ldy #S.TCP.ACKNUM+3 Get new ACK number from FrameIn...
|
2017-03-27 06:28:25 +00:00
|
|
|
|
ldx #3 Substract old ACK from socket
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
sec
|
2017-03-28 06:33:18 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
.1 lda (ZPFrameInPtr),y
|
|
|
|
|
pha
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sbc SKT.TmpCache+S.SOCKET.TCP.OUTSEQNUM,x
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sta TmpDWord,x
|
2017-03-29 06:33:26 +00:00
|
|
|
|
pla ....and Set SEQ = new SEQ
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTSEQNUM,x
|
2017-03-22 16:39:01 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2017-03-29 06:33:26 +00:00
|
|
|
|
lda TmpDWord+3
|
|
|
|
|
ldx TmpDWord+2
|
2017-03-22 16:39:01 +00:00
|
|
|
|
bne .2
|
|
|
|
|
tay
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
.2 clc
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.OUTTAIL
|
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTTAIL
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
txa
|
2018-10-08 15:41:00 +00:00
|
|
|
|
adc SKT.TmpCache+S.SOCKET.TCP.OUTTAIL+1
|
2017-03-22 16:39:01 +00:00
|
|
|
|
and /K.TCP.WSIZE-1
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTTAIL+1
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTFREE
|
2017-03-10 16:35:54 +00:00
|
|
|
|
clc
|
2017-03-29 06:33:26 +00:00
|
|
|
|
adc TmpDWord+3
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTFREE
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTFREE+1
|
2017-03-29 06:33:26 +00:00
|
|
|
|
adc TmpDWord+2
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTFREE+1
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTUSED
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sec
|
2017-03-29 06:33:26 +00:00
|
|
|
|
sbc TmpDWord+3
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTUSED
|
|
|
|
|
lda SKT.TmpCache+S.SOCKET.TCP.OUTUSED+1
|
2017-03-29 06:33:26 +00:00
|
|
|
|
sbc TmpDWord+2
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache+S.SOCKET.TCP.OUTUSED+1
|
2017-03-29 06:33:26 +00:00
|
|
|
|
|
2017-03-22 16:39:01 +00:00
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2018-10-08 15:41:00 +00:00
|
|
|
|
SKT.GetTCB ldy #S.SOCKET.TCP-S.SOCKET
|
2017-03-10 16:35:54 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.1 dey
|
2017-03-09 16:38:27 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
2018-10-08 15:41:00 +00:00
|
|
|
|
sta SKT.TmpCache,y
|
|
|
|
|
cpy #S.SOCKET
|
|
|
|
|
bne .1
|
2017-03-09 16:38:27 +00:00
|
|
|
|
|
2017-02-10 16:49:14 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-10-08 15:41:00 +00:00
|
|
|
|
SKT.StoreTCB ldy #S.SOCKET.TCP-S.SOCKET
|
|
|
|
|
|
|
|
|
|
.1 dey
|
|
|
|
|
lda SKT.TmpCache,y
|
|
|
|
|
sta (ZPPtrSKT),y
|
|
|
|
|
cpy #S.SOCKET
|
|
|
|
|
bne .1
|
2017-03-09 16:38:27 +00:00
|
|
|
|
|
2017-02-10 16:49:14 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-22 16:39:01 +00:00
|
|
|
|
SKT.Destroy ldy #S.SOCKET.SQ.hOutMem
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
beq .1
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
|
|
|
|
.1 ldy #S.SOCKET.SQ.hInMem
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
beq .2
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2017-03-22 16:39:01 +00:00
|
|
|
|
|
2018-10-08 15:41:00 +00:00
|
|
|
|
.2 lda #0
|
2017-03-22 16:39:01 +00:00
|
|
|
|
sta (ZPPtrSKT)
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-01-31 16:40:37 +00:00
|
|
|
|
SKT.SetFrameOutDstIP
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.REM.ADDR
|
2017-01-31 16:40:37 +00:00
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2018-09-17 15:42:38 +00:00
|
|
|
|
SKT.SetFrameOutTCPUDPPorts
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.LOC.PORT
|
2018-09-17 15:42:38 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
tax
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ldy #S.TCPUDP.SRCPORT
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
2018-10-01 05:48:42 +00:00
|
|
|
|
ldy #S.SOCKET.REM.PORT
|
2018-09-17 15:42:38 +00:00
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
tax
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtrSKT),y
|
|
|
|
|
ldy #S.TCPUDP.DSTPORT
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-01-31 16:40:37 +00:00
|
|
|
|
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
|
2018-10-09 15:47:06 +00:00
|
|
|
|
|
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
|
2017-03-30 06:31:12 +00:00
|
|
|
|
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.SKT
|
|
|
|
|
LOAD /A2OSX.SRC/LIB/LIBTCPIP.S
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ASM
|