General update.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
b0a108cd17
commit
59a7540c94
|
@ -9,8 +9,9 @@ enable_language(ASM)
|
|||
set(TARGET_LDSCRIPT_FLASH "${CMAKE_SOURCE_DIR}/GCC/T113i_RAM.ld")
|
||||
|
||||
set(TARGET_SOURCES
|
||||
"startup/c906_it.c"
|
||||
"startup/resource_table.c"
|
||||
"startup/start_c906.S"
|
||||
"startup/startup_c906.S"
|
||||
"startup/system_c906.c"
|
||||
"src/main.c"
|
||||
)
|
||||
|
|
|
@ -5,8 +5,8 @@ ENTRY( _start )
|
|||
* too high may cause SDRAM overflow.
|
||||
* Collision may occur with heap when stack gets too deep.
|
||||
*/
|
||||
__stack_size = 2048;
|
||||
__heap_size = 2048;
|
||||
__stack_size = 32768;
|
||||
__heap_size = 32768;
|
||||
|
||||
MEMORY
|
||||
{
|
||||
|
@ -18,28 +18,28 @@ SECTIONS
|
|||
{
|
||||
.resource_table :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
KEEP(*(SORT_NONE(.resource_table)))
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
} >SDRAM
|
||||
|
||||
.init :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
} >SDRAM
|
||||
|
||||
.vectors :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
KEEP(*(SORT_NONE(.vectors)))
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
} >SDRAM
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
_stext = .;
|
||||
|
||||
*(.text)
|
||||
|
@ -49,7 +49,7 @@ SECTIONS
|
|||
*(.rodata*)
|
||||
*(.gnu.linkonce.r.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
_etext = .;
|
||||
} >SDRAM
|
||||
|
||||
|
@ -96,7 +96,7 @@ SECTIONS
|
|||
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
_sdata = .;
|
||||
|
||||
*(.data .data.*)
|
||||
|
@ -105,7 +105,7 @@ SECTIONS
|
|||
*(.srodata .srodata.*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
_edata = .;
|
||||
} >SDRAM
|
||||
|
||||
|
@ -114,7 +114,7 @@ SECTIONS
|
|||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
_sbss = .;
|
||||
|
||||
*(.sbss)
|
||||
|
@ -125,25 +125,25 @@ SECTIONS
|
|||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(8);
|
||||
_ebss = .;
|
||||
} >SDRAM
|
||||
|
||||
.heap_stack :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
. = ALIGN(16);
|
||||
_end = .;
|
||||
PROVIDE(end = . );
|
||||
|
||||
. = . + __heap_size;
|
||||
. = ALIGN(8);
|
||||
. = ALIGN(16);
|
||||
PROVIDE(_heap_end = .);
|
||||
|
||||
. = . + __stack_size;
|
||||
. = ALIGN(8);
|
||||
. = ALIGN(16);
|
||||
} >SDRAM
|
||||
|
||||
/* Place initial SP to the end of SDRAM */
|
||||
__stack_top = ORIGIN(SDRAM) + LENGTH(SDRAM);
|
||||
PROVIDE(_eusrstack = __stack_top);
|
||||
__freertos_irq_stack_top = __stack_top;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#define __IRQ __attribute__((interrupt))
|
||||
#define __IRQ_NAKED __attribute__((naked))
|
||||
|
||||
__IRQ void Default_Handler(void) {
|
||||
for (;;) {
|
||||
/* -- */
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/* Custom CSR definitions */
|
||||
|
||||
#define CSR_MCOR 0x7C2
|
||||
#define CSR_MSMPR 0x7f3
|
||||
|
||||
/* Reset vector */
|
||||
|
||||
.section .init,"ax",@progbits
|
||||
.global _start
|
||||
_start:
|
||||
/* Initialize GP */
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
|
||||
|
||||
/* Initialize SP */
|
||||
la sp, __stack_top
|
||||
|
||||
/* Data section has been copied by framework. */
|
||||
|
||||
clear_bss:
|
||||
/* Clear bss section */
|
||||
la a0, _sbss
|
||||
la a1, _ebss
|
||||
bgeu a0, a1, post_crt0
|
||||
|
||||
loop_clear_bss:
|
||||
sd zero, (a0)
|
||||
addi a0, a0, 8
|
||||
bltu a0, a1, loop_clear_bss
|
||||
|
||||
post_crt0:
|
||||
jal SystemInit
|
||||
jal main
|
|
@ -0,0 +1,83 @@
|
|||
/* Custom CSR definitions */
|
||||
|
||||
/* Reset vector */
|
||||
|
||||
.section .init,"ax",@progbits
|
||||
.global _start
|
||||
.align 8
|
||||
_start:
|
||||
|
||||
/* Initialize GP */
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
|
||||
csrw mie, x0
|
||||
csrw mip, x0
|
||||
|
||||
li t0, 0x70013
|
||||
csrw 0x7c2, t0 /* MCOR */
|
||||
|
||||
li t0, 0
|
||||
csrw 0x7c1, t0 /* MHCR */
|
||||
|
||||
/* Enable FP */
|
||||
li t0, 0xa00007900
|
||||
csrw mstatus, t0
|
||||
|
||||
/* Initialize SP */
|
||||
la sp, __stack_top
|
||||
|
||||
/* Data section has been copied by framework. */
|
||||
|
||||
clear_bss:
|
||||
/* Clear bss section */
|
||||
la a0, _sbss
|
||||
la a1, _ebss
|
||||
bgeu a0, a1, main_entry
|
||||
|
||||
loop_clear_bss:
|
||||
sd zero, (a0)
|
||||
addi a0, a0, 8
|
||||
bltu a0, a1, loop_clear_bss
|
||||
|
||||
/* Exception system */
|
||||
la t0, vec_base
|
||||
addi t0, t0, 1
|
||||
csrw mtvec, t0
|
||||
|
||||
main_entry:
|
||||
jal SystemInit
|
||||
jal main
|
||||
|
||||
dead_loop:
|
||||
j dead_loop
|
||||
|
||||
.option push
|
||||
.option norvc
|
||||
.align 8
|
||||
vec_base:
|
||||
j Exception_Handler /* 00 Exception */
|
||||
j S_Software_IRQHandler /* 01 Supervisor software interrupt */
|
||||
j Default_Handler /* 02 Reserved */
|
||||
j M_Software_IRQHandler /* 03 Machine software interrupt */
|
||||
j Default_Handler /* 04 Reserved */
|
||||
j S_Timer_IRQHandler /* 05 Supervisor timer interrupt */
|
||||
j Default_Handler /* 06 Reserved */
|
||||
j M_Timer_IRQHandler /* 07 Machine timer interrupt */
|
||||
.option pop
|
||||
|
||||
.weak Exception_Handler
|
||||
.weak S_Software_IRQHandler
|
||||
.weak M_Software_IRQHandler
|
||||
.weak S_Timer_IRQHandler
|
||||
.weak M_Timer_IRQHandler
|
||||
|
||||
.align 8
|
||||
Exception_Handler:
|
||||
S_Software_IRQHandler:
|
||||
M_Software_IRQHandler:
|
||||
S_Timer_IRQHandler:
|
||||
M_Timer_IRQHandler:
|
||||
j Default_Handler
|
|
@ -1,3 +1,2 @@
|
|||
void SystemInit(void) {
|
||||
/* -- Nothing to do here for now. -- */
|
||||
}
|
Loading…
Reference in New Issue