diff --git a/apps/date65.c b/apps/date65.c index 56ec720..d99433e 100644 --- a/apps/date65.c +++ b/apps/date65.c @@ -50,7 +50,7 @@ void confirm_exit(void) void main(void) { - uint8_t drv_init = DRV_INIT_DEFAULT; + uint8_t eth_init = ETH_INIT_DEFAULT; uint32_t server; struct timespec time; @@ -71,16 +71,16 @@ void main(void) file = open("ethernet.slot", O_RDONLY); if (file != -1) { - read(file, &drv_init, 1); + read(file, ð_init, 1); close(file); - drv_init &= ~'0'; + eth_init &= ~'0'; } - printf("- %d\n", drv_init); + printf("- %d\n", eth_init); } #endif printf("\nInitializing "); - if (ip65_init(drv_init)) + if (ip65_init(eth_init)) { error_exit(); } diff --git a/apps/hfs65.c b/apps/hfs65.c index 2371451..34f1381 100644 --- a/apps/hfs65.c +++ b/apps/hfs65.c @@ -301,7 +301,7 @@ void error_exit(void) void main(void) { char cwd[FILENAME_MAX]; - unsigned char drv_init = DRV_INIT_DEFAULT; + unsigned char eth_init = ETH_INIT_DEFAULT; getcwd(cwd, sizeof(cwd)); @@ -320,16 +320,16 @@ void main(void) file = open("ethernet.slot", O_RDONLY); if (file != -1) { - read(file, &drv_init, 1); + read(file, ð_init, 1); close(file); - drv_init &= ~'0'; + eth_init &= ~'0'; } - printf("- %d", drv_init); + printf("- %d", eth_init); } #endif printf("\n\nInitializing "); - if (ip65_init(drv_init)) + if (ip65_init(eth_init)) { error_exit(); } diff --git a/apps/telnet65.s b/apps/telnet65.s index b140acd..cb5a189 100644 --- a/apps/telnet65.s +++ b/apps/telnet65.s @@ -10,8 +10,7 @@ .import abort_key .importzp abort_key_default .importzp abort_key_disable -.import drv_init -.importzp drv_init_default +.importzp eth_init_default .import get_filtered_input .import get_key .import get_key_if_available @@ -58,8 +57,8 @@ buffer_ptr = sreg .segment "STARTUP" jmp start -drv_init_value: - .byte drv_init_default +eth_init_value: + .byte eth_init_default .code @@ -74,23 +73,15 @@ start: jsr print_vt100 ldax #initializing jsr print_ascii_as_native - lda drv_init_value - jsr drv_init + lda eth_init_value jsr ip65_init bcc :+ ldax #device_not_found jsr print_ascii_as_native jmp error_exit -: ldax #eth_driver_name - jsr print_ascii_as_native - ldax #io_base_prefix - jsr print_ascii_as_native - lda eth_driver_io_base+1 - jsr print_hex - lda eth_driver_io_base - jsr print_hex - ldax #io_base_postfix +: ldax #eth_name jsr print_ascii_as_native + jsr print_cr ; get IP addr ldax #obtaining @@ -507,8 +498,6 @@ initializing: .byte 10,"Initializing ",0 obtaining: .byte "Obtaining IP address ",0 resolving: .byte 10,"Resolving to address ",0 connecting: .byte 10,"Connecting to ",0 -io_base_prefix: .byte " ($",0 -io_base_postfix: .byte ")",10,0 ok: .byte "Ok",10,10,0 device_not_found: .byte "- Device not found",10,0 abort: .byte "- User abort",10,0 @@ -524,13 +513,13 @@ welcome_1: .byte 27,")0" .byte 15,13,10 .byte 14,"x x" .byte 15,13,10 - .byte 14,"x",15,27,"[1m","Telnet65 v1.2",27,"[0m"," based on: ",14,"x" + .byte 14,"x",15," ",27,"[1m","Telnet65 v1.2",27,"[0m"," based on: ",14,"x" .byte 15,13,10 .byte 14,"x x" .byte 15,13,10,0 -welcome_2: .byte 14,"x",15,"- IP65 (oliverschmidt.github.io/ip65) ",14,"x" +welcome_2: .byte 14,"x",15," - IP65 (github.com/cc65/ip65) ",14,"x" .byte 15,13,10 - .byte 14,"x",15,"- CaTer (www.opppf.de/Cater) ",14,"x" + .byte 14,"x",15," - CaTer (www.opppf.de/Cater) ",14,"x" .byte 15,13,10 .byte 14,"x x" .byte 15,13,10 diff --git a/apps/tweet65.c b/apps/tweet65.c index b8f91b9..40d55d3 100644 --- a/apps/tweet65.c +++ b/apps/tweet65.c @@ -114,7 +114,7 @@ void input(char* str, unsigned int max, const char* tag) void main() { int retval; - uint8_t drv_init = DRV_INIT_DEFAULT; + uint8_t eth_init = ETH_INIT_DEFAULT; if (doesclrscrafterexit()) { @@ -169,16 +169,16 @@ void main() file = open("ethernet.slot", O_RDONLY); if (file != -1) { - read(file, &drv_init, 1); + read(file, ð_init, 1); close(file); - drv_init &= ~'0'; + eth_init &= ~'0'; } - printf("- %d\n", drv_init); + printf("- %d\n", eth_init); } #endif printf("\nInitializing "); - if (ip65_init(drv_init)) + if (ip65_init(eth_init)) { error_exit(); } diff --git a/apps/w5100.c b/apps/w5100.c index bc18b40..1c9afa6 100644 --- a/apps/w5100.c +++ b/apps/w5100.c @@ -114,12 +114,12 @@ static void set_quad(uint16_t addr, uint32_t data) } } -void w5100_config(void) +void w5100_config(uint8_t eth_init) { - w5100_mode = eth_driver_io_base; - w5100_addr_hi = eth_driver_io_base + 1; - w5100_addr_lo = eth_driver_io_base + 2; - w5100_data = eth_driver_io_base + 3; + w5100_mode = (uint8_t*)(eth_init << 4 | 0xC084); + w5100_addr_hi = w5100_mode + 1; + w5100_addr_lo = w5100_mode + 2; + w5100_data = w5100_mode + 3; // Source IP Address Register set_quad(0x000F, cfg_ip); diff --git a/apps/w5100.h b/apps/w5100.h index 6f59692..71466d8 100644 --- a/apps/w5100.h +++ b/apps/w5100.h @@ -48,7 +48,7 @@ extern volatile uint8_t* w5100_data; // Configure W5100 Ethernet controller with additional information from IP65 // after the IP65 TCP/IP stack has been configured. -void w5100_config(void); +void w5100_config(uint8_t eth_init); // Connect to server with IP address on TCP port . // Return true if the connection is established, return false otherwise. diff --git a/apps/wget65.c b/apps/wget65.c index 16518b8..b1a4c1a 100644 --- a/apps/wget65.c +++ b/apps/wget65.c @@ -472,7 +472,7 @@ int main(int, char *argv[]) uint16_t i; char *arg; char device; - uint8_t drv_init = DRV_INIT_DEFAULT; + uint8_t eth_init = ETH_INIT_DEFAULT; if (doesclrscrafterexit()) { @@ -503,14 +503,14 @@ int main(int, char *argv[]) file = open(self_path("ethernet.slot"), O_RDONLY); if (file != -1) { - read(file, &drv_init, 1); + read(file, ð_init, 1); close(file); - drv_init &= ~'0'; + eth_init &= ~'0'; } } - printf("- %d\n\nInitializing ", drv_init); - if (ip65_init(drv_init)) + printf("- %d\n\nInitializing ", eth_init); + if (ip65_init(eth_init)) { ip65_error_exit(true); } @@ -526,7 +526,7 @@ int main(int, char *argv[]) printf("- Ok\n\n"); // Copy IP config from IP65 to W5100 - w5100_config(); + w5100_config(eth_init); load_argument("wget.urls"); while (true) diff --git a/drivers/Makefile b/drivers/Makefile index 819f9b7..28bdb64 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -110,33 +110,33 @@ W5100OBJS=\ w5100driver.o \ ethernet.o -c64rrnet.lib: c64init.o rr-net.o $(CS8900AOBJS) $(C64OBJS) +c64rrnet.lib: rr-net.o $(CS8900AOBJS) c64init.o $(C64OBJS) -c64eth64.lib: c64init.o eth64.o $(LAN91C96OBJS) $(C64OBJS) +c64eth64.lib: eth64.o $(LAN91C96OBJS) c64init.o $(C64OBJS) -c64combo.lib: c64init.o rr-net.o eth64.o c64combo.o $(C64OBJS) +c64combo.lib: rr-net.o eth64.o c64combo.o c64init.o $(C64OBJS) -ip65_c64.lib: c64init.o rr-net.o eth64.o c64combo.o $(C64_OBJS) +ip65_c64.lib: rr-net.o eth64.o c64combo.o c64init.o $(C64_OBJS) -a2uther.lib: a2init.o uthernet.o $(CS8900AOBJS) $(A2OBJS) +a2uther.lib: uthernet.o $(CS8900AOBJS) a2init.o $(A2OBJS) -a2lancegs.lib: a2init.o lancegs.o $(LAN91C96OBJS) $(A2OBJS) +a2lancegs.lib: lancegs.o $(LAN91C96OBJS) a2init.o $(A2OBJS) -a2uther2.lib: a2init.o uthernet2.o $(W5100OBJS) $(A2OBJS) +a2uther2.lib: uthernet2.o $(W5100OBJS) a2init.o $(A2OBJS) -a2combo.lib: a2initcombo.o uthernet.o lancegs.o uthernet2.o a2combo.o $(A2OBJS) +a2combo.lib: uthernet.o lancegs.o uthernet2.o a2combo.o a2init.o $(A2OBJS) -ip65_apple2.lib: a2initcombo.o uthernet.o lancegs.o uthernet2.o a2combo.o $(A2_OBJS) +ip65_apple2.lib: uthernet.o lancegs.o uthernet2.o a2combo.o a2init.o $(A2_OBJS) -ip65_apple2_uther2.lib: a2init.o uthernet2.o $(W5100OBJS) $(A2_OBJS) +ip65_apple2_uther2.lib: uthernet2.o $(W5100OBJS) a2init.o $(A2_OBJS) -atrdragon.lib: atrinit.o dragoncart.o $(CS8900AOBJS) $(ATROBJS) +atrdragon.lib: dragoncart.o $(CS8900AOBJS) atrinit.o $(ATROBJS) -ip65_atari.lib: atrinit.o dragoncart.o $(CS8900AOBJS) $(ATR_OBJS) +ip65_atari.lib: dragoncart.o $(CS8900AOBJS) atrinit.o $(ATR_OBJS) -ip65_atarixl.lib: atrinit.o dragoncart.o $(CS8900AOBJS) $(ATRXL_OBJS) +ip65_atarixl.lib: dragoncart.o $(CS8900AOBJS) atrinit.o $(ATRXL_OBJS) -vic20rrnet.lib: vic20init.o vic20-rr-net.o $(CS8900AOBJS) $(VIC20OBJS) +vic20rrnet.lib: vic20-rr-net.o $(CS8900AOBJS) vic20init.o $(VIC20OBJS) clean: -rm -f *.o diff --git a/drivers/a2init.s b/drivers/a2init.s index 2c1101e..0e3b93b 100644 --- a/drivers/a2init.s +++ b/drivers/a2init.s @@ -1,48 +1 @@ -.include "zeropage.inc" - -.export drv_init -.exportzp drv_init_default = 3 ; Apple 2 default slot - -.import eth_driver_io_base - - -.code - -; set Apple 2 ethernet adaptor slot -; inputs: -; A: slot number (1-7) -; outputs: -; none -drv_init: - asl - asl - asl - asl - sta tmp1 - - lda eth_driver_io_base - and #%10001111 - ora tmp1 - sta eth_driver_io_base - rts - - - -; -- LICENSE FOR a2init.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 -- +.exportzp eth_init_default = 3 ; Apple 2 default slot diff --git a/drivers/a2initcombo.s b/drivers/a2initcombo.s deleted file mode 100644 index fef5ffc..0000000 --- a/drivers/a2initcombo.s +++ /dev/null @@ -1,60 +0,0 @@ -.include "zeropage.inc" - -.export drv_init -.exportzp drv_init_default = 3 ; Apple 2 default slot - -.import _w5100_driver_io_base -.import _cs8900a_driver_io_base -.import _lan91c96_driver_io_base - - -.code - -; set Apple 2 ethernet adaptor slot -; inputs: -; A: slot number (1-7) -; outputs: -; none -drv_init: - asl - asl - asl - asl - sta tmp1 - - lda _w5100_driver_io_base - and #%10001111 - ora tmp1 - sta _w5100_driver_io_base - - lda _cs8900a_driver_io_base - and #%10001111 - ora tmp1 - sta _cs8900a_driver_io_base - - lda _lan91c96_driver_io_base - and #%10001111 - ora tmp1 - sta _lan91c96_driver_io_base - rts - - - -; -- LICENSE FOR a2initcombo.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 -- diff --git a/drivers/atrinit.s b/drivers/atrinit.s index e682800..83abea7 100644 --- a/drivers/atrinit.s +++ b/drivers/atrinit.s @@ -1,8 +1 @@ -.export drv_init -.exportzp drv_init_default = 0 - - -.code - -drv_init: - rts +.exportzp eth_init_default = 0 diff --git a/drivers/c64init.s b/drivers/c64init.s index e682800..83abea7 100644 --- a/drivers/c64init.s +++ b/drivers/c64init.s @@ -1,8 +1 @@ -.export drv_init -.exportzp drv_init_default = 0 - - -.code - -drv_init: - rts +.exportzp eth_init_default = 0 diff --git a/drivers/cs8900a.s b/drivers/cs8900a.s index 449ad37..e0a6ec0 100644 --- a/drivers/cs8900a.s +++ b/drivers/cs8900a.s @@ -128,22 +128,25 @@ fixups = * - fixup ;--------------------------------------------------------------------- -; 3 most significant nibbles are fixed up at runtime -rxtxreg := $FFF0 -txcmd := $FFF4 -txlen := $FFF6 -isq := $FFF8 -packetpp := $FFFA -ppdata := $FFFC +; The addresses are fixed up at runtime +rxtxreg := $C080 +txcmd := $C084 +txlen := $C086 +isq := $C088 +packetpp := $C08A +ppdata := $C08C ;--------------------------------------------------------------------- .data init: - ; Save address of rxtxreg + ; Convert slot number to slot I/O offset + asl + asl + asl + asl sta reg - stx reg+1 ; Start with first fixup location lda #<(fixup01+1) @@ -155,13 +158,9 @@ init: ; Fixup address at location : lda (ptr),y - and #$0F + and #%10001111 ; Allow for re-init ora reg sta (ptr),y - iny - lda reg+1 - sta (ptr),y - dey ; Advance to next fixup location inx diff --git a/drivers/cs8900adriver.s b/drivers/cs8900adriver.s index 8f107e5..d7976b9 100644 --- a/drivers/cs8900adriver.s +++ b/drivers/cs8900adriver.s @@ -1,12 +1,10 @@ ; Cirrus Logic CS8900A driver .import _cs8900a -.import _cs8900a_driver_name -.import _cs8900a_driver_io_base +.import _cs8900a_name -.export eth = _cs8900a -.export eth_driver_name = _cs8900a_driver_name -.export eth_driver_io_base = _cs8900a_driver_io_base +.export eth = _cs8900a +.export eth_name = _cs8900a_name diff --git a/drivers/dragoncart.s b/drivers/dragoncart.s index 477767a..49582ac 100644 --- a/drivers/dragoncart.s +++ b/drivers/dragoncart.s @@ -1,7 +1,6 @@ ; Dragon Cart driver -.export _cs8900a_driver_name -.export _cs8900a_driver_io_base +.export _cs8900a_name __ATARI__ = 1 @@ -12,16 +11,10 @@ DYN_DRV = 0 .rodata -_cs8900a_driver_name: +_cs8900a_name: .byte "Dragon Cart",0 -.data - -_cs8900a_driver_io_base: - .word $d500 - - ; -- LICENSE FOR dragoncart.s -- ; The contents of this file are subject to the Mozilla Public License diff --git a/drivers/eth64.s b/drivers/eth64.s index b0d6b33..65995fe 100644 --- a/drivers/eth64.s +++ b/drivers/eth64.s @@ -1,7 +1,6 @@ ; ETH64 driver -.export _lan91c96_driver_name -.export _lan91c96_driver_io_base +.export _lan91c96_name __C64__ = 1 @@ -12,16 +11,10 @@ DYN_DRV = 0 .rodata -_lan91c96_driver_name: +_lan91c96_name: .byte "ETH64",0 -.data - -_lan91c96_driver_io_base: - .word $de00 - - ; -- LICENSE FOR eth64.s -- ; The contents of this file are subject to the Mozilla Public License diff --git a/drivers/ethernet.s b/drivers/ethernet.s index 108cbc2..2f0d32a 100644 --- a/drivers/ethernet.s +++ b/drivers/ethernet.s @@ -12,7 +12,6 @@ .import eth_outp_len .import eth -.import eth_driver_io_base .import cfg_mac @@ -32,10 +31,9 @@ .code ; initialize the ethernet adaptor -; inputs: none +; inputs: A = adaptor specific initialisation value or 'eth_init_default' ; outputs: carry flag is set if there was an error, clear otherwise eth_init: - ldax eth_driver_io_base jsr eth+driver::init ldx #5 : lda eth+driver::mac,x diff --git a/drivers/ethernetcombo.s b/drivers/ethernetcombo.s index c1dad7e..249554c 100644 --- a/drivers/ethernetcombo.s +++ b/drivers/ethernetcombo.s @@ -6,8 +6,7 @@ .export eth_init .export eth_rx .export eth_tx -.export eth_driver_name -.export eth_driver_io_base +.export eth_name .import eth_inp .import eth_inp_len @@ -15,16 +14,13 @@ .import eth_outp_len .import _w5100 -.import _w5100_driver_name -.import _w5100_driver_io_base +.import _w5100_name .import _cs8900a -.import _cs8900a_driver_name -.import _cs8900a_driver_io_base +.import _cs8900a_name .import _lan91c96 -.import _lan91c96_driver_name -.import _lan91c96_driver_io_base +.import _lan91c96_name .import cfg_mac @@ -45,8 +41,8 @@ eth = ptr1 .bss -eth_driver_name: .res 20 -eth_driver_io_base: .res 2 +eth_name: .res 20 +eth_init_value: .res 1 .code @@ -125,39 +121,37 @@ set_name: stax ptr1 ldy #18 ; sizeof(eth_driver_name)-2 : lda (ptr1),y - sta eth_driver_name,y + sta eth_name,y dey bpl :- rts ; initialize one of the known ethernet adaptors -; inputs: none +; inputs: A = adaptor specific initialisation value or 'eth_init_default' ; outputs: carry flag is set if there was an error, clear otherwise eth_init: + sta eth_init_value .ifdef __APPLE2__ ldax #_w5100 jsr patch_wrapper - ldax #_w5100_driver_name + ldax #_w5100_name jsr set_name - ldax _w5100_driver_io_base jsr init_adaptor bcc @done .endif ldax #_cs8900a jsr patch_wrapper - ldax #_cs8900a_driver_name + ldax #_cs8900a_name jsr set_name - ldax _cs8900a_driver_io_base jsr init_adaptor bcc @done ldax #_lan91c96 jsr patch_wrapper - ldax #_lan91c96_driver_name + ldax #_lan91c96_name jsr set_name - ldax _lan91c96_driver_io_base jsr init_adaptor @done: rts @@ -166,10 +160,10 @@ eth_init: .data ; initialize the ethernet adaptor -; inputs: ethernet adaptor i/o base addr +; inputs: none ; outputs: carry flag is set if there was an error, clear otherwise init_adaptor: - stax eth_driver_io_base + lda eth_init_value patch_init: jsr $ffff ; temporary vector - gets filled in later ldx #5 diff --git a/drivers/lan91c96.s b/drivers/lan91c96.s index 67def0d..c123b49 100644 --- a/drivers/lan91c96.s +++ b/drivers/lan91c96.s @@ -144,50 +144,53 @@ fixups = * - fixup ;--------------------------------------------------------------------- -; 3 most significant nibbles are fixed up at runtime -ethbsr := $FFFE ; Bank select register R/W (2B) +; The addresses are fixed up at runtime +ethbsr := $C08E ; Bank select register R/W (2B) ; Register bank 0 -ethtcr := $FFF0 ; Transmition control register R/W (2B) -ethephsr := $FFF2 ; EPH status register R/O (2B) -ethrcr := $FFF4 ; Receive control register R/W (2B) -ethecr := $FFF6 ; Counter register R/O (2B) -ethmir := $FFF8 ; Memory information register R/O (2B) -ethmcr := $FFFA ; Memory Config. reg. +0 R/W +1 R/O (2B) +ethtcr := $C080 ; Transmition control register R/W (2B) +ethephsr := $C082 ; EPH status register R/O (2B) +ethrcr := $C084 ; Receive control register R/W (2B) +ethecr := $C086 ; Counter register R/O (2B) +ethmir := $C088 ; Memory information register R/O (2B) +ethmcr := $C08A ; Memory Config. reg. +0 R/W +1 R/O (2B) ; Register bank 1 -ethcr := $FFF0 ; Configuration register R/W (2B) -ethbar := $FFF2 ; Base address register R/W (2B) -ethiar := $FFF4 ; Individual address register R/W (6B) -ethgpr := $FFFA ; General address register R/W (2B) -ethctr := $FFFC ; Control register R/W (2B) +ethcr := $C080 ; Configuration register R/W (2B) +ethbar := $C082 ; Base address register R/W (2B) +ethiar := $C084 ; Individual address register R/W (6B) +ethgpr := $C08A ; General address register R/W (2B) +ethctr := $C08C ; Control register R/W (2B) ; Register bank 2 -ethmmucr := $FFF0 ; MMU command register W/O (1B) -ethautotx := $FFF1 ; AUTO TX start register R/W (1B) -ethpnr := $FFF2 ; Packet number register R/W (1B) -etharr := $FFF3 ; Allocation result register R/O (1B) -ethfifo := $FFF4 ; FIFO ports register R/O (2B) -ethptr := $FFF6 ; Pointer register R/W (2B) -ethdata := $FFF8 ; Data register R/W (4B) -ethist := $FFFC ; Interrupt status register R/O (1B) -ethack := $FFFC ; Interrupt acknowledge register W/O (1B) -ethmsk := $FFFD ; Interrupt mask register R/W (1B) +ethmmucr := $C080 ; MMU command register W/O (1B) +ethautotx := $C081 ; AUTO TX start register R/W (1B) +ethpnr := $C082 ; Packet number register R/W (1B) +etharr := $C083 ; Allocation result register R/O (1B) +ethfifo := $C084 ; FIFO ports register R/O (2B) +ethptr := $C086 ; Pointer register R/W (2B) +ethdata := $C088 ; Data register R/W (4B) +ethist := $C08C ; Interrupt status register R/O (1B) +ethack := $C08C ; Interrupt acknowledge register W/O (1B) +ethmsk := $C08D ; Interrupt mask register R/W (1B) ; Register bank 3 -ethmt := $FFF0 ; Multicast table R/W (8B) -ethmgmt := $FFF8 ; Management interface R/W (2B) -ethrev := $FFFA ; Revision register R/W (2B) -ethercv := $FFFC ; Early RCV register R/W (2B) - - .data +ethmt := $C080 ; Multicast table R/W (8B) +ethmgmt := $C088 ; Management interface R/W (2B) +ethrev := $C08A ; Revision register R/W (2B) +ethercv := $C08C ; Early RCV register R/W (2B) ;--------------------------------------------------------------------- + .data + init: - ; Save address of register base + ; Convert slot number to slot I/O offset + asl + asl + asl + asl sta reg - stx reg+1 ; Start with first fixup location lda #<(fixup01+1) @@ -199,13 +202,9 @@ init: ; Fixup address at location : lda (ptr),y - and #$0F + and #%10001111 ; Allow for re-init ora reg sta (ptr),y - iny - lda reg+1 - sta (ptr),y - dey ; Advance to next fixup location inx diff --git a/drivers/lan91c96driver.s b/drivers/lan91c96driver.s index 1f56449..f9f05d5 100644 --- a/drivers/lan91c96driver.s +++ b/drivers/lan91c96driver.s @@ -1,12 +1,10 @@ ; Standard Microsystems LAN91C96 driver .import _lan91c96 -.import _lan91c96_driver_name -.import _lan91c96_driver_io_base +.import _lan91c96_name -.export eth = _lan91c96 -.export eth_driver_name = _lan91c96_driver_name -.export eth_driver_io_base = _lan91c96_driver_io_base +.export eth = _lan91c96 +.export eth_name = _lan91c96_name diff --git a/drivers/lancegs.s b/drivers/lancegs.s index 8eba86c..f100283 100644 --- a/drivers/lancegs.s +++ b/drivers/lancegs.s @@ -1,7 +1,6 @@ ; LANceGS driver -.export _lan91c96_driver_name -.export _lan91c96_driver_io_base +.export _lan91c96_name __APPLE2__ = 1 @@ -12,16 +11,10 @@ DYN_DRV = 0 .rodata -_lan91c96_driver_name: +_lan91c96_name: .byte "LANceGS",0 -.data - -_lan91c96_driver_io_base: - .word $c0b0 - - ; -- LICENSE FOR lancegs.s -- ; The contents of this file are subject to the Mozilla Public License diff --git a/drivers/rr-net.s b/drivers/rr-net.s index e8c0e0e..5297c96 100644 --- a/drivers/rr-net.s +++ b/drivers/rr-net.s @@ -1,7 +1,6 @@ ; RR-Net driver -.export _cs8900a_driver_name -.export _cs8900a_driver_io_base +.export _cs8900a_name __CBM__ = 1 @@ -13,16 +12,10 @@ DYN_DRV = 0 .rodata -_cs8900a_driver_name: +_cs8900a_name: .byte "RR-Net",0 -.data - -_cs8900a_driver_io_base: - .word $de08 - - ; -- LICENSE FOR rr-net.s -- ; The contents of this file are subject to the Mozilla Public License diff --git a/drivers/uthernet.s b/drivers/uthernet.s index fed78b1..257e5c9 100644 --- a/drivers/uthernet.s +++ b/drivers/uthernet.s @@ -1,7 +1,6 @@ ; Uthernet driver -.export _cs8900a_driver_name -.export _cs8900a_driver_io_base +.export _cs8900a_name __APPLE2__ = 1 @@ -12,16 +11,10 @@ DYN_DRV = 0 .rodata -_cs8900a_driver_name: +_cs8900a_name: .byte "Uthernet",0 -.data - -_cs8900a_driver_io_base: - .word $c0b0 - - ; -- LICENSE FOR uthernet.s -- ; The contents of this file are subject to the Mozilla Public License diff --git a/drivers/uthernet2.s b/drivers/uthernet2.s index e1d2938..cbbd24d 100644 --- a/drivers/uthernet2.s +++ b/drivers/uthernet2.s @@ -1,7 +1,6 @@ ; Uthernet II driver -.export _w5100_driver_name -.export _w5100_driver_io_base +.export _w5100_name __APPLE2__ = 1 @@ -12,16 +11,10 @@ DYN_DRV = 0 .rodata -_w5100_driver_name: +_w5100_name: .byte "Uthernet II",0 -.data - -_w5100_driver_io_base: - .word $c0b4 - - ; -- LICENSE FOR uthernet2.s -- ; The contents of this file are subject to the Mozilla Public License diff --git a/drivers/vic20-rr-net.s b/drivers/vic20-rr-net.s index df29ec4..6c2bc67 100644 --- a/drivers/vic20-rr-net.s +++ b/drivers/vic20-rr-net.s @@ -1,7 +1,6 @@ ; RR-Net driver, as seen on a VIC-20 (i.e. using a Masquerade adapter) -.export _cs8900a_driver_name -.export _cs8900a_driver_io_base +.export _cs8900a_name __CBM__ = 1 @@ -13,16 +12,10 @@ DYN_DRV = 0 .rodata -_cs8900a_driver_name: +_cs8900a_name: .asciiz "VIC20 RR-Net" -.data - -_cs8900a_driver_io_base: - .word $9808 - - ; -- LICENSE FOR vic20-rr-net.s -- ; The contents of this file are subject to the Mozilla Public License diff --git a/drivers/vic20init.s b/drivers/vic20init.s index e682800..83abea7 100644 --- a/drivers/vic20init.s +++ b/drivers/vic20init.s @@ -1,8 +1 @@ -.export drv_init -.exportzp drv_init_default = 0 - - -.code - -drv_init: - rts +.exportzp eth_init_default = 0 diff --git a/drivers/w5100.s b/drivers/w5100.s index 3d81601..1779859 100644 --- a/drivers/w5100.s +++ b/drivers/w5100.s @@ -104,19 +104,22 @@ fixups = * - fixup ;--------------------------------------------------------------------- -; 14 most significant bits are fixed up at runtime -mode := $FFFC|0 -addr := $FFFC|1 -data := $FFFC|3 - - .data +; The addresses are fixed up at runtime +mode := $C084 +addr := $C085 +data := $C087 ;--------------------------------------------------------------------- + .data + init: - ; Save address of register base + ; Convert slot number to slot I/O offset + asl + asl + asl + asl sta reg - stx reg+1 ; Start with first fixup location lda #<(fixup01+1) @@ -128,13 +131,9 @@ init: ; Fixup address at location : lda (ptr),y - and #$03 + and #%10001111 ; Allow for re-init ora reg sta (ptr),y - iny - lda reg+1 - sta (ptr),y - dey ; Advance to next fixup location inx @@ -147,9 +146,9 @@ init: bcc :- inc ptr+1 bcs :- ; Always +: ; Indirect Bus I/F mode, Address Auto-Increment -: fixup01:lda mode ora #$03 fixup02:sta mode diff --git a/drivers/w5100driver.s b/drivers/w5100driver.s index 603ebaa..091a1e7 100644 --- a/drivers/w5100driver.s +++ b/drivers/w5100driver.s @@ -1,12 +1,10 @@ ; WIZnet W5100 driver .import _w5100 -.import _w5100_driver_name -.import _w5100_driver_io_base +.import _w5100_name -.export eth = _w5100 -.export eth_driver_name = _w5100_driver_name -.export eth_driver_io_base = _w5100_driver_io_base +.export eth = _w5100 +.export eth_name = _w5100_name diff --git a/inc/commonprint.inc b/inc/commonprint.inc index dc25c52..6224c74 100644 --- a/inc/commonprint.inc +++ b/inc/commonprint.inc @@ -26,8 +26,7 @@ .import ascii_to_native -.import eth_driver_name -.import eth_driver_io_base +.import eth_name .importzp copy_src .import cfg_mac .import cfg_ip @@ -57,18 +56,8 @@ temp_ptr: .res 2 .endmacro .macro print_driver_init - ldax #eth_driver_name + ldax #eth_name jsr print_ascii_as_native - lda #'(' - jsr print_a - lda #'$' - jsr print_a - lda eth_driver_io_base+1 - jsr print_hex - lda eth_driver_io_base - jsr print_hex - lda #')' - jsr print_a ldax #init_msg jsr print_ascii_as_native .endmacro @@ -97,13 +86,13 @@ temp_ptr: .res 2 .import print_a .import print_cr -.import eth_driver_name +.import eth_name print_ip_config: ldax #interface_type jsr print_ascii_as_native - ldax #eth_driver_name + ldax #eth_name jsr print_ascii_as_native jsr print_cr diff --git a/inc/ip65.h b/inc/ip65.h index 7e8150b..01be24e 100644 --- a/inc/ip65.h +++ b/inc/ip65.h @@ -23,12 +23,12 @@ // extern uint8_t ip65_error; -// Driver initialization parameter values +// Ethernet driver initialization parameter values // #ifdef __APPLE2__ -#define DRV_INIT_DEFAULT 3 // Apple II slot number +#define ETH_INIT_DEFAULT 3 // Apple II slot number #else -#define DRV_INIT_DEFAULT 0 // Unused +#define ETH_INIT_DEFAULT 0 // Unused #endif // Initialize the IP stack @@ -38,18 +38,17 @@ extern uint8_t ip65_error; // except for dhcp_init which must also be called if the application // is using DHCP rather than hardcoded IP configuration. // -// Inputs: drv_init: Driver initialization parameter +// Inputs: eth_init: Ethernet driver initialization parameter // Output: true if there was an error, false otherwise // -bool __fastcall__ ip65_init(uint8_t drv_init); +bool __fastcall__ ip65_init(uint8_t eth_init); // Access to Ethernet configuration // -// Access to the three items below is only valid after ip65_init returned false. +// Access to the two items below is only valid after ip65_init returned false. // -extern uint8_t cfg_mac[6]; // MAC address of local machine -extern char eth_driver_name[]; // Zero terminated string containing driver name -extern uint8_t* eth_driver_io_base; // Ethernet chip I/O base address used by driver +extern uint8_t cfg_mac[6]; // MAC address of local machine +extern char eth_name[]; // Zero terminated string containing Ethernet driver name // Main IP polling loop // diff --git a/inc/net.inc b/inc/net.inc index e47fd41..910dcea 100644 --- a/inc/net.inc +++ b/inc/net.inc @@ -11,15 +11,12 @@ .import dhcp_init .import dhcp_server -.ifdef A2_SLOT_SCAN -.import drv_init -.endif +.importzp eth_init_default .macro init_ip_via_dhcp .ifdef A2_SLOT_SCAN lda #1 : pha - jsr drv_init jsr ip65_init pla bcc :+ @@ -28,6 +25,7 @@ bcc :- : .else + lda #eth_init_default jsr ip65_init .endif php diff --git a/ip65/Makefile b/ip65/Makefile index 8e146dd..9de3e58 100644 --- a/ip65/Makefile +++ b/ip65/Makefile @@ -23,8 +23,8 @@ IP65OBJS=\ dottedquad_c.o \ download.o \ download_c.o \ - driver_c.o \ eth.o \ + eth_c.o \ http.o \ http_c.o \ httpd.o \ diff --git a/ip65/driver_c.s b/ip65/driver_c.s deleted file mode 100644 index 718fe71..0000000 --- a/ip65/driver_c.s +++ /dev/null @@ -1,11 +0,0 @@ -.include "../inc/common.inc" - -.export _eth_driver_name -.export _eth_driver_io_base - -.import eth_driver_name -.import eth_driver_io_base - -_eth_driver_name := eth_driver_name - -_eth_driver_io_base := eth_driver_io_base diff --git a/ip65/eth_c.s b/ip65/eth_c.s new file mode 100644 index 0000000..ccaad37 --- /dev/null +++ b/ip65/eth_c.s @@ -0,0 +1,7 @@ +.include "../inc/common.inc" + +.export _eth_name + +.import eth_name + +_eth_name := eth_name diff --git a/ip65/ip65.s b/ip65/ip65.s index 3abff19..54ccc02 100644 --- a/ip65/ip65.s +++ b/ip65/ip65.s @@ -68,7 +68,7 @@ ip65_random_word: ; the only *_init routine that must be called by a user application, ; except for dhcp_init which must also be called if the application ; is using dhcp rather than hardcoded ip configuration -; inputs: none +; inputs: A = adaptor specific initialisation value or 'eth_init_default' ; outputs: carry flag is set if there was an error, clear otherwise ip65_init: jsr eth_init ; initialize ethernet driver diff --git a/ip65/ip65_c.s b/ip65/ip65_c.s index 83c31ab..2ca754f 100644 --- a/ip65/ip65_c.s +++ b/ip65/ip65_c.s @@ -9,10 +9,8 @@ .import ip65_process .import ip65_random_word .import ip65_error -.import drv_init _ip65_init: - jsr drv_init jsr ip65_init ldx #$00 txa diff --git a/test/tcp.c b/test/tcp.c index 7cc3a53..63a7a36 100644 --- a/test/tcp.c +++ b/test/tcp.c @@ -48,7 +48,7 @@ void main(void) } printf("Init\n"); - if (ip65_init(DRV_INIT_DEFAULT)) + if (ip65_init(ETH_INIT_DEFAULT)) { error_exit(); } diff --git a/test/udp.c b/test/udp.c index 61ef3b0..203a302 100644 --- a/test/udp.c +++ b/test/udp.c @@ -47,7 +47,7 @@ void main(void) } printf("Init\n"); - if (ip65_init(DRV_INIT_DEFAULT)) + if (ip65_init(ETH_INIT_DEFAULT)) { error_exit(); }