diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-28 10:46:36 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2021-04-28 10:46:36 +0200 |
| commit | 152f14654bfb438d074833e3c8d5392d300f5095 (patch) | |
| tree | 633e4dad7153a1d01f7f24b8fd0386c6fe7848ca /src/boot | |
| parent | f13b26eeb4f9afba3a1aed2516655b34139979aa (diff) | |
Debug trampoline and paging
Diffstat (limited to 'src/boot')
| -rw-r--r-- | src/boot/boot.S | 12 | ||||
| -rw-r--r-- | src/boot/trampoline.cc | 13 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/boot/boot.S b/src/boot/boot.S index 73ee637..d8795d0 100644 --- a/src/boot/boot.S +++ b/src/boot/boot.S @@ -1,8 +1,6 @@ .globl _start -.globl MB_INFO .extern _bss_start .extern _bss_end -.extern higherhalf .section .multiboot @@ -35,7 +33,7 @@ mb_header_start: # ----------- End tag # ----------- Ask framebuffer tag .align 8 -.short 6 +.short 5 .short 1 .int 20 .int 0 @@ -55,6 +53,7 @@ MB_INFO: # Will contains the Multiboot2 information data structure address _start: mov %ebx, (MB_INFO) + # ----- Setup PAE Paging (identity on the first 10MB) mov $8192, %ecx # 8*4096/4 (8 tables of 4096 byte each divide by 4 because of movl) mov $0, %eax @@ -122,8 +121,12 @@ mov %ax, %gs mov %ax, %ss mov $__stack_pma, %esp -# Setup +# Setup +movq (MB_INFO), %rdi +mov $0xFFFFFFFF,%rax +and %rax, %rdi call trampoline +movq %rax, (MB_INFO) mov $__kernel_vma, %rsp # Zeroing the .bss section @@ -138,6 +141,7 @@ start_zeroing: end_zeroing: # Launch kernel +movq (MB_INFO), %rdi call boucane # GDT diff --git a/src/boot/trampoline.cc b/src/boot/trampoline.cc index b03bd43..a75b472 100644 --- a/src/boot/trampoline.cc +++ b/src/boot/trampoline.cc @@ -10,6 +10,10 @@ /// @brief Define where first PAE paging paging will be u64 trampoline_next_page; +/// @brief Ensure +#define MAX_MB_INFOS 4096 +u8 mb_infos[MAX_MB_INFOS]; + u64 trampoline_paging_allocate_table(){ for(u64 i=0;i<512;i++) ((u64*)trampoline_next_page)[i]=0; @@ -63,7 +67,12 @@ void trampoline_paging_allocate_addr(u64* pml4_table, u64 virt, u64 phy, u16 opt /** * Setup High-Half Kernel Paging */ -extern "C" void trampoline(){ +extern "C" u8* trampoline(u8* mb_infos_addr){ + // Save mb infos before anything else + for(int i=0;i<MAX_MB_INFOS;i++){ + mb_infos[i]=mb_infos_addr[i]; + } + u64 kernel_vma,stack_pma; asm("movq $__kernel_vma, %0":"=r"(kernel_vma)); asm("movq $__userspace_pma, %0":"=r"(trampoline_next_page)); @@ -91,4 +100,6 @@ extern "C" void trampoline(){ "movq %0, %%rax \n\t" "movq %%rax, %%cr3 \n\t" :: "r" (pml4)); + + return mb_infos; }
\ No newline at end of file |
