From 18084da90157ddc7aa4448e5f216cf6a486a64c8 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Wed, 4 Aug 2021 16:40:14 -0700 Subject: Revert "Use __builtin_frame_address() instead of "sp" directly." This reverts commit 17bec41e9bd44c43901938b784680661b9b28a76. --- machine/mtrap.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'machine') diff --git a/machine/mtrap.h b/machine/mtrap.h index 2f2e499..e9ef139 100644 --- a/machine/mtrap.h +++ b/machine/mtrap.h @@ -48,13 +48,18 @@ typedef struct { volatile uint32_t* plic_s_ie; } hls_t; -#define MACHINE_STACK_TOP() ({ \ - uintptr_t sp = (uintptr_t)__builtin_frame_address(0) ; \ - (char *)((sp + RISCV_PGSIZE) & -RISCV_PGSIZE); }) +#define STACK_POINTER() ({ \ + uintptr_t __sp; \ + __asm__("mv %0, sp" : "=r"(__sp)); \ + __sp; \ +}) + +#define MACHINE_STACK_TOP() \ + ({ (void*)((STACK_POINTER() + RISCV_PGSIZE) & -RISCV_PGSIZE); }) // hart-local storage, at top of stack #define HLS() ((hls_t*)(MACHINE_STACK_TOP() - HLS_SIZE)) -#define OTHER_HLS(id) ((hls_t*)((char*)HLS() + RISCV_PGSIZE * ((id) - read_const_csr(mhartid)))) +#define OTHER_HLS(id) ((hls_t*)((void*)HLS() + RISCV_PGSIZE * ((id) - read_const_csr(mhartid)))) hls_t* hls_init(uintptr_t hart_id); void parse_config_string(); -- cgit v1.1