diff --git a/client/clients/rrnetboot.s b/client/clients/rrnetboot.s index 5376c67..25c7d5f 100644 --- a/client/clients/rrnetboot.s +++ b/client/clients/rrnetboot.s @@ -1,4 +1,4 @@ -;############# +; ############# ; ; This will boot a C64 with RR-NET from the network ; requires @@ -9,18 +9,17 @@ ; jonno@jamtronix.com - January 2009 ; -RRNETBOOT_IP65_DISPATCHER = $800d -RRNETBOOT_IP65_PROCESS =$8010 -RRNETBOOT_IP65_VBL =$8013 - - +NB65_DISPATCH_VECTOR = $800d +NB65_PERIODIC_PROCESSING_VECTOR =$8010 +NB65_VBL_VECTOR =$8013 + .include "../inc/nb65_constants.i" .include "../inc/common.i" .include "../inc/commonprint.i" .include "../inc/menu.i" .include "../inc/net.i" .include "../inc/c64keycodes.i" - .include "../inc/ip65_function_numbers.i" + .import cls .import get_key .import beep @@ -45,22 +44,22 @@ RRNETBOOT_IP65_VBL =$8013 .import __DATA_SIZE__ .bss - -;temp_bin: .res 1 -;temp_bcd: .res 2 + +ip65_param_buffer: .res $10 bin_file_jmp: .res 3 tftp_dir_buffer: .res 2000 + .segment "CARTRIDGE_HEADER" .word init ;cold start vector .word init ;warm start vector .byte $C3,$C2,$CD,$38,$30 ; "CBM80" .byte "NB65" ;netboot 65 signature -jmp ip65_dispatcher ; RRNETBOOT_IP65_DISPATCHER : entry point for IP65 functions -jmp ip65_process ;RRNETBOOT_IP65_PROCESS : routine to be periodically called to check for arrival of ethernet packects -jmp timer_vbl_handler ;RRNETBOOT_IP65_VBL : routine to be called during each vertical blank interrupt +jmp ip65_dispatcher ; NB65_DISPATCH_VECTOR : entry point for IP65 functions +jmp ip65_process ;NB65_PERIODIC_PROCESSING_VECTOR : routine to be periodically called to check for arrival of ethernet packects +jmp timer_vbl_handler ;NB65_VBL_VECTOR : routine to be called during each vertical blank interrupt .data jmp_old_irq: @@ -71,7 +70,7 @@ jmp_old_irq: irq_handler: - jsr RRNETBOOT_IP65_VBL + jsr NB65_VBL_VECTOR jmp jmp_old_irq remove_irq_handler: @@ -131,9 +130,14 @@ init: @tftp_boot: -print_driver_init - ldy #FN_IP65_INIT - jsr RRNETBOOT_IP65_DISPATCHER + ldy #NB65_GET_DRIVER_NAME + jsr NB65_DISPATCH_VECTOR + jsr print + ldax #init_msg + jsr print + + ldy #NB65_INIT_IP + jsr NB65_DISPATCH_VECTOR bcc :+ print_failed @@ -144,8 +148,8 @@ print_driver_init print_dhcp_init - ldy #FN_DHCP_INIT - jsr RRNETBOOT_IP65_DISPATCHER + ldy #NB65_INIT_DHCP + jsr NB65_DISPATCH_VECTOR bcc :+ print_failed jmp bad_boot @@ -154,7 +158,7 @@ print_driver_init jsr print_ip_config - ldx #3 + ldx #3 : lda cfg_tftp_server,x sta tftp_ip,x diff --git a/client/inc/commonprint.i b/client/inc/commonprint.i index 09b875c..631f4c6 100644 --- a/client/inc/commonprint.i +++ b/client/inc/commonprint.i @@ -1,4 +1,8 @@ - .zeropage +.ifndef NB65_API_VERSION +.include "../inc/nb65_constants.i" +.endif + +.zeropage pptr: .res 2 .bss temp_bin: .res 1 @@ -38,41 +42,66 @@ temp_bcd: .res 2 .import print_a .import print_cr .import cs_driver_name - +.import cfg_get_configuration_ptr print_ip_config: + + ldax #ip_address_msg jsr print - ldax #cfg_ip + jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear + adc #NB65_CFG_IP + bcc :+ + inx +: jsr print_dotted_quad jsr print_cr ldax #netmask_msg jsr print - ldax #cfg_netmask + jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear + adc #NB65_CFG_NETMASK + bcc :+ + inx +: jsr print_dotted_quad jsr print_cr ldax #gateway_msg jsr print - ldax #cfg_gateway + jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear + adc #NB65_CFG_GATEWAY + bcc :+ + inx +: jsr print_dotted_quad jsr print_cr ldax #dns_server_msg jsr print - ldax #cfg_dns - jsr print_dotted_quad + jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear + adc #NB65_CFG_DNS_SERVER + bcc :+ + inx +: jsr print_dotted_quad jsr print_cr ldax #dhcp_server_msg jsr print - ldax #dhcp_server + jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear + adc #NB65_CFG_DHCP_SERVER + bcc :+ + inx +: jsr print_dotted_quad jsr print_cr ldax #tftp_server_msg jsr print - ldax #cfg_tftp_server + jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear + adc #NB65_CFG_TFTP_SERVER + bcc :+ + inx +: jsr print_dotted_quad jsr print_cr diff --git a/client/inc/nb65_constants.i b/client/inc/nb65_constants.i new file mode 100644 index 0000000..49f57a8 --- /dev/null +++ b/client/inc/nb65_constants.i @@ -0,0 +1,17 @@ + +NB65_API_VERSION=$0001 + +;offsets in NB65 configuration structure +NB65_CFG_MAC = $00 ;6 byte MAC address +NB65_CFG_IP = NB65_CFG_MAC+$06 ;4 byte local IP address (will be overwritten by DHCP) +NB65_CFG_NETMASK = NB65_CFG_IP+$04 ;4 byte local netmask (will be overwritten by DHCP) +NB65_CFG_GATEWAY = NB65_CFG_NETMASK+$04 ;4 byte local gateway (will be overwritten by DHCP) +NB65_CFG_DNS_SERVER = NB65_CFG_GATEWAY+$04 ;4 byte IP address of DNS server (will be overwritten by DHCP) +NB65_CFG_TFTP_SERVER = NB65_CFG_DNS_SERVER+$04 ;4 byte IP address of TFTP server (can be broadcast address e.g. 255.255.255.255) +NB65_CFG_DHCP_SERVER = NB65_CFG_TFTP_SERVER+$04 ;4 byte IP address of DHCP server (will only be set by DHCP initialisation) + +NB65_GET_API_VERSION =0 ;no inputs, outputs X=major version number, A=minor version number +NB65_GET_DRIVER_NAME =1 ;no inputs, AX=pointer to asciiz driver name +NB65_GET_IP_CONFIG_PTR =2 ;no inputs, AX=pointer to IP configuration structure (which can be modified) +NB65_INIT_IP =3 ;no inputs or outputs +NB65_INIT_DHCP =4 ;no inputs or outputs diff --git a/client/ip65/config.s b/client/ip65/config.s index 22ff5d7..14edefb 100644 --- a/client/ip65/config.s +++ b/client/ip65/config.s @@ -1,5 +1,7 @@ ;IP configuration defaults ;most of these will be overwritten if dhcp is used for configuration + +.include "../inc/common.i" .export cfg_mac .export cfg_ip @@ -7,6 +9,22 @@ .export cfg_gateway .export cfg_dns .export cfg_tftp_server + .export cfg_get_configuration_ptr + .export dhcp_server + +.code + +;return a pointer to where the IP configuration is kept +;this is really only useful for the NB65 API - for anything +;linking directly against ip65, you would just import the +;address of the individual configuration elements, rather +;than use a base pointer+offsets to find each item. +;inputs: none +;outputs: AX = pointer to IP configuration. +cfg_get_configuration_ptr: + ldax #cfg_mac + clc + rts .data @@ -18,4 +36,4 @@ cfg_netmask: .byte 255, 255, 255, 0; netmask of local network (will be overwritt 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) 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 +dhcp_server: .res 4 ;will be set address of dhcp server that configuration was obtained from \ No newline at end of file diff --git a/client/ip65/function_dispatcher.s b/client/ip65/function_dispatcher.s index 50d1c60..dee5a01 100644 --- a/client/ip65/function_dispatcher.s +++ b/client/ip65/function_dispatcher.s @@ -1,8 +1,11 @@ -.include "../inc/ip65_function_numbers.i" + +.include "../inc/nb65_constants.i" +.include "../inc/common.i" .import ip65_init .import dhcp_init - +.import cs_driver_name +.import cfg_get_configuration_ptr .export ip65_dispatcher @@ -10,12 +13,31 @@ ip65_dispatcher: - cpy #FN_IP65_INIT + cpy #NB65_GET_API_VERSION + bne :+ + ldax #NB65_API_VERSION + clc + rts +: + + cpy #NB65_GET_DRIVER_NAME + bne :+ + ldax #cs_driver_name + clc + rts +: + + cpy #NB65_GET_IP_CONFIG_PTR + bne :+ + jmp cfg_get_configuration_ptr +: + + cpy #NB65_INIT_IP bne :+ jmp ip65_init : - cpy #FN_DHCP_INIT + cpy #NB65_INIT_DHCP bne :+ jmp dhcp_init :