Removed Ethernet driver I/O base.

So far the base address of the Ethernet chip was a general property of all Ethernet drivers. It served two purposes:
1. Allowing to use a single Ethernet driver for a certain Ethernet chip, no matter what machine was connected to the chip.
2. Allowing use an Ethernet card in all Apple II slots.

However, we now use customized Ethernet drivers for the individual machines so 1.) isn't relevant anymore. In fact one wants to omit the overhead of a runtime-adjustable base address where it isn't needed.

So only the Apple II slots are left. But this should rather be a driver-internal approach then. We should just hand the driver the slot number the user wants to use and have the driver do its thing.

Independently from the aspect if the driver parameter is a base address or a slot number the parameter handling was changed too. For asm programs there was so far a specific init function to be called prior to the main init function if it was desired to chnage the parameter default. This was done to keep the main init function backward compatible. But now that the parameter (now the slot number) is only used on the Apple II anyhow it seems reasonable to drop the specific init function again and just provide the parameter to the main init function. All C64-only user code can stay as-is. Only Apple II user code needs to by adjusted. Please note that this change only affects asm programs, C programs always used a single init function with the Apple II slot number as parameter.
This commit is contained in:
Oliver Schmidt 2019-05-02 14:44:24 +02:00
parent 6f0e4a97b1
commit 4577c2ab19
38 changed files with 178 additions and 403 deletions

View File

@ -50,7 +50,7 @@ void confirm_exit(void)
void main(void) void main(void)
{ {
uint8_t drv_init = DRV_INIT_DEFAULT; uint8_t eth_init = ETH_INIT_DEFAULT;
uint32_t server; uint32_t server;
struct timespec time; struct timespec time;
@ -71,16 +71,16 @@ void main(void)
file = open("ethernet.slot", O_RDONLY); file = open("ethernet.slot", O_RDONLY);
if (file != -1) if (file != -1)
{ {
read(file, &drv_init, 1); read(file, &eth_init, 1);
close(file); close(file);
drv_init &= ~'0'; eth_init &= ~'0';
} }
printf("- %d\n", drv_init); printf("- %d\n", eth_init);
} }
#endif #endif
printf("\nInitializing "); printf("\nInitializing ");
if (ip65_init(drv_init)) if (ip65_init(eth_init))
{ {
error_exit(); error_exit();
} }

View File

@ -301,7 +301,7 @@ void error_exit(void)
void main(void) void main(void)
{ {
char cwd[FILENAME_MAX]; char cwd[FILENAME_MAX];
unsigned char drv_init = DRV_INIT_DEFAULT; unsigned char eth_init = ETH_INIT_DEFAULT;
getcwd(cwd, sizeof(cwd)); getcwd(cwd, sizeof(cwd));
@ -320,16 +320,16 @@ void main(void)
file = open("ethernet.slot", O_RDONLY); file = open("ethernet.slot", O_RDONLY);
if (file != -1) if (file != -1)
{ {
read(file, &drv_init, 1); read(file, &eth_init, 1);
close(file); close(file);
drv_init &= ~'0'; eth_init &= ~'0';
} }
printf("- %d", drv_init); printf("- %d", eth_init);
} }
#endif #endif
printf("\n\nInitializing "); printf("\n\nInitializing ");
if (ip65_init(drv_init)) if (ip65_init(eth_init))
{ {
error_exit(); error_exit();
} }

View File

@ -10,8 +10,7 @@
.import abort_key .import abort_key
.importzp abort_key_default .importzp abort_key_default
.importzp abort_key_disable .importzp abort_key_disable
.import drv_init .importzp eth_init_default
.importzp drv_init_default
.import get_filtered_input .import get_filtered_input
.import get_key .import get_key
.import get_key_if_available .import get_key_if_available
@ -58,8 +57,8 @@ buffer_ptr = sreg
.segment "STARTUP" .segment "STARTUP"
jmp start jmp start
drv_init_value: eth_init_value:
.byte drv_init_default .byte eth_init_default
.code .code
@ -74,23 +73,15 @@ start:
jsr print_vt100 jsr print_vt100
ldax #initializing ldax #initializing
jsr print_ascii_as_native jsr print_ascii_as_native
lda drv_init_value lda eth_init_value
jsr drv_init
jsr ip65_init jsr ip65_init
bcc :+ bcc :+
ldax #device_not_found ldax #device_not_found
jsr print_ascii_as_native jsr print_ascii_as_native
jmp error_exit jmp error_exit
: ldax #eth_driver_name : ldax #eth_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
jsr print_ascii_as_native jsr print_ascii_as_native
jsr print_cr
; get IP addr ; get IP addr
ldax #obtaining ldax #obtaining
@ -507,8 +498,6 @@ initializing: .byte 10,"Initializing ",0
obtaining: .byte "Obtaining IP address ",0 obtaining: .byte "Obtaining IP address ",0
resolving: .byte 10,"Resolving to address ",0 resolving: .byte 10,"Resolving to address ",0
connecting: .byte 10,"Connecting to ",0 connecting: .byte 10,"Connecting to ",0
io_base_prefix: .byte " ($",0
io_base_postfix: .byte ")",10,0
ok: .byte "Ok",10,10,0 ok: .byte "Ok",10,10,0
device_not_found: .byte "- Device not found",10,0 device_not_found: .byte "- Device not found",10,0
abort: .byte "- User abort",10,0 abort: .byte "- User abort",10,0
@ -524,13 +513,13 @@ welcome_1: .byte 27,")0"
.byte 15,13,10 .byte 15,13,10
.byte 14,"x x" .byte 14,"x x"
.byte 15,13,10 .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 15,13,10
.byte 14,"x x" .byte 14,"x x"
.byte 15,13,10,0 .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 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 15,13,10
.byte 14,"x x" .byte 14,"x x"
.byte 15,13,10 .byte 15,13,10

View File

@ -114,7 +114,7 @@ void input(char* str, unsigned int max, const char* tag)
void main() void main()
{ {
int retval; int retval;
uint8_t drv_init = DRV_INIT_DEFAULT; uint8_t eth_init = ETH_INIT_DEFAULT;
if (doesclrscrafterexit()) if (doesclrscrafterexit())
{ {
@ -169,16 +169,16 @@ void main()
file = open("ethernet.slot", O_RDONLY); file = open("ethernet.slot", O_RDONLY);
if (file != -1) if (file != -1)
{ {
read(file, &drv_init, 1); read(file, &eth_init, 1);
close(file); close(file);
drv_init &= ~'0'; eth_init &= ~'0';
} }
printf("- %d\n", drv_init); printf("- %d\n", eth_init);
} }
#endif #endif
printf("\nInitializing "); printf("\nInitializing ");
if (ip65_init(drv_init)) if (ip65_init(eth_init))
{ {
error_exit(); error_exit();
} }

View File

@ -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_mode = (uint8_t*)(eth_init << 4 | 0xC084);
w5100_addr_hi = eth_driver_io_base + 1; w5100_addr_hi = w5100_mode + 1;
w5100_addr_lo = eth_driver_io_base + 2; w5100_addr_lo = w5100_mode + 2;
w5100_data = eth_driver_io_base + 3; w5100_data = w5100_mode + 3;
// Source IP Address Register // Source IP Address Register
set_quad(0x000F, cfg_ip); set_quad(0x000F, cfg_ip);

View File

@ -48,7 +48,7 @@ extern volatile uint8_t* w5100_data;
// Configure W5100 Ethernet controller with additional information from IP65 // Configure W5100 Ethernet controller with additional information from IP65
// after the IP65 TCP/IP stack has been configured. // 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 <server_addr> on TCP port <server_port>. // Connect to server with IP address <server_addr> on TCP port <server_port>.
// Return true if the connection is established, return false otherwise. // Return true if the connection is established, return false otherwise.

View File

@ -472,7 +472,7 @@ int main(int, char *argv[])
uint16_t i; uint16_t i;
char *arg; char *arg;
char device; char device;
uint8_t drv_init = DRV_INIT_DEFAULT; uint8_t eth_init = ETH_INIT_DEFAULT;
if (doesclrscrafterexit()) if (doesclrscrafterexit())
{ {
@ -503,14 +503,14 @@ int main(int, char *argv[])
file = open(self_path("ethernet.slot"), O_RDONLY); file = open(self_path("ethernet.slot"), O_RDONLY);
if (file != -1) if (file != -1)
{ {
read(file, &drv_init, 1); read(file, &eth_init, 1);
close(file); close(file);
drv_init &= ~'0'; eth_init &= ~'0';
} }
} }
printf("- %d\n\nInitializing ", drv_init); printf("- %d\n\nInitializing ", eth_init);
if (ip65_init(drv_init)) if (ip65_init(eth_init))
{ {
ip65_error_exit(true); ip65_error_exit(true);
} }
@ -526,7 +526,7 @@ int main(int, char *argv[])
printf("- Ok\n\n"); printf("- Ok\n\n");
// Copy IP config from IP65 to W5100 // Copy IP config from IP65 to W5100
w5100_config(); w5100_config(eth_init);
load_argument("wget.urls"); load_argument("wget.urls");
while (true) while (true)

View File

@ -110,33 +110,33 @@ W5100OBJS=\
w5100driver.o \ w5100driver.o \
ethernet.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: clean:
-rm -f *.o -rm -f *.o

View File

@ -1,48 +1 @@
.include "zeropage.inc" .exportzp eth_init_default = 3 ; Apple 2 default slot
.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 --

View File

@ -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 --

View File

@ -1,8 +1 @@
.export drv_init .exportzp eth_init_default = 0
.exportzp drv_init_default = 0
.code
drv_init:
rts

View File

@ -1,8 +1 @@
.export drv_init .exportzp eth_init_default = 0
.exportzp drv_init_default = 0
.code
drv_init:
rts

View File

@ -128,22 +128,25 @@ fixups = * - fixup
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; 3 most significant nibbles are fixed up at runtime ; The addresses are fixed up at runtime
rxtxreg := $FFF0 rxtxreg := $C080
txcmd := $FFF4 txcmd := $C084
txlen := $FFF6 txlen := $C086
isq := $FFF8 isq := $C088
packetpp := $FFFA packetpp := $C08A
ppdata := $FFFC ppdata := $C08C
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.data .data
init: init:
; Save address of rxtxreg ; Convert slot number to slot I/O offset
asl
asl
asl
asl
sta reg sta reg
stx reg+1
; Start with first fixup location ; Start with first fixup location
lda #<(fixup01+1) lda #<(fixup01+1)
@ -155,13 +158,9 @@ init:
; Fixup address at location ; Fixup address at location
: lda (ptr),y : lda (ptr),y
and #$0F and #%10001111 ; Allow for re-init
ora reg ora reg
sta (ptr),y sta (ptr),y
iny
lda reg+1
sta (ptr),y
dey
; Advance to next fixup location ; Advance to next fixup location
inx inx

View File

@ -1,12 +1,10 @@
; Cirrus Logic CS8900A driver ; Cirrus Logic CS8900A driver
.import _cs8900a .import _cs8900a
.import _cs8900a_driver_name .import _cs8900a_name
.import _cs8900a_driver_io_base
.export eth = _cs8900a .export eth = _cs8900a
.export eth_driver_name = _cs8900a_driver_name .export eth_name = _cs8900a_name
.export eth_driver_io_base = _cs8900a_driver_io_base

View File

@ -1,7 +1,6 @@
; Dragon Cart driver ; Dragon Cart driver
.export _cs8900a_driver_name .export _cs8900a_name
.export _cs8900a_driver_io_base
__ATARI__ = 1 __ATARI__ = 1
@ -12,16 +11,10 @@ DYN_DRV = 0
.rodata .rodata
_cs8900a_driver_name: _cs8900a_name:
.byte "Dragon Cart",0 .byte "Dragon Cart",0
.data
_cs8900a_driver_io_base:
.word $d500
; -- LICENSE FOR dragoncart.s -- ; -- LICENSE FOR dragoncart.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License

View File

@ -1,7 +1,6 @@
; ETH64 driver ; ETH64 driver
.export _lan91c96_driver_name .export _lan91c96_name
.export _lan91c96_driver_io_base
__C64__ = 1 __C64__ = 1
@ -12,16 +11,10 @@ DYN_DRV = 0
.rodata .rodata
_lan91c96_driver_name: _lan91c96_name:
.byte "ETH64",0 .byte "ETH64",0
.data
_lan91c96_driver_io_base:
.word $de00
; -- LICENSE FOR eth64.s -- ; -- LICENSE FOR eth64.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License

View File

@ -12,7 +12,6 @@
.import eth_outp_len .import eth_outp_len
.import eth .import eth
.import eth_driver_io_base
.import cfg_mac .import cfg_mac
@ -32,10 +31,9 @@
.code .code
; initialize the ethernet adaptor ; 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 ; outputs: carry flag is set if there was an error, clear otherwise
eth_init: eth_init:
ldax eth_driver_io_base
jsr eth+driver::init jsr eth+driver::init
ldx #5 ldx #5
: lda eth+driver::mac,x : lda eth+driver::mac,x

View File

@ -6,8 +6,7 @@
.export eth_init .export eth_init
.export eth_rx .export eth_rx
.export eth_tx .export eth_tx
.export eth_driver_name .export eth_name
.export eth_driver_io_base
.import eth_inp .import eth_inp
.import eth_inp_len .import eth_inp_len
@ -15,16 +14,13 @@
.import eth_outp_len .import eth_outp_len
.import _w5100 .import _w5100
.import _w5100_driver_name .import _w5100_name
.import _w5100_driver_io_base
.import _cs8900a .import _cs8900a
.import _cs8900a_driver_name .import _cs8900a_name
.import _cs8900a_driver_io_base
.import _lan91c96 .import _lan91c96
.import _lan91c96_driver_name .import _lan91c96_name
.import _lan91c96_driver_io_base
.import cfg_mac .import cfg_mac
@ -45,8 +41,8 @@ eth = ptr1
.bss .bss
eth_driver_name: .res 20 eth_name: .res 20
eth_driver_io_base: .res 2 eth_init_value: .res 1
.code .code
@ -125,39 +121,37 @@ set_name:
stax ptr1 stax ptr1
ldy #18 ; sizeof(eth_driver_name)-2 ldy #18 ; sizeof(eth_driver_name)-2
: lda (ptr1),y : lda (ptr1),y
sta eth_driver_name,y sta eth_name,y
dey dey
bpl :- bpl :-
rts rts
; initialize one of the known ethernet adaptors ; 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 ; outputs: carry flag is set if there was an error, clear otherwise
eth_init: eth_init:
sta eth_init_value
.ifdef __APPLE2__ .ifdef __APPLE2__
ldax #_w5100 ldax #_w5100
jsr patch_wrapper jsr patch_wrapper
ldax #_w5100_driver_name ldax #_w5100_name
jsr set_name jsr set_name
ldax _w5100_driver_io_base
jsr init_adaptor jsr init_adaptor
bcc @done bcc @done
.endif .endif
ldax #_cs8900a ldax #_cs8900a
jsr patch_wrapper jsr patch_wrapper
ldax #_cs8900a_driver_name ldax #_cs8900a_name
jsr set_name jsr set_name
ldax _cs8900a_driver_io_base
jsr init_adaptor jsr init_adaptor
bcc @done bcc @done
ldax #_lan91c96 ldax #_lan91c96
jsr patch_wrapper jsr patch_wrapper
ldax #_lan91c96_driver_name ldax #_lan91c96_name
jsr set_name jsr set_name
ldax _lan91c96_driver_io_base
jsr init_adaptor jsr init_adaptor
@done: @done:
rts rts
@ -166,10 +160,10 @@ eth_init:
.data .data
; initialize the ethernet adaptor ; 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 ; outputs: carry flag is set if there was an error, clear otherwise
init_adaptor: init_adaptor:
stax eth_driver_io_base lda eth_init_value
patch_init: patch_init:
jsr $ffff ; temporary vector - gets filled in later jsr $ffff ; temporary vector - gets filled in later
ldx #5 ldx #5

View File

@ -144,50 +144,53 @@ fixups = * - fixup
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; 3 most significant nibbles are fixed up at runtime ; The addresses are fixed up at runtime
ethbsr := $FFFE ; Bank select register R/W (2B) ethbsr := $C08E ; Bank select register R/W (2B)
; Register bank 0 ; Register bank 0
ethtcr := $FFF0 ; Transmition control register R/W (2B) ethtcr := $C080 ; Transmition control register R/W (2B)
ethephsr := $FFF2 ; EPH status register R/O (2B) ethephsr := $C082 ; EPH status register R/O (2B)
ethrcr := $FFF4 ; Receive control register R/W (2B) ethrcr := $C084 ; Receive control register R/W (2B)
ethecr := $FFF6 ; Counter register R/O (2B) ethecr := $C086 ; Counter register R/O (2B)
ethmir := $FFF8 ; Memory information register R/O (2B) ethmir := $C088 ; Memory information register R/O (2B)
ethmcr := $FFFA ; Memory Config. reg. +0 R/W +1 R/O (2B) ethmcr := $C08A ; Memory Config. reg. +0 R/W +1 R/O (2B)
; Register bank 1 ; Register bank 1
ethcr := $FFF0 ; Configuration register R/W (2B) ethcr := $C080 ; Configuration register R/W (2B)
ethbar := $FFF2 ; Base address register R/W (2B) ethbar := $C082 ; Base address register R/W (2B)
ethiar := $FFF4 ; Individual address register R/W (6B) ethiar := $C084 ; Individual address register R/W (6B)
ethgpr := $FFFA ; General address register R/W (2B) ethgpr := $C08A ; General address register R/W (2B)
ethctr := $FFFC ; Control register R/W (2B) ethctr := $C08C ; Control register R/W (2B)
; Register bank 2 ; Register bank 2
ethmmucr := $FFF0 ; MMU command register W/O (1B) ethmmucr := $C080 ; MMU command register W/O (1B)
ethautotx := $FFF1 ; AUTO TX start register R/W (1B) ethautotx := $C081 ; AUTO TX start register R/W (1B)
ethpnr := $FFF2 ; Packet number register R/W (1B) ethpnr := $C082 ; Packet number register R/W (1B)
etharr := $FFF3 ; Allocation result register R/O (1B) etharr := $C083 ; Allocation result register R/O (1B)
ethfifo := $FFF4 ; FIFO ports register R/O (2B) ethfifo := $C084 ; FIFO ports register R/O (2B)
ethptr := $FFF6 ; Pointer register R/W (2B) ethptr := $C086 ; Pointer register R/W (2B)
ethdata := $FFF8 ; Data register R/W (4B) ethdata := $C088 ; Data register R/W (4B)
ethist := $FFFC ; Interrupt status register R/O (1B) ethist := $C08C ; Interrupt status register R/O (1B)
ethack := $FFFC ; Interrupt acknowledge register W/O (1B) ethack := $C08C ; Interrupt acknowledge register W/O (1B)
ethmsk := $FFFD ; Interrupt mask register R/W (1B) ethmsk := $C08D ; Interrupt mask register R/W (1B)
; Register bank 3 ; Register bank 3
ethmt := $FFF0 ; Multicast table R/W (8B) ethmt := $C080 ; Multicast table R/W (8B)
ethmgmt := $FFF8 ; Management interface R/W (2B) ethmgmt := $C088 ; Management interface R/W (2B)
ethrev := $FFFA ; Revision register R/W (2B) ethrev := $C08A ; Revision register R/W (2B)
ethercv := $FFFC ; Early RCV register R/W (2B) ethercv := $C08C ; Early RCV register R/W (2B)
.data
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.data
init: init:
; Save address of register base ; Convert slot number to slot I/O offset
asl
asl
asl
asl
sta reg sta reg
stx reg+1
; Start with first fixup location ; Start with first fixup location
lda #<(fixup01+1) lda #<(fixup01+1)
@ -199,13 +202,9 @@ init:
; Fixup address at location ; Fixup address at location
: lda (ptr),y : lda (ptr),y
and #$0F and #%10001111 ; Allow for re-init
ora reg ora reg
sta (ptr),y sta (ptr),y
iny
lda reg+1
sta (ptr),y
dey
; Advance to next fixup location ; Advance to next fixup location
inx inx

View File

@ -1,12 +1,10 @@
; Standard Microsystems LAN91C96 driver ; Standard Microsystems LAN91C96 driver
.import _lan91c96 .import _lan91c96
.import _lan91c96_driver_name .import _lan91c96_name
.import _lan91c96_driver_io_base
.export eth = _lan91c96 .export eth = _lan91c96
.export eth_driver_name = _lan91c96_driver_name .export eth_name = _lan91c96_name
.export eth_driver_io_base = _lan91c96_driver_io_base

View File

@ -1,7 +1,6 @@
; LANceGS driver ; LANceGS driver
.export _lan91c96_driver_name .export _lan91c96_name
.export _lan91c96_driver_io_base
__APPLE2__ = 1 __APPLE2__ = 1
@ -12,16 +11,10 @@ DYN_DRV = 0
.rodata .rodata
_lan91c96_driver_name: _lan91c96_name:
.byte "LANceGS",0 .byte "LANceGS",0
.data
_lan91c96_driver_io_base:
.word $c0b0
; -- LICENSE FOR lancegs.s -- ; -- LICENSE FOR lancegs.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License

View File

@ -1,7 +1,6 @@
; RR-Net driver ; RR-Net driver
.export _cs8900a_driver_name .export _cs8900a_name
.export _cs8900a_driver_io_base
__CBM__ = 1 __CBM__ = 1
@ -13,16 +12,10 @@ DYN_DRV = 0
.rodata .rodata
_cs8900a_driver_name: _cs8900a_name:
.byte "RR-Net",0 .byte "RR-Net",0
.data
_cs8900a_driver_io_base:
.word $de08
; -- LICENSE FOR rr-net.s -- ; -- LICENSE FOR rr-net.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License

View File

@ -1,7 +1,6 @@
; Uthernet driver ; Uthernet driver
.export _cs8900a_driver_name .export _cs8900a_name
.export _cs8900a_driver_io_base
__APPLE2__ = 1 __APPLE2__ = 1
@ -12,16 +11,10 @@ DYN_DRV = 0
.rodata .rodata
_cs8900a_driver_name: _cs8900a_name:
.byte "Uthernet",0 .byte "Uthernet",0
.data
_cs8900a_driver_io_base:
.word $c0b0
; -- LICENSE FOR uthernet.s -- ; -- LICENSE FOR uthernet.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License

View File

@ -1,7 +1,6 @@
; Uthernet II driver ; Uthernet II driver
.export _w5100_driver_name .export _w5100_name
.export _w5100_driver_io_base
__APPLE2__ = 1 __APPLE2__ = 1
@ -12,16 +11,10 @@ DYN_DRV = 0
.rodata .rodata
_w5100_driver_name: _w5100_name:
.byte "Uthernet II",0 .byte "Uthernet II",0
.data
_w5100_driver_io_base:
.word $c0b4
; -- LICENSE FOR uthernet2.s -- ; -- LICENSE FOR uthernet2.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License

View File

@ -1,7 +1,6 @@
; RR-Net driver, as seen on a VIC-20 (i.e. using a Masquerade adapter) ; RR-Net driver, as seen on a VIC-20 (i.e. using a Masquerade adapter)
.export _cs8900a_driver_name .export _cs8900a_name
.export _cs8900a_driver_io_base
__CBM__ = 1 __CBM__ = 1
@ -13,16 +12,10 @@ DYN_DRV = 0
.rodata .rodata
_cs8900a_driver_name: _cs8900a_name:
.asciiz "VIC20 RR-Net" .asciiz "VIC20 RR-Net"
.data
_cs8900a_driver_io_base:
.word $9808
; -- LICENSE FOR vic20-rr-net.s -- ; -- LICENSE FOR vic20-rr-net.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License

View File

@ -1,8 +1 @@
.export drv_init .exportzp eth_init_default = 0
.exportzp drv_init_default = 0
.code
drv_init:
rts

View File

@ -104,19 +104,22 @@ fixups = * - fixup
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
; 14 most significant bits are fixed up at runtime ; The addresses are fixed up at runtime
mode := $FFFC|0 mode := $C084
addr := $FFFC|1 addr := $C085
data := $FFFC|3 data := $C087
.data
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
.data
init: init:
; Save address of register base ; Convert slot number to slot I/O offset
asl
asl
asl
asl
sta reg sta reg
stx reg+1
; Start with first fixup location ; Start with first fixup location
lda #<(fixup01+1) lda #<(fixup01+1)
@ -128,13 +131,9 @@ init:
; Fixup address at location ; Fixup address at location
: lda (ptr),y : lda (ptr),y
and #$03 and #%10001111 ; Allow for re-init
ora reg ora reg
sta (ptr),y sta (ptr),y
iny
lda reg+1
sta (ptr),y
dey
; Advance to next fixup location ; Advance to next fixup location
inx inx
@ -147,9 +146,9 @@ init:
bcc :- bcc :-
inc ptr+1 inc ptr+1
bcs :- ; Always bcs :- ; Always
:
; Indirect Bus I/F mode, Address Auto-Increment ; Indirect Bus I/F mode, Address Auto-Increment
:
fixup01:lda mode fixup01:lda mode
ora #$03 ora #$03
fixup02:sta mode fixup02:sta mode

View File

@ -1,12 +1,10 @@
; WIZnet W5100 driver ; WIZnet W5100 driver
.import _w5100 .import _w5100
.import _w5100_driver_name .import _w5100_name
.import _w5100_driver_io_base
.export eth = _w5100 .export eth = _w5100
.export eth_driver_name = _w5100_driver_name .export eth_name = _w5100_name
.export eth_driver_io_base = _w5100_driver_io_base

View File

@ -26,8 +26,7 @@
.import ascii_to_native .import ascii_to_native
.import eth_driver_name .import eth_name
.import eth_driver_io_base
.importzp copy_src .importzp copy_src
.import cfg_mac .import cfg_mac
.import cfg_ip .import cfg_ip
@ -57,18 +56,8 @@ temp_ptr: .res 2
.endmacro .endmacro
.macro print_driver_init .macro print_driver_init
ldax #eth_driver_name ldax #eth_name
jsr print_ascii_as_native 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 ldax #init_msg
jsr print_ascii_as_native jsr print_ascii_as_native
.endmacro .endmacro
@ -97,13 +86,13 @@ temp_ptr: .res 2
.import print_a .import print_a
.import print_cr .import print_cr
.import eth_driver_name .import eth_name
print_ip_config: print_ip_config:
ldax #interface_type ldax #interface_type
jsr print_ascii_as_native jsr print_ascii_as_native
ldax #eth_driver_name ldax #eth_name
jsr print_ascii_as_native jsr print_ascii_as_native
jsr print_cr jsr print_cr

View File

@ -23,12 +23,12 @@
// //
extern uint8_t ip65_error; extern uint8_t ip65_error;
// Driver initialization parameter values // Ethernet driver initialization parameter values
// //
#ifdef __APPLE2__ #ifdef __APPLE2__
#define DRV_INIT_DEFAULT 3 // Apple II slot number #define ETH_INIT_DEFAULT 3 // Apple II slot number
#else #else
#define DRV_INIT_DEFAULT 0 // Unused #define ETH_INIT_DEFAULT 0 // Unused
#endif #endif
// Initialize the IP stack // 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 // except for dhcp_init which must also be called if the application
// is using DHCP rather than hardcoded IP configuration. // 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 // 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 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 uint8_t cfg_mac[6]; // MAC address of local machine
extern char eth_driver_name[]; // Zero terminated string containing driver name extern char eth_name[]; // Zero terminated string containing Ethernet driver name
extern uint8_t* eth_driver_io_base; // Ethernet chip I/O base address used by driver
// Main IP polling loop // Main IP polling loop
// //

View File

@ -11,15 +11,12 @@
.import dhcp_init .import dhcp_init
.import dhcp_server .import dhcp_server
.ifdef A2_SLOT_SCAN .importzp eth_init_default
.import drv_init
.endif
.macro init_ip_via_dhcp .macro init_ip_via_dhcp
.ifdef A2_SLOT_SCAN .ifdef A2_SLOT_SCAN
lda #1 lda #1
: pha : pha
jsr drv_init
jsr ip65_init jsr ip65_init
pla pla
bcc :+ bcc :+
@ -28,6 +25,7 @@
bcc :- bcc :-
: :
.else .else
lda #eth_init_default
jsr ip65_init jsr ip65_init
.endif .endif
php php

View File

@ -23,8 +23,8 @@ IP65OBJS=\
dottedquad_c.o \ dottedquad_c.o \
download.o \ download.o \
download_c.o \ download_c.o \
driver_c.o \
eth.o \ eth.o \
eth_c.o \
http.o \ http.o \
http_c.o \ http_c.o \
httpd.o \ httpd.o \

View File

@ -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

7
ip65/eth_c.s Normal file
View File

@ -0,0 +1,7 @@
.include "../inc/common.inc"
.export _eth_name
.import eth_name
_eth_name := eth_name

View File

@ -68,7 +68,7 @@ ip65_random_word:
; the only *_init routine that must be called by a user application, ; the only *_init routine that must be called by a user application,
; except for dhcp_init which must also be called if the application ; except for dhcp_init which must also be called if the application
; is using dhcp rather than hardcoded ip configuration ; 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 ; outputs: carry flag is set if there was an error, clear otherwise
ip65_init: ip65_init:
jsr eth_init ; initialize ethernet driver jsr eth_init ; initialize ethernet driver

View File

@ -9,10 +9,8 @@
.import ip65_process .import ip65_process
.import ip65_random_word .import ip65_random_word
.import ip65_error .import ip65_error
.import drv_init
_ip65_init: _ip65_init:
jsr drv_init
jsr ip65_init jsr ip65_init
ldx #$00 ldx #$00
txa txa

View File

@ -48,7 +48,7 @@ void main(void)
} }
printf("Init\n"); printf("Init\n");
if (ip65_init(DRV_INIT_DEFAULT)) if (ip65_init(ETH_INIT_DEFAULT))
{ {
error_exit(); error_exit();
} }

View File

@ -47,7 +47,7 @@ void main(void)
} }
printf("Init\n"); printf("Init\n");
if (ip65_init(DRV_INIT_DEFAULT)) if (ip65_init(ETH_INIT_DEFAULT))
{ {
error_exit(); error_exit();
} }