Fixed cstartup.s

This commit is contained in:
Kyle J Cardoza 2024-07-07 23:35:11 -04:00
parent 57ce078167
commit cc21b3d4bb
4 changed files with 65 additions and 5 deletions

View File

@ -40,8 +40,7 @@ CFLAGS += --debug \
ASFLAGS += --debug ASFLAGS += --debug
endif endif
LDFLAGS := --no-data-init-table-section \ LDFLAGS := --rtattr cstartup=sentinel65x \
--rtattr cstartup=sentinel65x \
--verbose \ --verbose \
--output-format raw --output-format raw

View File

@ -19,6 +19,7 @@
(section data) (section data)
(section chuge) (section chuge)
(section ihuge) (section ihuge)
(section data_init_table)
(section (irq_trampolines #xC0F000)) (section (irq_trampolines #xC0F000))
(section (irq_vectors #xC0FF80)) (section (irq_vectors #xC0FF80))
) )

View File

@ -7,6 +7,7 @@
.section stack .section stack
.section cstack .section cstack
.section heap .section heap
.section data_init_table
.extern main, exit .extern main, exit
.extern _Dp, _Vfp .extern _Dp, _Vfp
@ -39,18 +40,61 @@ __program_root_section:
txs ; set stack txs ; set stack
lda ##_DirectPageStart lda ##_DirectPageStart
tcd ; set direct page tcd ; set direct page
#ifdef __CALYPSI_DATA_MODEL_SMALL__
lda ##0
#else
lda ##.word2 _NearBaseAddress lda ##.word2 _NearBaseAddress
#endif
stz dp:.tiny(_Vfp+2) stz dp:.tiny(_Vfp+2)
xba ; A upper half = data bank xba ; A upper half = data bank
pha pha
plb ; pop 8 dummy plb ; pop 8 dummy
plb ; set data bank plb ; set data bank
#ifdef __CALYPSI_CODE_MODEL_COMPACT__
jmp long:_Trampoline_program_start
.section compactcode, noreorder
_Trampoline_program_start:
#define CODE compactcode
#else
#define CODE code
#endif
call __low_level_init
;;; **** Initialize data sections if needed.
.section CODE, 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)
call __initialize_sections
;;; **** Initialize streams if needed.
.section CODE, noroot, noreorder
.pubweak __call_initialize_global_streams
.extern __initialize_global_streams
__call_initialize_global_streams:
call __initialize_global_streams
;;; **** Initialize heap if needed. ;;; **** Initialize heap if needed.
.section code, noroot, noreorder .section CODE, noroot, noreorder
.pubweak __call_heap_initialize .pubweak __call_heap_initialize
.extern __heap_initialize, __default_heap .extern __heap_initialize, __default_heap
__call_heap_initialize: __call_heap_initialize:
#ifdef __CALYPSI_DATA_MODEL_SMALL__
lda ##.sectionSize heap
sta dp:.tiny(_Dp+2)
lda ##.sectionStart heap
sta dp:.tiny(_Dp+0)
lda ##__default_heap
#else
lda ##.word2 (.sectionStart heap) lda ##.word2 (.sectionStart heap)
sta dp:.tiny(_Dp+6) sta dp:.tiny(_Dp+6)
lda ##.word0 (.sectionStart heap) lda ##.word0 (.sectionStart heap)
@ -61,9 +105,24 @@ __call_heap_initialize:
sta dp:.tiny(_Dp+0) sta dp:.tiny(_Dp+0)
ldx ##.word2 (.sectionSize heap) ldx ##.word2 (.sectionSize heap)
lda ##.word0 (.sectionSize heap) lda ##.word0 (.sectionSize heap)
#endif
call __heap_initialize call __heap_initialize
.section code, root, noreorder .section CODE, root, noreorder
lda ##0 ; argc = 0 lda ##0 ; argc = 0
call main call main
jump exit jump exit
;;; ***************************************************************************
;;;
;;; __low_level_init - custom low level initialization
;;;
;;; This default routine just returns doing nothing. You can provide your own
;;; routine, either in C or assembly for doing custom low leve initialization.
;;;
;;; ***************************************************************************
.section libcode
.pubweak __low_level_init
__low_level_init:
return

View File

@ -11,11 +11,12 @@
#include "kernel/device.h" #include "kernel/device.h"
#include "kernel/file.h" #include "kernel/file.h"
#include "kernel/device/null.h"
static bool device_init_all_run = false; static bool device_init_all_run = false;
Device *device[DEVICE_MAX] = { Device *device[DEVICE_MAX] = {
NULL &NullDevice
}; };
struct device_map *device_map[DEVICE_MAP_MAX] = {0}; struct device_map *device_map[DEVICE_MAP_MAX] = {0};