mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
arch/risc-v: Use riscv_fpuconfig to enable FPU
Use common function instead of chip specified code. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
@@ -126,20 +126,6 @@ bl602_entry_zero_wifi_bss_loop:
|
|||||||
bltu a0, a1, bl602_entry_zero_wifi_bss_loop
|
bltu a0, a1, bl602_entry_zero_wifi_bss_loop
|
||||||
bl602_entry_zero_wifi_bss_end:
|
bl602_entry_zero_wifi_bss_end:
|
||||||
|
|
||||||
#ifndef __riscv_float_abi_soft
|
|
||||||
|
|
||||||
/* Enable FPU */
|
|
||||||
|
|
||||||
li t0, MSTATUS_FS
|
|
||||||
csrs mstatus, t0
|
|
||||||
csrr t1, mstatus
|
|
||||||
and t1, t1, t0
|
|
||||||
beqz t1, bl602_entry_enable_fpu_end
|
|
||||||
fssr x0
|
|
||||||
|
|
||||||
bl602_entry_enable_fpu_end:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auipc ra, 0
|
auipc ra, 0
|
||||||
addi sp, sp, -16
|
addi sp, sp, -16
|
||||||
sw ra, 8(sp)
|
sw ra, 8(sp)
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ __cyg_profile_func_exit(void *this_fn, void *call_site)
|
|||||||
|
|
||||||
void bfl_main(void)
|
void bfl_main(void)
|
||||||
{
|
{
|
||||||
|
/* Configure FPU */
|
||||||
|
|
||||||
|
riscv_fpuconfig();
|
||||||
|
|
||||||
/* set interrupt vector */
|
/* set interrupt vector */
|
||||||
|
|
||||||
asm volatile("csrw mtvec, %0" ::"r"((uintptr_t)exception_common + 2));
|
asm volatile("csrw mtvec, %0" ::"r"((uintptr_t)exception_common + 2));
|
||||||
|
|||||||
@@ -52,13 +52,6 @@ __start:
|
|||||||
|
|
||||||
sfence.vma x0,x0
|
sfence.vma x0,x0
|
||||||
|
|
||||||
/* enable FPU if CFLAGS has 'f' or 'd' in -march */
|
|
||||||
|
|
||||||
#ifdef __riscv_flen
|
|
||||||
li a0, MSTATUS_FS_INIT
|
|
||||||
csrs mstatus, a0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* enable thead ISA extension:
|
/* enable thead ISA extension:
|
||||||
* BIT22: enable the THEAD ISA extensions.
|
* BIT22: enable the THEAD ISA extensions.
|
||||||
* BIT21: enable extended attributes in PTE.
|
* BIT21: enable extended attributes in PTE.
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ void __c906_start(uint32_t mhartid)
|
|||||||
const uint32_t *src;
|
const uint32_t *src;
|
||||||
uint32_t *dest;
|
uint32_t *dest;
|
||||||
|
|
||||||
|
/* Configure FPU */
|
||||||
|
|
||||||
|
riscv_fpuconfig();
|
||||||
|
|
||||||
if (0 != mhartid)
|
if (0 != mhartid)
|
||||||
{
|
{
|
||||||
while (true);
|
while (true);
|
||||||
|
|||||||
@@ -116,20 +116,15 @@ __start:
|
|||||||
|
|
||||||
sfence.vma x0, x0
|
sfence.vma x0, x0
|
||||||
|
|
||||||
/* enable FPU and accelerator if present, setting ignored on E51
|
/* Enable accelerator if present, setting ignored on E51
|
||||||
* 15,16 = MSTATUS_XS, 17,18 = MSTATUS_MPRV
|
* 15,16 = MSTATUS_XS, 17,18 = MSTATUS_MPRV
|
||||||
* not defined on riscv-v/include/csr.h
|
* not defined on riscv-v/include/csr.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* li t0, MSTATUS_FS_DIRTY | (1 << 15) | (1 << 16) | (1 << 17) | (1 << 18) */
|
/* li t0, (1 << 15) | (1 << 16) | (1 << 17) | (1 << 18) */
|
||||||
li t0, 0x00006000 | 0x00018000 /* MSTATUS_FS | MSTATUS_XS */
|
li t0, 0x00018000 /* MSTATUS_XS */
|
||||||
csrs mstatus, t0
|
csrs mstatus, t0
|
||||||
|
|
||||||
/* Init floating point control register to zero */
|
|
||||||
#ifdef __riscv_flen
|
|
||||||
fscsr x0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
.skip_e51:
|
.skip_e51:
|
||||||
|
|
||||||
/* initialize global pointer, global data
|
/* initialize global pointer, global data
|
||||||
|
|||||||
@@ -116,6 +116,13 @@ void __mpfs_start(uint64_t mhartid)
|
|||||||
const uint32_t *src;
|
const uint32_t *src;
|
||||||
uint32_t *dest;
|
uint32_t *dest;
|
||||||
|
|
||||||
|
/* Configure FPU (hart 0 don't have an FPU) */
|
||||||
|
|
||||||
|
if (mhartid != 0)
|
||||||
|
{
|
||||||
|
riscv_fpuconfig();
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear .bss. We'll do this inline (vs. calling memset) just to be
|
/* Clear .bss. We'll do this inline (vs. calling memset) just to be
|
||||||
* certain that there are no issues with the state of global variables.
|
* certain that there are no issues with the state of global variables.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ void qemu_rv_start(int mhartid)
|
|||||||
{
|
{
|
||||||
uint32_t *dest;
|
uint32_t *dest;
|
||||||
|
|
||||||
|
/* Configure FPU */
|
||||||
|
|
||||||
|
riscv_fpuconfig();
|
||||||
|
|
||||||
if (mhartid > 0)
|
if (mhartid > 0)
|
||||||
{
|
{
|
||||||
goto cpux;
|
goto cpux;
|
||||||
|
|||||||
Reference in New Issue
Block a user