push
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
; Pointer to Long Mode Global Descriptor Table (GDT, arch/gdt.cc)
|
; Pointer to Long Mode Global Descriptor Table (GDT, arch/gdt.cc)
|
||||||
[EXTERN gdt_long_mode_pointer]
|
[EXTERN gdt_long_mode_pointer]
|
||||||
|
|
||||||
[GLOBAL long_mode]
|
[GLOBAL long_mode]
|
||||||
long_mode:
|
long_mode:
|
||||||
|
|
||||||
@@ -247,7 +246,6 @@ long_mode_start:
|
|||||||
|
|
||||||
; Call high-level (C++) kernel initialization function
|
; Call high-level (C++) kernel initialization function
|
||||||
call kernel_init
|
call kernel_init
|
||||||
|
|
||||||
; Print `STOP` to screen and stop
|
; Print `STOP` to screen and stop
|
||||||
mov rax, 0x2f502f4f2f544f53
|
mov rax, 0x2f502f4f2f544f53
|
||||||
mov qword [0xb8000], rax
|
mov qword [0xb8000], rax
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "../compiler/libc.h"
|
#include "../compiler/libc.h"
|
||||||
#include "../debug/output.h"
|
#include "../debug/output.h"
|
||||||
#include "../interrupt/handlers.h"
|
#include "../interrupt/handlers.h"
|
||||||
|
#include "../memory/pageframealloc.h"
|
||||||
extern "C" [[noreturn]] void kernel_init() {
|
extern "C" [[noreturn]] void kernel_init() {
|
||||||
// Setup and load Interrupt Description Table (IDT)
|
// Setup and load Interrupt Description Table (IDT)
|
||||||
initInterruptHandlers();
|
initInterruptHandlers();
|
||||||
@@ -16,6 +16,8 @@ extern "C" [[noreturn]] void kernel_init() {
|
|||||||
// Initialize PICs
|
// Initialize PICs
|
||||||
PIC::initialize();
|
PIC::initialize();
|
||||||
|
|
||||||
|
PageFrameAllocator::init();
|
||||||
|
|
||||||
// Call global constructors
|
// Call global constructors
|
||||||
CSU::initializer();
|
CSU::initializer();
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,14 @@
|
|||||||
#include "./device/serialstream.h"
|
#include "./device/serialstream.h"
|
||||||
|
|
||||||
// Separate title window on first line (for simplicity at scrolling)
|
// Separate title window on first line (for simplicity at scrolling)
|
||||||
|
|
||||||
|
void PageFrameAllocator::init();
|
||||||
|
|
||||||
|
|
||||||
static TextStream tout(0, CGA::COLUMNS, 0, 1);
|
static TextStream tout(0, CGA::COLUMNS, 0, 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SerialStream sout;
|
SerialStream sout;
|
||||||
|
|
||||||
TextStream dout(0, 80, 17, 25);
|
TextStream dout(0, 80, 17, 25);
|
||||||
@@ -40,12 +46,11 @@ alignas(4096) four_lvl_paging_t paging_tree;
|
|||||||
static const uint32_t NUM_APPS = 9;
|
static const uint32_t NUM_APPS = 9;
|
||||||
Application apps[NUM_APPS];
|
Application apps[NUM_APPS];
|
||||||
|
|
||||||
static KeyboardApplication kapp;
|
//static KeyboardApplication kapp;
|
||||||
|
|
||||||
// Main function
|
// Main function
|
||||||
extern "C" int main() {
|
extern "C" int main() {
|
||||||
|
|
||||||
PageFrameAllocator::init();
|
|
||||||
memset(&paging_tree, 0, sizeof(four_lvl_paging_t));
|
memset(&paging_tree, 0, sizeof(four_lvl_paging_t));
|
||||||
create_basic_page_table((uintptr_t)&paging_tree);
|
create_basic_page_table((uintptr_t)&paging_tree);
|
||||||
load_cr3((void*)&paging_tree.l4);
|
load_cr3((void*)&paging_tree.l4);
|
||||||
@@ -76,7 +81,7 @@ extern "C" int main() {
|
|||||||
g.vault().scheduler.ready(&(apps[i]));
|
g.vault().scheduler.ready(&(apps[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
g.vault().scheduler.ready(&kapp);
|
//g.vault().scheduler.ready(&kapp);
|
||||||
|
|
||||||
// Enable Interrupts
|
// Enable Interrupts
|
||||||
Core::Interrupt::enable();
|
Core::Interrupt::enable();
|
||||||
|
|||||||
@@ -12,14 +12,14 @@
|
|||||||
PageFrame PageFrameAllocator::PageFrames[4294967296 / 4096];
|
PageFrame PageFrameAllocator::PageFrames[4294967296 / 4096];
|
||||||
|
|
||||||
void mark_pageframes(uintptr_t start, uintptr_t end, bool available){
|
void mark_pageframes(uintptr_t start, uintptr_t end, bool available){
|
||||||
DBG << "start: " << hex << start << " end: " << end;
|
// DBG << "start: " << hex << start << " end: " << end;
|
||||||
start = Page::floor(start);
|
start = Page::floor(start);
|
||||||
end = Page::ceil(end);
|
end = Page::ceil(end);
|
||||||
if(start > 4294967296)
|
if(start > 4294967296)
|
||||||
start = 4294967296;
|
start = 4294967296;
|
||||||
if(end > 4294967296)
|
if(end > 4294967296)
|
||||||
end = 4294967296;
|
end = 4294967296;
|
||||||
DBG << " page start: " << hex << start << " end: " << end << endl;
|
//DBG << " page start: " << hex << start << " end: " << end << endl;
|
||||||
|
|
||||||
for(uint64_t i = start; i < end; i += 4096){
|
for(uint64_t i = start; i < end; i += 4096){
|
||||||
uint64_t pg = i/4096;
|
uint64_t pg = i/4096;
|
||||||
@@ -62,19 +62,14 @@ void PageFrameAllocator::init(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//mark other known regions as unavailable
|
//mark other known regions as unavailable
|
||||||
DBG << "kernel image ";
|
|
||||||
mark_pageframes((uintptr_t)&___KERNEL_START___, (uintptr_t)&___KERNEL_END___, false);
|
mark_pageframes((uintptr_t)&___KERNEL_START___, (uintptr_t)&___KERNEL_END___, false);
|
||||||
|
|
||||||
DBG << "ISA adresses ";
|
|
||||||
mark_pageframes(0x00F00000, 0x00FFFFFF, false);
|
mark_pageframes(0x00F00000, 0x00FFFFFF, false);
|
||||||
|
|
||||||
DBG << "LAPIC ";
|
|
||||||
mark_pageframes(0xfee00000, 0xfee003f0, false);
|
mark_pageframes(0xfee00000, 0xfee003f0, false);
|
||||||
|
|
||||||
DBG << "IO APIC ";
|
|
||||||
mark_pageframes(APIC::getIOAPICAddress(), APIC::getIOAPICAddress()+0x10, false);
|
mark_pageframes(APIC::getIOAPICAddress(), APIC::getIOAPICAddress()+0x10, false);
|
||||||
|
|
||||||
stats();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageFrameAllocator::stats(){
|
void PageFrameAllocator::stats(){
|
||||||
|
|||||||
Reference in New Issue
Block a user