Introduced IP65 "combo" libraries.

Up to now every IP65 library contained exactly one Ethernet driver. In scenarios without strict memory limitations I might however be benefitial to have an IP65 library containing all Ethernet drivers available for a given target.

The Ethernet hardware detection that was already present before is used in this scenario to try to initialize one Ethernet driver after the other until one succeeds. If all drivers fail to initialize the user gets informed as usual.

The WIZ811MJ driver was primarily introduced for orthogonality reasons. There are however at least two W5100-based prototypes for the C64 so it makes at least some sense. The name was chosen as sort of placeholder for "something containing a W5100 chip".
This commit is contained in:
Oliver Schmidt 2015-07-07 19:43:32 +02:00
parent 190edaeba0
commit 8279ef4d63
16 changed files with 423 additions and 65 deletions

View File

@ -1,16 +1,22 @@
# c64rrnet.lib : C64 with RR-Net or clone (default base addr: $de0x)
# c64rrnet.lib : C64 with RR-Net (or clone) (default base addr: $de0x)
# c64eth64.lib : C64 with ETH64 (default base addr: $de0x)
# c64wiz811.lib : C64 with WIZ811MJ (default base addr: $de0x)
# c64combo.lib : C64 with RR-Net or ETH64 or WIZ811MJ (default base addr: $de0x)
# a2uther.lib : Apple ][ with Uthernet (default slot: #3)
# a2lancegs.lib : Apple ][ with LANceGS (default slot: #3)
# a2uther2.lib : Apple ][ with Uthernet II (default slot: #3)
# a2combo.lib : Apple ][ with Uthernet or LANceGS or Uthernet II (default slot: #3)
# vic20rrnet.lib : VIC20 with RR-Net or clone (default base addr: $980x)
DRIVERS=\
c64rrnet.lib \
c64eth64.lib \
c64wiz811.lib \
c64combo.lib \
a2uther.lib \
a2lancegs.lib \
a2uther2.lib \
a2combo.lib \
vic20rrnet.lib
all: $(DRIVERS)
@ -19,7 +25,6 @@ all: $(DRIVERS)
ca65 -D DYN_DRV=0 $<
C64OBJS=\
contiki.o \
c64print.o \
c64timer.o \
c64kernal.o \
@ -28,7 +33,6 @@ C64OBJS=\
cbmcharconv.o
A2OBJS=\
contiki.o \
a2print.o \
a2timer.o \
a2kernal.o \
@ -37,7 +41,6 @@ A2OBJS=\
a2charconv.o
VIC20OBJS=\
contiki.o \
vic20print.o \
vic20timer.o \
vic20kernal.o \
@ -45,22 +48,31 @@ VIC20OBJS=\
vic20filteredinput.o \
cbmcharconv.o
c64rrnet.lib: rr-net.o cs8900a.o $(C64OBJS)
c64rrnet.lib: rr-net.o cs8900a.o cs8900adriver.o ethernet.o $(C64OBJS)
ar65 a $@ $^
c64eth64.lib: eth64.o lan91c96.o $(C64OBJS)
c64eth64.lib: eth64.o lan91c96.o lan91c96driver.o ethernet.o $(C64OBJS)
ar65 a $@ $^
a2uther.lib: uthernet.o cs8900a.o $(A2OBJS)
c64wiz811.lib: wiz811mj.o w5100.o w5100driver.o ethernet.o $(C64OBJS)
ar65 a $@ $^
a2lancegs.lib: lancegs.o lan91c96.o $(A2OBJS)
c64combo.lib: rr-net.o cs8900a.o eth64.o lan91c96.o wiz811mj.o w5100.o ethernetcombo.o $(C64OBJS)
ar65 a $@ $^
a2uther2.lib: uthernet2.o w5100.o $(A2OBJS)
a2uther.lib: uthernet.o cs8900a.o cs8900adriver.o ethernet.o $(A2OBJS)
ar65 a $@ $^
vic20rrnet.lib: vic20-rr-net.o cs8900a.o $(VIC20OBJS)
a2lancegs.lib: lancegs.o lan91c96.o lan91c96driver.o ethernet.o $(A2OBJS)
ar65 a $@ $^
a2uther2.lib: uthernet2.o w5100.o w5100driver.o ethernet.o $(A2OBJS)
ar65 a $@ $^
a2combo.lib: uthernet.o cs8900a.o lancegs.o lan91c96.o uthernet2.o w5100.o ethernetcombo.o $(A2OBJS)
ar65 a $@ $^
vic20rrnet.lib: vic20-rr-net.o cs8900a.o cs8900adriver.o ethernet.o $(VIC20OBJS)
ar65 a $@ $^
clean:

30
drivers/cs8900adriver.s Normal file
View File

@ -0,0 +1,30 @@
; Cirrus Logic CS8900A driver
.import _cs8900a
.import _cs8900a_driver_name
.import _cs8900a_driver_io_base
.export eth = _cs8900a
.export eth_driver_name = _cs8900a_driver_name
.export eth_driver_io_base = _cs8900a_driver_io_base
; -- LICENSE FOR cs8900adriver.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

View File

@ -1,21 +1,18 @@
; ETH64 driver
.import _lan91c96
.export eth = _lan91c96
.export eth_driver_name
.export eth_driver_io_base
.export _lan91c96_driver_name
.export _lan91c96_driver_io_base
.rodata
eth_driver_name:
_lan91c96_driver_name:
.byte "ETH64",0
.data
eth_driver_io_base:
_lan91c96_driver_io_base:
.word $de00

View File

@ -1,4 +1,4 @@
; Contiki driver wrapper
; Wrapper for Contiki ethernet driver
.include "../inc/common.i"
@ -11,12 +11,11 @@
.import eth_outp
.import eth_outp_len
.import eth
.import eth_driver_io_base
.import cfg_mac
.import eth
.struct driver
drvtype .byte 3
apiver .byte
@ -36,8 +35,6 @@
; inputs: none
; outputs: carry flag is set if there was an error, clear otherwise
eth_init:
ldax #1518
stax eth+driver::bufsize
ldax eth_driver_io_base
jsr eth+driver::init
ldx #5
@ -45,6 +42,8 @@ eth_init:
sta cfg_mac,x
dex
bpl :-
ldax #1518
stax eth+driver::bufsize
rts
; receive a packet
@ -76,7 +75,7 @@ eth_tx:
; -- LICENSE FOR contiki.s --
; -- LICENSE FOR ethernet.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at

233
drivers/ethernetcombo.s Normal file
View File

@ -0,0 +1,233 @@
; Wrapper for combination of Contiki ethernet drivers
.include "zeropage.inc"
.include "../inc/common.i"
.export eth_init
.export eth_rx
.export eth_tx
.export eth_driver_name
.export eth_driver_io_base
.import eth_inp
.import eth_inp_len
.import eth_outp
.import eth_outp_len
.import _cs8900a
.import _cs8900a_driver_name
.import _cs8900a_driver_io_base
.import _lan91c96
.import _lan91c96_driver_name
.import _lan91c96_driver_io_base
.import _w5100
.import _w5100_driver_name
.import _w5100_driver_io_base
.import cfg_mac
.struct driver
drvtype .byte 3
apiver .byte
mac .byte 6
bufaddr .addr
bufsize .word
init .byte 3
poll .byte 3
send .byte 3
exit .byte 3
.endstruct
eth = ptr1
.bss
eth_driver_name: .res 20
eth_driver_io_base: .res 2
.code
; computes pointer to ethernet driver struct member
; inputs:
; eth: pointer to Contiki ethernet driver
; A: offset of driver struct member
; outputs:
; AX: pointer to ethernet driver struct member
add_driver_offset:
clc
adc eth
ldx eth+1
bcc :+
inx
: rts
; increment AX by one
; inputs:
; AX: value to increment
; outputs:
; AX: incremented value
incr_ax:
clc
adc #1
bcc :+
inx
: rts
; patches Contiki ethernet driver into wrapper code
; inputs:
; AX: pointer to Contiki ethernet driver
; outputs:
; none
patch_wrapper:
stax eth
lda #driver::mac
jsr add_driver_offset
stax patch_mac+1
lda #driver::bufaddr
jsr add_driver_offset
stax patch_bufaddr_rx+1
stax patch_bufaddr_tx+1
jsr incr_ax
stax patch_bufaddr_rx+4
stax patch_bufaddr_tx+4
lda #driver::bufsize
jsr add_driver_offset
stax patch_bufsize+1
jsr incr_ax
stax patch_bufsize+4
lda #driver::init
jsr add_driver_offset
stax patch_init+1
lda #driver::poll
jsr add_driver_offset
stax patch_poll+1
lda #driver::send
jsr add_driver_offset
stax patch_send+1
rts
; set ethernet driver name
; inputs:
; AX: pointer to name
; outputs:
; none
set_name:
stax ptr1
ldy #18 ; sizeof(eth_driver_name)-2
: lda (ptr1),y
sta eth_driver_name,y
dey
bpl :-
rts
; initialize one of the known ethernet adaptors
; inputs: none
; outputs: carry flag is set if there was an error, clear otherwise
eth_init:
ldax #_cs8900a
jsr patch_wrapper
ldax #_cs8900a_driver_name
jsr set_name
ldax _cs8900a_driver_io_base
jsr init_adaptor
bcc @done
ldax #_lan91c96
jsr patch_wrapper
ldax #_lan91c96_driver_name
jsr set_name
ldax _lan91c96_driver_io_base
jsr init_adaptor
bcc @done
ldax #_w5100
jsr patch_wrapper
ldax #_w5100_driver_name
jsr set_name
ldax _w5100_driver_io_base
jsr init_adaptor
@done:
rts
.data
; initialize the ethernet adaptor
; inputs: ethernet adaptor i/o base addr
; outputs: carry flag is set if there was an error, clear otherwise
init_adaptor:
stax eth_driver_io_base
patch_init:
jsr $ffff ; temporary vector - gets filled in later
ldx #5
patch_mac:
: lda $ffff,x ; temporary addr - gets filled in later
sta cfg_mac,x
dex
bpl :-
ldax #1518
patch_bufsize:
stax $fffe ; temporary addr - gets filled in later
rts
; receive a packet
; inputs: none
; outputs:
; if there was an error receiving the packet (or no packet was ready) then carry flag is set
; if packet was received correctly then carry flag is clear,
; eth_inp contains the received packet,
; and eth_inp_len contains the length of the packet
eth_rx:
ldax #eth_inp
patch_bufaddr_rx:
stax $fffe ; temporary addr - gets filled in later
patch_poll:
jsr $ffff ; temporary vector - gets filled in later
stax eth_inp_len
rts
; send a packet
; inputs:
; eth_outp: packet to send
; eth_outp_len: length of packet to send
; outputs:
; if there was an error sending the packet then carry flag is set
; otherwise carry flag is cleared
eth_tx:
ldax #eth_outp
patch_bufaddr_tx:
stax $fffe ; temporary addr - gets filled in later
ldax eth_outp_len
patch_send:
jmp $ffff ; temporary vector - gets filled in later
; -- LICENSE FOR ethernetcombo.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

30
drivers/lan91c96driver.s Normal file
View File

@ -0,0 +1,30 @@
; Standard Microsystems LAN91C96 driver
.import _lan91c96
.import _lan91c96_driver_name
.import _lan91c96_driver_io_base
.export eth = _lan91c96
.export eth_driver_name = _lan91c96_driver_name
.export eth_driver_io_base = _lan91c96_driver_io_base
; -- LICENSE FOR lan91c96driver.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

View File

@ -1,21 +1,18 @@
; LANceGS driver
.import _lan91c96
.export eth = _lan91c96
.export eth_driver_name
.export eth_driver_io_base
.export _lan91c96_driver_name
.export _lan91c96_driver_io_base
.rodata
eth_driver_name:
_lan91c96_driver_name:
.byte "LANceGS",0
.data
eth_driver_io_base:
_lan91c96_driver_io_base:
.word $c0b0

View File

@ -1,21 +1,18 @@
; RR-Net driver
.import _cs8900a
.export eth = _cs8900a
.export eth_driver_name
.export eth_driver_io_base
.export _cs8900a_driver_name
.export _cs8900a_driver_io_base
.rodata
eth_driver_name:
_cs8900a_driver_name:
.byte "RR-Net",0
.data
eth_driver_io_base:
_cs8900a_driver_io_base:
.word $de08

View File

@ -1,21 +1,18 @@
; Uthernet driver
.import _cs8900a
.export eth = _cs8900a
.export eth_driver_name
.export eth_driver_io_base
.export _cs8900a_driver_name
.export _cs8900a_driver_io_base
.rodata
eth_driver_name:
_cs8900a_driver_name:
.byte "Uthernet",0
.data
eth_driver_io_base:
_cs8900a_driver_io_base:
.word $c0b0

View File

@ -1,21 +1,18 @@
; Uthernet II driver
.import _w5100
.export eth = _w5100
.export eth_driver_name
.export eth_driver_io_base
.export _w5100_driver_name
.export _w5100_driver_io_base
.rodata
eth_driver_name:
_w5100_driver_name:
.byte "Uthernet II",0
.data
eth_driver_io_base:
_w5100_driver_io_base:
.word $c0b4

View File

@ -1,21 +1,18 @@
; RR-Net driver, as seen on a VIC-20 (i.e. using a Masquerade adapter)
.import _cs8900a
.export eth = _cs8900a
.export eth_driver_name
.export eth_driver_io_base
.export _cs8900a_driver_name
.export _cs8900a_driver_io_base
.rodata
eth_driver_name:
_cs8900a_driver_name:
.asciiz "VIC20 RR-Net"
.data
eth_driver_io_base:
_cs8900a_driver_io_base:
.word $9808

30
drivers/w5100driver.s Normal file
View File

@ -0,0 +1,30 @@
; WIZnet W5100 driver
.import _w5100
.import _w5100_driver_name
.import _w5100_driver_io_base
.export eth = _w5100
.export eth_driver_name = _w5100_driver_name
.export eth_driver_io_base = _w5100_driver_io_base
; -- LICENSE FOR w5100driver.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

37
drivers/wiz811mj.s Normal file
View File

@ -0,0 +1,37 @@
; WIZ811MJ driver
.export _w5100_driver_name
.export _w5100_driver_io_base
.rodata
_w5100_driver_name:
.byte "WIZ811MJ",0
.data
_w5100_driver_io_base:
.word $de00
; -- LICENSE FOR wiz811mj.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

View File

@ -14,8 +14,10 @@
.import cfg_get_configuration_ptr
.macro init_ip_via_dhcp
print_driver_init
jsr ip65_init
php
print_driver_init
plp
bcc :+
print_failed
sec

View File

@ -1,5 +1,5 @@
# Build for Cirrus Logic CS8900A based devices:
# make
# make eth=cl
# Build for Standard Microsystems LAN91C96 based devices:
# make eth=sm
@ -7,16 +7,20 @@
# Build for WIZnet W5100 based devices:
# make eth=wn
ifeq ($(eth),sm)
ifeq ($(eth),cl)
C64DRIVERLIB = ../drivers/c64rrnet.lib
A2DRIVERLIB = ../drivers/a2uther.lib
else ifeq ($(eth),sm)
C64DRIVERLIB = ../drivers/c64eth64.lib
A2DRIVERLIB = ../drivers/a2lancegs.lib
else ifeq ($(eth),wn)
C64DRIVERLIB = ../drivers/c64wiz811.lib
A2DRIVERLIB = ../drivers/a2uther2.lib
else
C64DRIVERLIB = ../drivers/c64rrnet.lib
A2DRIVERLIB = ../drivers/a2uther.lib
VICDRIVERLIB = ../drivers/vic20rrnet.lib
C64DRIVERLIB = ../drivers/c64combo.lib
A2DRIVERLIB = ../drivers/a2combo.lib
endif
VICDRIVERLIB = ../drivers/vic20rrnet.lib
UDP =\
dns \

View File

@ -22,7 +22,6 @@
jsr print_a
jsr print_cr
jsr print_ip_config
init_ip_via_dhcp
; jsr overwrite_with_hardcoded_dns_server
jsr print_ip_config