diff options
Diffstat (limited to 'libcpu')
35 files changed, 250 insertions, 78 deletions
diff --git a/libcpu/Kconfig b/libcpu/Kconfig index ae2767dec9..974c421138 100644 --- a/libcpu/Kconfig +++ b/libcpu/Kconfig @@ -106,6 +106,14 @@ config ARCH_RISCV config ARCH_RISCV_FPU bool +config ARCH_RISCV_FPU_S + select ARCH_RISCV_FPU + bool + +config ARCH_RISCV_FPU_D + select ARCH_RISCV_FPU + bool + config ARCH_RISCV32 select ARCH_RISCV bool diff --git a/libcpu/aarch64/common/cpu.c b/libcpu/aarch64/common/cpu.c index 962a53a071..84d3df2e8a 100644 --- a/libcpu/aarch64/common/cpu.c +++ b/libcpu/aarch64/common/cpu.c @@ -76,7 +76,7 @@ void rt_hw_spin_unlock(rt_hw_spinlock_t *lock) /*@{*/ /** shutdown CPU */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arc/em/cpuport.c b/libcpu/arc/em/cpuport.c index 34f538881f..1a2593644a 100644 --- a/libcpu/arc/em/cpuport.c +++ b/libcpu/arc/em/cpuport.c @@ -32,7 +32,7 @@ struct init_stack_frame { /** * shutdown CPU */ -void rt_hw_cpu_shutdown(void) +RT_WEAK void rt_hw_cpu_shutdown(void) { } diff --git a/libcpu/arm/AT91SAM7S/cpu.c b/libcpu/arm/AT91SAM7S/cpu.c index 8d28063eb1..b24ab5644b 100644 --- a/libcpu/arm/AT91SAM7S/cpu.c +++ b/libcpu/arm/AT91SAM7S/cpu.c @@ -20,7 +20,7 @@ * this function will reset CPU * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { } @@ -28,7 +28,7 @@ void rt_hw_cpu_reset() * this function will shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/AT91SAM7X/cpu.c b/libcpu/arm/AT91SAM7X/cpu.c index 484c19d10a..046f7e8ced 100644 --- a/libcpu/arm/AT91SAM7X/cpu.c +++ b/libcpu/arm/AT91SAM7X/cpu.c @@ -20,7 +20,7 @@ * this function will reset CPU * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { } @@ -28,7 +28,7 @@ void rt_hw_cpu_reset() * this function will shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/am335x/cpu.c b/libcpu/arm/am335x/cpu.c index cae865fe50..469276466b 100644 --- a/libcpu/arm/am335x/cpu.c +++ b/libcpu/arm/am335x/cpu.c @@ -149,7 +149,7 @@ rt_base_t rt_hw_cpu_dcache_status() * shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/arm926/cpuport.c b/libcpu/arm/arm926/cpuport.c index 035e97d543..dc93f42ed6 100644 --- a/libcpu/arm/arm926/cpuport.c +++ b/libcpu/arm/arm926/cpuport.c @@ -146,7 +146,7 @@ rt_base_t rt_hw_cpu_dcache_status() * reset cpu by dog's time-out * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { rt_kprintf("Restarting system...\n"); @@ -161,7 +161,7 @@ void rt_hw_cpu_reset() * shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/armv6/cpuport.c b/libcpu/arm/armv6/cpuport.c index c8e9201722..f886e7e164 100644 --- a/libcpu/arm/armv6/cpuport.c +++ b/libcpu/arm/armv6/cpuport.c @@ -147,7 +147,7 @@ rt_base_t rt_hw_cpu_dcache_status() * reset cpu by dog's time-out * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { rt_kprintf("Restarting system...\n"); @@ -162,7 +162,7 @@ void rt_hw_cpu_reset() * shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/cortex-a/cpu.c b/libcpu/arm/cortex-a/cpu.c index 7c6bf58a4b..6775b781bc 100644 --- a/libcpu/arm/cortex-a/cpu.c +++ b/libcpu/arm/cortex-a/cpu.c @@ -74,7 +74,7 @@ void rt_hw_spin_unlock(rt_hw_spinlock_t *lock) /*@{*/ /** shutdown CPU */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/cortex-m3/cpuport.c b/libcpu/arm/cortex-m3/cpuport.c index d58782e2c5..b6c4c9743c 100644 --- a/libcpu/arm/cortex-m3/cpuport.c +++ b/libcpu/arm/cortex-m3/cpuport.c @@ -344,7 +344,7 @@ void rt_hw_hard_fault_exception(struct exception_info * exception_info) /** * shutdown CPU */ -void rt_hw_cpu_shutdown(void) +RT_WEAK void rt_hw_cpu_shutdown(void) { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/cortex-m33/cpuport.c b/libcpu/arm/cortex-m33/cpuport.c index a589ba3462..42b5798507 100644 --- a/libcpu/arm/cortex-m33/cpuport.c +++ b/libcpu/arm/cortex-m33/cpuport.c @@ -431,7 +431,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) /** * shutdown CPU */ -void rt_hw_cpu_shutdown(void) +RT_WEAK void rt_hw_cpu_shutdown(void) { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/cortex-m4/cpuport.c b/libcpu/arm/cortex-m4/cpuport.c index dc8a9aab59..2e47832259 100644 --- a/libcpu/arm/cortex-m4/cpuport.c +++ b/libcpu/arm/cortex-m4/cpuport.c @@ -428,7 +428,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) /** * shutdown CPU */ -void rt_hw_cpu_shutdown(void) +RT_WEAK void rt_hw_cpu_shutdown(void) { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/cortex-m7/cpuport.c b/libcpu/arm/cortex-m7/cpuport.c index e701a52307..aeb9f14ac5 100644 --- a/libcpu/arm/cortex-m7/cpuport.c +++ b/libcpu/arm/cortex-m7/cpuport.c @@ -428,7 +428,7 @@ void rt_hw_hard_fault_exception(struct exception_info *exception_info) /** * shutdown CPU */ -void rt_hw_cpu_shutdown(void) +RT_WEAK void rt_hw_cpu_shutdown(void) { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/cortex-r4/cpu.c b/libcpu/arm/cortex-r4/cpu.c index d2e8130e7c..23c16e383c 100644 --- a/libcpu/arm/cortex-r4/cpu.c +++ b/libcpu/arm/cortex-r4/cpu.c @@ -20,7 +20,7 @@ * this function will reset CPU * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { } @@ -28,7 +28,7 @@ void rt_hw_cpu_reset() * this function will shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/dm36x/cpuport.c b/libcpu/arm/dm36x/cpuport.c index f6e8a20056..99edb96260 100644 --- a/libcpu/arm/dm36x/cpuport.c +++ b/libcpu/arm/dm36x/cpuport.c @@ -145,7 +145,7 @@ rt_base_t rt_hw_cpu_dcache_status() * reset cpu by dog's time-out * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { rt_kprintf("Restarting system...\n"); @@ -160,7 +160,7 @@ void rt_hw_cpu_reset() * shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/lpc214x/cpuport.c b/libcpu/arm/lpc214x/cpuport.c index 2543a5e0a9..54e7e9b0c8 100644 --- a/libcpu/arm/lpc214x/cpuport.c +++ b/libcpu/arm/lpc214x/cpuport.c @@ -163,7 +163,7 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, * this function will reset CPU * */ -void rt_hw_cpu_reset(void) +RT_WEAK void rt_hw_cpu_reset(void) { } @@ -171,7 +171,7 @@ void rt_hw_cpu_reset(void) * this function will shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/lpc24xx/cpu.c b/libcpu/arm/lpc24xx/cpu.c index f3a61e16a3..0453722d1d 100644 --- a/libcpu/arm/lpc24xx/cpu.c +++ b/libcpu/arm/lpc24xx/cpu.c @@ -20,7 +20,7 @@ * this function will reset CPU * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { } @@ -28,7 +28,7 @@ void rt_hw_cpu_reset() * this function will shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/realview-a8-vmm/cpu.c b/libcpu/arm/realview-a8-vmm/cpu.c index 2d78715011..dbdb4ac515 100644 --- a/libcpu/arm/realview-a8-vmm/cpu.c +++ b/libcpu/arm/realview-a8-vmm/cpu.c @@ -18,7 +18,7 @@ /*@{*/ /** shutdown CPU */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/s3c24x0/cpu.c b/libcpu/arm/s3c24x0/cpu.c index 4d3bf3c1ab..2adf526a5c 100644 --- a/libcpu/arm/s3c24x0/cpu.c +++ b/libcpu/arm/s3c24x0/cpu.c @@ -148,7 +148,7 @@ rt_base_t rt_hw_cpu_dcache_status() * reset cpu by dog's time-out * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { /* Disable all interrupt except the WDT */ INTMSK = (~((rt_uint32_t)1 << INTWDT)); @@ -171,7 +171,7 @@ void rt_hw_cpu_reset() * shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/s3c44b0/cpu.c b/libcpu/arm/s3c44b0/cpu.c index 03ebefba18..9d60b09688 100644 --- a/libcpu/arm/s3c44b0/cpu.c +++ b/libcpu/arm/s3c44b0/cpu.c @@ -100,7 +100,7 @@ rt_base_t rt_hw_cpu_dcache_status() * this function will reset CPU * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { } @@ -108,7 +108,7 @@ void rt_hw_cpu_reset() * this function will shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/sep4020/cpu.c b/libcpu/arm/sep4020/cpu.c index ee4eab626b..92ba2cf86a 100644 --- a/libcpu/arm/sep4020/cpu.c +++ b/libcpu/arm/sep4020/cpu.c @@ -152,7 +152,7 @@ rt_base_t rt_hw_cpu_dcache_status() * reset cpu by dog's time-out * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { /* enable watchdog */ @@ -173,7 +173,7 @@ void rt_hw_cpu_reset() * shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t UNUSED level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/arm/zynq7000/cpu.c b/libcpu/arm/zynq7000/cpu.c index 5f3a3e7b02..f6b7f5d852 100644 --- a/libcpu/arm/zynq7000/cpu.c +++ b/libcpu/arm/zynq7000/cpu.c @@ -16,7 +16,7 @@ * reset cpu by dog's time-out * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { while (1); /* loop forever and wait for reset to happen */ @@ -27,7 +27,7 @@ void rt_hw_cpu_reset() * shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/avr32/uc3/cpu.c b/libcpu/avr32/uc3/cpu.c index b77e78dc5b..fdd8a4d56c 100644 --- a/libcpu/avr32/uc3/cpu.c +++ b/libcpu/avr32/uc3/cpu.c @@ -23,7 +23,7 @@ * reset cpu by dog's time-out * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { /*NOTREACHED*/ } diff --git a/libcpu/mips/gs232/cpuport.c b/libcpu/mips/gs232/cpuport.c index 1b13719449..e3c078241f 100644 --- a/libcpu/mips/gs232/cpuport.c +++ b/libcpu/mips/gs232/cpuport.c @@ -23,7 +23,7 @@ * this function will reset CPU * */ -void rt_hw_cpu_reset(void) +RT_WEAK void rt_hw_cpu_reset(void) { /* open the watch-dog */ WDT_EN = 0x01; /* watch dog enable */ @@ -38,7 +38,7 @@ void rt_hw_cpu_reset(void) * this function will shutdown CPU * */ -void rt_hw_cpu_shutdown(void) +RT_WEAK void rt_hw_cpu_shutdown(void) { rt_kprintf("shutdown...\n"); diff --git a/libcpu/risc-v/common/context_gcc.S b/libcpu/risc-v/common/context_gcc.S index 5c9f05c4e8..9f356f4191 100644 --- a/libcpu/risc-v/common/context_gcc.S +++ b/libcpu/risc-v/common/context_gcc.S @@ -7,6 +7,7 @@ * Date Author Notes * 2018/10/28 Bernard The unify RISC-V porting implementation * 2018/12/27 Jesven Add SMP support + * 2020/11/20 BalanceTWK Add FPU support */ #include "cpuport.h" @@ -72,6 +73,43 @@ rt_hw_context_switch: * mstatus.mie -> sp(2) * x(i) -> sp(i-4) */ +#ifdef ARCH_RISCV_FPU + addi sp, sp, -32 * FREGBYTES + + FSTORE f0, 0 * FREGBYTES(sp) + FSTORE f1, 1 * FREGBYTES(sp) + FSTORE f2, 2 * FREGBYTES(sp) + FSTORE f3, 3 * FREGBYTES(sp) + FSTORE f4, 4 * FREGBYTES(sp) + FSTORE f5, 5 * FREGBYTES(sp) + FSTORE f6, 6 * FREGBYTES(sp) + FSTORE f7, 7 * FREGBYTES(sp) + FSTORE f8, 8 * FREGBYTES(sp) + FSTORE f9, 9 * FREGBYTES(sp) + FSTORE f10, 10 * FREGBYTES(sp) + FSTORE f11, 11 * FREGBYTES(sp) + FSTORE f12, 12 * FREGBYTES(sp) + FSTORE f13, 13 * FREGBYTES(sp) + FSTORE f14, 14 * FREGBYTES(sp) + FSTORE f15, 15 * FREGBYTES(sp) + FSTORE f16, 16 * FREGBYTES(sp) + FSTORE f17, 17 * FREGBYTES(sp) + FSTORE f18, 18 * FREGBYTES(sp) + FSTORE f19, 19 * FREGBYTES(sp) + FSTORE f20, 20 * FREGBYTES(sp) + FSTORE f21, 21 * FREGBYTES(sp) + FSTORE f22, 22 * FREGBYTES(sp) + FSTORE f23, 23 * FREGBYTES(sp) + FSTORE f24, 24 * FREGBYTES(sp) + FSTORE f25, 25 * FREGBYTES(sp) + FSTORE f26, 26 * FREGBYTES(sp) + FSTORE f27, 27 * FREGBYTES(sp) + FSTORE f28, 28 * FREGBYTES(sp) + FSTORE f29, 29 * FREGBYTES(sp) + FSTORE f30, 30 * FREGBYTES(sp) + FSTORE f31, 31 * FREGBYTES(sp) + +#endif addi sp, sp, -32 * REGBYTES STORE sp, (a0) @@ -174,7 +212,7 @@ rt_hw_context_switch_exit: LOAD x1, 1 * REGBYTES(sp) - li t0, 0x00001800 + li t0, 0x00007800 csrw mstatus, t0 LOAD a0, 2 * REGBYTES(sp) csrs mstatus, a0 @@ -209,4 +247,42 @@ rt_hw_context_switch_exit: LOAD x31, 31 * REGBYTES(sp) addi sp, sp, 32 * REGBYTES + +#ifdef ARCH_RISCV_FPU + FLOAD f0, 0 * FREGBYTES(sp) + FLOAD f1, 1 * FREGBYTES(sp) + FLOAD f2, 2 * FREGBYTES(sp) + FLOAD f3, 3 * FREGBYTES(sp) + FLOAD f4, 4 * FREGBYTES(sp) + FLOAD f5, 5 * FREGBYTES(sp) + FLOAD f6, 6 * FREGBYTES(sp) + FLOAD f7, 7 * FREGBYTES(sp) + FLOAD f8, 8 * FREGBYTES(sp) + FLOAD f9, 9 * FREGBYTES(sp) + FLOAD f10, 10 * FREGBYTES(sp) + FLOAD f11, 11 * FREGBYTES(sp) + FLOAD f12, 12 * FREGBYTES(sp) + FLOAD f13, 13 * FREGBYTES(sp) + FLOAD f14, 14 * FREGBYTES(sp) + FLOAD f15, 15 * FREGBYTES(sp) + FLOAD f16, 16 * FREGBYTES(sp) + FLOAD f17, 17 * FREGBYTES(sp) + FLOAD f18, 18 * FREGBYTES(sp) + FLOAD f19, 19 * FREGBYTES(sp) + FLOAD f20, 20 * FREGBYTES(sp) + FLOAD f21, 21 * FREGBYTES(sp) + FLOAD f22, 22 * FREGBYTES(sp) + FLOAD f23, 23 * FREGBYTES(sp) + FLOAD f24, 24 * FREGBYTES(sp) + FLOAD f25, 25 * FREGBYTES(sp) + FLOAD f26, 26 * FREGBYTES(sp) + FLOAD f27, 27 * FREGBYTES(sp) + FLOAD f28, 28 * FREGBYTES(sp) + FLOAD f29, 29 * FREGBYTES(sp) + FLOAD f30, 30 * FREGBYTES(sp) + FLOAD f31, 31 * FREGBYTES(sp) + + addi sp, sp, 32 * FREGBYTES +#endif + mret diff --git a/libcpu/risc-v/common/cpuport.c b/libcpu/risc-v/common/cpuport.c index a44dc40f79..6cb8aaf3e7 100644 --- a/libcpu/risc-v/common/cpuport.c +++ b/libcpu/risc-v/common/cpuport.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2018/10/28 Bernard The unify RISC-V porting code. + * 2020/11/20 BalanceTWK Add FPU support */ #include <rthw.h> @@ -53,6 +54,40 @@ struct rt_hw_stack_frame rt_ubase_t t4; /* x29 - t4 - temporary register 4 */ rt_ubase_t t5; /* x30 - t5 - temporary register 5 */ rt_ubase_t t6; /* x31 - t6 - temporary register 6 */ +#ifdef ARCH_RISCV_FPU + rv_floatreg_t f0; /* f0 */ + rv_floatreg_t f1; /* f1 */ + rv_floatreg_t f2; /* f2 */ + rv_floatreg_t f3; /* f3 */ + rv_floatreg_t f4; /* f4 */ + rv_floatreg_t f5; /* f5 */ + rv_floatreg_t f6; /* f6 */ + rv_floatreg_t f7; /* f7 */ + rv_floatreg_t f8; /* f8 */ + rv_floatreg_t f9; /* f9 */ + rv_floatreg_t f10; /* f10 */ + rv_floatreg_t f11; /* f11 */ + rv_floatreg_t f12; /* f12 */ + rv_floatreg_t f13; /* f13 */ + rv_floatreg_t f14; /* f14 */ + rv_floatreg_t f15; /* f15 */ + rv_floatreg_t f16; /* f16 */ + rv_floatreg_t f17; /* f17 */ + rv_floatreg_t f18; /* f18 */ + rv_floatreg_t f19; /* f19 */ + rv_floatreg_t f20; /* f20 */ + rv_floatreg_t f21; /* f21 */ + rv_floatreg_t f22; /* f22 */ + rv_floatreg_t f23; /* f23 */ + rv_floatreg_t f24; /* f24 */ + rv_floatreg_t f25; /* f25 */ + rv_floatreg_t f26; /* f26 */ + rv_floatreg_t f27; /* f27 */ + rv_floatreg_t f28; /* f28 */ + rv_floatreg_t f29; /* f29 */ + rv_floatreg_t f30; /* f30 */ + rv_floatreg_t f31; /* f31 */ +#endif }; /** @@ -116,7 +151,7 @@ void rt_hw_context_switch_interrupt(rt_ubase_t from, rt_ubase_t to) #endif /* end of RT_USING_SMP */ /** shutdown CPU */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/risc-v/common/cpuport.h b/libcpu/risc-v/common/cpuport.h index 95268732cb..d6cec2f0cf 100644 --- a/libcpu/risc-v/common/cpuport.h +++ b/libcpu/risc-v/common/cpuport.h @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2018-10-03 Bernard The first version + * 2020/11/20 BalanceTWK Add FPU support */ #ifndef CPUPORT_H__ @@ -24,4 +25,19 @@ #define REGBYTES 4 #endif +#ifdef ARCH_RISCV_FPU +#ifdef ARCH_RISCV_FPU_D +#define FSTORE fsd +#define FLOAD fld +#define FREGBYTES 8 +#define rv_floatreg_t rt_int64_t +#endif +#ifdef ARCH_RISCV_FPU_S +#define FSTORE fsw +#define FLOAD flw +#define FREGBYTES 4 +#define rv_floatreg_t rt_int32_t +#endif +#endif + #endif diff --git a/libcpu/risc-v/k210/interrupt_gcc.S b/libcpu/risc-v/k210/interrupt_gcc.S index 0393ea51f8..dc4a720dea 100644 --- a/libcpu/risc-v/k210/interrupt_gcc.S +++ b/libcpu/risc-v/k210/interrupt_gcc.S @@ -15,6 +15,43 @@ .align 2 .global trap_entry trap_entry: +#ifdef ARCH_RISCV_FPU + addi sp, sp, -32 * FREGBYTES + + FSTORE f0, 0 * FREGBYTES(sp) + FSTORE f1, 1 * FREGBYTES(sp) + FSTORE f2, 2 * FREGBYTES(sp) + FSTORE f3, 3 * FREGBYTES(sp) + FSTORE f4, 4 * FREGBYTES(sp) + FSTORE f5, 5 * FREGBYTES(sp) + FSTORE f6, 6 * FREGBYTES(sp) + FSTORE f7, 7 * FREGBYTES(sp) + FSTORE f8, 8 * FREGBYTES(sp) + FSTORE f9, 9 * FREGBYTES(sp) + FSTORE f10, 10 * FREGBYTES(sp) + FSTORE f11, 11 * FREGBYTES(sp) + FSTORE f12, 12 * FREGBYTES(sp) + FSTORE f13, 13 * FREGBYTES(sp) + FSTORE f14, 14 * FREGBYTES(sp) + FSTORE f15, 15 * FREGBYTES(sp) + FSTORE f16, 16 * FREGBYTES(sp) + FSTORE f17, 17 * FREGBYTES(sp) + FSTORE f18, 18 * FREGBYTES(sp) + FSTORE f19, 19 * FREGBYTES(sp) + FSTORE f20, 20 * FREGBYTES(sp) + FSTORE f21, 21 * FREGBYTES(sp) + FSTORE f22, 22 * FREGBYTES(sp) + FSTORE f23, 23 * FREGBYTES(sp) + FSTORE f24, 24 * FREGBYTES(sp) + FSTORE f25, 25 * FREGBYTES(sp) + FSTORE f26, 26 * FREGBYTES(sp) + FSTORE f27, 27 * FREGBYTES(sp) + FSTORE f28, 28 * FREGBYTES(sp) + FSTORE f29, 29 * FREGBYTES(sp) + FSTORE f30, 30 * FREGBYTES(sp) + FSTORE f31, 31 * FREGBYTES(sp) + +#endif /* save thread context to thread stack */ addi sp, sp, -32 * REGBYTES diff --git a/libcpu/risc-v/k210/startup_gcc.S b/libcpu/risc-v/k210/startup_gcc.S index f5c0d8fa94..cc7126e8ab 100644 --- a/libcpu/risc-v/k210/startup_gcc.S +++ b/libcpu/risc-v/k210/startup_gcc.S @@ -67,38 +67,38 @@ _start: csrs mstatus, t0 fssr x0 - fmv.d.x f0, x0 - fmv.d.x f1, x0 - fmv.d.x f2, x0 - fmv.d.x f3, x0 - fmv.d.x f4, x0 - fmv.d.x f5, x0 - fmv.d.x f6, x0 - fmv.d.x f7, x0 - fmv.d.x f8, x0 - fmv.d.x f9, x0 - fmv.d.x f10,x0 - fmv.d.x f11,x0 - fmv.d.x f12,x0 - fmv.d.x f13,x0 - fmv.d.x f14,x0 - fmv.d.x f15,x0 - fmv.d.x f16,x0 - fmv.d.x f17,x0 - fmv.d.x f18,x0 - fmv.d.x f19,x0 - fmv.d.x f20,x0 - fmv.d.x f21,x0 - fmv.d.x f22,x0 - fmv.d.x f23,x0 - fmv.d.x f24,x0 - fmv.d.x f25,x0 - fmv.d.x f26,x0 - fmv.d.x f27,x0 - fmv.d.x f28,x0 - fmv.d.x f29,x0 - fmv.d.x f30,x0 - fmv.d.x f31,x0 + fmv.w.x f0, x0 + fmv.w.x f1, x0 + fmv.w.x f2, x0 + fmv.w.x f3, x0 + fmv.w.x f4, x0 + fmv.w.x f5, x0 + fmv.w.x f6, x0 + fmv.w.x f7, x0 + fmv.w.x f8, x0 + fmv.w.x f9, x0 + fmv.w.x f10,x0 + fmv.w.x f11,x0 + fmv.w.x f12,x0 + fmv.w.x f13,x0 + fmv.w.x f14,x0 + fmv.w.x f15,x0 + fmv.w.x f16,x0 + fmv.w.x f17,x0 + fmv.w.x f18,x0 + fmv.w.x f19,x0 + fmv.w.x f20,x0 + fmv.w.x f21,x0 + fmv.w.x f22,x0 + fmv.w.x f23,x0 + fmv.w.x f24,x0 + fmv.w.x f25,x0 + fmv.w.x f26,x0 + fmv.w.x f27,x0 + fmv.w.x f28,x0 + fmv.w.x f29,x0 + fmv.w.x f30,x0 + fmv.w.x f31,x0 .option push .option norelax diff --git a/libcpu/risc-v/nuclei/cpuport.c b/libcpu/risc-v/nuclei/cpuport.c index e456438f70..717e9bb1c7 100644 --- a/libcpu/risc-v/nuclei/cpuport.c +++ b/libcpu/risc-v/nuclei/cpuport.c @@ -152,7 +152,7 @@ void rt_hw_context_switch(rt_ubase_t from, rt_ubase_t to) * @brief shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/risc-v/t-head/e906/cpuport.c b/libcpu/risc-v/t-head/e906/cpuport.c index 5597aa237a..998bfdc340 100644 --- a/libcpu/risc-v/t-head/e906/cpuport.c +++ b/libcpu/risc-v/t-head/e906/cpuport.c @@ -157,7 +157,7 @@ void rt_hw_interrupt_enable(rt_base_t level) } /** shutdown CPU */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/rx/cpuport.c b/libcpu/rx/cpuport.c index 681c0e8e6e..a01f598e99 100644 --- a/libcpu/rx/cpuport.c +++ b/libcpu/rx/cpuport.c @@ -182,7 +182,7 @@ void rt_hw_context_switch_interrupt(rt_uint32_t from, rt_uint32_t to) * * @author LXZ (2014/11/8) */ -void rt_hw_cpu_shutdown(void) +RT_WEAK void rt_hw_cpu_shutdown(void) { rt_kprintf("shutdown...\n"); diff --git a/libcpu/ti-dsp/c28x/cpuport.c b/libcpu/ti-dsp/c28x/cpuport.c index 3f88606c65..0c7dce2a4e 100644 --- a/libcpu/ti-dsp/c28x/cpuport.c +++ b/libcpu/ti-dsp/c28x/cpuport.c @@ -121,7 +121,7 @@ int __rt_ffs(int value) /** * shutdown CPU */ -void rt_hw_cpu_shutdown(void) +RT_WEAK void rt_hw_cpu_shutdown(void) { rt_kprintf("shutdown...\n"); diff --git a/libcpu/unicore32/sep6200/cpu.c b/libcpu/unicore32/sep6200/cpu.c index ebea8750e1..9452b4e59d 100644 --- a/libcpu/unicore32/sep6200/cpu.c +++ b/libcpu/unicore32/sep6200/cpu.c @@ -259,7 +259,7 @@ static void sep6200_poweroff(void) * reset cpu by dog's time-out * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { rt_kprintf("Soft reset, Restarting system...\n"); @@ -274,7 +274,7 @@ void rt_hw_cpu_reset() * shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_uint32_t level; rt_kprintf("shutdown...\n"); diff --git a/libcpu/xilinx/microblaze/cpu.c b/libcpu/xilinx/microblaze/cpu.c index 50a0e34dcd..d37dcda350 100755 --- a/libcpu/xilinx/microblaze/cpu.c +++ b/libcpu/xilinx/microblaze/cpu.c @@ -18,7 +18,7 @@ * this function will reset CPU * */ -void rt_hw_cpu_reset() +RT_WEAK void rt_hw_cpu_reset() { } @@ -26,7 +26,7 @@ void rt_hw_cpu_reset() * this function will shutdown CPU * */ -void rt_hw_cpu_shutdown() +RT_WEAK void rt_hw_cpu_shutdown() { rt_kprintf("shutdown...\n"); |
