combined boot.s into cstartup.s
This commit is contained in:
parent
f749b29b7b
commit
70988d6df1
|
@ -1,58 +0,0 @@
|
|||
//; SPDX-License-Identifier: MIT
|
||||
//;
|
||||
//; boot/boot.s
|
||||
//; Boot code for Sentinel 65X
|
||||
//;
|
||||
//; Copyright <20> 2024 Kyle J Cardoza <Kyle.Cardoza@icloud.com>
|
||||
|
||||
#include "sentinel65x.h"
|
||||
|
||||
.extern __program_root_section
|
||||
|
||||
.section boot, noreorder
|
||||
.asciz "WDC"
|
||||
w65c265s_init:
|
||||
// Disable interrupts
|
||||
sei
|
||||
stz UIER
|
||||
stz TIER
|
||||
stz EIER
|
||||
short_a
|
||||
long_i
|
||||
|
||||
// We reset the VERA at boot. So P4.2 is an output, held
|
||||
// low until later in the boot sequence.
|
||||
lda #1 << 2
|
||||
trb PD4
|
||||
tsb PDD4
|
||||
|
||||
// Now we delay a while.
|
||||
ldy ##0x0FFF
|
||||
delay_y
|
||||
dey
|
||||
bne delay_y
|
||||
|
||||
// Enable all the in-use chip select lines.
|
||||
lda #0b11110011
|
||||
sta PCS7
|
||||
|
||||
// Disable the on-CPU ROM
|
||||
w65c265s_rom_off
|
||||
|
||||
// Disable the on-CPU RAM
|
||||
w65c265s_sram_off
|
||||
|
||||
; Set P5.4 and P5.5 as output
|
||||
lda #0b00110000
|
||||
trb PDD5
|
||||
tsb PDD5
|
||||
trb PD5
|
||||
|
||||
; Set P6.1 as output
|
||||
lda #0b00000010
|
||||
trb PDD6
|
||||
tsb PDD6
|
||||
trb PD6
|
||||
|
||||
// And we are booted enough to jump to high ROM.
|
||||
jmp long:__program_root_section
|
|
@ -1,102 +1,136 @@
|
|||
;;; Startup variant, change attribute value if you make your own
|
||||
.rtmodel cstartup,"sentinel65x"
|
||||
.rtmodel cstartup,"sentinel65x"
|
||||
|
||||
.rtmodel version, "1"
|
||||
.rtmodel core, "*"
|
||||
.rtmodel version, "1"
|
||||
.rtmodel core, "*"
|
||||
|
||||
.section stack
|
||||
.section cstack
|
||||
.section heap
|
||||
.section data_init_table
|
||||
.section stack
|
||||
.section cstack
|
||||
.section heap
|
||||
.section data_init_table
|
||||
|
||||
.extern main, exit
|
||||
.extern _Dp, _Vfp
|
||||
.extern _DirectPageStart
|
||||
.extern main, exit
|
||||
.extern _Dp, _Vfp
|
||||
.extern _DirectPageStart
|
||||
|
||||
#ifndef __CALYPSI_DATA_MODEL_SMALL__
|
||||
.extern _NearBaseAddress
|
||||
.extern _NearBaseAddress
|
||||
#endif
|
||||
|
||||
#include "macros.h"
|
||||
#include "65c816.h"
|
||||
#include "w65c265s.h"
|
||||
#include "65c816.h"
|
||||
|
||||
;;; ***************************************************************************
|
||||
;;;
|
||||
;;; __program_start - actual start point of the program
|
||||
;;;
|
||||
;;; Set up CPU stack, ini
|
||||
#include "65c816.h"tialize sections and call main().
|
||||
;;; You can override this with your own routine, or tailor it as needed.
|
||||
;;; The easiest way to make custom initialization is to provide your own
|
||||
;;; __low_level_init which gets called after stacks have been initialized.
|
||||
;;;
|
||||
;;; ***************************************************************************
|
||||
|
||||
.section code, noreorder
|
||||
.pubweak __program_root_section
|
||||
.section boot, noreorder
|
||||
.pubweak __program_root_section
|
||||
|
||||
__program_root_section:
|
||||
wdm #0x80
|
||||
clc
|
||||
xce ; native 16-bit mode
|
||||
rep #0x38 ; 16-bit registers, no decimal mode
|
||||
ldx ##.sectionEnd stack
|
||||
txs ; set stack
|
||||
lda ##_DirectPageStart
|
||||
tcd ; set direct page
|
||||
lda ##.word2 _NearBaseAddress
|
||||
stz dp:.tiny(_Vfp+2)
|
||||
xba ; A upper half = data bank
|
||||
pha
|
||||
plb ; pop 8 dummy
|
||||
plb ; set data bank
|
||||
.asciz "WDC"
|
||||
w65c265s_init:
|
||||
// Disable interrupts
|
||||
sei
|
||||
stz UIER
|
||||
stz TIER
|
||||
stz EIER
|
||||
short_a
|
||||
long_i
|
||||
|
||||
// We reset the VERA at boot. So P4.2 is an output, held
|
||||
// low until later in the boot sequence.
|
||||
lda #1 << 2
|
||||
trb PD4
|
||||
tsb PDD4
|
||||
|
||||
// Now we delay a while.
|
||||
ldy ##0x0FFF
|
||||
delay_y
|
||||
dey
|
||||
bne delay_y
|
||||
|
||||
// Enable all the in-use chip select lines.
|
||||
lda #0b11110011
|
||||
sta PCS7
|
||||
|
||||
// Disable the on-CPU ROM
|
||||
w65c265s_rom_off
|
||||
|
||||
// Disable the on-CPU RAM
|
||||
w65c265s_sram_off
|
||||
|
||||
; Set P5.4 and P5.5 as output
|
||||
lda #0b00110000
|
||||
trb PDD5
|
||||
tsb PDD5
|
||||
trb PD5
|
||||
|
||||
; Set P6.1 as output
|
||||
lda #0b00000010
|
||||
trb PDD6
|
||||
tsb PDD6
|
||||
trb PD6
|
||||
|
||||
|
||||
wdm #0x80
|
||||
clc
|
||||
xce ; native 16-bit mode
|
||||
rep #0x38 ; 16-bit registers, no decimal mode
|
||||
ldx ##.sectionEnd stack
|
||||
txs ; set stack
|
||||
lda ##_DirectPageStart
|
||||
tcd ; set direct page
|
||||
lda ##.word2 _NearBaseAddress
|
||||
stz dp:.tiny(_Vfp+2)
|
||||
xba ; A upper half = data bank
|
||||
pha
|
||||
plb ; pop 8 dummy
|
||||
plb ; set data bank
|
||||
|
||||
;;; **** Initialize data sections if needed.
|
||||
.section code, noroot, noreorder
|
||||
.pubweak __data_initialization_needed
|
||||
.extern __initialize_sections
|
||||
.section boot, noroot, noreorder
|
||||
.pubweak __data_initialization_needed
|
||||
.extern __initialize_sections
|
||||
|
||||
__data_initialization_needed:
|
||||
lda ##.word2 (.sectionEnd data_init_table)
|
||||
sta dp:.tiny(_Dp+6)
|
||||
lda ##.word0 (.sectionEnd data_init_table)
|
||||
sta dp:.tiny(_Dp+4)
|
||||
lda ##.word2 (.sectionStart data_init_table)
|
||||
sta dp:.tiny(_Dp+2)
|
||||
lda ##.word0 (.sectionStart data_init_table)
|
||||
sta dp:.tiny(_Dp+0)
|
||||
jsl long:__initialize_sections
|
||||
lda ##.word2 (.sectionEnd data_init_table)
|
||||
sta dp:.tiny(_Dp+6)
|
||||
lda ##.word0 (.sectionEnd data_init_table)
|
||||
sta dp:.tiny(_Dp+4)
|
||||
lda ##.word2 (.sectionStart data_init_table)
|
||||
sta dp:.tiny(_Dp+2)
|
||||
lda ##.word0 (.sectionStart data_init_table)
|
||||
sta dp:.tiny(_Dp+0)
|
||||
jsl long:__initialize_sections
|
||||
|
||||
;;; **** Initialize streams if needed.
|
||||
.section code, noroot, noreorder
|
||||
.pubweak __call_initialize_global_streams
|
||||
.extern __initialize_global_streams
|
||||
.section boot, noroot, noreorder
|
||||
.pubweak __call_initialize_global_streams
|
||||
.extern __initialize_global_streams
|
||||
|
||||
__call_initialize_global_streams:
|
||||
jsl long:__initialize_global_streams
|
||||
jsl long:__initialize_global_streams
|
||||
|
||||
;;; **** Initialize heap if needed.
|
||||
.section code, noroot, noreorder
|
||||
.pubweak __call_heap_initialize
|
||||
.extern __heap_initialize, __default_heap
|
||||
.section boot, noroot, noreorder
|
||||
.pubweak __call_heap_initialize
|
||||
.extern __heap_initialize, __default_heap
|
||||
|
||||
__call_heap_initialize:
|
||||
lda ##.word2 (.sectionStart heap)
|
||||
sta dp:.tiny(_Dp+6)
|
||||
lda ##.word0 (.sectionStart heap)
|
||||
sta dp:.tiny(_Dp+4)
|
||||
lda ##.word2 __default_heap
|
||||
sta dp:.tiny(_Dp+2)
|
||||
lda ##.word0 __default_heap
|
||||
sta dp:.tiny(_Dp+0)
|
||||
ldx ##.word2 (.sectionSize heap)
|
||||
lda ##.word0 (.sectionSize heap)
|
||||
jsl long:__heap_initialize
|
||||
lda ##.word2 (.sectionStart heap)
|
||||
sta dp:.tiny(_Dp+6)
|
||||
lda ##.word0 (.sectionStart heap)
|
||||
sta dp:.tiny(_Dp+4)
|
||||
lda ##.word2 __default_heap
|
||||
sta dp:.tiny(_Dp+2)
|
||||
lda ##.word0 __default_heap
|
||||
sta dp:.tiny(_Dp+0)
|
||||
ldx ##.word2 (.sectionSize heap)
|
||||
lda ##.word0 (.sectionSize heap)
|
||||
jsl long:__heap_initialize
|
||||
|
||||
wdm #0x81
|
||||
wdm #0x81
|
||||
|
||||
.section code, root, noreorder
|
||||
lda ##0 ; argc = 0
|
||||
jsl long:main
|
||||
jmp long:exit
|
||||
.section boot, root, noreorder
|
||||
lda ##0 ; argc = 0
|
||||
jsl long:main
|
||||
jmp long:exit
|
|
@ -6,5 +6,14 @@
|
|||
// Copyright © 2024 Kyle J Cardoza <Kyle.Cardoza@icloud.com>
|
||||
|
||||
void main(void) {
|
||||
|
||||
// Light Red LED
|
||||
__asm(
|
||||
" sep #0x20\n"
|
||||
" lda #0b00010000\n"
|
||||
" tsb 0x00DF21\n"
|
||||
" rep #0x20\n"
|
||||
);
|
||||
|
||||
for (;;) {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue