[memory] Rework memory_initialize for new loader

Created a new `memory_initialize()` function that uses the new-style
kernel args structure from the new bootloader.

Additionally:
* Fixed a hard-coded interrupt EOI address that didn't work with new
  memory locations
* Make the `page_manager::fault_handler()` automatically grant pages
  in the kernel heap

Tags: boot page fault
This commit is contained in:
Justin C. Miller
2020-05-24 16:27:48 -07:00
parent fc3d919f25
commit 35b1d37df0
6 changed files with 95 additions and 222 deletions

View File

@@ -1,5 +1,7 @@
#include <stdint.h>
#include "kernel_memory.h"
#include "apic.h"
#include "console.h"
#include "cpu.h"
@@ -15,6 +17,8 @@
static const uint16_t PIC1 = 0x20;
static const uint16_t PIC2 = 0xa0;
constexpr uintptr_t apic_eoi_addr = 0xfee000b0 + ::memory::page_offset;
extern "C" {
void _halt();
@@ -273,7 +277,7 @@ isr_handler(cpu_state *regs)
print_stacktrace(2);
_halt();
}
*reinterpret_cast<uint32_t *>(0xffffff80fee000b0) = 0;
*reinterpret_cast<uint32_t *>(apic_eoi_addr) = 0;
}
void
@@ -290,5 +294,5 @@ irq_handler(cpu_state *regs)
_halt();
}
*reinterpret_cast<uint32_t *>(0xffffff80fee000b0) = 0;
*reinterpret_cast<uint32_t *>(apic_eoi_addr) = 0;
}