589f2a5b3db2e34d35517084cb4827941ff1349b
[lunaix-os.git] / lunaix-os / arch / x86 / includes / sys / boot / bstage.h
1 #ifndef __LUNAIX_BSTAGE_H
2 #define __LUNAIX_BSTAGE_H
3 #include <lunaix/types.h>
4
5 #define boot_text __attribute__((section(".boot.text")))
6 #define boot_data __attribute__((section(".boot.data")))
7 #define boot_bss __attribute__((section(".boot.bss")))
8
9 /*
10     Bridge the far symbol to the vicinity.
11
12     Which is a workaround for relocation 
13     issue where symbol define in kernel 
14     code is too far away from the boot code.
15 */
16 #ifdef CONFIG_ARCH_X86_64
17 #define bridge_farsym(far_sym)          \
18     asm(                                \
19         ".section .boot.bss\n"         \
20         ".align 8\n"                    \
21         ".globl __lc_" #far_sym "\n"    \
22         "__lc_" #far_sym ":\n"          \
23         ".8byte " #far_sym "\n"         \
24         ".previous\n"                   \
25     );                                  \
26     extern unsigned long __lc_##far_sym[];
27 #define __far(far_sym)  (__lc_##far_sym[0])
28
29 #else
30 #define bridge_farsym(far_sym) extern u8_t far_sym[];
31 #define __far(far_sym) ((ptr_t)far_sym)
32
33 #endif
34
35 ptr_t remap_kernel();
36
37 #endif /* __LUNAIX_BSTAGE_H */