mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-02 14:23:19 +08:00
玄铁全系列RISC-V内核支持(E系列/R系列/C系列) (#10343)
This commit is contained in:
@@ -468,7 +468,16 @@
|
||||
"RTT_BSP": "xuantie",
|
||||
"RTT_TOOL_CHAIN": "sourcery-Xuantie-900-gcc-elf-newlib",
|
||||
"SUB_RTT_BSP": [
|
||||
"xuantie/smartl/e906"
|
||||
"xuantie/smartl/e902",
|
||||
"xuantie/smartl/e906",
|
||||
"xuantie/smartl/e907",
|
||||
"xuantie/xiaohui/c906",
|
||||
"xuantie/xiaohui/c907",
|
||||
"xuantie/xiaohui/c908",
|
||||
"xuantie/xiaohui/c910",
|
||||
"xuantie/xiaohui/r908",
|
||||
"xuantie/xiaohui/r910",
|
||||
"xuantie/xiaohui/r920"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -21,7 +21,7 @@ MEMORY
|
||||
DRAM : ORIGIN = 0x50000000, LENGTH = 0x100000 /* on-chip DRAM 1*1MB */
|
||||
}
|
||||
|
||||
__min_heap_size = 0x200;
|
||||
__min_heap_size = 0x20000;
|
||||
PROVIDE (__ram_end = 0x50100000 - 0x8);
|
||||
PROVIDE (__heap_end = __ram_end);
|
||||
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler
|
||||
j Default_Handler
|
||||
j Default_Handler
|
||||
j Default_Handler
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#else
|
||||
la sp, g_top_irqstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,9 @@
|
||||
#include <csi_config.h>
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.global __rt_rvstack
|
||||
.equ Mcoret_Handler, SW_handler
|
||||
.equ Mirq_Handler, SW_handler
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
@@ -102,7 +104,7 @@ Reset_Handler:
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
la a0, rtthread_startup
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
@@ -118,6 +120,7 @@ __exit:
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
__rt_rvstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler
|
||||
j Default_Handler
|
||||
j Default_Handler
|
||||
j Default_Handler
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#else
|
||||
la sp, g_top_irqstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
-188
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
lw a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
-842
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd]
|
||||
src = ['startup.S']
|
||||
src += ['system.c']
|
||||
src += ['trap_c.c']
|
||||
src += ['vectors.S']
|
||||
|
||||
group = DefineGroup('sys', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -23,7 +23,9 @@
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.global __rt_rvstack
|
||||
.equ Mcoret_Handler, SW_handler
|
||||
.equ Mirq_Handler, SW_handler
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
@@ -132,7 +134,7 @@ Reset_Handler:
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
la a0, rtthread_startup
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
@@ -169,6 +171,7 @@ hart_out_of_bounds_loop:
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
__rt_rvstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
@@ -177,6 +180,7 @@ g_top_irqstack:
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
|
||||
-188
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
lw a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
-326
File diff suppressed because it is too large
Load Diff
-64
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
-842
File diff suppressed because it is too large
Load Diff
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
-188
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
lw a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
-326
File diff suppressed because it is too large
Load Diff
-64
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
-842
File diff suppressed because it is too large
Load Diff
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
-188
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
lw a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
-326
File diff suppressed because it is too large
Load Diff
-64
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
-842
File diff suppressed because it is too large
Load Diff
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd]
|
||||
src = ['startup.S']
|
||||
src += ['system.c']
|
||||
src += ['trap_c.c']
|
||||
src += ['vectors.S']
|
||||
|
||||
group = DefineGroup('sys', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -23,7 +23,9 @@
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.global __rt_rvstack
|
||||
.equ Mcoret_Handler, SW_handler
|
||||
.equ Mirq_Handler, SW_handler
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
@@ -132,7 +134,7 @@ Reset_Handler:
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
la a0, rtthread_startup
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
@@ -169,6 +171,7 @@ hart_out_of_bounds_loop:
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
__rt_rvstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
-188
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
-521
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd]
|
||||
src = ['startup.S']
|
||||
src += ['system.c']
|
||||
src += ['trap_c.c']
|
||||
src += ['vectors.S']
|
||||
|
||||
group = DefineGroup('sys', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -23,7 +23,9 @@
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.global __rt_rvstack
|
||||
.equ Mcoret_Handler, SW_handler
|
||||
.equ Mirq_Handler, SW_handler
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
@@ -132,7 +134,7 @@ Reset_Handler:
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
la a0, rtthread_startup
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
@@ -169,6 +171,7 @@ hart_out_of_bounds_loop:
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
__rt_rvstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
-188
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
#ifndef CONFIG_NR_CPUS
|
||||
#define CONFIG_NR_CPUS 1
|
||||
#endif
|
||||
|
||||
.globl Reset_Handler
|
||||
|
||||
.section .vectors
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
j Default_Handler /* 0 */
|
||||
j Stspend_Handler /* 1 */
|
||||
j Default_Handler /* 2 */
|
||||
j Mtspend_Handler /* 3 */
|
||||
j Default_Handler /* 4 */
|
||||
j Scoret_Handler /* 5 */
|
||||
j Default_Handler /* 6 */
|
||||
j Mcoret_Handler /* 7 */
|
||||
j Default_Handler /* 8 */
|
||||
j Sirq_Handler /* 9 */
|
||||
j Default_Handler /* 10 */
|
||||
j Mirq_Handler /* 11 */
|
||||
j Default_Handler /* 12 */
|
||||
j Default_Handler /* 13 */
|
||||
j Default_Handler /* 14 */
|
||||
j Default_Handler /* 15 */
|
||||
#if CONFIG_ECC_L1_ENABLE
|
||||
j ECC_L1_Handler /* 16 */
|
||||
#else
|
||||
j Default_Handler /* 16 */
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
.rept 9
|
||||
.long 0
|
||||
.endr
|
||||
.long Reset_Handler
|
||||
_start:
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
/* disable ie and clear all interrupts */
|
||||
csrw mie, zero
|
||||
csrw mip, zero
|
||||
|
||||
/* Disable MIE to avoid triggering interrupts before the first task starts. */
|
||||
/* This bit is set when a task recovers context. */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrc mstatus, (1 << 1)
|
||||
#else
|
||||
csrc mstatus, (1 << 3)
|
||||
#endif
|
||||
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, __Vectors
|
||||
li a1, 0x1
|
||||
or a0, a0,a1
|
||||
csrw mtvec, a0
|
||||
|
||||
/* get cpu id */
|
||||
csrr a0, mhartid
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
/* check if hart is within range */
|
||||
/* tp: hart id */
|
||||
li t0, CONFIG_NR_CPUS
|
||||
bge a0, t0, hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_base_mainstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_MAINSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_MAINSTACK + g_base_mainstack */
|
||||
#else
|
||||
la sp, g_base_irqstack
|
||||
addi t1, a0, 1
|
||||
li t2, CONFIG_ARCH_INTERRUPTSTACK
|
||||
mul t1, t1, t2
|
||||
add sp, sp, t1 /* sp = (cpuid + 1) * CONFIG_ARCH_INTERRUPTSTACK + g_base_irqstack */
|
||||
#endif
|
||||
|
||||
/* other cpu core, jump to cpu entry directly */
|
||||
bnez a0, secondary_cpu_entry
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
la a0, SystemInit
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
la a0, smode_init
|
||||
jalr a0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
/* Enable interrupt */
|
||||
#if defined(CONFIG_RISCV_SMODE) && CONFIG_RISCV_SMODE
|
||||
csrs sstatus, (1 << 1)
|
||||
#else
|
||||
csrs mstatus, (1 << 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
la a0, pre_main
|
||||
jalr a0
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.type secondary_cpu_entry, %function
|
||||
secondary_cpu_entry:
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
la a0, secondary_boot_flag
|
||||
ld a0, 0(a0)
|
||||
li a1, 0xa55a
|
||||
beq a0, a1, 1f
|
||||
#endif
|
||||
j secondary_cpu_entry
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
1:
|
||||
jal secondary_cpu_c_start
|
||||
|
||||
.size secondary_cpu_entry, . - secondary_cpu_entry
|
||||
|
||||
hart_out_of_bounds_loop:
|
||||
/* Harts in this loop are out of bounds, increase CONFIG_NR_CPUS. */
|
||||
wfi
|
||||
j hart_out_of_bounds_loop
|
||||
#endif
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK * CONFIG_NR_CPUS
|
||||
g_top_irqstack:
|
||||
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK * CONFIG_NR_CPUS
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SMP) && CONFIG_SMP
|
||||
.data
|
||||
.global secondary_boot_flag
|
||||
.align 3
|
||||
secondary_boot_flag:
|
||||
.dword 0
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
-521
File diff suppressed because it is too large
Load Diff
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.section .vectors, "aw", @progbits
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long tspend_handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_IRQHandler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
|
||||
/* External interrupts */
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
|
||||
.globl Reset_Handler
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
_start:
|
||||
.text
|
||||
.long Reset_Handler
|
||||
.align 2
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, Default_Handler
|
||||
ori a0, a0, 3
|
||||
csrw mtvec, a0
|
||||
|
||||
la a0, __Vectors
|
||||
csrw mtvt, a0
|
||||
|
||||
la sp, g_top_irqstack
|
||||
csrw mscratch, sp
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
jal SystemInit
|
||||
#endif
|
||||
|
||||
jal pre_main
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.section .stack
|
||||
.align 3
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 3
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
#endif
|
||||
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
csi_vic_set_prio(i, 1);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_KERNEL_NONE
|
||||
/* tspend use lower priority */
|
||||
csi_vic_set_prio(Machine_Software_IRQn, 0);
|
||||
/* tspend use positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* enable theadisaee */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22);
|
||||
__set_MXSTATUS(status);
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 15; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[15]);
|
||||
printk("mstatus: %p\n", (void *)regs[16]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.section .vectors, "aw", @progbits
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long tspend_handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_IRQHandler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
|
||||
/* External interrupts */
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
|
||||
.globl Reset_Handler
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
_start:
|
||||
.text
|
||||
.long Reset_Handler
|
||||
.align 2
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, Default_Handler
|
||||
ori a0, a0, 3
|
||||
csrw mtvec, a0
|
||||
|
||||
la a0, __Vectors
|
||||
csrw mtvt, a0
|
||||
|
||||
la sp, g_top_irqstack
|
||||
csrw mscratch, sp
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
jal SystemInit
|
||||
#endif
|
||||
|
||||
jal pre_main
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.section .stack
|
||||
.align 3
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 3
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
#endif
|
||||
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
csi_vic_set_prio(i, 1);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_KERNEL_NONE
|
||||
/* tspend use lower priority */
|
||||
csi_vic_set_prio(Machine_Software_IRQn, 0);
|
||||
/* tspend use positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* enable theadisaee */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22);
|
||||
__set_MXSTATUS(status);
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 15; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[15]);
|
||||
printk("mstatus: %p\n", (void *)regs[16]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.section .vectors, "aw", @progbits
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long tspend_handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_IRQHandler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
|
||||
/* External interrupts */
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
|
||||
.globl Reset_Handler
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
_start:
|
||||
.text
|
||||
.long Reset_Handler
|
||||
.align 2
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, Default_Handler
|
||||
ori a0, a0, 3
|
||||
csrw mtvec, a0
|
||||
|
||||
la a0, __Vectors
|
||||
csrw mtvt, a0
|
||||
|
||||
la sp, g_top_irqstack
|
||||
csrw mscratch, sp
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
jal SystemInit
|
||||
#endif
|
||||
|
||||
jal pre_main
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.section .stack
|
||||
.align 3
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 3
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
#endif
|
||||
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
csi_vic_set_prio(i, 1);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_KERNEL_NONE
|
||||
/* tspend use lower priority */
|
||||
csi_vic_set_prio(Machine_Software_IRQn, 0);
|
||||
/* tspend use positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* enable theadisaee */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22);
|
||||
__set_MXSTATUS(status);
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 15; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[15]);
|
||||
printk("mstatus: %p\n", (void *)regs[16]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.section .vectors, "aw", @progbits
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long tspend_handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_IRQHandler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
|
||||
/* External interrupts */
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
.globl Reset_Handler
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
_start:
|
||||
.text
|
||||
.long Reset_Handler
|
||||
.align 2
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, Default_Handler
|
||||
ori a0, a0, 3
|
||||
csrw mtvec, a0
|
||||
|
||||
la a0, __Vectors
|
||||
csrw mtvt, a0
|
||||
|
||||
la sp, g_top_irqstack
|
||||
csrw mscratch, sp
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
jal SystemInit
|
||||
#endif
|
||||
|
||||
jal pre_main
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_dcache_enable();
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
csi_dcache_clean();
|
||||
csi_icache_invalid();
|
||||
#endif
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
}
|
||||
|
||||
/* tspend use positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* enable theadisaee & MM */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22 | 1 << 15);
|
||||
__set_MXSTATUS(status);
|
||||
|
||||
#if __riscv_flen
|
||||
/* enable float ISA */
|
||||
status = __get_MSTATUS();
|
||||
status |= (1 << MSTATUS_FS_SHIFT);
|
||||
__set_MSTATUS(status);
|
||||
#endif
|
||||
/* enable mexstatus SPUSHEN and disable SPSWAPEN */
|
||||
#if CONFIG_CPU_XUANTIE_E906 || CONFIG_CPU_XUANTIE_E906F || CONFIG_CPU_XUANTIE_E906FD || CONFIG_CPU_XUANTIE_E906P || CONFIG_CPU_XUANTIE_E906FP || CONFIG_CPU_XUANTIE_E906FDP \
|
||||
|| CONFIG_CPU_XUANTIE_E907 || CONFIG_CPU_XUANTIE_E907F || CONFIG_CPU_XUANTIE_E907FD || CONFIG_CPU_XUANTIE_E907P || CONFIG_CPU_XUANTIE_E907FP || CONFIG_CPU_XUANTIE_E907FDP
|
||||
status = __get_MEXSTATUS();
|
||||
status |= (0x1 << 16);
|
||||
status &= ~(0x2 << 16);
|
||||
__set_MEXSTATUS(status);
|
||||
#endif
|
||||
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
.global __rt_rvstack
|
||||
.section .vectors, "aw", @progbits
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long tspend_handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_IRQHandler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
|
||||
/* External interrupts */
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
.globl Reset_Handler
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
_start:
|
||||
.text
|
||||
.long Reset_Handler
|
||||
.align 2
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, Default_Handler
|
||||
ori a0, a0, 3
|
||||
csrw mtvec, a0
|
||||
|
||||
la a0, __Vectors
|
||||
csrw mtvt, a0
|
||||
|
||||
la sp, g_top_irqstack
|
||||
csrw mscratch, sp
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
jal SystemInit
|
||||
#endif
|
||||
|
||||
jal rtthread_startup
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
__rt_rvstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_dcache_enable();
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
csi_dcache_clean();
|
||||
csi_icache_invalid();
|
||||
#endif
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
}
|
||||
|
||||
/* tspend use positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* enable theadisaee & MM */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22 | 1 << 15);
|
||||
__set_MXSTATUS(status);
|
||||
|
||||
#if __riscv_flen
|
||||
/* enable float ISA */
|
||||
status = __get_MSTATUS();
|
||||
status |= (1 << MSTATUS_FS_SHIFT);
|
||||
__set_MSTATUS(status);
|
||||
#endif
|
||||
/* enable mexstatus SPUSHEN and disable SPSWAPEN */
|
||||
#if CONFIG_CPU_XUANTIE_E906 || CONFIG_CPU_XUANTIE_E906F || CONFIG_CPU_XUANTIE_E906FD || CONFIG_CPU_XUANTIE_E906P || CONFIG_CPU_XUANTIE_E906FP || CONFIG_CPU_XUANTIE_E906FDP \
|
||||
|| CONFIG_CPU_XUANTIE_E907 || CONFIG_CPU_XUANTIE_E907F || CONFIG_CPU_XUANTIE_E907FD || CONFIG_CPU_XUANTIE_E907P || CONFIG_CPU_XUANTIE_E907FP || CONFIG_CPU_XUANTIE_E907FDP
|
||||
status = __get_MEXSTATUS();
|
||||
status |= (0x1 << 16);
|
||||
status &= ~(0x2 << 16);
|
||||
__set_MEXSTATUS(status);
|
||||
#endif
|
||||
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.section .vectors, "aw", @progbits
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long tspend_handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_IRQHandler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
|
||||
/* External interrupts */
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
.globl Reset_Handler
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
_start:
|
||||
.text
|
||||
.long Reset_Handler
|
||||
.align 2
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, Default_Handler
|
||||
ori a0, a0, 3
|
||||
csrw mtvec, a0
|
||||
|
||||
la a0, __Vectors
|
||||
csrw mtvt, a0
|
||||
|
||||
la sp, g_top_irqstack
|
||||
csrw mscratch, sp
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
jal SystemInit
|
||||
#endif
|
||||
|
||||
jal pre_main
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_dcache_enable();
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
csi_dcache_clean();
|
||||
csi_icache_invalid();
|
||||
#endif
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
}
|
||||
|
||||
/* tspend use positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* enable theadisaee & MM */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22 | 1 << 15);
|
||||
__set_MXSTATUS(status);
|
||||
|
||||
#if __riscv_flen
|
||||
/* enable float ISA */
|
||||
status = __get_MSTATUS();
|
||||
status |= (1 << MSTATUS_FS_SHIFT);
|
||||
__set_MSTATUS(status);
|
||||
#endif
|
||||
/* enable mexstatus SPUSHEN and disable SPSWAPEN */
|
||||
#if CONFIG_CPU_XUANTIE_E906 || CONFIG_CPU_XUANTIE_E906F || CONFIG_CPU_XUANTIE_E906FD || CONFIG_CPU_XUANTIE_E906P || CONFIG_CPU_XUANTIE_E906FP || CONFIG_CPU_XUANTIE_E906FDP \
|
||||
|| CONFIG_CPU_XUANTIE_E907 || CONFIG_CPU_XUANTIE_E907F || CONFIG_CPU_XUANTIE_E907FD || CONFIG_CPU_XUANTIE_E907P || CONFIG_CPU_XUANTIE_E907FP || CONFIG_CPU_XUANTIE_E907FDP
|
||||
status = __get_MEXSTATUS();
|
||||
status |= (0x1 << 16);
|
||||
status &= ~(0x2 << 16);
|
||||
__set_MEXSTATUS(status);
|
||||
#endif
|
||||
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.section .vectors, "aw", @progbits
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long tspend_handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_IRQHandler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
|
||||
/* External interrupts */
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
.globl Reset_Handler
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
_start:
|
||||
.text
|
||||
.long Reset_Handler
|
||||
.align 2
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, Default_Handler
|
||||
ori a0, a0, 3
|
||||
csrw mtvec, a0
|
||||
|
||||
la a0, __Vectors
|
||||
csrw mtvt, a0
|
||||
|
||||
la sp, g_top_irqstack
|
||||
csrw mscratch, sp
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
jal SystemInit
|
||||
#endif
|
||||
|
||||
jal pre_main
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_dcache_enable();
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
csi_dcache_clean();
|
||||
csi_icache_invalid();
|
||||
#endif
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
}
|
||||
|
||||
/* tspend use positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* enable theadisaee & MM */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22 | 1 << 15);
|
||||
__set_MXSTATUS(status);
|
||||
|
||||
#if __riscv_flen
|
||||
/* enable float ISA */
|
||||
status = __get_MSTATUS();
|
||||
status |= (1 << MSTATUS_FS_SHIFT);
|
||||
__set_MSTATUS(status);
|
||||
#endif
|
||||
/* enable mexstatus SPUSHEN and disable SPSWAPEN */
|
||||
#if CONFIG_CPU_XUANTIE_E906 || CONFIG_CPU_XUANTIE_E906F || CONFIG_CPU_XUANTIE_E906FD || CONFIG_CPU_XUANTIE_E906P || CONFIG_CPU_XUANTIE_E906FP || CONFIG_CPU_XUANTIE_E906FDP \
|
||||
|| CONFIG_CPU_XUANTIE_E907 || CONFIG_CPU_XUANTIE_E907F || CONFIG_CPU_XUANTIE_E907FD || CONFIG_CPU_XUANTIE_E907P || CONFIG_CPU_XUANTIE_E907FP || CONFIG_CPU_XUANTIE_E907FDP
|
||||
status = __get_MEXSTATUS();
|
||||
status |= (0x1 << 16);
|
||||
status &= ~(0x2 << 16);
|
||||
__set_MEXSTATUS(status);
|
||||
#endif
|
||||
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_core.h>
|
||||
#if defined(AOS_COMP_DEBUG) && (AOS_COMP_DEBUG > 0)
|
||||
#include <debug/dbg.h>
|
||||
#else
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
void (*trap_c_callback)(void);
|
||||
|
||||
void trap_c(uintptr_t *regs)
|
||||
{
|
||||
int i;
|
||||
unsigned long vec = 0;
|
||||
|
||||
vec = __get_MCAUSE();
|
||||
|
||||
printk("CPU Exception(mcause);: NO.0x%lx", vec);
|
||||
printk("\n");
|
||||
|
||||
for (i = 0; i < 31; i++) {
|
||||
printk("x%d: %p\t", i + 1, (void *)regs[i]);
|
||||
|
||||
if ((i % 4) == 3) {
|
||||
printk("\n");
|
||||
}
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("mepc : %p\n", (void *)regs[31]);
|
||||
printk("mstatus: %p\n", (void *)regs[32]);
|
||||
|
||||
if (trap_c_callback) {
|
||||
trap_c_callback();
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void exceptionHandler(void *context)
|
||||
{
|
||||
trap_c((uintptr_t *)context);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
|
||||
.section .vectors, "aw", @progbits
|
||||
.align 6
|
||||
.globl __Vectors
|
||||
.type __Vectors, @object
|
||||
__Vectors:
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long tspend_handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_IRQHandler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
.long Default_Handler
|
||||
|
||||
/* External interrupts */
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
.long Default_IRQHandler
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
.globl Reset_Handler
|
||||
.text
|
||||
.align 2
|
||||
j Reset_Handler
|
||||
.align 2
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.long 0x594B5343 /* CSKY ASCII */
|
||||
.align 2
|
||||
_start:
|
||||
.text
|
||||
.long Reset_Handler
|
||||
.align 2
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
.option pop
|
||||
la a0, Default_Handler
|
||||
ori a0, a0, 3
|
||||
csrw mtvec, a0
|
||||
|
||||
la a0, __Vectors
|
||||
csrw mtvt, a0
|
||||
|
||||
la sp, g_top_irqstack
|
||||
csrw mscratch, sp
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
la sp, g_top_mainstack
|
||||
#endif
|
||||
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
jal SystemInit
|
||||
#endif
|
||||
|
||||
jal pre_main
|
||||
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
__exit:
|
||||
j __exit
|
||||
|
||||
.section .stack
|
||||
.align 4
|
||||
.global g_base_irqstack
|
||||
.global g_top_irqstack
|
||||
g_base_irqstack:
|
||||
.space CONFIG_ARCH_INTERRUPTSTACK
|
||||
g_top_irqstack:
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
.align 4
|
||||
.global g_base_mainstack
|
||||
.global g_top_mainstack
|
||||
g_base_mainstack:
|
||||
.space CONFIG_ARCH_MAINSTACK
|
||||
g_top_mainstack:
|
||||
#endif
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2024 Alibaba Group Holding Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <csi_config.h>
|
||||
#include <soc.h>
|
||||
#include <csi_core.h>
|
||||
#include <drv/irq.h>
|
||||
#include <drv/dma.h>
|
||||
#include <drv/tick.h>
|
||||
#include <drv/etb.h>
|
||||
#include <drv/spiflash.h>
|
||||
#include "riscv_csr.h"
|
||||
|
||||
#if (defined(CONFIG_KERNEL_RHINO) || defined(CONFIG_KERNEL_FREERTOS) || defined(CONFIG_KERNEL_RTTHREAD)) && defined(CONFIG_KERNEL_NONE)
|
||||
#error "Please check the current system is baremetal or not!!!"
|
||||
#endif
|
||||
|
||||
extern void section_data_copy(void);
|
||||
extern void section_ram_code_copy(void);
|
||||
extern void section_bss_clear(void);
|
||||
|
||||
static void cache_init(void)
|
||||
{
|
||||
csi_dcache_enable();
|
||||
csi_icache_enable();
|
||||
}
|
||||
|
||||
static void section_init(void)
|
||||
{
|
||||
#if CONFIG_XIP
|
||||
section_data_copy();
|
||||
section_ram_code_copy();
|
||||
csi_dcache_clean();
|
||||
csi_icache_invalid();
|
||||
#endif
|
||||
section_bss_clear();
|
||||
}
|
||||
|
||||
static void clic_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* get interrupt level from info */
|
||||
CLIC->CLICCFG = (((CLIC->CLICINFO & CLIC_INFO_CLICINTCTLBITS_Msk) >> CLIC_INFO_CLICINTCTLBITS_Pos) << CLIC_CLICCFG_NLBIT_Pos);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
CLIC->CLICINT[i].IP = 0;
|
||||
CLIC->CLICINT[i].ATTR = 1; /* use vector interrupt */
|
||||
}
|
||||
|
||||
/* tspend use positive interrupt */
|
||||
CLIC->CLICINT[Machine_Software_IRQn].ATTR = 0x3;
|
||||
csi_irq_enable(Machine_Software_IRQn);
|
||||
}
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
clic_init();
|
||||
#ifdef CONFIG_KERNEL_NONE
|
||||
__enable_excp_irq();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief initialize the system
|
||||
* Initialize the psr and vbr.
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
void SystemInit(void)
|
||||
{
|
||||
/* enable theadisaee & MM */
|
||||
uint32_t status = __get_MXSTATUS();
|
||||
status |= (1 << 22 | 1 << 15);
|
||||
__set_MXSTATUS(status);
|
||||
|
||||
#if __riscv_flen
|
||||
/* enable float ISA */
|
||||
status = __get_MSTATUS();
|
||||
status |= (1 << MSTATUS_FS_SHIFT);
|
||||
__set_MSTATUS(status);
|
||||
#endif
|
||||
/* enable mexstatus SPUSHEN and disable SPSWAPEN */
|
||||
#if CONFIG_CPU_XUANTIE_E906 || CONFIG_CPU_XUANTIE_E906F || CONFIG_CPU_XUANTIE_E906FD || CONFIG_CPU_XUANTIE_E906P || CONFIG_CPU_XUANTIE_E906FP || CONFIG_CPU_XUANTIE_E906FDP \
|
||||
|| CONFIG_CPU_XUANTIE_E907 || CONFIG_CPU_XUANTIE_E907F || CONFIG_CPU_XUANTIE_E907FD || CONFIG_CPU_XUANTIE_E907P || CONFIG_CPU_XUANTIE_E907FP || CONFIG_CPU_XUANTIE_E907FDP
|
||||
status = __get_MEXSTATUS();
|
||||
status |= (0x1 << 16);
|
||||
status &= ~(0x2 << 16);
|
||||
__set_MEXSTATUS(status);
|
||||
#endif
|
||||
|
||||
cache_init();
|
||||
section_init();
|
||||
interrupt_init();
|
||||
soc_set_sys_freq(20000000);
|
||||
csi_tick_init();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user