diff --git a/baremetal/lib/aarch64.S b/baremetal/lib/aarch64.S index 65916ea..cd97272 100644 --- a/baremetal/lib/aarch64.S +++ b/baremetal/lib/aarch64.S @@ -8,7 +8,7 @@ mystart: isb /* Load the vector table. */ - ldr x0, =vector_table + ldr x0, =lkmc_vector_table msr vbar_el1, x0 /* Prepare the stack for main, mandatory for C code. */ diff --git a/lkmc.c b/lkmc.c index deb6261..bc11c30 100644 --- a/lkmc.c +++ b/lkmc.c @@ -15,12 +15,12 @@ void lkmc_assert_fail() { #if defined(__aarch64__) #define LKMC_SYSREG_READ_WRITE(type, name) \ - type CONCAT(CONCAT(LKMC_SYSREG_SYMBOL_PREFIX, name), _read(void)) { \ + type LKMC_CONCAT(LKMC_CONCAT(LKMC_SYSREG_SYMBOL_PREFIX, name), _read(void)) { \ type name; \ __asm__ __volatile__("mrs %0, " #name : "=r" (name) : : ); \ return name; \ } \ - void CONCAT(CONCAT(LKMC_SYSREG_SYMBOL_PREFIX, name), _write(type name)) { \ + void LKMC_CONCAT(LKMC_CONCAT(LKMC_SYSREG_SYMBOL_PREFIX, name), _write(type name)) { \ __asm__ __volatile__("msr " #name ", %0" : : "r" (name) : ); \ } LKMC_SYSREG_OPS diff --git a/lkmc.h b/lkmc.h index e0ceb83..affa151 100644 --- a/lkmc.h +++ b/lkmc.h @@ -11,8 +11,8 @@ void lkmc_assert_fail(); #endif /* https://stackoverflow.com/questions/1489932/how-to-concatenate-twice-with-the-c-preprocessor-and-expand-a-macro-as-in-arg */ -#define CONCAT_EVAL(a,b) a ## b -#define CONCAT(a,b) CONCAT_EVAL(a, b) +#define LKMC_CONCAT_EVAL(a,b) a ## b +#define LKMC_CONCAT(a,b) LKMC_CONCAT_EVAL(a, b) #define LKMC_GLOBAL(name) \ .global name; \ @@ -148,8 +148,8 @@ LKMC_VECTOR_SYMBOL_PREFIX ## func_name:; \ /* Define the actual vector table. */ #define LKMC_VECTOR_TABLE \ .align 11; \ - .global vector_table; \ -vector_table:; \ + LKMC_GLOBAL(lkmc_vector_table); \ + ; \ LKMC_VECTOR_ENTRY(curr_el_sp0_sync); \ LKMC_VECTOR_ENTRY(curr_el_sp0_irq); \ LKMC_VECTOR_ENTRY(curr_el_sp0_fiq); \ @@ -239,8 +239,8 @@ void lkmc_vector_trap_handler(LkmcVectorExceptionFrame *exception); #define LKMC_SYSREG_SYMBOL_PREFIX lkmc_sysreg_ #define LKMC_SYSREG_READ_WRITE(type, name) \ - type CONCAT(CONCAT(LKMC_SYSREG_SYMBOL_PREFIX, name), _read)(void); \ - void CONCAT(CONCAT(LKMC_SYSREG_SYMBOL_PREFIX, name), _write)(type name) + type LKMC_CONCAT(LKMC_CONCAT(LKMC_SYSREG_SYMBOL_PREFIX, name), _read)(void); \ + void LKMC_CONCAT(LKMC_CONCAT(LKMC_SYSREG_SYMBOL_PREFIX, name), _write)(type name) #define LKMC_SYSREG_OPS \ LKMC_SYSREG_READ_WRITE(uint32_t, cntv_ctl_el0); \ LKMC_SYSREG_READ_WRITE(uint32_t, daif); \