git-svn-id: http://svn.code.sf.net/p/netboot65/code@115 93682198-c243-4bdb-bd91-e943c89aac3b

This commit is contained in:
jonnosan 2009-04-16 23:40:10 +00:00
parent e67eb412b5
commit c9b386c8de
7 changed files with 244 additions and 33 deletions

View File

@ -13,6 +13,13 @@
.export print_decimal
.export print_dotted_quad
.export print_arp_cache
.export mac_address_msg
.export ip_address_msg
.export netmask_msg
.export gateway_msg
.export dns_server_msg
.export tftp_server_msg
.import arp_cache
.importzp ac_size

View File

@ -54,7 +54,7 @@ NB65_GET_LAST_ERROR EQU $FF ;no inputs, outputs A EQU error code (fr
NB65_CFG_MAC EQU $00 ;6 byte MAC address
NB65_CFG_IP EQU $06 ;4 byte local IP address (will be overwritten by DHCP)
NB65_CFG_NETMASK EQU $0A ;4 byte local netmask (will be overwritten by DHCP)
NB65_CFG_GATEWAY EQU $0D ;4 byte local gateway (will be overwritten by DHCP)
NB65_CFG_GATEWAY EQU $0E ;4 byte local gateway (will be overwritten by DHCP)
NB65_CFG_DNS_SERVER EQU $12 ;4 byte IP address of DNS server (will be overwritten by DHCP)
NB65_CFG_DHCP_SERVER EQU $16 ;4 byte IP address of DHCP server (will only be set by DHCP initialisation)
NB65_DRIVER_NAME EQU $1A ;2 byte pointer to name of driver

View File

@ -21,6 +21,7 @@
.import ip65_error
.import tftp_clear_callbacks
.import tftp_download
.import tftp_upload
.import tftp_set_callback_vector
.import dns_ip
.import dns_resolve
@ -91,6 +92,14 @@ set_tftp_params:
rts
set_tftp_callback_vector:
ldy #NB65_TFTP_POINTER+1
lda (nb65_params),y
tax
dey
lda (nb65_params),y
jmp tftp_set_callback_vector
nb65_dispatcher:
stax nb65_params
stax old_ax
@ -293,15 +302,16 @@ irq_handler_installed:
cpy #NB65_TFTP_CALLBACK_DOWNLOAD
bne :+
jsr set_tftp_params
ldy #NB65_TFTP_POINTER+1
lda (nb65_params),y
tax
dey
lda (nb65_params),y
jsr tftp_set_callback_vector
jsr set_tftp_callback_vector
jmp tftp_download
:
cpy #NB65_TFTP_CALLBACK_UPLOAD
bne :+
jsr set_tftp_params
jsr set_tftp_callback_vector
jmp tftp_upload
:
cpy #NB65_PRINT_ASCIIZ
bne :+

View File

@ -419,7 +419,14 @@ tftp_in:
@skip_first_2_bytes_in_calculating_copy_src:
ldax #udp_inp+$0e
@got_pointer_to_tftp_data:
stax copy_src
ldax #output_buffer+2
stax copy_dest
ldax tftp_data_block_length
stax output_buffer
jsr copymem
ldax #output_buffer
jsr tftp_callback_vector
jsr send_ack
@ -477,6 +484,11 @@ tftp_in:
;copy to RAM
;assumes tftp_data_block_length has been set, and AX should point to start of data
copy_tftp_block_to_ram:
clc
adc #02 ;skip the 2 byte length at start of buffer
bcc :+
inx
:
stax copy_src
ldax tftp_current_memloc
stax copy_dest

View File

@ -53,14 +53,30 @@
.import get_filtered_input
.import filter_text
.import filter_dns
.import filter_ip
.import print_arp_cache
.import arp_calculate_gateway_mask
.import parse_dotted_quad
.import dotted_quad_value
.import cfg_ip
.import cfg_netmask
.import cfg_gateway
.import cfg_dns
.import cfg_tftp_server
.import print_dotted_quad
.import print_hex
.import print_ip_config
.import ok_msg
.import failed_msg
.import init_msg
.import ip_address_msg
.import netmask_msg
.import gateway_msg
.import dns_server_msg
.import tftp_server_msg
.import print_a
.import print_cr
.import print
@ -101,7 +117,7 @@ call_downloaded_prg:
.byte $01 ;NB65_API_VERSION
.byte BANKSWITCH_SUPPORT ;
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 packects
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
@ -218,14 +234,114 @@ main_menu:
jsr print
ldax #config_menu_msg
jsr print
ldax #current
jsr print
ldax #tftp_server
jsr print
ldax #cfg_tftp_server
jsr print_dotted_quad
jsr print_ip_config
jsr print_cr
ldax #enter_new_tftp_server
jsr get_key
cmp #KEYCODE_F1
bne @not_ip
ldax #new
jsr print
ldax #ip_address_msg
jsr print
jsr print_cr
ldax #filter_ip
jsr get_filtered_input
bcs @no_ip_address_entered
jsr parse_dotted_quad
bcc @no_ip_resolve_error
jmp @change_config
@no_ip_resolve_error:
ldax #dotted_quad_value
stax copy_src
ldax #cfg_ip
stax copy_dest
ldax #4
jsr copymem
@no_ip_address_entered:
jmp @change_config
@not_ip:
cmp #KEYCODE_F2
bne @not_netmask
ldax #new
jsr print
ldax #netmask_msg
jsr print
jsr print_cr
ldax #filter_ip
jsr get_filtered_input
bcs @no_netmask_entered
jsr parse_dotted_quad
bcc @no_netmask_resolve_error
jmp @change_config
@no_netmask_resolve_error:
ldax #dotted_quad_value
stax copy_src
ldax #cfg_netmask
stax copy_dest
ldax #4
jsr copymem
@no_netmask_entered:
jmp @change_config
@not_netmask:
cmp #KEYCODE_F3
bne @not_gateway
ldax #new
jsr print
ldax #gateway_msg
jsr print
jsr print_cr
ldax #filter_ip
jsr get_filtered_input
bcs @no_gateway_entered
jsr parse_dotted_quad
bcc @no_gateway_resolve_error
jmp @change_config
@no_gateway_resolve_error:
ldax #dotted_quad_value
stax copy_src
ldax #cfg_gateway
stax copy_dest
ldax #4
jsr copymem
jsr arp_calculate_gateway_mask ;we have modified our netmask, so we need to recalculate gw_test
@no_gateway_entered:
jmp @change_config
@not_gateway:
cmp #KEYCODE_F4
bne @not_dns_server
ldax #new
jsr print
ldax #dns_server_msg
jsr print
jsr print_cr
ldax #filter_ip
jsr get_filtered_input
bcs @no_dns_server_entered
jsr parse_dotted_quad
bcc @no_dns_resolve_error
jmp @change_config
@no_dns_resolve_error:
ldax #dotted_quad_value
stax copy_src
ldax #cfg_dns
stax copy_dest
ldax #4
jsr copymem
@no_dns_server_entered:
jmp @change_config
@not_dns_server:
cmp #KEYCODE_F5
bne @not_tftp_server
ldax #new
jsr print
ldax #tftp_server_msg
jsr print
jsr print_cr
ldax #filter_dns
@ -245,12 +361,22 @@ main_menu:
ldax #4
jsr copymem
@no_server_entered:
jmp @change_config
@not_tftp_server:
cmp #KEYCODE_F6
bne @not_main_menu
jmp main_menu
@not_main_menu:
jmp @get_key
@resolve_error:
print_failed
jsr wait_for_keypress
jmp main_menu
jsr @change_config
@tftp_boot:
@ -423,17 +549,23 @@ netboot65_msg:
.byte "NETBOOT65 - C64 NETWORK BOOT CLIENT V0.4",13
.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 0
util_menu_msg:
.byte 13," UTILITIES",13,13
.byte "F1: ARP TABLE",13
.byte " F7: MAIN MENU",13,13
.byte 0
config_menu_msg:
.byte "NETBOOT65 CONFIGURATION",13,0
.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 0
downloading_msg: .asciiz "DOWNLOADING "
@ -453,13 +585,9 @@ error_code:
current:
.byte "CURRENT ",0
enter_new_tftp_server:
.byte"ENTER "
new_tftp_server:
.byte "NEW "
tftp_server:
.byte "TFTP SERVER: ",0
new:
.byte"NEW ",0
tftp_dir_filemask:
.asciiz "*.PRG"

View File

@ -3,7 +3,9 @@
.define EQU =
.include "../inc/nb65_constants.i"
.endif
.include "../ip65/copymem.s"
; load A/X macro
.macro ldax arg
.if (.match (.left (1, arg), #)) ; immediate mode
@ -137,7 +139,9 @@ init:
call #NB65_PRINT_DOTTED_QUAD
print_cr
;tftp callback test
;tftp send test
lda #0
sta block_number
lda #$FF
@ -148,7 +152,25 @@ init:
bpl :-
ldax #test_file
stax nb65_param_buffer+NB65_TFTP_FILENAME
ldax #tftp_callback
ldax #tftp_upload_callback
stax nb65_param_buffer+NB65_TFTP_POINTER
ldax #nb65_param_buffer
call #NB65_TFTP_CALLBACK_UPLOAD
@download_test:
;tftp download callback test
lda #0
sta block_number
lda #$FF
ldx #$03
:
sta nb65_param_buffer,x ;set TFTP server as broadcast address
dex
bpl :-
ldax #test_file
stax nb65_param_buffer+NB65_TFTP_FILENAME
ldax #tftp_download_callback
stax nb65_param_buffer+NB65_TFTP_POINTER
ldax #nb65_param_buffer
call #NB65_TFTP_CALLBACK_DOWNLOAD
@ -176,14 +198,41 @@ init:
jmp @loop_forever
tftp_callback:
tftp_upload_callback:
stax copy_dest
inc block_number
print #sending
print #block_no
lda block_number
jsr print_hex
print_cr
lda block_number
asl
cmp #$10
beq @last_block
clc
adc #$a0
tax
lda #0
stax copy_src
ldax #$200
jsr copymem
ldax #$200
rts
@last_block:
ldax #0
rts
tftp_download_callback:
inc block_number
print #received
print #block_no
lda block_number
jsr print_hex
print_cr
rts
udp_callback:
ldax #nb65_param_buffer
@ -199,7 +248,8 @@ udp_callback:
print_cr
print #recv_from
print #received
print #from
ldax #nb65_param_buffer+NB65_REMOTE_IP
call #NB65_PRINT_DOTTED_QUAD
@ -312,8 +362,12 @@ hexdigits:
test_hostname:
.byte "RETROHACKERS.COM",0 ;this should be an A record
recv_from:
.asciiz "RECEIVED FROM: "
received:
.asciiz "RECEIVED "
sending:
.asciiz "SENDING "
from:
.asciiz " FROM: "
listening:
.byte "LISTENING ON UDP PORT 64",13,0
@ -361,7 +415,7 @@ reply_message_end:
reply_message_length=reply_message_end-reply_message
test_file:
.byte "BOOTA2.PG2",0
.byte "TESTFILE.BIN",0
nb65_signature:
.byte $4E,$42,$36,$35 ; "NB65" - API signature

Binary file not shown.