Skip to content

Commit

Permalink
Revert "Use __builtin_frame_address() instead of "sp" directly."
Browse files Browse the repository at this point in the history
This reverts commit 17bec41.
  • Loading branch information
aswaterman committed Aug 4, 2021
1 parent 17bec41 commit 18084da
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions machine/mtrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 18084da

Please sign in to comment.