diff --git a/client/cfg/a2bin.cfg b/client/cfg/a2bin.cfg index 68fbc04..8382ad8 100644 --- a/client/cfg/a2bin.cfg +++ b/client/cfg/a2bin.cfg @@ -10,6 +10,7 @@ SEGMENTS { STARTUP: load = RAM,run=RAM, type = ro, define = yes; CODE: load = RAM, run=RAM, type = ro, define = yes; RODATA: load = RAM, run=RAM, type = ro , define = yes; + IP65_DEFAULTS: load = RAM, run=RAM, type = ro , define = yes; DATA: load = RAM, run=RAM, type = rw , define = yes; BSS: load=RAM, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; diff --git a/client/cfg/a2language_card.cfg b/client/cfg/a2language_card.cfg index ff8dd2b..87b0491 100644 --- a/client/cfg/a2language_card.cfg +++ b/client/cfg/a2language_card.cfg @@ -12,6 +12,7 @@ SEGMENTS { STARTUP: load = RAM,run=RAM, type = ro, define = yes; CODE: load = RAM, run=LANGUAGE_CARD, type = ro, define = yes; RODATA: load = RAM, run=LANGUAGE_CARD, type = ro , define = yes; + IP65_DEFAULTS: load = RAM, run=LANGUAGE_CARD, type = ro , define = yes; DATA: load = RAM, run=LANGUAGE_CARD, type = rw , define = yes; BSS: load=LANGUAGE_CARD, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; diff --git a/client/cfg/c64prg.cfg b/client/cfg/c64prg.cfg index e029d57..b59f2d5 100644 --- a/client/cfg/c64prg.cfg +++ b/client/cfg/c64prg.cfg @@ -8,7 +8,8 @@ SEGMENTS { STARTUP: load = RAM, type = ro ,define = yes; CODE: load = RAM, type = ro,define = yes; DATA: load = RAM, type = rw,define = yes; - RODATA: load = RAM, type = ro,define = yes; + RODATA: load = RAM, type = ro,define = yes; + IP65_DEFAULTS: load = RAM, type = rw,define = yes; BSS: load = RAM, type = bss; ZEROPAGE: load = ZP, type = zp; IP65ZP: load = IP65ZP, type = zp; diff --git a/client/cfg/rrbin.cfg b/client/cfg/rrbin.cfg index 45b9dc5..960c89a 100644 --- a/client/cfg/rrbin.cfg +++ b/client/cfg/rrbin.cfg @@ -4,13 +4,15 @@ MEMORY { IP65ZP: start = $A3, size = $0E, type = rw, define = yes; HEADER: start = $8000, size = $18, file = %O; - ROM: start = $8018, size = $1F00, define = yes, file = %O; + DEFAULTS: start = $8018, size = $1E, file = %O; + ROM: start = $8036, size = $1FC8, define = yes, file = %O; RAM: start = $C010, size = $0fE0, define = yes; } SEGMENTS { CARTRIDGE_HEADER: load = HEADER, type = ro; + IP65_DEFAULTS: load = DEFAULTS, type = ro; CODE: load = ROM, type = ro; RODATA: load = ROM, run=ROM, type = ro; DATA: load = ROM, run = RAM, type = rw, define = yes; diff --git a/client/ip65/config.s b/client/ip65/config.s index 309bb3e..16f9f6b 100644 --- a/client/ip65/config.s +++ b/client/ip65/config.s @@ -10,8 +10,11 @@ .export cfg_dns .export cfg_tftp_server .export cfg_get_configuration_ptr + .export cfg_init .export dhcp_server - + .import copymem + .importzp copy_src + .importzp copy_dest .code ;return a pointer to where the IP configuration is kept @@ -25,15 +28,39 @@ cfg_get_configuration_ptr: ldax #cfg_mac clc rts - -.data - -cfg_mac: .byte $00, $80, $10, $6d, $76, $30 ;mac address to be assigned to local machine -;cfg_ip: .byte 192, 168, 0, 64 -cfg_ip: .byte 0,0,0,0 ;ip address of local machine (will be overwritten if dhcp_init is called) -cfg_netmask: .byte 255, 255, 255, 0; netmask of local network (will be overwritten if dhcp_init is called) -cfg_gateway: .byte 0, 0, 0, 0 ;ip address of router on local network (will be overwritten if dhcp_init is called) -cfg_dns: .byte 0, 0, 0, 0; ip address of dns server to use (will be overwritten if dhcp_init is called) +;copy the IP stack defaults (probably stored in ROM) to the running values in RAM +;inputs: none +;outputs: AX = pointer to IP configuration. +cfg_init: + ldax #cfg_mac_default + stax copy_src + ldax #cfg_mac + stax copy_dest + ldax #cfg_size + jmp copymem + +.segment "IP65_DEFAULTS" +cfg_mac_default: .byte $00, $80, $10, $6d, $76, $30 ;mac address to be assigned to local machine +cfg_ip_default: .byte 192, 168, 1, 64 ;ip address of local machine (will be overwritten if dhcp_init is called) +;cfg_ip_default: .byte 0,0,0,0 ;ip address of local machine (will be overwritten if dhcp_init is called) +cfg_netmask_default: .byte 255, 255, 255, 0; netmask of local network (will be overwritten if dhcp_init is called) +;cfg_gateway_default: .byte 0, 0, 0, 0 ;ip address of router on local network (will be overwritten if dhcp_init is called) +cfg_gateway_default: .byte 192, 168, 1, 1 ;ip address of router on local network (will be overwritten if dhcp_init is called) +cfg_dns_default: .byte 0, 0, 0, 0; ip address of dns server to use (will be overwritten if dhcp_init is called) +dhcp_server_default: .res 4 ;will be set address of dhcp server that configuration was obtained from +cfg_tftp_server_default: .byte $ff,$ff,$ff,$ff ; ip address of server to send tftp requests to (can be a broadcast address) +cfg_end_defaults: +cfg_size=cfg_end_defaults-cfg_mac_default+1 + + +.bss + +cfg_mac: .res 6 ;mac address to be assigned to local machine +cfg_ip: .res 4 ;ip address of local machine (will be overwritten if dhcp_init is called) +cfg_netmask: .res 4, 0; netmask of local network (will be overwritten if dhcp_init is called) +cfg_gateway: .res 4 ;ip address of router on local network (will be overwritten if dhcp_init is called) +cfg_dns: .res 4; ip address of dns server to use (will be overwritten if dhcp_init is called) dhcp_server: .res 4 ;will be set address of dhcp server that configuration was obtained from -cfg_tftp_server: .byte $ff,$ff,$ff,$ff ; ip address of server to send tftp requests to (can be a broadcast address) \ No newline at end of file +cfg_tftp_server: .res 4 ; ip address of server to send tftp requests to (can be a broadcast address) + diff --git a/client/ip65/function_dispatcher.s b/client/ip65/function_dispatcher.s index 22a2a36..9eaa134 100644 --- a/client/ip65/function_dispatcher.s +++ b/client/ip65/function_dispatcher.s @@ -109,18 +109,23 @@ nb65_dispatcher: bne :+ lda irq_handler_installed_flag bne irq_handler_installed + jsr ip65_init + bcs init_failed + jsr dhcp_init + bcc dhcp_ok + jmp ip65_init ;if DHCP failed, then reinite the IP stack (which will reset IP address etc to cartridge default values) +dhcp_ok: ;install our IRQ handler ldax $314 ;previous IRQ handler stax jmp_old_irq+1 sei ;don't want any interrupts while we fiddle with the vector ldax #irq_handler stax $314 ;previous IRQ handler - cli sta irq_handler_installed_flag - jsr ip65_init - jmp dhcp_init + cli irq_handler_installed: clc +init_failed: rts : diff --git a/client/ip65/ip65.s b/client/ip65/ip65.s index 6ac7c99..e816b2c 100644 --- a/client/ip65/ip65.s +++ b/client/ip65/ip65.s @@ -1,6 +1,11 @@ ; ip65 main routines .include "../inc/common.i" + +.ifndef NB65_API_VERSION_NUMBER + .define EQU = + .include "../inc/nb65_constants.i" +.endif .export ip65_init .export ip65_process @@ -10,8 +15,9 @@ .export ip65_ctr_ip .export ip65_error + + .import cfg_init - .import eth_init .import timer_init .import arp_init @@ -44,15 +50,18 @@ ip65_error: .res 1 ;last error code ; inputs: none ; outputs: none ip65_init: - + jsr cfg_init ;copy default values (including MAC address) to RAM jsr eth_init ; initialize ethernet driver - bcs @fail + bcc @ok + lda #NB65_ERROR_DEVICE_FAILURE + sta ip65_error + rts +@ok: jsr timer_init ; initialize timer jsr arp_init ; initialize arp jsr ip_init ; initialize ip, icmp, udp, and tcp - clc -@fail: + clc rts diff --git a/client/nb65/nb65_c64.s b/client/nb65/nb65_c64.s index ae2d163..eda701b 100644 --- a/client/nb65/nb65_c64.s +++ b/client/nb65/nb65_c64.s @@ -50,6 +50,7 @@ .import timer_vbl_handler .import nb65_dispatcher .import ip65_process + .import ip65_init .import get_filtered_input .import filter_text .import filter_dns @@ -120,7 +121,6 @@ jmp nb65_dispatcher ; NB65_DISPATCH_VECTOR : entry point for NB65 functions jmp ip65_process ;NB65_PERIODIC_PROCESSING_VECTOR : routine to be periodically called to check for arrival of ethernet packets jmp timer_vbl_handler ;NB65_VBL_VECTOR : routine to be called during each vertical blank interrupt - .code @@ -175,6 +175,11 @@ ldax #init_msg jsr print nb65call #NB65_INITIALIZE + bcc main_menu + print_failed + jsr print_errorcode + jsr wait_for_keypress + jmp exit_to_basic main_menu: lda #21 ;make sure we are in upper case @@ -236,7 +241,7 @@ main_menu: jsr print jsr print_ip_config jsr print_cr - +@get_key_config_menu: jsr get_key cmp #KEYCODE_F1 bne @not_ip @@ -365,11 +370,18 @@ main_menu: @not_tftp_server: + cmp #KEYCODE_F6 + bne @not_reset + jsr ip65_init ;this will reset everything + jmp @change_config +@not_reset: +cmp #KEYCODE_F7 bne @not_main_menu jmp main_menu + @not_main_menu: - jmp @get_key + jmp @get_key_config_menu @resolve_error: @@ -550,21 +562,22 @@ netboot65_msg: .byte 0 main_menu_msg: .byte 13," MAIN MENU",13,13 -.byte "F1: TFTP BOOT F3: BASIC",13 -.byte "F5: UTILITIES F7: CONFIG",13,13 +.byte "F1: TFTP BOOT F3: BASIC",13 +.byte "F5: UTILITIES F7: CONFIG",13,13 .byte 0 util_menu_msg: .byte 13," UTILITIES",13,13 .byte "F1: ARP TABLE",13 -.byte " F7: MAIN MENU",13,13 +.byte " F7: MAIN MENU",13,13 .byte 0 config_menu_msg: .byte 13," CONFIGURATION",13,13 -.byte "F1: IP ADDRESS F2: NETMASK",13 -.byte "F3: GATEWAY F4: DNS SERVER",13 -.byte "F5: TFTP SERVER F6: MAIN MENU",13,13 +.byte "F1: IP ADDRESS F2: NETMASK",13 +.byte "F3: GATEWAY F4: DNS SERVER",13 +.byte "F5: TFTP SERVER F6: RESET TO DEFAULTS",13,13 +.byte "F7: MAIN MENU",13,13 .byte 0 downloading_msg: .asciiz "DOWNLOADING " diff --git a/client/nb65/set_ip_config.rb b/client/nb65/set_ip_config.rb new file mode 100644 index 0000000..c9d850c --- /dev/null +++ b/client/nb65/set_ip_config.rb @@ -0,0 +1,95 @@ +#cartridge offsets: +# $18=MAC address (6 bytes) +# $1E=IP address (4 bytes) +# $22=netmask (4 bytes) +# $26=gateway (4 bytes) +# $2A=DNS (4 bytes) +# $2E=TFTP server (4 bytes) + + +@cartridge_offsets={ +#symobol => offset, length + :mac=>[0x18,6], + :ip=>[0x1e,4], + :netmask=>[0x22,4], + :gateway=>[0x26,4], + :dns=>[0x2a,4], + :tftp=>[0x2e,4], + } + + @progname=File.basename($0) + def show_options + puts "valid options are: #{@cartridge_offsets.keys.join(", ")}" +end + def usage + puts "#{@progname}