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
|
|
|
|
*--------------------------------------
|
2017-02-13 07:26:18 +00:00
|
|
|
|
* FRM.New
|
|
|
|
|
* In:
|
|
|
|
|
* Y,A = DataLen
|
|
|
|
|
* X = S.IP.PROTOCOL.xxx
|
|
|
|
|
* Out:
|
|
|
|
|
* Y,A = Frame PTR
|
|
|
|
|
* X = hMem
|
2017-01-31 16:40:37 +00:00
|
|
|
|
*--------------------------------------
|
2017-02-13 07:26:18 +00:00
|
|
|
|
FRM.NewIP stx .8+1
|
|
|
|
|
>STYA ZPDataOutLen
|
2017-02-15 16:14:41 +00:00
|
|
|
|
cpx #S.IP.PROTOCOL.TCP
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bne .1
|
2018-07-23 06:28:47 +00:00
|
|
|
|
lda #S.TCP
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bra .4
|
|
|
|
|
|
|
|
|
|
.1 cpx #S.IP.PROTOCOL.UDP
|
|
|
|
|
bne .2
|
2018-07-23 06:28:47 +00:00
|
|
|
|
lda #S.UDP
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bra .4
|
|
|
|
|
|
2018-07-23 06:28:47 +00:00
|
|
|
|
.2 lda #S.IP
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bra .4
|
|
|
|
|
|
2018-07-24 06:24:23 +00:00
|
|
|
|
.4 sta .5+1 save Header len for reset later
|
2017-02-13 07:26:18 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPDataOutLen
|
|
|
|
|
sta ZPFrameOutLen
|
2018-07-23 06:28:47 +00:00
|
|
|
|
tay
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
adc ZPDataOutLen+1
|
|
|
|
|
sta ZPFrameOutLen+1
|
|
|
|
|
|
2018-07-20 11:51:08 +00:00
|
|
|
|
>SYSCALL getmem
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bcs .9
|
2017-01-30 16:30:39 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
stx hFrameOut
|
|
|
|
|
>STYA ZPFrameOutPtr
|
|
|
|
|
|
2018-07-23 06:28:47 +00:00
|
|
|
|
ldy #0
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
|
|
|
|
.5 ldx #$ff Self Modified, header length
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
|
|
|
|
|
.6 sta (ZPFrameOutPtr),y
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .6
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
* clc
|
|
|
|
|
adc ZPFrameOutPtr
|
|
|
|
|
sta ZPDataOutPtr
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
adc ZPFrameOutPtr+1
|
|
|
|
|
sta ZPDataOutPtr+1
|
|
|
|
|
|
2018-07-23 06:28:47 +00:00
|
|
|
|
lda DCB.NIC+S.DCB.NIC.FLAGS
|
|
|
|
|
and #S.DCB.NIC.FLAGS.IPOFFLOAD
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bne .7
|
2016-04-18 20:16:54 +00:00
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ldy #S.ETH.ETHERTYPE
|
|
|
|
|
lda /S.ETH.ETHERTYPE.IP
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
iny
|
|
|
|
|
lda #S.ETH.ETHERTYPE.IP
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.V.IHL.DSCP.ECN
|
|
|
|
|
lda #$45
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
* iny
|
|
|
|
|
* lda #$0
|
|
|
|
|
* sta (ZPFrameOutPtr),y
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
* ldy #S.IP.FRAGMENT.FLAGS
|
|
|
|
|
* sta (ZPFrameOutPtr),y
|
|
|
|
|
* iny
|
|
|
|
|
* sta (ZPFrameOutPtr),y
|
2017-02-13 07:26:18 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.IDENTIFICATION+1
|
|
|
|
|
|
|
|
|
|
lda IP.ID
|
|
|
|
|
ldx IP.ID+1
|
|
|
|
|
inc
|
|
|
|
|
bne .61
|
|
|
|
|
inx
|
|
|
|
|
stx IP.ID+1
|
|
|
|
|
|
|
|
|
|
.61 sta IP.ID
|
|
|
|
|
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
dey
|
|
|
|
|
txa
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.TTL
|
|
|
|
|
lda #K.IP.TTL
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
.7 ldy #S.IP.PROTOCOL
|
|
|
|
|
|
|
|
|
|
.8 lda #$ff
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-01-30 16:30:39 +00:00
|
|
|
|
FRM.SendIP ldx #3 Copy SRC.IP even if IP offload
|
2016-04-18 20:16:54 +00:00
|
|
|
|
ldy #S.IP.SRC+3 for proper UDP/TCP CRC calculation
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.1 lda IPCFG+S.IPCFG.IP,x
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
2016-03-20 22:16:01 +00:00
|
|
|
|
bpl .1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2018-07-23 06:28:47 +00:00
|
|
|
|
lda DCB.NIC+S.DCB.NIC.FLAGS
|
|
|
|
|
and #S.DCB.NIC.FLAGS.IPOFFLOAD
|
2016-04-18 20:16:54 +00:00
|
|
|
|
bne .21
|
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ldy #S.IP.TOTAL.LENGTH+1
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPFrameOutLen
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sec
|
2018-07-26 06:03:49 +00:00
|
|
|
|
sbc #S.ETH
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
dey
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda ZPFrameOutLen+1
|
2018-07-26 06:03:49 +00:00
|
|
|
|
sbc /S.ETH
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
ldy #S.IP.HDR.CHECKSUM
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
stz IP.CHECKSUM RESET.IP.CHECKSUM
|
|
|
|
|
stz IP.CHECKSUM+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
clc
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.V.IHL.DSCP.ECN
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ldx #10 10 words for IP Header
|
|
|
|
|
|
2017-01-31 16:40:37 +00:00
|
|
|
|
.2 lda (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
adc IP.CHECKSUM
|
|
|
|
|
sta IP.CHECKSUM
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
iny
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameOutPtr),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
adc IP.CHECKSUM+1
|
|
|
|
|
sta IP.CHECKSUM+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
|
|
|
|
dex
|
2016-03-20 22:16:01 +00:00
|
|
|
|
bne .2
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ldy #S.IP.HDR.CHECKSUM
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda IP.CHECKSUM
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc #0
|
2016-01-16 22:04:22 +00:00
|
|
|
|
eor #$FF
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda IP.CHECKSUM+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc #0
|
2016-01-16 22:04:22 +00:00
|
|
|
|
eor #$FF
|
2017-01-31 16:40:37 +00:00
|
|
|
|
sta (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-04-18 20:16:54 +00:00
|
|
|
|
.21 ldy #S.IP.PROTOCOL
|
2017-01-31 16:40:37 +00:00
|
|
|
|
lda (ZPFrameOutPtr),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
cmp #S.IP.PROTOCOL.TCP
|
|
|
|
|
bne .3
|
|
|
|
|
jsr TCP.ComputeChecksum
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bra .5
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
.3 cmp #S.IP.PROTOCOL.UDP
|
2016-03-20 22:16:01 +00:00
|
|
|
|
bne .4
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
lda ZPFrameOutLen
|
|
|
|
|
sec
|
2018-07-23 06:28:47 +00:00
|
|
|
|
sbc #S.IP
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.UDP.LENGTH+1
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
|
|
|
|
lda ZPFrameOutLen+1
|
2018-07-23 06:28:47 +00:00
|
|
|
|
sbc /S.IP
|
2017-02-15 16:14:41 +00:00
|
|
|
|
|
|
|
|
|
dey
|
|
|
|
|
sta (ZPFrameOutPtr),y
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
jsr UDP.ComputeChecksum
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bra .5
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2017-02-13 07:26:18 +00:00
|
|
|
|
.4 cmp #S.IP.PROTOCOL.ICMP
|
2016-03-20 22:16:01 +00:00
|
|
|
|
bne .5
|
2017-02-13 07:26:18 +00:00
|
|
|
|
jsr ICMP.ComputeChecksum
|
|
|
|
|
|
2018-07-23 06:28:47 +00:00
|
|
|
|
.5 lda DCB.NIC+S.DCB.NIC.FLAGS
|
|
|
|
|
and #S.DCB.NIC.FLAGS.ARPOFFLOAD
|
2017-02-13 07:26:18 +00:00
|
|
|
|
bne .6
|
2016-03-20 22:16:01 +00:00
|
|
|
|
|
|
|
|
|
jsr IP.SetDestMAC
|
|
|
|
|
bcs FRM.Queue
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2018-08-08 15:13:37 +00:00
|
|
|
|
.6 jsr FRM.Send
|
2018-05-24 15:21:38 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
bcs FRM.Queue
|
2017-01-31 16:40:37 +00:00
|
|
|
|
|
2017-01-29 21:47:19 +00:00
|
|
|
|
lda hFrameOut
|
2016-03-20 22:16:01 +00:00
|
|
|
|
beq .9
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2016-03-20 22:16:01 +00:00
|
|
|
|
|
2016-03-27 21:06:56 +00:00
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-01-29 21:47:19 +00:00
|
|
|
|
FRM.Queue ldy hFrameOut no hFrame, cannot queue for retry
|
2016-03-27 21:06:56 +00:00
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
ldx FRM.QUEUE.Head
|
|
|
|
|
inx
|
|
|
|
|
cpx #K.FRMQUEUE.SIZE
|
|
|
|
|
bne .1
|
|
|
|
|
ldx #0
|
|
|
|
|
.1 cpx FRM.QUEUE.Tail
|
|
|
|
|
beq .9
|
|
|
|
|
ldy FRM.QUEUE.Head
|
|
|
|
|
stx FRM.QUEUE.Head
|
|
|
|
|
|
|
|
|
|
sta FRM.QUEUE.State,y
|
|
|
|
|
lda #K.FRMSEND.RETRY
|
|
|
|
|
sta FRM.QUEUE.Retry,y
|
2017-01-29 21:47:19 +00:00
|
|
|
|
lda hFrameOut
|
2016-03-27 21:06:56 +00:00
|
|
|
|
sta FRM.QUEUE.hMem,y
|
2018-07-23 15:28:42 +00:00
|
|
|
|
lda ZPFrameOutLen
|
|
|
|
|
sta FRM.QUEUE.LenL,x
|
|
|
|
|
lda ZPFrameOutLen+1
|
|
|
|
|
sta FRM.QUEUE.LenH,x
|
2016-03-27 21:06:56 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2016-03-20 22:16:01 +00:00
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2016-01-16 22:04:22 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-20 22:16:01 +00:00
|
|
|
|
FRM.Retry ldx FRM.QUEUE.Tail
|
|
|
|
|
|
|
|
|
|
.10 cpx FRM.QUEUE.Head
|
2018-07-24 06:24:23 +00:00
|
|
|
|
beq .8 Queue is empty, exit...
|
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
lda FRM.QUEUE.hMem,x
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
2017-01-31 16:40:37 +00:00
|
|
|
|
>STYA ZPFrameOutPtr
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
ldx FRM.QUEUE.Tail
|
2018-08-08 15:13:37 +00:00
|
|
|
|
|
|
|
|
|
lda FRM.QUEUE.LenL,x
|
|
|
|
|
sta ZPFrameOutLen
|
|
|
|
|
lda FRM.QUEUE.LenH,x
|
|
|
|
|
sta ZPFrameOutLen+1
|
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
lda FRM.QUEUE.State,x
|
|
|
|
|
cmp #ERR.DEV+1 Device error ?
|
|
|
|
|
bcc .1 yes, retry sending...
|
|
|
|
|
jsr IP.SetDestMAC Err is ARP or higher, retry getting MAC
|
|
|
|
|
bcs .2 still error getting dest MAC
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2018-08-08 15:13:37 +00:00
|
|
|
|
.1 jsr FRM.Send try sending again to DRV
|
2016-03-20 22:16:01 +00:00
|
|
|
|
bcc .3
|
|
|
|
|
|
|
|
|
|
.2 ldx FRM.QUEUE.Tail save error...
|
|
|
|
|
sta FRM.QUEUE.State,x
|
|
|
|
|
dec FRM.QUEUE.Retry,x
|
|
|
|
|
bne .8 exit....until next run!
|
|
|
|
|
|
|
|
|
|
.3 ldx FRM.QUEUE.Tail Success,or max retry, discard entry
|
|
|
|
|
lda FRM.QUEUE.hMem,x
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.4 ldx FRM.QUEUE.Tail
|
|
|
|
|
inx
|
|
|
|
|
cpx #K.FRMQUEUE.SIZE
|
|
|
|
|
bne .5
|
|
|
|
|
ldx #0
|
|
|
|
|
.5 stx FRM.QUEUE.Tail
|
|
|
|
|
bra .10
|
2016-03-16 16:37:02 +00:00
|
|
|
|
|
2016-03-20 22:16:01 +00:00
|
|
|
|
.8 rts
|
2016-01-16 22:04:22 +00:00
|
|
|
|
*--------------------------------------
|
2018-08-08 15:13:37 +00:00
|
|
|
|
FRM.Send >PUSHW ZPFrameOutLen
|
|
|
|
|
>PUSHW ZPFrameOutPtr
|
|
|
|
|
lda IPCFG+S.IPCFG.hFD
|
2018-07-23 06:28:47 +00:00
|
|
|
|
|
2018-08-08 15:13:37 +00:00
|
|
|
|
>SYSCALL write
|
2018-05-24 15:21:38 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-01-16 22:04:22 +00:00
|
|
|
|
MAN
|
2017-03-30 06:31:12 +00:00
|
|
|
|
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.FRM
|
|
|
|
|
LOAD /A2OSX.SRC/LIB/LIBTCPIP.S
|
2016-01-16 22:04:22 +00:00
|
|
|
|
ASM
|