mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
Merge pull request #358 from oliverschmidt/master
Optimized 6502 Ethernet drivers.
This commit is contained in:
commit
4772455a9a
@ -74,14 +74,7 @@ fixup: .byte fixup02-fixup01, fixup03-fixup02, fixup04-fixup03
|
|||||||
.byte fixup17-fixup16, fixup18-fixup17, fixup19-fixup18
|
.byte fixup17-fixup16, fixup18-fixup17, fixup19-fixup18
|
||||||
.byte fixup20-fixup19, fixup21-fixup20, fixup22-fixup21
|
.byte fixup20-fixup19, fixup21-fixup20, fixup22-fixup21
|
||||||
.byte fixup23-fixup22, fixup24-fixup23, fixup25-fixup24
|
.byte fixup23-fixup22, fixup24-fixup23, fixup25-fixup24
|
||||||
.byte fixup26-fixup25, fixup27-fixup26, fixup28-fixup27
|
.byte fixup26-fixup25
|
||||||
.byte fixup29-fixup28, fixup30-fixup29, fixup31-fixup30
|
|
||||||
.byte fixup32-fixup31, fixup33-fixup32, fixup34-fixup33
|
|
||||||
.byte fixup35-fixup34, fixup36-fixup35, fixup37-fixup36
|
|
||||||
.byte fixup38-fixup37, fixup39-fixup38, fixup40-fixup39
|
|
||||||
.byte fixup41-fixup40, fixup42-fixup41, fixup43-fixup42
|
|
||||||
.byte fixup44-fixup43, fixup45-fixup44, fixup46-fixup45
|
|
||||||
.byte fixup47-fixup46, fixup48-fixup47
|
|
||||||
|
|
||||||
fixups = * - fixup
|
fixups = * - fixup
|
||||||
|
|
||||||
@ -140,56 +133,39 @@ fixup01:lda isq+1
|
|||||||
ora #$01 ; Set clockport bit
|
ora #$01 ; Set clockport bit
|
||||||
fixup02:sta isq+1
|
fixup02:sta isq+1
|
||||||
|
|
||||||
; Turn on transmission and reception of frames
|
|
||||||
; PACKETPP = $0112, PPDATA = $00C0
|
|
||||||
lda #$12
|
|
||||||
ldx #$01
|
|
||||||
fixup03:sta packetpp
|
|
||||||
fixup04:stx packetpp+1
|
|
||||||
lda #$C0
|
|
||||||
ldx #$00
|
|
||||||
fixup05:sta ppdata
|
|
||||||
fixup06:stx ppdata+1
|
|
||||||
|
|
||||||
; Accept valid unicast + broadcast frames
|
; Accept valid unicast + broadcast frames
|
||||||
; PACKETPP = $0104, PPDATA = $0D05
|
; PACKETPP = $0104, PPDATA = $0D05
|
||||||
lda #$04
|
lda #$04
|
||||||
ldx #$01
|
jsr packetpp_01
|
||||||
fixup07:sta packetpp
|
|
||||||
fixup08:stx packetpp+1
|
|
||||||
lda #$05
|
lda #$05
|
||||||
ldx #$0D
|
ldx #$0D
|
||||||
fixup09:sta ppdata
|
fixup03:sta ppdata
|
||||||
fixup10:stx ppdata+1
|
fixup04:stx ppdata+1
|
||||||
|
|
||||||
; Set MAC address
|
; Set MAC address
|
||||||
; PACKETPP = $0158, PPDATA = MAC[0], MAC[1]
|
; PACKETPP = $0158, PPDATA = MAC[0], MAC[1]
|
||||||
lda #$58
|
|
||||||
ldx #$01
|
|
||||||
fixup11:sta packetpp
|
|
||||||
fixup12:stx packetpp+1
|
|
||||||
lda mac
|
|
||||||
ldx mac+1
|
|
||||||
fixup13:sta ppdata
|
|
||||||
fixup14:stx ppdata+1
|
|
||||||
; PACKETPP = $015A, PPDATA = MAC[2], MAC[3]
|
; PACKETPP = $015A, PPDATA = MAC[2], MAC[3]
|
||||||
lda #$5A
|
; PACKETPP = $015C, PPDATA = MAC[4], MAC[5]
|
||||||
ldx #$01
|
ldy #$58
|
||||||
fixup15:sta packetpp
|
: tya
|
||||||
fixup16:stx packetpp+1
|
jsr packetpp_01
|
||||||
lda mac+2
|
lda mac-$58,y
|
||||||
ldx mac+3
|
ldx mac-$58+1,y
|
||||||
fixup17:sta ppdata
|
fixup05:sta ppdata
|
||||||
fixup18:stx ppdata+1
|
fixup06:stx ppdata+1
|
||||||
; PACKETPP = 0x015C, PPDATA = MAC[4], MAC[5]
|
iny
|
||||||
lda #$5C
|
iny
|
||||||
ldx #$01
|
cpy #$58+6
|
||||||
fixup19:sta packetpp
|
bcc :-
|
||||||
fixup20:stx packetpp+1
|
|
||||||
lda mac+4
|
; Turn on transmission and reception of frames
|
||||||
ldx mac+5
|
; PACKETPP = $0112, PPDATA = $00D3
|
||||||
fixup21:sta ppdata
|
lda #$12
|
||||||
fixup22:stx ppdata+1
|
jsr packetpp_01
|
||||||
|
lda #$D3
|
||||||
|
ldx #$00
|
||||||
|
fixup07:sta ppdata
|
||||||
|
fixup08:stx ppdata+1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
@ -199,10 +175,8 @@ poll:
|
|||||||
; are any valid unicast frames avaliable
|
; are any valid unicast frames avaliable
|
||||||
; PACKETPP = $0124, PPDATA & $0D00 ?
|
; PACKETPP = $0124, PPDATA & $0D00 ?
|
||||||
lda #$24
|
lda #$24
|
||||||
ldx #$01
|
jsr packetpp_01
|
||||||
fixup23:sta packetpp
|
fixup09:lda ppdata+1
|
||||||
fixup24:stx packetpp+1
|
|
||||||
fixup25:lda ppdata+1
|
|
||||||
and #$0D
|
and #$0D
|
||||||
bne :+
|
bne :+
|
||||||
|
|
||||||
@ -216,27 +190,23 @@ fixup25:lda ppdata+1
|
|||||||
; Read receiver event and discard it
|
; Read receiver event and discard it
|
||||||
; RXTXREG
|
; RXTXREG
|
||||||
:
|
:
|
||||||
fixup26:ldx rxtxreg+1
|
fixup10:ldx rxtxreg+1
|
||||||
fixup27:lda rxtxreg
|
fixup11:lda rxtxreg
|
||||||
|
|
||||||
; Read frame length
|
; Read frame length
|
||||||
; cnt = len = RXTXREG
|
; cnt = len = RXTXREG
|
||||||
fixup28:ldx rxtxreg+1
|
fixup12:ldx rxtxreg+1
|
||||||
fixup29:lda rxtxreg
|
fixup13:lda rxtxreg
|
||||||
sta len
|
sta len
|
||||||
stx len+1
|
stx len+1
|
||||||
sta cnt
|
sta cnt
|
||||||
stx cnt+1
|
stx cnt+1
|
||||||
|
|
||||||
; Adjust odd frame length
|
; Adjust odd frame length
|
||||||
lsr
|
jsr adjustcnt
|
||||||
bcc :+
|
|
||||||
inc cnt
|
|
||||||
bne :+
|
|
||||||
inc cnt+1
|
|
||||||
|
|
||||||
; Is bufsize < cnt ?
|
; Is bufsize < cnt ?
|
||||||
: sec
|
sec
|
||||||
lda bufsize
|
lda bufsize
|
||||||
sbc cnt
|
sbc cnt
|
||||||
lda bufsize+1
|
lda bufsize+1
|
||||||
@ -244,14 +214,7 @@ fixup29:lda rxtxreg
|
|||||||
bcs :+
|
bcs :+
|
||||||
|
|
||||||
; Yes, skip frame
|
; Yes, skip frame
|
||||||
; PACKETPP = $0102, PPDATA = PPDATA | $0040
|
jsr skipframe
|
||||||
lda #$02
|
|
||||||
ldx #$01
|
|
||||||
fixup30:sta packetpp
|
|
||||||
fixup31:stx packetpp+1
|
|
||||||
fixup32:lda ppdata
|
|
||||||
ora #$40
|
|
||||||
fixup33:sta ppdata
|
|
||||||
|
|
||||||
; No frame ready
|
; No frame ready
|
||||||
lda #$00
|
lda #$00
|
||||||
@ -259,25 +222,18 @@ fixup33:sta ppdata
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
; Read bytes into buffer
|
; Read bytes into buffer
|
||||||
: lda bufaddr
|
: jsr adjustptr
|
||||||
ldx bufaddr+1
|
:
|
||||||
sta ptr
|
fixup14:lda rxtxreg
|
||||||
stx ptr+1
|
|
||||||
ldx cnt+1
|
|
||||||
ldy #$00
|
|
||||||
read:
|
|
||||||
fixup34:lda rxtxreg
|
|
||||||
sta (ptr),y
|
sta (ptr),y
|
||||||
iny
|
iny
|
||||||
fixup35:lda rxtxreg+1
|
fixup15:lda rxtxreg+1
|
||||||
sta (ptr),y
|
sta (ptr),y
|
||||||
iny
|
iny
|
||||||
bne :+
|
bne :-
|
||||||
inc ptr+1
|
inc ptr+1
|
||||||
: cpy cnt
|
|
||||||
bne read
|
|
||||||
dex
|
dex
|
||||||
bpl read
|
bpl :-
|
||||||
|
|
||||||
; Return frame length
|
; Return frame length
|
||||||
lda len
|
lda len
|
||||||
@ -292,44 +248,31 @@ send:
|
|||||||
stx cnt+1
|
stx cnt+1
|
||||||
|
|
||||||
; Transmit command
|
; Transmit command
|
||||||
lda #$C0
|
lda #$C9
|
||||||
ldx #$00
|
ldx #$00
|
||||||
fixup36:sta txcmd
|
fixup16:sta txcmd
|
||||||
fixup37:stx txcmd+1
|
fixup17:stx txcmd+1
|
||||||
lda cnt
|
lda cnt
|
||||||
ldx cnt+1
|
ldx cnt+1
|
||||||
fixup38:sta txlen
|
fixup18:sta txlen
|
||||||
fixup39:stx txlen+1
|
fixup19:stx txlen+1
|
||||||
|
|
||||||
; Adjust odd frame length
|
; Adjust odd frame length
|
||||||
lsr
|
jsr adjustcnt
|
||||||
bcc :+
|
|
||||||
inc cnt
|
|
||||||
bne :+
|
|
||||||
inc cnt+1
|
|
||||||
|
|
||||||
; 8 retries
|
; 8 retries
|
||||||
: ldy #$08
|
ldy #$08
|
||||||
|
|
||||||
; Check for avaliable buffer space
|
; Check for avaliable buffer space
|
||||||
; PACKETPP = $0138, PPDATA & $0100 ?
|
; PACKETPP = $0138, PPDATA & $0100 ?
|
||||||
: lda #$38
|
: lda #$38
|
||||||
ldx #$01
|
jsr packetpp_01
|
||||||
fixup40:sta packetpp
|
fixup20:lda ppdata+1
|
||||||
fixup41:stx packetpp+1
|
|
||||||
fixup42:lda ppdata+1
|
|
||||||
and #$01
|
and #$01
|
||||||
bne :+
|
bne :+
|
||||||
|
|
||||||
; No space avaliable, skip a received frame
|
; No space avaliable, skip a received frame
|
||||||
; PACKETPP = $0102, PPDATA = PPDATA | $0040
|
jsr skipframe
|
||||||
lda #$02
|
|
||||||
ldx #$01
|
|
||||||
fixup43:sta packetpp
|
|
||||||
fixup44:stx packetpp+1
|
|
||||||
fixup45:lda ppdata
|
|
||||||
ora #$40
|
|
||||||
fixup46:sta ppdata
|
|
||||||
|
|
||||||
; And try again
|
; And try again
|
||||||
dey
|
dey
|
||||||
@ -340,24 +283,17 @@ fixup46:sta ppdata
|
|||||||
; --------------
|
; --------------
|
||||||
|
|
||||||
; Write bytes from buffer
|
; Write bytes from buffer
|
||||||
: lda bufaddr
|
: jsr adjustptr
|
||||||
ldx bufaddr+1
|
: lda (ptr),y
|
||||||
sta ptr
|
fixup21:sta rxtxreg
|
||||||
stx ptr+1
|
|
||||||
ldx cnt+1
|
|
||||||
ldy #$00
|
|
||||||
write: lda (ptr),y
|
|
||||||
fixup47:sta rxtxreg
|
|
||||||
iny
|
iny
|
||||||
lda (ptr),y
|
lda (ptr),y
|
||||||
fixup48:sta rxtxreg+1
|
fixup22:sta rxtxreg+1
|
||||||
iny
|
iny
|
||||||
bne :+
|
bne :-
|
||||||
inc ptr+1
|
inc ptr+1
|
||||||
: cpy cnt
|
|
||||||
bne write
|
|
||||||
dex
|
dex
|
||||||
bpl write
|
bpl :-
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
@ -366,3 +302,50 @@ exit:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
|
packetpp_01:
|
||||||
|
ldx #$01
|
||||||
|
fixup23:sta packetpp
|
||||||
|
fixup24:stx packetpp+1
|
||||||
|
rts
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
|
skipframe:
|
||||||
|
; PACKETPP = $0102, PPDATA = PPDATA | $0040
|
||||||
|
lda #$02
|
||||||
|
jsr packetpp_01
|
||||||
|
fixup25:lda ppdata
|
||||||
|
ora #$40
|
||||||
|
fixup26:sta ppdata
|
||||||
|
rts
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
|
adjustcnt:
|
||||||
|
lsr
|
||||||
|
bcc :+
|
||||||
|
inc cnt
|
||||||
|
bne :+
|
||||||
|
inc cnt+1
|
||||||
|
: rts
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
|
adjustptr:
|
||||||
|
lda cnt
|
||||||
|
eor #$FF ; Two's complement part 1
|
||||||
|
tay
|
||||||
|
iny ; Two's complement part 2
|
||||||
|
sty reg
|
||||||
|
sec
|
||||||
|
lda bufaddr
|
||||||
|
sbc reg
|
||||||
|
sta ptr
|
||||||
|
lda bufaddr+1
|
||||||
|
sbc #$00
|
||||||
|
sta ptr+1
|
||||||
|
ldx cnt+1
|
||||||
|
rts
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
@ -78,8 +78,7 @@ fixup: .byte fixup02-fixup01, fixup03-fixup02, fixup04-fixup03
|
|||||||
.byte fixup29-fixup28, fixup30-fixup29, fixup31-fixup30
|
.byte fixup29-fixup28, fixup30-fixup29, fixup31-fixup30
|
||||||
.byte fixup32-fixup31, fixup33-fixup32, fixup34-fixup33
|
.byte fixup32-fixup31, fixup33-fixup32, fixup34-fixup33
|
||||||
.byte fixup35-fixup34, fixup36-fixup35, fixup37-fixup36
|
.byte fixup35-fixup34, fixup36-fixup35, fixup37-fixup36
|
||||||
.byte fixup38-fixup37, fixup39-fixup38, fixup40-fixup39
|
.byte fixup38-fixup37
|
||||||
.byte fixup41-fixup40, fixup42-fixup41
|
|
||||||
|
|
||||||
fixups = * - fixup
|
fixups = * - fixup
|
||||||
|
|
||||||
@ -160,14 +159,14 @@ init:
|
|||||||
|
|
||||||
; Reset ETH card
|
; Reset ETH card
|
||||||
: lda #$00 ; Bank 0
|
: lda #$00 ; Bank 0
|
||||||
fixup00:sta ethbsr
|
fixup01:sta ethbsr
|
||||||
|
|
||||||
lda #%10000000 ; Software reset
|
lda #%10000000 ; Software reset
|
||||||
fixup01:sta ethrcr+1
|
fixup02:sta ethrcr+1
|
||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
fixup02:sty ethrcr
|
fixup03:sty ethrcr
|
||||||
fixup03:sty ethrcr+1
|
fixup04:sty ethrcr+1
|
||||||
|
|
||||||
; Delay
|
; Delay
|
||||||
: cmp ($FF,x) ; 6 cycles
|
: cmp ($FF,x) ; 6 cycles
|
||||||
@ -179,45 +178,39 @@ fixup03:sty ethrcr+1
|
|||||||
; Enable transmit and receive
|
; Enable transmit and receive
|
||||||
lda #%10000001 ; Enable transmit TXENA, PAD_EN
|
lda #%10000001 ; Enable transmit TXENA, PAD_EN
|
||||||
ldx #%00000011 ; Enable receive, strip CRC ???
|
ldx #%00000011 ; Enable receive, strip CRC ???
|
||||||
fixup04:sta ethtcr
|
fixup05:sta ethtcr
|
||||||
fixup05:stx ethrcr+1
|
fixup06:stx ethrcr+1
|
||||||
|
|
||||||
lda #$01 ; Bank 1
|
lda #$01 ; Bank 1
|
||||||
fixup06:sta ethbsr
|
fixup07:sta ethbsr
|
||||||
|
|
||||||
fixup07:lda ethcr+1
|
fixup08:lda ethcr+1
|
||||||
ora #%00010000 ; No wait (IOCHRDY)
|
ora #%00010000 ; No wait (IOCHRDY)
|
||||||
fixup08:sta ethcr+1
|
fixup09:sta ethcr+1
|
||||||
|
|
||||||
lda #%00001001 ; Auto release
|
lda #%00001001 ; Auto release
|
||||||
fixup09:sta ethctr+1
|
fixup10:sta ethctr+1
|
||||||
|
|
||||||
; Set MAC address
|
; Set MAC address
|
||||||
lda mac
|
ldy #$00
|
||||||
ldx mac+1
|
: lda mac,y
|
||||||
fixup10:sta ethiar
|
fixup11:sta ethiar,y
|
||||||
fixup11:stx ethiar+1
|
iny
|
||||||
lda mac+2
|
cpy #$06
|
||||||
ldx mac+3
|
bcc :-
|
||||||
fixup12:sta ethiar+2
|
|
||||||
fixup13:stx ethiar+3
|
|
||||||
lda mac+4
|
|
||||||
ldx mac+5
|
|
||||||
fixup14:sta ethiar+4
|
|
||||||
fixup15:stx ethiar+5
|
|
||||||
|
|
||||||
; Set interrupt mask
|
; Set interrupt mask
|
||||||
lda #$02 ; Bank 2
|
lda #$02 ; Bank 2
|
||||||
fixup16:sta ethbsr
|
fixup12:sta ethbsr
|
||||||
|
|
||||||
lda #%00000000 ; No interrupts
|
lda #%00000000 ; No interrupts
|
||||||
fixup17:sta ethmsk
|
fixup13:sta ethmsk
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
poll:
|
poll:
|
||||||
fixup18:lda ethist
|
fixup14:lda ethist
|
||||||
and #%00000001 ; RCV INT
|
and #%00000001 ; RCV INT
|
||||||
bne :+
|
bne :+
|
||||||
|
|
||||||
@ -230,12 +223,12 @@ fixup18:lda ethist
|
|||||||
|
|
||||||
: lda #$00
|
: lda #$00
|
||||||
ldx #%11100000 ; RCV, AUTO INCR., READ
|
ldx #%11100000 ; RCV, AUTO INCR., READ
|
||||||
fixup19:sta ethptr
|
fixup15:sta ethptr
|
||||||
fixup20:stx ethptr+1
|
fixup16:stx ethptr+1
|
||||||
|
|
||||||
; Last word contains 'last data byte' and $60 or 'fill byte' and $40
|
; Last word contains 'last data byte' and $60 or 'fill byte' and $40
|
||||||
fixup21:lda ethdata ; Status word
|
fixup17:lda ethdata ; Status word
|
||||||
fixup22:lda ethdata ; Need high byte only
|
fixup18:lda ethdata ; Need high byte only
|
||||||
|
|
||||||
; Move ODDFRM bit into carry:
|
; Move ODDFRM bit into carry:
|
||||||
; - Even packet length -> carry clear -> subtract 6 bytes
|
; - Even packet length -> carry clear -> subtract 6 bytes
|
||||||
@ -247,10 +240,10 @@ fixup22:lda ethdata ; Need high byte only
|
|||||||
lsr
|
lsr
|
||||||
|
|
||||||
; The packet contains 3 extra words
|
; The packet contains 3 extra words
|
||||||
fixup23:lda ethdata ; Total number of bytes
|
fixup19:lda ethdata ; Total number of bytes
|
||||||
sbc #$05 ; Actually 5 or 6 depending on carry
|
sbc #$05 ; Actually 5 or 6 depending on carry
|
||||||
sta len
|
sta len
|
||||||
fixup24:lda ethdata
|
fixup20:lda ethdata
|
||||||
sbc #$00
|
sbc #$00
|
||||||
sta len+1
|
sta len+1
|
||||||
|
|
||||||
@ -265,7 +258,7 @@ fixup24:lda ethdata
|
|||||||
; Yes, skip packet
|
; Yes, skip packet
|
||||||
; Remove and release RX packet from the FIFO
|
; Remove and release RX packet from the FIFO
|
||||||
lda #%10000000
|
lda #%10000000
|
||||||
fixup25:sta ethmmucr
|
fixup21:sta ethmmucr
|
||||||
|
|
||||||
; No packet available
|
; No packet available
|
||||||
lda #$00
|
lda #$00
|
||||||
@ -273,26 +266,19 @@ fixup25:sta ethmmucr
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
; Read bytes into buffer
|
; Read bytes into buffer
|
||||||
: lda bufaddr
|
: jsr adjustptr
|
||||||
ldx bufaddr+1
|
:
|
||||||
sta ptr
|
fixup22:lda ethdata
|
||||||
stx ptr+1
|
|
||||||
ldx len+1
|
|
||||||
ldy #$00
|
|
||||||
read:
|
|
||||||
fixup26:lda ethdata
|
|
||||||
sta (ptr),y
|
sta (ptr),y
|
||||||
iny
|
iny
|
||||||
bne :+
|
bne :-
|
||||||
inc ptr+1
|
inc ptr+1
|
||||||
: cpy len
|
|
||||||
bne read
|
|
||||||
dex
|
dex
|
||||||
bpl read
|
bpl :-
|
||||||
|
|
||||||
; Remove and release RX packet from the FIFO
|
; Remove and release RX packet from the FIFO
|
||||||
lda #%10000000
|
lda #%10000000
|
||||||
fixup27:sta ethmmucr
|
fixup23:sta ethmmucr
|
||||||
|
|
||||||
; Return packet length
|
; Return packet length
|
||||||
lda len
|
lda len
|
||||||
@ -309,14 +295,14 @@ send:
|
|||||||
; Allocate memory for TX
|
; Allocate memory for TX
|
||||||
txa
|
txa
|
||||||
ora #%00100000
|
ora #%00100000
|
||||||
fixup28:sta ethmmucr
|
fixup24:sta ethmmucr
|
||||||
|
|
||||||
; 8 retries
|
; 8 retries
|
||||||
ldy #$08
|
ldy #$08
|
||||||
|
|
||||||
; Wait for allocation ready
|
; Wait for allocation ready
|
||||||
:
|
:
|
||||||
fixup29:lda ethist
|
fixup25:lda ethist
|
||||||
and #%00001000 ; ALLOC INT
|
and #%00001000 ; ALLOC INT
|
||||||
bne :+
|
bne :+
|
||||||
|
|
||||||
@ -330,21 +316,21 @@ fixup29:lda ethist
|
|||||||
|
|
||||||
; Acknowledge interrupt, is it necessary ???
|
; Acknowledge interrupt, is it necessary ???
|
||||||
: lda #%00001000
|
: lda #%00001000
|
||||||
fixup30:sta ethack
|
fixup26:sta ethack
|
||||||
|
|
||||||
; Set packet address
|
; Set packet address
|
||||||
fixup31:lda etharr
|
fixup27:lda etharr
|
||||||
fixup32:sta ethpnr
|
fixup28:sta ethpnr
|
||||||
|
|
||||||
lda #$00
|
lda #$00
|
||||||
ldx #%01000000 ; AUTO INCR.
|
ldx #%01000000 ; AUTO INCR.
|
||||||
fixup33:sta ethptr
|
fixup29:sta ethptr
|
||||||
fixup34:stx ethptr+1
|
fixup30:stx ethptr+1
|
||||||
|
|
||||||
; Status written by CSMA
|
; Status written by CSMA
|
||||||
lda #$00
|
lda #$00
|
||||||
fixup35:sta ethdata
|
fixup31:sta ethdata
|
||||||
fixup36:sta ethdata
|
fixup32:sta ethdata
|
||||||
|
|
||||||
; Check packet length parity:
|
; Check packet length parity:
|
||||||
; - Even packet length -> carry set -> add 6 bytes
|
; - Even packet length -> carry set -> add 6 bytes
|
||||||
@ -356,30 +342,23 @@ fixup36:sta ethdata
|
|||||||
; The packet contains 3 extra words
|
; The packet contains 3 extra words
|
||||||
lda len
|
lda len
|
||||||
adc #$05 ; Actually 5 or 6 depending on carry
|
adc #$05 ; Actually 5 or 6 depending on carry
|
||||||
fixup37:sta ethdata
|
fixup33:sta ethdata
|
||||||
lda len+1
|
lda len+1
|
||||||
adc #$00
|
adc #$00
|
||||||
fixup38:sta ethdata
|
fixup34:sta ethdata
|
||||||
|
|
||||||
; Send the packet
|
; Send the packet
|
||||||
; ---------------
|
; ---------------
|
||||||
|
|
||||||
; Write bytes from buffer
|
; Write bytes from buffer
|
||||||
lda bufaddr
|
jsr adjustptr
|
||||||
ldx bufaddr+1
|
: lda (ptr),y
|
||||||
sta ptr
|
fixup35:sta ethdata
|
||||||
stx ptr+1
|
|
||||||
ldx len+1
|
|
||||||
ldy #$00
|
|
||||||
write: lda (ptr),y
|
|
||||||
fixup39:sta ethdata
|
|
||||||
iny
|
iny
|
||||||
bne :+
|
bne :-
|
||||||
inc ptr+1
|
inc ptr+1
|
||||||
: cpy len
|
|
||||||
bne write
|
|
||||||
dex
|
dex
|
||||||
bpl write
|
bpl :-
|
||||||
|
|
||||||
; Odd packet length ?
|
; Odd packet length ?
|
||||||
lda len
|
lda len
|
||||||
@ -392,13 +371,13 @@ fixup39:sta ethdata
|
|||||||
|
|
||||||
; No
|
; No
|
||||||
: lda #$00
|
: lda #$00
|
||||||
fixup40:sta ethdata ; Fill byte
|
fixup36:sta ethdata ; Fill byte
|
||||||
:
|
:
|
||||||
fixup41:sta ethdata ; Control byte
|
fixup37:sta ethdata ; Control byte
|
||||||
|
|
||||||
; Add packet to FIFO
|
; Add packet to FIFO
|
||||||
lda #%11000000 ; ENQUEUE PACKET - transmit packet
|
lda #%11000000 ; ENQUEUE PACKET - transmit packet
|
||||||
fixup42:sta ethmmucr
|
fixup38:sta ethmmucr
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
@ -407,3 +386,21 @@ exit:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
;---------------------------------------------------------------------
|
;---------------------------------------------------------------------
|
||||||
|
|
||||||
|
adjustptr:
|
||||||
|
lda len
|
||||||
|
eor #$FF ; Two's complement part 1
|
||||||
|
tay
|
||||||
|
iny ; Two's complement part 2
|
||||||
|
sty reg
|
||||||
|
sec
|
||||||
|
lda bufaddr
|
||||||
|
sbc reg
|
||||||
|
sta ptr
|
||||||
|
lda bufaddr+1
|
||||||
|
sbc #$00
|
||||||
|
sta ptr+1
|
||||||
|
ldx len+1
|
||||||
|
rts
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user