add startup options to wizboot

git-svn-id: http://svn.code.sf.net/p/netboot65/code@311 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
jonnosan 2011-05-28 11:11:07 +00:00
parent 82259443a8
commit cf599fe9a2
9 changed files with 867 additions and 10 deletions

View File

@ -5,7 +5,7 @@ AFLAGS=
INCFILES=\
../inc/common.i\
../inc/commonprint.i\
commonprint.i\
../inc/net.i\
../inc/menu.i\
../inc/kipper_constants.i\
@ -33,7 +33,6 @@ all: ip65 drivers\
kippergo.prg \
kippergo_rr.bin \
kipperdisk.d64 \
netbootwiz.bin \
kipperkart.o: kipperkart.s $(INCFILES) ../inc/ping.i ../inc/disk_transfer.i ../inc/sidplay.i ../inc/config_menu.i
$(AS) $(AFLAGS) -o $@ $<
@ -115,9 +114,6 @@ kkwiz.bin: kipperkart.o $(IP65WIZNETLIB) $(C64WIZNETLIB) $(INCFILES) ../cfg/c64_
ruby fix_cart.rb $@ 16384
# ruby set_ip_config.rb $@ mac auto
netbootwiz.bin: netboot.o $(IP65WIZNETLIB) $(C64WIZNETLIB) $(INCFILES) ../cfg/c64_8kcart.cfg
$(LD) -m netboot.map -vm -C ../cfg/c64_8kcart.cfg -o $@ $< $(IP65WIZNETLIB) $(C64WIZNETLIB)
ruby fix_cart.rb $@ 8192

View File

@ -80,6 +80,9 @@ DEFAULT_W5100_BASE = $DE04
;base address
eth_init:
lda $de01
eor #$01
sta $de01
ldax #DEFAULT_W5100_BASE

View File

@ -1 +1 @@
.byte "1.0.38"
.byte "1.0.39"

View File

@ -18,10 +18,11 @@
.export tftp_upload
.export tftp_data_block_length
.export tftp_set_callback_vector
.export tftp_callback_vector
.export tftp_clear_callbacks
.export tftp_filesize
.export tftp_upload_from_memory
.import ip65_process
.import ip65_process
.import ip65_error
@ -160,6 +161,7 @@ set_tftp_opcode:
ldx #$69
inc tftp_client_port_low_byte ;each transfer uses a different client port
lda tftp_client_port_low_byte ;so we don't get confused by late replies to a previous call
jsr udp_add_listener
bcc :+ ;bail if we couldn't listen on the port we want
@ -171,7 +173,7 @@ set_tftp_opcode:
lda #TFTP_MAX_RESENDS
sta tftp_resend_counter
@outer_delay_loop:
jsr timer_read
jsr timer_read
txa
and #TFTP_TIMER_MASK
sta tftp_timer ;we only care about the high byte
@ -181,9 +183,11 @@ set_tftp_opcode:
cmp #tftp_initializing
bne @not_initializing
jsr send_request_packet
jmp @inner_delay_loop
@not_initializing:
cmp #tftp_error
bne @not_error

View File

@ -1,8 +1,37 @@
AS=ca65
LD=ld65
CFLAGS=-Oirs -t $(TARGET)
AFLAGS=
INCFILES=\
../inc/common.i\
../inc/commonprint.i\
../inc/net.i\
../inc/menu.i\
../inc/kipper_constants.i\
../inc/version.i\
IP65LIB=../ip65/ip65.lib
IP65TCPLIB=../ip65/ip65_tcp.lib
C64RRNETLIB=../drivers/c64rrnet.lib
C64WIZNETLIB=../drivers/c64wiznet.lib
IP65WIZNETLIB=../ip65/ip65_wiznet.lib
all: kipperwizdisk.d64
all: ip65 drivers\
wizboot.bin \
wizboot2.prg \
bootc64.prg \
cartheader.prg \
wizboot.prg \
%.o: %.s $(INCFILES)
$(AS) $(AFLAGS) $<
%.prg: %.o $(IP65WIZNETLIB) $(C64WIZNETLIB) $(INCFILES) ../cfg/c64prg.cfg
$(LD) -m $*.map -vm -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65WIZNETLIB) $(C64WIZNETLIB)
#../basic/wizkb.prg ../basic/wizbob.prg
kipperwizdisk.d64: ../carts/kkwiz.prg ../kipperterm2/kt2wiz.prg
ripxplore.rb --init CbmDos $@ -a ../carts/kkwiz.prg
@ -11,3 +40,25 @@ kipperwizdisk.d64: ../carts/kkwiz.prg ../kipperterm2/kt2wiz.prg
ripxplore.rb $@ -a ../kipperterm2/kt2wiz.prg -t C64Prg
ripxplore.rb $@ -a ../examples/webnoter.prg -t C64Prg
cp $@ ../../server/boot/
wizboot.bin: wizboot.o $(IP65WIZNETLIB) $(C64WIZNETLIB) $(INCFILES) ../cfg/c64_8kcart.cfg
$(LD) -m wizboot.map -vm -C ../cfg/c64_8kcart.cfg -o $@ $< $(IP65WIZNETLIB) $(C64WIZNETLIB)
ruby ../carts/fix_cart.rb $@ 8192
wizboot.prg: wizboot.bin cartheader.prg
cat cartheader.prg wizboot.bin > wizboot.prg
clean:
rm -f *.o *.bin *.map *.prg *.pg2 *.dsk *.d64
distclean: clean
rm -f *~
ip65:
make -C ../ip65 all
drivers:
make -C ../drivers all
bootc64.prg:
cp wizboot.prg ../../server/boot/bootc64.prg

View File

@ -0,0 +1,54 @@
.include "../inc/common.i"
.import copymem
.importzp copy_src
.importzp copy_dest
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
.word basicstub ; load address
basicstub:
.word @nextline
.word 2003
.byte $9e
.byte <(((init / 1000) .mod 10) + $30)
.byte <(((init / 100 ) .mod 10) + $30)
.byte <(((init / 10 ) .mod 10) + $30)
.byte <(((init ) .mod 10) + $30)
.byte 0
@nextline:
.word 0
init:
;copy BASIC to RAM
ldax #$A000
stax copy_src
stax copy_dest
ldax #$2000
jsr copymem
;copy cart data from end of file to $8000 (RAM)
ldax #cart_data
stax copy_src
ldax #$8000
stax copy_dest
ldax #$2000
jsr copymem
;swap out the cartridge (also swaps out BASIC)
lda $01
and #$fe ;reset bit 0
sta $01
;execute the cartridge from RAM
jmp ($8002)
.bss
cart_data: ;this should point to where the cart data gets appended.
.res $2000

381
client/wiznet/commonprint.i Normal file
View File

@ -0,0 +1,381 @@
.ifndef KPR_API_VERSION_NUMBER
.define EQU =
.include "../inc/kipper_constants.i"
.endif
.export print_hex
.export print_ip_config
.export dhcp_msg
.export ok_msg
.export failed_msg
.export init_msg
.export print
.export print
.export print_integer
.export print_dotted_quad
.export mac_address_msg
.export ip_address_msg
.export netmask_msg
.export gateway_msg
.export dns_server_msg
.export tftp_server_msg
.import ip65_error
.export print_errorcode
.export press_a_key_to_continue
.import eth_driver_name
.import eth_driver_io_base
.importzp copy_src
.import cfg_tftp_server
;reuse the copy_src zero page var
pptr = copy_src
.bss
temp_bin: .res 2
temp_bcd: .res 3
temp_ptr: .res 2
.code
.macro print_driver_init
ldax #eth_driver_name
jsr print
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
jsr print
.endmacro
.macro print_dhcp_init
ldax #dhcp_msg
jsr print
ldax #init_msg
jsr print
.endmacro
.macro print_failed
ldax #failed_msg
jsr print
jsr print_cr
.endmacro
.macro print_ok
ldax #ok_msg
jsr print
jsr print_cr
.endmacro
.code
.import print_a
.import print_cr
.import eth_driver_name
print_ip_config:
ldax #interface_type
jsr print
ldax #eth_driver_name
jsr print
jsr print_cr
ldax #mac_address_msg
jsr print
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
;first 6 bytes of cfg_get_configuration_ptr is MAC address
jsr print_mac
jsr print_cr
ldax #ip_address_msg
jsr print
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
adc #KPR_CFG_IP
bcc :+
inx
:
jsr print_dotted_quad
jsr print_cr
ldax #netmask_msg
jsr print
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
adc #KPR_CFG_NETMASK
bcc :+
inx
:
jsr print_dotted_quad
jsr print_cr
ldax #gateway_msg
jsr print
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
adc #KPR_CFG_GATEWAY
bcc :+
inx
:
jsr print_dotted_quad
jsr print_cr
ldax #dns_server_msg
jsr print
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
adc #KPR_CFG_DNS_SERVER
bcc :+
inx
: jsr print_dotted_quad
jsr print_cr
ldax #tftp_server_msg
jsr print
ldax #cfg_tftp_server
jsr print_dotted_quad
jsr print_cr
ldax #dhcp_server_msg
jsr print
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
adc #KPR_CFG_DHCP_SERVER
bcc :+
inx
:
jsr print_dotted_quad
jsr print_cr
rts
print:
sta pptr
stx pptr + 1
@print_loop:
ldy #0
lda (pptr),y
beq @done_print
jsr print_a
inc pptr
bne @print_loop
inc pptr+1
bne @print_loop ;if we ever get to $ffff, we've probably gone far enough ;-)
@done_print:
rts
;print the 4 bytes pointed at by AX as dotted decimals
print_dotted_quad:
sta pptr
stx pptr + 1
lda #0
@print_one_byte:
pha
tay
lda (pptr),y
ldx #0
jsr print_integer
pla
cmp #3
beq @done
clc
adc #1
pha
lda #'.'
jsr print_a
pla
bne @print_one_byte
@done:
rts
;print 6 bytes printed at by AX as a MAC address
print_mac:
stax pptr
ldy #0
@one_mac_digit:
tya ;just to set the Z flag
pha
beq @dont_print_colon
lda #':'
jsr print_a
@dont_print_colon:
pla
tay
lda (pptr),y
jsr print_hex
iny
cpy #06
bne @one_mac_digit
rts
print_integer: ;print 16 bit number in AX as a decimal number
;hex to bcd routine taken from Andrew Jacob's code at http://www.6502.org/source/integers/hex2dec-more.htm
stax temp_bin
sed ; Switch to decimal mode
lda #0 ; Ensure the result is clear
sta temp_bcd
sta temp_bcd+1
sta temp_bcd+2
ldx #16 ; The number of source bits
:
asl temp_bin+0 ; Shift out one bit
rol temp_bin+1
lda temp_bcd+0 ; And add into result
adc temp_bcd+0
sta temp_bcd+0
lda temp_bcd+1 ; propagating any carry
adc temp_bcd+1
sta temp_bcd+1
lda temp_bcd+2 ; ... thru whole result
adc temp_bcd+2
sta temp_bcd+2
dex ; And repeat for next bit
bne :-
stx temp_bin+1 ;x is now zero - reuse temp_bin as a count of non-zero digits
cld ;back to binary
ldx #2
stx temp_bin+1 ;reuse temp_bin+1 as loop counter
@print_one_byte:
ldx temp_bin+1
lda temp_bcd,x
pha
lsr
lsr
lsr
lsr
jsr @print_one_digit
pla
and #$0f
jsr @print_one_digit
dec temp_bin+1
bpl @print_one_byte
rts
@print_one_digit:
cmp #0
beq @this_digit_is_zero
inc temp_bin ;increment count of non-zero digits
@ok_to_print:
clc
adc #'0'
jsr print_a
rts
@this_digit_is_zero:
ldx temp_bin ;how many non-zero digits have we printed?
bne @ok_to_print
ldx temp_bin+1 ;how many digits are left to print?
bne @this_is_not_last_digit
inc temp_bin ;to get to this point, this must be the high nibble of the last byte.
;by making 'count of non-zero digits' to be >0, we force printing of the last digit
@this_is_not_last_digit:
rts
print_hex:
pha
pha
lsr
lsr
lsr
lsr
tax
lda hexdigits,x
jsr print_a
pla
and #$0F
tax
lda hexdigits,x
jsr print_a
pla
rts
print_errorcode:
ldax #error_code
jsr print
lda ip65_error
jsr print_hex
jmp print_cr
.rodata
hexdigits:
.byte "0123456789abcdef"
interface_type:
.byte "interface : ",0
mac_address_msg:
.byte "mac address : ", 0
ip_address_msg:
.byte "ip address : ", 0
netmask_msg:
.byte "netmask : ", 0
gateway_msg:
.byte "gateway : ", 0
dns_server_msg:
.byte "dns server : ", 0
dhcp_server_msg:
.byte "dhcp server : ", 0
tftp_server_msg:
.byte "tftp server : ", 0
dhcp_msg:
.byte "dhcp",0
init_msg:
.byte " initializing ",0
failed_msg:
.byte "failed", 0
ok_msg:
.byte "ok", 0
dns_lookup_failed_msg:
.byte "dns lookup failed", 0
error_code:
.asciiz "error code: "
press_a_key_to_continue:
.byte "press a key to continue",10,0
;-- LICENSE FOR commonprint.i --
; 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 --

316
client/wiznet/wizboot.s Normal file
View File

@ -0,0 +1,316 @@
; #############
;
; jonno@jamtronix.com - May 2011
;
.include "../inc/common.i"
.include "commonprint.i"
.import ip65_init
.import dhcp_init
.import tftp_ip
.importzp tftp_filename
.import tftp_load_address
.import tftp_download
.import tftp_callback_vector
.import cls
.import beep
.import exit_to_basic
.import timer_vbl_handler
.import get_key_ip65
.import cfg_ip
.import cfg_netmask
.import cfg_gateway
.import cfg_dns
.import cfg_tftp_server
.import cfg_get_configuration_ptr
.import dns_ip
.import dns_set_hostname
.import dns_resolve
.import copymem
.importzp copy_src
.importzp copy_dest
.import get_filtered_input
.import __DATA_LOAD__
.import __DATA_RUN__
.import __DATA_SIZE__
.import __SELF_MODIFIED_CODE_LOAD__
.import __SELF_MODIFIED_CODE_RUN__
.import __SELF_MODIFIED_CODE_SIZE__
SCNKEY=$FF9F ;Query keyboard - put matrix code into $00CB & status of shift keys $028D
.bss
tmp_load_address: .res 2
shift_pressed_on_bootup : .res 1
.data
exit_cart:
call_downloaded_prg:
jsr $0000 ;overwritten when we load a file
jmp warm_init
.segment "CARTRIDGE_HEADER"
.word cold_init ;cold start vector
.word warm_init ;warm start vector
.byte $C3,$C2,$CD,$38,$30 ; "CBM80"
.byte $0,$0,$0 ;reserved for future use
.byte $0,$0,$0 ;reserved for future use
.byte $0,$0,$0 ;reserved for future use
.byte $0,$0,$0 ;reserved for future use
.byte $0,$0,$0 ;reserved for future use
.code
cold_init:
;first let the kernal do a normal startup
sei
jsr $fda3 ;initialize CIA I/O
jsr $fd50 ;RAM test, set pointers
jsr $fd15 ;set vectors for KERNAL
jsr $ff5B ;init. VIC
cli ;KERNAL init. finished
warm_init:
jsr SCNKEY ;Query keyboard - put matrix code into $00CB & status of shift keys $028D
lda $028D
and #$02
beq @commodore_key_not_pressed
jmp $e394
@commodore_key_not_pressed:
lda $028D
and #$01
sta shift_pressed_on_bootup
;set some funky colours
LDA #$05 ;green
STA $D020 ;border
LDA #$00 ;black
STA $D021 ;background
lda #$05 ;petscii for white text
jsr print_a
;relocate our r/w data
ldax #__DATA_LOAD__
stax copy_src
ldax #__DATA_RUN__
stax copy_dest
ldax #__DATA_SIZE__
jsr copymem
ldax #__SELF_MODIFIED_CODE_LOAD__
stax copy_src
ldax #__SELF_MODIFIED_CODE_RUN__
stax copy_dest
ldax #__SELF_MODIFIED_CODE_SIZE__
jsr copymem
ldax #wizboot_msg
jsr print
;monkey patch the TFTP callback handler
ldax tftp_callback_vector+1
stax new_tftp_callback_vector+1
ldax #new_tftp_callback_vector
stax tftp_callback_vector+1
jsr ip65_init
bcs init_failed
jsr dhcp_init
bcc init_ok
init_failed:
jsr print_errorcode
jsr print_ip_config
flash_forever:
inc $d020
jmp flash_forever
init_ok:
lda shift_pressed_on_bootup
bne @skip_resolving_tftp_hostname
ldax #resolving_tftp_hostname
jsr print
jsr print_cr
ldax #tftp_hostname
jsr dns_set_hostname
bcs init_failed
jsr dns_resolve
bcs init_failed
ldx #$03
@copy_tftp_ip_loop:
lda dns_ip,x
sta cfg_tftp_server,x
dex
bpl @copy_tftp_ip_loop
@skip_resolving_tftp_hostname:
ldx #$03
:
lda cfg_tftp_server,x
sta tftp_ip,x
dex
bpl :-
jsr print_cr
jsr print_ip_config
tftp_boot:
ldax #tftp_file
stax tftp_filename
ldax #$0000 ;load address will be first 2 bytes of file we download (LO/HI order)
stax tftp_load_address
ldax #downloading_msg
jsr print
ldax tftp_filename
jsr print
jsr print_cr
jsr tftp_download
bcc file_downloaded_ok
ldax #tftp_download_fail_msg
jsr print
jsr print_errorcode
jsr wait_for_keypress
return_to_main:
jmp tftp_boot
file_downloaded_ok:
ldax #tftp_download_ok_msg
jsr print
ldax tftp_load_address
boot_into_file:
stax tmp_load_address ;use the param buffer as a temp holding place for the load address
;get ready to bank out
jsr $ffe7 ; make sure all files have been closed.
;check whether the file we just downloaded was a BASIC prg
lda tmp_load_address
cmp #01
bne @not_a_basic_file
lda tmp_load_address+1
cmp #$08
bne @not_a_basic_file
jsr $e453 ;set BASIC vectors
jsr $e3bf ;initialize BASIC
jsr $a86e
jsr $a533 ; re-bind BASIC lines
ldx $22 ;load end-of-BASIC pointer (lo byte)
ldy $23 ;load end-of-BASIC pointer (hi byte)
stx $2d ;save end-of-BASIC pointer (lo byte)
sty $2e ;save end-of-BASIC pointer (hi byte)
jsr $a659 ; CLR (reset variables)
ldax #$a7ae ; jump to BASIC interpreter loop
jmp exit_cart_via_ax
@not_a_basic_file:
ldax tmp_load_address
exit_cart_via_ax:
sta call_downloaded_prg+1
stx call_downloaded_prg+2
jmp exit_cart
wait_for_keypress:
ldax #press_a_key_to_continue
jsr print
@loop:
jsr $ffe4
beq @loop
rts
get_key:
@loop:
jsr $ffe4
beq @loop
rts
.rodata
wizboot_msg:
.byte 147,14,13,"wiznet cart - v"
.include "../inc/version.i"
.byte 13
.byte 13," hold c= for basic / shift for lan boot",13,13
.byte 0
downloading_msg: .byte 13,"downloading ",0
tftp_download_fail_msg:
.byte "download failed", 13, 0
tftp_download_ok_msg:
.byte 13,"download ok", 13, 0
tftp_file:
.asciiz "bootc64.prg"
resolving_tftp_hostname:
.byte "resolving "
tftp_hostname:
.asciiz "jamtronix.com"
.data
new_tftp_callback_vector:
jsr $ffff
lda #'.'
jmp print_a
;we need a 'dummy' segment here - some drivers use this segment (e.g. wiznet), some don't (e.g. rr-net)
;if we don't declare this, we get an 'undefined segment' error when linking to a driver that doesn't use it.
.segment "SELF_MODIFIED_CODE"
;-- LICENSE FOR wizboot.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 wizboot.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2011
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

52
client/wiznet/wizboot2.s Normal file
View File

@ -0,0 +1,52 @@
.include "../inc/common.i"
.import cfg_get_configuration_ptr
.include "../inc/commonprint.i"
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
.word basicstub ; load address
basicstub:
.word @nextline
.word 2003
.byte $9e
.byte <(((init / 1000) .mod 10) + $30)
.byte <(((init / 100 ) .mod 10) + $30)
.byte <(((init / 10 ) .mod 10) + $30)
.byte <(((init ) .mod 10) + $30)
.byte 0
@nextline:
.word 0
init:
ldax #hello
jsr print
:
inc $d020
jmp :-
.data
hello: .byte "hello world!",0
;-- LICENSE FOR wizboot2.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 wizboot2.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2011
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --