Initial commit
[nyankernel.git] / arch / x64 / kernel / vmnyan.LD
blob4decea28dd3fdc79b0071cfb5740eb24cb98cdc5
1 #include <nyan/kconfig.h>
3 #include <arch/ptbls_types.h>
4 #include <arch/mm.h>
6 OUTPUT_FORMAT(binary);
7 OUTPUT_ARCH(i386:x86-64);
8 SECTIONS {
9         . = 0;
10         ld_img_start = .;
11         .init_va_jmp_code : {
12                 */arch/x64/kernel/head.cpp.s.o(.head_text_va_jmp_code)
13         }
14         .init : {
15                 */arch/x64/kernel/head.cpp.s.o(.head_text)
16                 INCLUDE arch/x64/kernel/init/vmnyan.ld.script.part;
17         }
18         . = ALIGN(1 << 21); // 2MiB
19         .kernel : {
20                 INCLUDE arch/x64/kernel/vmnyan.ld.script.part;
21         }
22         . = ALIGN(1 << 21); // 2MiB
23         ld_img_end = .;
24         ld_img_bytes_n = . - ld_img_start;
25         ld_img_p2mibs_n = (ld_img_end - ld_img_start) / (1 << 21);
26         ld_img_p2mibs_n_sz = ld_img_p2mibs_n * (1 << PTS_ENTRY_BYTES_N_LOG2); // byte count of 2MiB entries
27         /* some absolute kernel virtual addresses for initialization, the kernel start virtual
28            address is computed from its page table entries */
29         ld_free_pages_list_va = ABSOLUTE((CANONICAL_HI_VA_MSK \
30                                         | (CONFIG_KERNEL_PT256TIB_512GIBENT_HI_IDX * (1 << 39) \
31                                         + CONFIG_KERNEL_PT512GIB_1GIBENT_IDX * (1 << 30))) \
32                                                                 + free_pages_list - startup);
34 ASSERT(SIZEOF(.init_va_jmp_code) <= (1 << 21), "ERROR: the code for the jump into our kernel virtual address space does not fit into the first 2MiB page of the kernel image");