Skip to content

Commit

Permalink
go some way towards having etherkick reset to non-etherkicking mode
Browse files Browse the repository at this point in the history
to simplify debugging.
  • Loading branch information
gardners committed Apr 19, 2015
1 parent bf386b4 commit 84e573d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
4 changes: 3 additions & 1 deletion etherkick.c
Expand Up @@ -20,6 +20,8 @@ unsigned char all_done_routine[128]={

// Routine to copy memory from $0004000-$0007FFF to $FFF8000-$FFFBFFF,
// and then jump to $8100 to simulate reset.
// Actually, we jump to $8200, which by convention must have a reset entry point
// that disables etherkick until next boot, so that no switch fiddling is required.
unsigned char kickstart_replace_routine[128]={
0xa9, 0x00, 0x5b, 0xa9, 0x00, 0x85, 0x80, 0xa9,
0x40, 0x85, 0x81, 0xa9, 0x00, 0x85, 0x82, 0xa9,
Expand All @@ -28,7 +30,7 @@ unsigned char kickstart_replace_routine[128]={
0x0f, 0x85, 0x87, 0xa3, 0x00, 0xea, 0xb2, 0x80,
0xea, 0x92, 0x84, 0x1b, 0xd0, 0xf7, 0xe6, 0x81,
0xe6, 0x85, 0xa5, 0x81, 0xc9, 0x80, 0xd0, 0xed,
0x4c, 0x00, 0x81
0x4c, 0x00, 0x81
};

unsigned char dma_load_routine[128+1024]={
Expand Down
46 changes: 38 additions & 8 deletions kickstart.a65
Expand Up @@ -188,7 +188,7 @@ trap_entry_points:
jmp nosuchtrap
nop
; Traps $40-$4F (reset, page fault and other system-generated traps)
jmp reset_entry ; Trap #$40 (power on / reset)
jmp reset_entry_allow_etherkick ; Trap #$40 (power on / reset)
nop
jmp page_fault ; Trap #$41 (page fault)
nop
Expand All @@ -208,9 +208,19 @@ trap_entry_points:
; Leave room for traps to $7F
.advance $8200

;;; ----------------------------------------------------------------------------
;;; Etherkick / kickup utility functions
;;; ----------------------------------------------------------------------------
; We place a small routine at precisely $8200 that allows etherkick to reset
; kickstart, without it allowing etherkick mode until reset. This allows the
; etherkick process to update kickstart, and then start it normally, without
; requiring the operator to fiddle any switches.
jmp reset_entry_no_etherkick

;;; ----------------------------------------------------------------------------
;;; Hypervisor traps
;;; ----------------------------------------------------------------------------


;;; ----------------------------------------------------------------------------
;;; Illegal trap / trap sub-function handlers
Expand Down Expand Up @@ -309,8 +319,20 @@ reset_machine_state:
;;; CPU Hypervisor reset/trap routines
;;; ----------------------------------------------------------------------------

reset_entry:
kickstart_entry:
reset_entry_allow_etherkick:
sei
lda #$00
sta kickstart_boot_flags
jmp reset_entry_common

reset_entry_no_etherkick:
sei
lda #$80
sta kickstart_boot_flags
jmp reset_entry_common

reset_entry_common:

jsr reset_machine_state

; display welcome screen
Expand All @@ -325,7 +347,10 @@ kickstart_entry:
; check keyboard for 0-9 down to select alternate rom
jsr keyboardread

; If switch 8 and 9 are set, then wait forever for ethernet packets
; If switch 8 and 9 are set, and etherkick mode is not disabled
; then wait forever for ethernet packets
lda kickstart_boot_flags
bmi normalboot
lda $d6f1
and #$02
beq normalboot
Expand Down Expand Up @@ -773,7 +798,7 @@ romfiletoolong:
ldz file_sectorsread
jsr printhex
jsr sdwaitawhile
jmp reset_entry
jmp reset_entry_allow_etherkick
romfiletooshort:
ldx #<msg_romfileshorterror
ldy #>msg_romfileshorterror
Expand All @@ -783,7 +808,7 @@ romfiletooshort:
ldz file_sectorsread
jsr printhex
jsr sdwaitawhile
jmp reset_entry
jmp reset_entry_allow_etherkick

fileopenerror:
ldx #<msg_fileopenerror
Expand All @@ -794,13 +819,13 @@ sdcarderror: ldx #<msg_sdcarderror
ldy #>msg_sdcarderror
jsr printmessage
jsr sdwaitawhile
jmp reset_entry
jmp reset_entry_allow_etherkick

badfs: ldx #<msg_badformat
ldy #>msg_badformat
jsr printmessage
jsr sdwaitawhile
jmp reset_entry
jmp reset_entry_allow_etherkick
;;; ----------------------------------------------------------------------------
;;; FAT file system routines
;;; ----------------------------------------------------------------------------
Expand Down Expand Up @@ -2398,6 +2423,11 @@ dos_error_code:
; Kickstart ZP at $BF00-$BFFF
.checkpc $BF00
.advance $BF00,$3e

kickstart_boot_flags:
; $80 = disable etherkick this boot only
.byte 0

; Temporary vector storage for DOS
dos_scratch_vector: .word 0,0
dos_scratch_byte_1: .byte 0
Expand Down

0 comments on commit 84e573d

Please sign in to comment.