arch/risc-v: Refine riscv_testset.S

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2021-12-29 18:39:41 +08:00 committed by Xiang Xiao
parent 2b60468845
commit c15195b126
8 changed files with 36 additions and 20 deletions

View file

@ -146,6 +146,7 @@ config ARCH_RV_ISA_M
config ARCH_RV_ISA_A
bool
default n
select ARCH_HAVE_TESTSET
config ARCH_RV_ISA_C
bool
@ -162,11 +163,6 @@ config ARCH_RV_ISA_D
depends on ARCH_RV_ISA_F
select ARCH_HAVE_DPFPU
config ARCH_RV32I
bool
default n
select ARCH_HAVE_SETJMP
config ARCH_FAMILY
string
default "rv32" if ARCH_RV32

View file

@ -25,6 +25,8 @@ HEAD_ASRC = bl602_vectors.S
# Specify our general Assembly files
CHIP_ASRCS = bl602_head.S riscv_syscall.S bl602_entry.S
CMN_ASRCS += riscv_testset.S
# Specify C code within the common directory to be included
CMN_CSRCS += riscv_initialize.c riscv_swint.c
CMN_CSRCS += riscv_createstack.c riscv_exit.c

View file

@ -25,6 +25,8 @@ HEAD_ASRC = c906_vectors.S
# Specify our general Assembly files
CHIP_ASRCS = c906_head.S
CMN_ASRCS += riscv_testset.S
# Specify C code within the common directory to be included
CMN_CSRCS += riscv_initialize.c riscv_swint.c
CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_fault.c

View file

@ -1,5 +1,5 @@
/****************************************************************************
* arch/risc-v/src/rv64gc/riscv_testset.S
* arch/risc-v/src/common/riscv_testset.S
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -25,12 +25,20 @@
#include <nuttx/config.h>
#include <arch/spinlock.h>
.file "arm_testset.S"
.file "riscv_testset.S"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_ARCH_RV32
#define LR_INST lr.w
#define SC_INST sc.w
#else
#define LR_INST lr.d
#define SC_INST sc.d
#endif
/****************************************************************************
* Public Symbols
****************************************************************************/
@ -78,29 +86,29 @@
up_testset:
li a1, SP_LOCKED
li a1, SP_LOCKED
/* Test if the spinlock is locked or not */
retry:
lr.d a2, (a0) /* Test if spinlock is locked or not */
beq a2, a1, locked /* Already locked? Go to locked: */
LR_INST a2, (a0) /* Test if spinlock is locked or not */
beq a2, a1, locked /* Already locked? Go to locked: */
/* Not locked ... attempt to lock it */
sc.d a2, a1, (a0) /* Attempt to set the locked state (a1) to (a0) */
bnez a2, retry /* a2 will not be zero, if sc.b failed, try again */
SC_INST a2, a1, (a0) /* Attempt to set the locked state (a1) to (a0) */
bnez a2, retry /* a2 will not be zero, if sc.b failed, try again */
/* Lock acquired -- return SP_UNLOCKED */
fence /* Required before accessing protected resource */
li a0, SP_UNLOCKED
jr ra
fence /* Required before accessing protected resource */
li a0, SP_UNLOCKED
jr ra
/* Lock not acquired -- return SP_LOCKED */
locked:
li a0, SP_LOCKED
jr ra
li a0, SP_LOCKED
jr ra
.size up_testset, . - up_testset
.end

View file

@ -25,6 +25,8 @@ HEAD_ASRC = fe310_vectors.S
# Specify our general Assembly files
CHIP_ASRCS = fe310_head.S riscv_syscall.S
CMN_ASRCS += riscv_testset.S
# Specify C code within the common directory to be included
CMN_CSRCS += riscv_initialize.c riscv_swint.c
CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c

View file

@ -25,6 +25,8 @@ HEAD_ASRC = litex_vectors.S
# Specify our general Assembly files
CHIP_ASRCS = litex_head.S riscv_syscall.S
CMN_ASRCS += riscv_testset.S
# Specify C code within the common directory to be included
CMN_CSRCS += riscv_initialize.c riscv_swint.c
CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c

View file

@ -25,6 +25,8 @@ HEAD_ASRC = mpfs_vectors.S
# Specify our general Assembly files
CHIP_ASRCS = mpfs_head.S
CMN_ASRCS += riscv_testset.S
# Specify C code within the common directory to be included
CMN_CSRCS += riscv_initialize.c riscv_swint.c
CMN_CSRCS += riscv_createstack.c riscv_exit.c riscv_fault.c

View file

@ -25,6 +25,8 @@ HEAD_ASRC = qemu_rv32_head.S
# Specify our general Assembly files
CHIP_ASRCS = qemu_rv32_vectors.S riscv_syscall.S
CMN_ASRCS += riscv_testset.S
# Specify C code within the common directory to be included
CMN_CSRCS += riscv_initialize.c riscv_swint.c
CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c
@ -39,15 +41,15 @@ CMN_CSRCS += riscv_checkstack.c
endif
ifeq ($(CONFIG_ARCH_HAVE_VFORK),y)
CMN_CSRCS += riscv_vfork.c
CMN_CSRCS += riscv_vfork.c
endif
ifeq ($(CONFIG_SCHED_THREAD_LOCAL),y)
CMN_CSRCS += riscv_tls.c
CMN_CSRCS += riscv_tls.c
endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += riscv_fpu.S
CMN_ASRCS += riscv_fpu.S
endif
# Specify our C code within this directory to be included