mirror of
https://github.com/bobbimanners/emailler.git
synced 2024-08-20 02:29:32 +00:00
git-svn-id: http://svn.code.sf.net/p/netboot65/code@117 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
parent
945ace04a4
commit
76612411e4
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -9,6 +9,7 @@ SEGMENTS {
|
||||
CODE: load = RAM, type = ro,define = yes;
|
||||
DATA: load = RAM, type = rw,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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
@ -26,14 +29,38 @@ cfg_get_configuration_ptr:
|
||||
clc
|
||||
rts
|
||||
|
||||
.data
|
||||
;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
|
||||
|
||||
cfg_mac: .byte $00, $80, $10, $6d, $76, $30 ;mac address to be assigned to local machine
|
||||
;cfg_ip: .byte 192, 168, 0, 64
|
||||
.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
|
||||
|
||||
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)
|
||||
|
||||
.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)
|
||||
cfg_tftp_server: .res 4 ; ip address of server to send tftp requests to (can be a broadcast address)
|
||||
|
||||
|
@ -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
|
||||
:
|
||||
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
.include "../inc/common.i"
|
||||
|
||||
.ifndef NB65_API_VERSION_NUMBER
|
||||
.define EQU =
|
||||
.include "../inc/nb65_constants.i"
|
||||
.endif
|
||||
|
||||
.export ip65_init
|
||||
.export ip65_process
|
||||
|
||||
@ -11,6 +16,7 @@
|
||||
|
||||
.export ip65_error
|
||||
|
||||
.import cfg_init
|
||||
|
||||
.import eth_init
|
||||
.import timer_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:
|
||||
rts
|
||||
|
||||
|
||||
|
@ -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:
|
||||
@ -564,7 +576,8 @@ 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 "F5: TFTP SERVER F6: RESET TO DEFAULTS",13,13
|
||||
.byte "F7: MAIN MENU",13,13
|
||||
.byte 0
|
||||
|
||||
downloading_msg: .asciiz "DOWNLOADING "
|
||||
|
95
client/nb65/set_ip_config.rb
Normal file
95
client/nb65/set_ip_config.rb
Normal file
@ -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} <image> <option> <value> [<option> <value> ..]"
|
||||
puts "multiple options may be set"
|
||||
show_options
|
||||
end
|
||||
|
||||
number_of_options=ARGV.length
|
||||
usage unless number_of_options>=3
|
||||
usage unless (number_of_options%2) ==1 #must be an odd number of options
|
||||
filename=ARGV[0]
|
||||
if !(FileTest.file?(filename)) then
|
||||
puts "file '#{filename}' not found"
|
||||
exit
|
||||
end
|
||||
|
||||
|
||||
filebytes=File.open(filename,"rb").read
|
||||
|
||||
if !(filebytes[0x09,4]=="NB65") then
|
||||
puts "file '#{filename}' does not appear to be a netboot65 cartridge image"
|
||||
exit
|
||||
end
|
||||
|
||||
(number_of_options/2).times do |i|
|
||||
option=ARGV[i*2+1]
|
||||
value=ARGV[i*2+2]
|
||||
# puts "#{option} : #{value}"
|
||||
offsets=@cartridge_offsets[option.to_sym]
|
||||
if offsets.nil? then
|
||||
puts "invalid option #{option}"
|
||||
show_options
|
||||
exit
|
||||
end
|
||||
option_offset=offsets[0]
|
||||
option_length=offsets[1]
|
||||
|
||||
if option_length==6 then
|
||||
split_values=value.split(":")
|
||||
if (split_values.length!=6) || (split_values[5].nil?) then
|
||||
puts "'#{value}' is not a valid MAC address. (e.g. 12:34:56:78:ab:cd)"
|
||||
exit
|
||||
end
|
||||
mac=[]
|
||||
6.times do |j|
|
||||
mac[j]=split_values[j].hex
|
||||
# puts "#{split_values[j]}->#{"%02X" % mac[j]}"
|
||||
end
|
||||
packed_option=mac.pack("cccccc")
|
||||
else #it must be an IP
|
||||
split_values=value.split(".")
|
||||
if (split_values.length!=4) || (split_values[3].nil?) then
|
||||
puts "'#{value}' is not a valid IP format. (e.g. 192.168.1.64)"
|
||||
exit
|
||||
end
|
||||
ip=[]
|
||||
4.times do |j|
|
||||
ip[j]=split_values[j].to_i
|
||||
# puts "#{split_values[j]}->#{ip[j]}"
|
||||
if (ip[j]<0) || (ip[j]>255) then
|
||||
puts "'#{value}' is not a valid IP format. (e.g. 192.168.1.64)"
|
||||
exit
|
||||
end
|
||||
|
||||
end
|
||||
packed_option=ip.pack("cccc")
|
||||
end
|
||||
filebytes[option_offset,option_length]=packed_option
|
||||
end
|
||||
|
||||
filehandle=File.open(filename,"wb")
|
||||
filehandle<<filebytes
|
||||
filehandle.close
|
Loading…
Reference in New Issue
Block a user