Moving to higher half KRNL

This commit is contained in:
Oscar 2017-02-03 19:10:51 -08:00
parent ce06ee6bbd
commit e263f26b6b
4 changed files with 10 additions and 7 deletions

Binary file not shown.

View File

@ -18,7 +18,7 @@ ALL_TARGET_DIRS := $(addprefix $(TARGET_DIR)/,$(call rdircard, $(SOURCE_DIR)))
ASM_HEADER_DIRS := $(call rdircardex, $(SOURCE_DIR), *.inc)
C_FLAGS := -std=c11 -g -c -mcmodel=kernel -fno-exceptions -ffreestanding -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -masm=intel -Wall -Werror -Wextra -Wno-comment $(addprefix -I, $(HEADER_DIRS))
ASM_FLAGS := -f elf64 -F dwarf -g $(addprefix -I, $(ASM_HEADER_DIRS))
ASM_FLAGS := -w+all -f elf64 -F dwarf -g $(addprefix -I, $(ASM_HEADER_DIRS))
LD_FLAGS := -lgcc -nodefaultlibs -nostartfiles -nostdlib -Wl,-n -Wl,--build-id=none
C_SRC := $(call rwildcard, $(SOURCE_DIR), *.c)

View File

@ -64,10 +64,10 @@ cld
cmp eax,MULTIBOOT_LOADED_MAGIC
je .loaded_by_grub
hlt
.loaded_by_grub:
.loaded_by_grub:
; set stack pointer
mov esp, 0
mov esp, GET_PADDR(hal_temp_stack)
; save multiboot_info*
mov esi,ebx
@ -81,7 +81,7 @@ hlt
.init_x64:
; disable paging first
mov eax, cr0 ; Set the A-register to control register 0.
and eax, 01111111111111111111111111111111b ; Clear the PG-bit, which is bit 31.
and eax, 0x7FFFFFFF ; Clear the PG-bit, which is bit 31.
mov cr0, eax ; Set control register 0 to the A-register.
; write values for pml4
@ -188,13 +188,14 @@ KERNEL_HEAP_SIZE equ 8192
KERNEL_STACK_SIZE equ 8192
align 4096 ;4k alignment
hal_temp_heap:
times KERNEL_HEAP_SIZE db 0 ; initially 8k heap
align 4096 ;4k alignment
times KERNEL_STACK_SIZE db 0 ; initially 8k stack
hal_temp_stack:
; PAGE TABLES YA BOI GUZMA YO!
align 4096
; temporary page table
PML4_BASE:
times 512 dq 0 ;reserved the rest for page entries

View File

@ -2,4 +2,6 @@ HAL_KERNEL_BASE_PADDR equ 0x1000000 ; #16 MB
global HAL_KERNEL_BASE_PADDR
HAL_KERNEL_BASE_VADDR equ 0xFFFFFFFF80000000
global HAL_KERNEL_BASE_VADDR
global HAL_KERNEL_BASE_VADDR
%define GET_PADDR(x) x - HAL_KERNEL_BASE_VADDR