📄 crtbegin.spp
字号:
; pointer
#endif /* PARMUSP */
spp #MMU_PG ; select register page 0 [MMU]
/* +------------------------------------------------------------+
| PART 5 : MEMORY/REGISTER FILE INITIALIZATION |
+------------------------------------------------------------+ */
#if defined(HAS_SECINFO)
#include <sys/secinfo.h>
#define DPR1_MASK 0x40
#define DPR2_MASK 0x80
;
; Sections to initialize are described thru the section
; information table constructed by the linker, located at
; _secinfo_table address within .secinfo ELF section.
;
LABEL(sections_init):
ld r0, #_has_secinfo_table ; load at run-time secinfo table
; flag
or r0, r0
jpz LABEL(sections_fini) ; skip init process
ld DPR2_P, #pag(_secinfo_table) ; dpr2 get the page number of
; the secinfo table
ldw rr10, #pof(_secinfo_table) ; load address of secinfo table
or r10, #DPR2_MASK ; secinfo table uses dpr2
LABEL(sections_begin):
ld r8, (rr10)+ ; load the next section type
;
; Init data-like sections (such .data section).
; Data-like section initialization relies on the AT mechanism of ld
;
LABEL(memory_data_init):
btjxf r8.1, LABEL(memory_data_end)
ld DPR0_P, (rr10)+ ; load page number of start
; address in dpr0
ldw rr0, (rr10)+ ; load page offset of start
; address of current section
ldw rr4, (rr10)+ ; size of current section
ld DPR1_P, (rr10)+ ; load page number of load
; address in dpr1
ldw rr2, (rr10)+ ; load page offset of load
; address of current section
or r2, #DPR1_MASK ; ensure 2MSb is dpr1
LABEL(memory_data_begin):
lddd (rr0)+, (rr2)+ ; copy one byte
dwjxnz rr4, LABEL(memory_data_begin) ; loop while length is not 0
LABEL(memory_data_end):
;
; Init bss-like sections (such .bss section).
; Such section is initialized with the 0 value.
;
LABEL(memory_bss_init):
btjxf r8.2, LABEL(memory_bss_end)
ld DPR0_P, (rr10)+ ; load page number of start
; address in dpr0
ldw rr0, (rr10)+ ; page offset of start address
; of current section
ldw rr4, (rr10)+ ; size of current section
ld r3, (rr10)+ ; fill value
LABEL(memory_bss_begin):
ld (rr0)+, r3 ; set one byte at memory (rr0)
dwjxnz rr4, LABEL(memory_bss_begin) ; loop while length is not 0
LABEL(memory_bss_end):
;
; Init data-like section in R-file (such .reg8_data section)
; Such section initialization relies on the AT mechanism of ld
;
LABEL(rfile_data_init):
btjxf r8.3, LABEL(rfile_data_end)
ldw rr0, (rr10)+ ; r0 = first register number
; r1 = size of current section
ld DPR0_P, (rr10)+ ; load page number of load
; address in dpr1
ldw rr2, (rr10)+ ; page offset of load address
; of current section
LABEL(rfile_data_begin):
ld (r0)+, (rr2)+ ; copy one byte in R-file from
; memory
djxnz r1, LABEL(rfile_data_begin) ; loop while length is not 0
LABEL(rfile_data_end):
;
; Init bss-like section in R-file (such .reg8_bss section)
; Such section is initialized with the 0 value.
; (see note of bss initialization section).
;
LABEL(rfile_bss_init):
btjxf r8.4, LABEL(rfile_bss_end)
ldw rr0, (rr10)+ ; r0 = first register number
; r1 = size of current section
ld r2, (rr10)+ ; fill value
LABEL(rfile_bss_begin):
ld (r0), r2 ; set one byte in R-file
inc r0 ; increment counter
djxnz r1, LABEL(rfile_bss_begin) ; loop while length is not 0
LABEL(rfile_bss_end):
;
; Initialize registers which have a fixed numbers.
;
LABEL(rfile_explicit_init):
btjxf r8.5, LABEL(rfile_explicit_end)
ldw rr0, (rr10)+ ; r0 = first register number
; r1 = size of value
LABEL(rfile_explicit_begin):
ld (r0)+, (rr10)+ ; copy one byte at a time
djxnz r1, LABEL(rfile_explicit_begin) ; loop while length is not 0
LABEL(rfile_explicit_end):
;
; Each entry within the secinfo table is fully located
; within a page. This entry type forces the secinfo table
; pointer to align itself on the next page by increasing
; page number (in dpr2) and set offset to 0.
;
LABEL(page_switch_init):
btjxf r8.6, LABEL(page_switch_end)
inc DPR2_P ; point on next page
xor r11, r11 ; load address of secinfo table
ld r10, #DPR2_MASK ; secinfo table uses dpr2
LABEL(page_switch_end):
LABEL(sections_fini):
btjxf r8.0, LABEL(sections_begin)
#endif /* HAS_SECINFO */
/* +------------------------------------------------------------+
| PART 6 : MMU SETUP |
+------------------------------------------------------------+ */
#if defined(MEDIUM)
;
; Initialisation of registers controlling external memory interface
; EMR1 reset value is x000-000M
; MC, DS2EN, ASAF, NMB, ET0, BSZ should be checked against user
; memory configuration and EMR1 set accordingly
;
; EMR2 reset value is M000-1111
; ENCSR is 0, which selects ST9 compatibility mode for interrupt handling.
; DMEMSEL, PAS1, PAS0, DAS1 and DAS0 should be checked against user memory
; configuration and set complementarily to WCR in page #0 (see below)
; DPRREM is forced to one to have DPRi registers accessible in group E
;
or EMR2, #EMR2_dprrem ; remap data page registers
;
; Initialization of DPR registers with initial value
;
ld DPR0, #_idpr0
;
; ST9+V6_TUTORIAL: beginning of modification
; The following lines are commented
;
; ld DPR1, #_idpr1
; ld DPR2, #_idpr2
;
; ST9+V6_TUTORIAL: end of modification
;
ld DPR3, #_idpr3
#else /* MEDIUM */
;
; Initialization of DPR registers with initial values
;
ld DPR0_P, #_idpr0
ld DPR1_P, #_idpr1
ld DPR2_P, #_idpr2
ld DPR3_P, #_idpr3
ld ISR, CSR
#endif /* MEDIUM */
#if defined(MEDIUM) || defined (SPECMED)
; ENCSR is 1, use CSR for interrupt handling.
or EMR2, #EMR2_encsr ; enable csr during interrupts
#endif /* MEDIUM */
#if defined(COMPACT)
; in compact programming model, the startup file
; will assumes that CSR = ISR, set by the bootrom
#endif /* COMPACT */
.endproc
/* +------------------------------------------------------------+
| PART 7 : CALL MAIN |
+------------------------------------------------------------+ */
.global __initialize_end
.global ___initialize_end
.proc __initialize_end
__initialize_end:
___initialize_end:
;
; Call the main routine
;
_call M_(main)
.endproc
/* +------------------------------------------------------------+
| PART 8 : TERMINATION |
+------------------------------------------------------------+ */
.global __terminate_begin
.global ___terminate_begin
__terminate_begin:
___terminate_begin:
.global __terminate_end
.global ___terminate_end
__terminate_end:
___terminate_end:
.global __Halt
.global ___Halt
.proc __Halt
__Halt:
___Halt:
jr . ; loop forever
.endproc
;
; End of start-up file end
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -