aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2020-01-28 08:27:13 -0800
committerAndrew Waterman <andrew@sifive.com>2021-08-04 16:41:26 -0700
commitdac6ac2a87367583bf92cf24d0aabde6c215ccb1 (patch)
tree45b4654c47490b05969e566ef4d1c95aa7b5a9ad
parent423801e35d048187d88fcbff55e20c4c34d27bee (diff)
downloadriscv-pk-dac6ac2a87367583bf92cf24d0aabde6c215ccb1.zip
riscv-pk-dac6ac2a87367583bf92cf24d0aabde6c215ccb1.tar.gz
riscv-pk-dac6ac2a87367583bf92cf24d0aabde6c215ccb1.tar.bz2
Use __builtin_frame_address() instead of "sp" directly.
Also use pointer arithmetic on char * instead of void *.
-rw-r--r--machine/mtrap.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/machine/mtrap.h b/machine/mtrap.h
index a8dbeff..2f2e499 100644
--- a/machine/mtrap.h
+++ b/machine/mtrap.h
@@ -49,12 +49,12 @@ typedef struct {
} hls_t;
#define MACHINE_STACK_TOP() ({ \
- register uintptr_t sp asm ("sp"); \
- (void*)((sp + RISCV_PGSIZE) & -RISCV_PGSIZE); })
+ uintptr_t sp = (uintptr_t)__builtin_frame_address(0) ; \
+ (char *)((sp + 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*)((void*)HLS() + RISCV_PGSIZE * ((id) - read_const_csr(mhartid))))
+#define OTHER_HLS(id) ((hls_t*)((char*)HLS() + RISCV_PGSIZE * ((id) - read_const_csr(mhartid))))
hls_t* hls_init(uintptr_t hart_id);
void parse_config_string();