mirror of
https://github.com/A2osX/A2osX.git
synced 2025-01-27 09:34:38 +00:00
Kernel 0.9.2
This commit is contained in:
parent
e45693c1ae
commit
c57b3819e1
@ -119,16 +119,16 @@ S.SOCKADDR.PORT .EQ 6
|
||||
*
|
||||
S.SOCKADDR .EQ 8
|
||||
*--------------------------------------
|
||||
S.SOCKET.AF .EQ S.FD.SOCK+0
|
||||
S.SOCKET.T .EQ S.FD.SOCK+1
|
||||
S.SOCKET.T.RAW .EQ 0
|
||||
S.SOCKET.T.DGRAM .EQ 2
|
||||
S.SOCKET.T.STREAM .EQ 4
|
||||
S.SOCKET.T.SEQPACKET .EQ 6
|
||||
S.SOCKET.AF .EQ S.FD.DSOCK+0
|
||||
S.SOCKET.T .EQ S.FD.DSOCK+1
|
||||
S.SOCKET.T.RAW .EQ 0 S.FD.T.DSOCK,ICMP...
|
||||
S.SOCKET.T.DGRAM .EQ 2 S.FD.T.DSOCK,UDP
|
||||
S.SOCKET.T.SEQPACKET .EQ 4 S.FD.T.DSOCK,TCP
|
||||
S.SOCKET.T.STREAM .EQ 6 S.FD.T.SSOCK,TCP
|
||||
|
||||
S.SOCKET.PROTO .EQ S.FD.SOCK+2
|
||||
S.SOCKET.PROTO .EQ S.FD.DSOCK+2
|
||||
|
||||
S.SOCKET.O .EQ S.FD.SOCK+3
|
||||
S.SOCKET.O .EQ S.FD.DSOCK+3
|
||||
S.SOCKET.O.DEBUG .EQ $01
|
||||
S.SOCKET.O.ACCEPTCONN .EQ $02
|
||||
S.SOCKET.O.REUSEADDR .EQ $04
|
||||
@ -138,23 +138,23 @@ S.SOCKET.O.BROADCAST .EQ $20
|
||||
S.SOCKET.O.USELOOPBACK .EQ $40
|
||||
S.SOCKET.O.LINGER .EQ $80
|
||||
|
||||
S.SOCKET.LOC.ADDR .EQ S.FD.SOCK+4
|
||||
S.SOCKET.LOC.PORT .EQ S.FD.SOCK+8
|
||||
S.SOCKET.REM.ADDR .EQ S.FD.SOCK+10
|
||||
S.SOCKET.REM.PORT .EQ S.FD.SOCK+14
|
||||
S.SOCKET.LOC.ADDR .EQ S.FD.DSOCK+4
|
||||
S.SOCKET.LOC.PORT .EQ S.FD.DSOCK+8
|
||||
S.SOCKET.REM.ADDR .EQ S.FD.DSOCK+10
|
||||
S.SOCKET.REM.PORT .EQ S.FD.DSOCK+14
|
||||
*--------------------------------------
|
||||
* Listen type Queue
|
||||
* Raw Type Queue
|
||||
* Datagram type Queue
|
||||
S.SOCKET.HQ.HEAD .EQ S.FD.SOCK+16
|
||||
S.SOCKET.HQ.TAIL .EQ S.FD.SOCK+17
|
||||
S.SOCKET.HQ .EQ S.FD.SOCK+18
|
||||
S.SOCKET.HQ.HEAD .EQ S.FD.DSOCK+16
|
||||
S.SOCKET.HQ.TAIL .EQ S.FD.DSOCK+17
|
||||
S.SOCKET.HQ .EQ S.FD.DSOCK+18
|
||||
S.SOCKET.HQ.MAX .EQ 14 14 hMem (frames)
|
||||
* Stream type Queue
|
||||
S.SOCKET.SQ.hInMem .EQ S.FD.SOCK+16
|
||||
S.SOCKET.SQ.hOutMem .EQ S.FD.SOCK+17
|
||||
S.SOCKET.SQ.hInMem .EQ S.FD.DSOCK+16
|
||||
S.SOCKET.SQ.hOutMem .EQ S.FD.DSOCK+17
|
||||
*
|
||||
S.SOCKET .EQ S.FD.SOCK+32
|
||||
S.SOCKET .EQ S.FD.DSOCK+32
|
||||
*--------------------------------------
|
||||
S.SOCKET.TCP.S .EQ S.SOCKET
|
||||
S.SOCKET.TCP.S.CLOSED .EQ 0
|
||||
|
@ -16,34 +16,72 @@ AUTO 4,1
|
||||
* CC: A = hSOCKET
|
||||
* CS: A = EC
|
||||
*\--------------------------------------
|
||||
SKT.Socket sta FD.SSOCK+S.SOCKET.T save type
|
||||
tax
|
||||
SKT.Socket tax type (RAW,DGRAM,SEQPACKET,STREAM)
|
||||
|
||||
>PULLA get protocol (RAW)
|
||||
>PULLA get protocol (RAW)
|
||||
|
||||
jmp (J.SKT.Socket,x)
|
||||
SKT.Socket.I jmp (J.SKT.Socket,x)
|
||||
|
||||
SKT.Socket.RAW ldy #S.SOCKET
|
||||
bra SKT.Socket.NEW
|
||||
SKT.Socket.RAW ldy #S.SOCKET socket.size
|
||||
bra SKT.Socket.DSOCK
|
||||
SKT.Socket.DGRAM
|
||||
lda #S.IP.PROTOCOL.UDP
|
||||
ldy #S.SOCKET
|
||||
bra SKT.Socket.NEW
|
||||
ldy #S.SOCKET socket.size
|
||||
bra SKT.Socket.DSOCK
|
||||
SKT.Socket.SEQPACKET
|
||||
lda #S.IP.PROTOCOL.TCP
|
||||
ldy #S.SOCKET.TCP socket.size
|
||||
|
||||
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
|
||||
>SYSCALL GetMem0
|
||||
bcs .99
|
||||
>STYA ZPTmpPtr1
|
||||
stx FD.DSOCK+S.FD.DSOCK.HSKT
|
||||
|
||||
jsr SKT.Socket.FindFree
|
||||
bcs .9
|
||||
|
||||
ldy #FD.DSOCK.SIZE-1
|
||||
|
||||
.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
|
||||
bra SKT.Socket.NEW
|
||||
SKT.Socket.SEQPACKET
|
||||
lda #S.IP.PROTOCOL.TCP
|
||||
ldy #S.SOCKET.TCP
|
||||
|
||||
SKT.Socket.NEW sta FD.SSOCK+S.SOCKET.PROTO
|
||||
lda #0
|
||||
|
||||
stx FD.SSOCK+S.SOCKET.T save type
|
||||
sta FD.SSOCK+S.SOCKET.PROTO ICMP,UDP,TCP
|
||||
lda #0 Y = socket.size
|
||||
>SYSCALL GetMem0
|
||||
bcs .99
|
||||
>STYA ZPPtrSKT
|
||||
stx FD.SSOCK+S.FD.SOCK.HSKT
|
||||
>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
|
||||
ldy #0
|
||||
|
||||
.1 lda SKT.TABLE,y
|
||||
@ -56,19 +94,10 @@ SKT.Socket.NEW sta FD.SSOCK+S.SOCKET.PROTO
|
||||
>SYSCALL freemem
|
||||
lda #K.E.OOH
|
||||
sec
|
||||
.99 rts
|
||||
rts
|
||||
|
||||
.2 txa x = hFD
|
||||
sta SKT.TABLE,y
|
||||
|
||||
ldy #FD.SSOCK.SIZE-1
|
||||
|
||||
.3 lda FD.SSOCK,y
|
||||
sta (ZPPtrSKT),y
|
||||
dey
|
||||
bpl .3
|
||||
|
||||
txa
|
||||
clc
|
||||
rts
|
||||
*/--------------------------------------
|
||||
@ -88,7 +117,7 @@ SKT.Socket.NEW sta FD.SSOCK+S.SOCKET.PROTO
|
||||
SKT.bind >SYSCALL GetMemPtr
|
||||
>STYA ZPPtrSKT
|
||||
|
||||
jsr SKT.GetLocAddr
|
||||
jsr SKT.PullLocAddr
|
||||
|
||||
lda SKT.LOC.ADDR+S.SOCKADDR.PORT
|
||||
bne .1
|
||||
@ -128,7 +157,7 @@ SKT.bind >SYSCALL GetMemPtr
|
||||
SKT.connect >SYSCALL GetMemPtr
|
||||
>STYA ZPPtrSKT
|
||||
|
||||
jsr SKT.GetRemAddr
|
||||
jsr SKT.PullRemAddr
|
||||
|
||||
ldy #S.SOCKET.T
|
||||
lda (ZPPtrSKT),y
|
||||
@ -219,7 +248,7 @@ SKT.listen >SYSCALL GetMemPtr
|
||||
|
||||
ldy #S.SOCKET.T
|
||||
lda (ZPPtrSKT),y
|
||||
cmp #S.SOCKET.T.STREAM+1
|
||||
cmp #S.SOCKET.T.SEQPACKET+1
|
||||
bcc .9
|
||||
|
||||
ldy #S.SOCKET.TCP.S
|
||||
@ -465,12 +494,12 @@ SKT.Write >SYSCALL GetMemPtr
|
||||
|
||||
.99 lda #ERR.SKT.BAD
|
||||
sec
|
||||
.9 rts
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # SKT.Recv (RAW,DGRAM,SEQPACKET)
|
||||
* # SKT.RecvFrom (RAW,DGRAM,SEQPACKET)
|
||||
* hMem recv(hFD fd);
|
||||
* hMem recv(hFD fd, const struct sockaddr *addr);
|
||||
* hMem recvfrom(hFD fd, struct sockaddr *addr);
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHW addr` (RecvFrom)
|
||||
@ -480,16 +509,26 @@ SKT.Write >SYSCALL GetMemPtr
|
||||
* CC: A = hMem
|
||||
* CS: A = EC
|
||||
*\--------------------------------------
|
||||
SKT.Recv >SYSCALL GetMemPtr
|
||||
SKT.RecvFrom sec
|
||||
.HS 90 BCC
|
||||
SKT.Recv clc
|
||||
php
|
||||
|
||||
>SYSCALL GetMemPtr
|
||||
>STYA ZPPtrSKT
|
||||
|
||||
ldy #S.SOCKET.T
|
||||
lda (ZPPtrSKT),y
|
||||
cmp #S.SOCKET.T.STREAM
|
||||
beq .99
|
||||
|
||||
ldy #S.SOCKET.HQ.TAIL
|
||||
lda (ZPPtrSKT),y
|
||||
tax
|
||||
|
||||
ldy #S.SOCKET.HQ.HEAD
|
||||
cmp (ZPPtrSKT),y
|
||||
beq .99
|
||||
beq .90
|
||||
|
||||
inc
|
||||
cmp #S.SOCKET.HQ.MAX
|
||||
@ -504,11 +543,28 @@ SKT.Recv >SYSCALL GetMemPtr
|
||||
adc #S.SOCKET.HQ
|
||||
tay
|
||||
lda (ZPPtrSKT),y
|
||||
clc
|
||||
rts
|
||||
plp
|
||||
bcc .9
|
||||
pha
|
||||
>SYSCALL GetMemPtr
|
||||
>STYA ZPFrameInPtr
|
||||
|
||||
.99 sec
|
||||
>PULLW ZPTmpPtr1 addr
|
||||
|
||||
|
||||
pla
|
||||
clc
|
||||
.9 rts
|
||||
|
||||
.99 plp
|
||||
lda #ERR.SKT.BAD
|
||||
sec
|
||||
rts
|
||||
|
||||
.90 plp
|
||||
lda #0 no data
|
||||
sec
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # SKT.Send (RAW,DGRAM,SEQPACKET)
|
||||
* # SKT.SendTo (RAW,DGRAM,SEQPACKET)
|
||||
@ -526,23 +582,25 @@ SKT.Recv >SYSCALL GetMemPtr
|
||||
* CC: Y,A = bytes written
|
||||
* CS: A = EC
|
||||
*\--------------------------------------
|
||||
SKT.Send >SYSCALL GetMemPtr
|
||||
SKT.SendTo sec
|
||||
.HS 90 BCC
|
||||
SKT.Send clc
|
||||
php
|
||||
>SYSCALL GetMemPtr
|
||||
>STYA ZPPtrSKT
|
||||
>PULLW ZPDataInPtr
|
||||
plp
|
||||
|
||||
bcc .1
|
||||
|
||||
jsr SKT.PullRemAddr
|
||||
|
||||
.1 >PULLW ZPDataInPtr
|
||||
>PULLW ZPDataInLen
|
||||
|
||||
ldy #S.SOCKET.T
|
||||
lda (ZPPtrSKT),y
|
||||
|
||||
cmp #S.SOCKET.T.DGRAM
|
||||
beq SKT.Send.UDP
|
||||
|
||||
cmp #S.SOCKET.T.RAW
|
||||
beq SKT.Send.RAW
|
||||
|
||||
lda #ERR.SKT.BAD
|
||||
sec
|
||||
SKT.Send.9 rts
|
||||
tax
|
||||
jmp (J.SKT.send,x)
|
||||
*--------------------------------------
|
||||
SKT.Send.RAW ldy #S.SOCKET.RAW.PROTO
|
||||
lda (ZPPtrSKT),y
|
||||
@ -552,20 +610,29 @@ SKT.Send.RAW ldy #S.SOCKET.RAW.PROTO
|
||||
jsr FRM.NewIP
|
||||
bcs SKT.Send.9
|
||||
|
||||
bra SKT.Send.UDP.8
|
||||
bra SKT.Send.DGRAM.8
|
||||
*--------------------------------------
|
||||
SKT.Send.UDP ldx #S.IP.PROTOCOL.UDP
|
||||
SKT.Send.DGRAM ldx #S.IP.PROTOCOL.UDP
|
||||
>LDYA ZPDataInLen
|
||||
jsr FRM.NewIP
|
||||
bcs SKT.Send.9
|
||||
|
||||
jsr SKT.SetFrameOutTCPUDPPorts
|
||||
|
||||
SKT.Send.UDP.8 jsr SKT.SetFrameOutDstIP
|
||||
SKT.Send.DGRAM.8
|
||||
|
||||
jsr SKT.SetFrameOutDstIP
|
||||
|
||||
jsr SKT.CopyDataInToOut
|
||||
|
||||
jmp FRM.SendIP
|
||||
*--------------------------------------
|
||||
SKT.Send.STREAM lda #ERR.SKT.BAD
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
SKT.Send.SEQPACKET
|
||||
bra *
|
||||
*/--------------------------------------
|
||||
* # SKT.GetTable
|
||||
* Get socket table
|
||||
@ -582,7 +649,7 @@ SKT.GetTable >LDYA L.SKT.Table
|
||||
*--------------------------------------
|
||||
* PRIVATE
|
||||
*--------------------------------------
|
||||
SKT.GetLocAddr >PULLW ZPTmpPtr1
|
||||
SKT.PullLocAddr >PULLW ZPTmpPtr1
|
||||
|
||||
ldy #S.SOCKADDR-1
|
||||
|
||||
@ -592,7 +659,7 @@ SKT.GetLocAddr >PULLW ZPTmpPtr1
|
||||
bne .1
|
||||
rts
|
||||
*--------------------------------------
|
||||
SKT.GetRemAddr >PULLW ZPTmpPtr1
|
||||
SKT.PullRemAddr >PULLW ZPTmpPtr1
|
||||
|
||||
ldy #S.SOCKADDR-1
|
||||
|
||||
|
@ -39,32 +39,24 @@ TCP.IN.JMP.LISTEN
|
||||
cmp #S.TCP.OPTIONS.SYN
|
||||
bne TCP.IN.JMP.CLOSED
|
||||
|
||||
|
||||
lda #S.SOCKET.T.STREAM
|
||||
sta SKT.Template+S.SOCKET.T
|
||||
stz SKT.Template+S.SOCKET.O
|
||||
stz SKT.Template+S.SOCKET.TCP.S
|
||||
lda #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK
|
||||
sta SKT.Template+S.SOCKET.TCP.O
|
||||
|
||||
>PUSHW L.SKT.Template
|
||||
ldy #S.SOCKET.T Create a new client socket
|
||||
lda (ZPPtrSKT),y
|
||||
tax Same type a listening socket
|
||||
|
||||
jsr SKT.Socket.I get new socket in ZPTmpPtr1
|
||||
bcs TCP.IN.JMP.CLOSED
|
||||
|
||||
jsr SKT.New Assign OUTNEXTSEQ
|
||||
bcs .99
|
||||
|
||||
sty .1+1
|
||||
sta .2+1
|
||||
txa
|
||||
|
||||
jsr SKT.AddToQueueA
|
||||
jsr SKT.AddToQueueA Queued successfully ?
|
||||
|
||||
bcs .99 Queued successfully ?
|
||||
bcs TCP.IN.JMP.CLOSED no, discard frame and new socket
|
||||
|
||||
jsr ARP.AddFromFrameInPtr
|
||||
|
||||
.1 lda #$ff
|
||||
lda ZPTmpPtr1
|
||||
sta ZPPtrSKT
|
||||
.2 lda #$ff
|
||||
ldaZPTmpPtr1+1
|
||||
sta ZPPtrSKT+1
|
||||
|
||||
jsr TCP.IN.ACKTheSYN
|
||||
|
@ -114,7 +114,6 @@ L.DNS.SOCKET .DA DNS.SOCKET
|
||||
L.DNS.MSG .DA DNS.MSG
|
||||
L.ARP.CACHE .DA ARP.CACHE
|
||||
L.DNS.CACHE .DA DNS.CACHE
|
||||
L.SKT.Template .DA SKT.Template
|
||||
L.SKT.Table .DA SKT.Table
|
||||
L.HST.SScanF .DA HST.SScanF
|
||||
L.IOCTL .DA IOCTL
|
||||
@ -137,13 +136,17 @@ J.SKT.Socket .DA SKT.Socket.RAW
|
||||
J.SKT.connect .DA SKT.connect.RAW
|
||||
.DA SKT.connect.DGRAM
|
||||
.DA SKT.connect.STREAM
|
||||
.DA SKT.connect.SEQPACKET
|
||||
.DA SKT.connect.SEQPACKET
|
||||
J.SKT.send .DA SKT.send.RAW
|
||||
.DA SKT.send.DGRAM
|
||||
.DA SKT.send.STREAM
|
||||
.DA SKT.send.SEQPACKET
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
LIB.LOAD ldx RefCount
|
||||
bne .8
|
||||
|
||||
sta FD.SSOCK+S.FD.HANDLER
|
||||
sta FD.DSOCK+S.FD.HANDLER
|
||||
|
||||
jsr ARP.CLEAR
|
||||
|
||||
@ -287,17 +290,32 @@ CFG.HOSTS.SScanF .AZ "%d.%d.%d.%d %s %s"
|
||||
*--------------------------------------
|
||||
SKT.TABLE .BS K.SKTTABLE.SIZE
|
||||
*--------------------------------------
|
||||
FD.SSOCK .BS 1 S.FD.HANDLER
|
||||
.DA #S.FD.T.SSOCK
|
||||
.BS 1 S.FD.SOCK.HSKT
|
||||
.DA #0 S.FD.SOCK.OPEN
|
||||
.DA #0 S.FD.SOCK.CLOSE
|
||||
.DA #LIBTCPIP.SKT.Read
|
||||
.DA #LIBTCPIP.SKT.Write
|
||||
.DA #0 S.FD.SOCK.STATUS
|
||||
FD.DSOCK .DA #S.FD.T.DSOCK
|
||||
.BS 1 S.FD.HANDLER
|
||||
.BS 1 S.FD.DSOCK.HSKT
|
||||
.DA #0 S.FD.DSOCK.OPEN
|
||||
.DA #0 S.FD.DSOCK.CLOSE
|
||||
.DA #LIBTCPIP.SKT.Recv
|
||||
.DA #LIBTCPIP.SKT.Send
|
||||
.DA #0 S.FD.DSOCK.STATUS
|
||||
*--------------------------------------
|
||||
.DA #AF.INET S.SOCKET.AF
|
||||
.BS 1 S.SOCKET.T
|
||||
.BS 1 S.SOCKET.PROTO
|
||||
FD.DSOCK.SIZE .EQ *-FD.DSOCK
|
||||
*--------------------------------------
|
||||
FD.SSOCK .DA #S.FD.T.SSOCK
|
||||
.BS 1 S.FD.HANDLER
|
||||
.BS 1 S.FD.DSOCK.HSKT
|
||||
.DA #0 S.FD.DSOCK.OPEN
|
||||
.DA #0 S.FD.DSOCK.CLOSE
|
||||
.DA #LIBTCPIP.SKT.Read
|
||||
.DA #LIBTCPIP.SKT.Write
|
||||
.DA #0 S.FD.DSOCK.STATUS
|
||||
*--------------------------------------
|
||||
.DA #AF.INET S.SOCKET.AF
|
||||
.DA #S.SOCKET.T.STREAM
|
||||
.BS #S.IP.PROTOCOL.TCP
|
||||
FD.SSOCK.SIZE .EQ *-FD.SSOCK
|
||||
*--------------------------------------
|
||||
IOCTL .BS S.IOCTL
|
||||
|
Loading…
x
Reference in New Issue
Block a user