arch/riscv: Access [m|s]scratch through CSR_SCRATCH macro
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
be2fee7d6e
commit
e959775397
@ -37,6 +37,7 @@
|
||||
/* CSR definitions */
|
||||
|
||||
# define CSR_STATUS sstatus /* Global status register */
|
||||
# define CSR_SCRATCH sscratch /* Scratch register */
|
||||
# define CSR_EPC sepc /* Exception program counter */
|
||||
# define CSR_IE sie /* Interrupt enable register */
|
||||
# define CSR_CAUSE scause /* Interrupt cause register */
|
||||
@ -69,6 +70,7 @@
|
||||
/* CSR definitions */
|
||||
|
||||
# define CSR_STATUS mstatus /* Global status register */
|
||||
# define CSR_SCRATCH mscratch /* Scratch register */
|
||||
# define CSR_EPC mepc /* Exception program counter */
|
||||
# define CSR_IE mie /* Interrupt enable register */
|
||||
# define CSR_CAUSE mcause /* Interrupt cause register */
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include <arch/barriers.h>
|
||||
#include <arch/mode.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
@ -87,7 +88,7 @@ void riscv_percpu_add_hart(uintptr_t hartid)
|
||||
|
||||
/* Set the scratch register value to point to the scratch area */
|
||||
|
||||
WRITE_CSR(sscratch, &g_scratch[hartid]);
|
||||
WRITE_CSR(CSR_SCRATCH, &g_scratch[hartid]);
|
||||
|
||||
/* Make sure it sticks */
|
||||
|
||||
@ -108,7 +109,7 @@ void riscv_percpu_add_hart(uintptr_t hartid)
|
||||
|
||||
uintptr_t riscv_percpu_get_hartid(void)
|
||||
{
|
||||
uintptr_t scratch = READ_CSR(sscratch);
|
||||
uintptr_t scratch = READ_CSR(CSR_SCRATCH);
|
||||
|
||||
DEBUGASSERT(scratch >= (uintptr_t) &g_scratch &&
|
||||
scratch <= (uintptr_t) &g_scratch + sizeof(g_scratch));
|
||||
|
Loading…
Reference in New Issue
Block a user