mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Fixed using ALIGN() instead of dceil() in vmm
This commit is contained in:
+11
-11
@@ -10,14 +10,13 @@
|
||||
|
||||
__noreturn
|
||||
void _start(void) {
|
||||
int err = 0;
|
||||
|
||||
// Serial console for debugging
|
||||
if (serial_init(COM1) < 0) panic("Failed to initialize Serial driver.");
|
||||
if ((err = serial_init(COM1)) < 0) panic("Failed to initialize Serial driver. (%d)", err);
|
||||
|
||||
// Load structures from bootloader
|
||||
if (boot_init() < 0) panic("Failed to parse bootloader structures.");
|
||||
|
||||
// The most important function in the world.
|
||||
splash();
|
||||
if ((err = boot_init()) < 0) panic("Failed to parse bootloader structures. (%d)", err);
|
||||
|
||||
// CPUID thingy :p
|
||||
uint32_t eax = 0;
|
||||
@@ -26,16 +25,17 @@ void _start(void) {
|
||||
pr_info("[kernel] CPUID_GETVENDORID: %s\n", s);
|
||||
|
||||
// System init
|
||||
if (gdt_init() < 0) panic("Failed to initalize GDT.");
|
||||
if (isr_init() < 0) panic("Failed to initalize ISRs.");
|
||||
if ((err = gdt_init()) < 0) panic("Failed to initalize GDT. (%d)", err);
|
||||
if ((err = isr_init()) < 0) panic("Failed to initalize ISRs. (%d)", err);
|
||||
|
||||
// Memory management
|
||||
if (pmm_init() < 0) panic("Failed to initalize Physical Memory Manager.");
|
||||
if (pag_init() < 0) panic("Failed to initalize Paging.");
|
||||
if ((err = pmm_init()) < 0) panic("Failed to initalize Physical Memory Manager. (%d)", err);
|
||||
if ((err = pag_init()) < 0) panic("Failed to initalize Paging. (%d)", err);
|
||||
|
||||
panic("Yeah..");
|
||||
// The most important function in the world.
|
||||
splash();
|
||||
|
||||
// Patiently wait for things to do :)
|
||||
while (1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+5
-3
@@ -11,6 +11,8 @@
|
||||
// VIRTUAL address of the kernels PML4
|
||||
uint64_t* pag_kernel_pml4 = NULL;
|
||||
|
||||
// abcabcaaabcaab
|
||||
|
||||
int pag_init(void) {
|
||||
pag_kernel_pml4 = TO_VIRT(pmm_alloc());
|
||||
if (IS_ERR(pag_kernel_pml4)) return PTR_ERR(pag_kernel_pml4);
|
||||
@@ -20,14 +22,14 @@ int pag_init(void) {
|
||||
pag_kernel_pml4,
|
||||
(void*)bootloader.kernel_virt_base,
|
||||
(void*)bootloader.kernel_phys_base,
|
||||
ALIGN(bootloader.executable->size, PAGE_SIZE),
|
||||
dceil(bootloader.executable->size, PAGE_SIZE),
|
||||
PTE_FLAG_WRITE | PTE_FLAG_PRESENT
|
||||
);
|
||||
if (ret != SUCCESS) return ret;
|
||||
|
||||
for (size_t i = 0; i < bootloader.mm_entry_count; i++) {
|
||||
struct limine_memmap_entry* entry = bootloader.mm_entries[i];
|
||||
|
||||
|
||||
uint64_t flags = 0;
|
||||
switch (entry->type) {
|
||||
case LIMINE_MEMMAP_USABLE: flags = PTE_FLAG_WRITE; break;
|
||||
@@ -50,7 +52,7 @@ int pag_init(void) {
|
||||
ret = pag_map_region(
|
||||
pag_kernel_pml4,
|
||||
(void*)(entry->base + bootloader.hhdm_offset), (void*)entry->base,
|
||||
ALIGN(entry->length, PAGE_SIZE),
|
||||
dceil(entry->length, PAGE_SIZE),
|
||||
flags | PTE_FLAG_PRESENT
|
||||
);
|
||||
if (ret != SUCCESS) return ret;
|
||||
|
||||
Reference in New Issue
Block a user