mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:47:44 +00:00
Kernel: Introduce basic pre-kernel environment
This implements a simple bootloader that is capable of loading ELF64 kernel images. It does this by using QEMU/GRUB to load the kernel image from disk and pass it to our bootloader as a Multiboot module. The bootloader then parses the ELF image and sets it up appropriately. The kernel's entry point is a C++ function with architecture-native code. Co-authored-by: Liav A <liavalb@gmail.com>
This commit is contained in:
parent
357ddd393e
commit
7e94b090fe
30 changed files with 1207 additions and 181 deletions
|
@ -1,6 +1,19 @@
|
|||
#define _BOOTLOADER
|
||||
#include <Kernel/Sections.h>
|
||||
|
||||
.section .text
|
||||
|
||||
.global gdt64ptr
|
||||
gdt64ptr:
|
||||
#if ARCH(X86_64)
|
||||
.quad 0
|
||||
#else
|
||||
.int 0
|
||||
#endif
|
||||
|
||||
.global code64_sel
|
||||
code64_sel:
|
||||
.short 0
|
||||
|
||||
.extern init_ap
|
||||
.type init_ap, @function
|
||||
|
||||
|
@ -92,16 +105,15 @@ apic_ap_start32:
|
|||
movl %eax, %cr0
|
||||
|
||||
/* load the temporary 64-bit gdt from boot that points above 3GB */
|
||||
mov $(gdt64ptr - KERNEL_BASE), %eax
|
||||
// FIXME: uncomment this
|
||||
//mov gdt64ptr, %eax
|
||||
lgdt (%eax)
|
||||
|
||||
/* jump above 3GB into our identity mapped area now */
|
||||
ljmpl $code64_sel, $(apic_ap_start64 - apic_ap_start + 0xc0008000)
|
||||
// FIXME: this assumes that code64_sel is always 8
|
||||
ljmpl $8, $(apic_ap_start64 - apic_ap_start + 0xc0008000)
|
||||
.code64
|
||||
apic_ap_start64:
|
||||
movabs $gdt64ptr, %rax
|
||||
lgdt (%rax)
|
||||
|
||||
mov $0, %ax
|
||||
mov %ax, %ss
|
||||
mov %ax, %ds
|
||||
|
@ -129,7 +141,8 @@ apic_ap_start64:
|
|||
|
||||
/* push the Processor pointer this CPU is going to use */
|
||||
movq (ap_cpu_init_processor_info_array - apic_ap_start)(%ebp), %rax
|
||||
movq $KERNEL_BASE, %r8
|
||||
movabsq $(kernel_base), %r8
|
||||
movq (%r8), %r8
|
||||
addq %r8, %rax
|
||||
movq 0(%rax, %rsi, 4), %rax
|
||||
push %rax
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue