Sun, 24 Dec 2017 16:57:59 +0100
7 files changed,
41 insertions(+),
18 deletions(-)
M
boot/boot.s
→
boot/boot.s
@@ -31,6 +31,8 @@ # reset bootdrive
reset: movw $reset_msg, %si call print + movw $bootdrive_msg, %si + call print movb $0x00, %ah int $0x13@@ -71,6 +73,9 @@ lgdt (GDT_DESCRIPTOR)
movw $done_msg, %si call print + +DEBUG: + jmp DEBUG lidt (IDT_DESCRIPTOR)@@ -119,11 +124,14 @@ print_end:
ret reset_msg: - .ascii "Resetting bootdrive..." + .ascii "Resett" .byte 0 load_msg: - .ascii "Loading bootdrive..." + .ascii "Load" + +bootdrive_msg: + .ascii "ing bootdrive..." .byte 0 gdt_msg:
D
include/kernel.h
@@ -1,8 +0,0 @@
-#ifndef KERNEL_H -#define KERNEL_H - -#define KERNEL_VIRTUAL_ADDR ((void*)0xC0000000) -#define KERNEL_PHYS_ADDR ((void*)0x00100000) -#define KERNEL_STACK_ADDR ((void*)0xD0000000) - -#endif
M
kernel/entry.s
→
kernel/entry.s
@@ -1,12 +1,13 @@
.section .text .global _kernel_start _kernel_start: + # move stack to kernel space + mov $__KERNEL_STACK_ADDR, %eax + mov %eax, %esp + mov %esp, %ebp + + # call main call main loop: jmp loop - -.section .data -kernel_msg: - .ascii "Welcome to the high kernel. Please take a seat and enjoy the fucking show" - .byte 0
A
kernel/page_allocator.c
@@ -0,0 +1,14 @@
+#include "page_allocator.h" +#include "paging.h" + +uint8_t* first_free = (uint8_t*)0x00200000; + +void* get_free_page() { + void* res = first_free; + first_free += PAGE_SIZE; + return res; +} + +void mark_as_free(void* page_addr) { + +}
A
kernel/page_allocator.h
@@ -0,0 +1,7 @@
+#ifndef PAGE_ALLOCATOR_H +#define PAGE_ALLOCATOR_H + +void* get_free_page(); +void mark_as_free(void* page_addr); + +#endif
M
second_stage/paging.c
→
second_stage/paging.c
@@ -1,6 +1,5 @@
#include "paging.h" #include "linker.h" -#include "kernel.h" void *ss_memset(void *ptr, uint8_t value, uint32_t num) { for (uint32_t i = 0; i < num; i++) {@@ -20,10 +19,10 @@
// map page directory to itself (*pdir)[PAGE_DIR_INDEX(PAGE_ENTRY_COUNT - 1)].entry = MAKE_PAGE_ENTRY(pdir, 0b000000000011); - // map kernel to 0xC0000000 + // map 4M of kernel to 0xC0000000 (*pdir)[PAGE_DIR_INDEX(KERNEL_VMA)].entry = MAKE_PAGE_ENTRY(kernel, 0b000000000011); - for (uint32_t i = 0; i < 1 << 8; i++) { + for (uint32_t i = 0; i < 1 << 10; i++) { (*kernel)[i].entry = MAKE_PAGE_ENTRY(0x100000 + PAGE_SIZE * i, 0b000000000011); }