summaryrefslogtreecommitdiff
path: root/kc/core
diff options
context:
space:
mode:
Diffstat (limited to 'kc/core')
-rw-r--r--kc/core/memory/memory.c30
-rw-r--r--kc/core/memory/page_early.c14
-rw-r--r--kc/core/pic8259.c1
3 files changed, 33 insertions, 12 deletions
diff --git a/kc/core/memory/memory.c b/kc/core/memory/memory.c
index f50752f..63631ff 100644
--- a/kc/core/memory/memory.c
+++ b/kc/core/memory/memory.c
@@ -26,6 +26,7 @@
static void *temp_page_map(kc_phys_addr paddr, enum page_map_flags flags);
static void temp_page_unmap(void *address);
+static kc_phys_addr boot_page_alloc(enum page_alloc_flags type);
static void *page_map_at(
void *vaddr,
@@ -79,6 +80,8 @@ static struct vm_temp_state
}
temp_state;
+static kc_phys_addr (*current_alloc_func)(enum page_alloc_flags) = boot_page_alloc;
+
struct vm_tree *vm_get_tree(void)
{
return &vm_state.tree;
@@ -93,11 +96,14 @@ void page_init(void)
void page_init_final(void)
{
- kprintf("finishing page frame allocator initialization\n");
- page_early_final();
+ if (current_alloc_func == boot_page_alloc)
+ {
+ kprintf("finishing page frame allocator initialization\n");
+ page_early_final();
+ current_alloc_func = page_stack_alloc;
+ }
}
-
void page_set_present(kc_phys_addr page)
{
page_stack_set_present(page);
@@ -118,17 +124,21 @@ void page_set_free(kc_phys_addr page)
page_stack_set_free(page);
}
-kc_phys_addr page_alloc(enum page_alloc_flags type)
+static kc_phys_addr boot_page_alloc(enum page_alloc_flags type)
{
- kc_phys_addr paddr = 0;
- if ((paddr = page_stack_alloc(type)) > 0)
- {
- return paddr;
- }
- else
+ kc_phys_addr paddr = page_stack_alloc(type);
+
+ if (paddr == 0)
{
return page_early_alloc(type);
}
+
+ return paddr;
+}
+
+kc_phys_addr page_alloc(enum page_alloc_flags type)
+{
+ return current_alloc_func(type);
}
void page_free(kc_phys_addr page)
diff --git a/kc/core/memory/page_early.c b/kc/core/memory/page_early.c
index 933f01b..144e8ea 100644
--- a/kc/core/memory/page_early.c
+++ b/kc/core/memory/page_early.c
@@ -19,6 +19,17 @@ void page_early_init(void)
early_state.first = &boot_data->memory.entries[0];
early_state.last = &boot_data->memory.entries[boot_data->memory.count];
early_state.current = early_state.first;
+
+ kprintf("memory ranges\n");
+
+ struct memory_range *current = early_state.first;
+
+ do
+ {
+ kprintf("base %#0.16lx size %#0.16lx type %d\n", current->base, current->size, current->type);
+ current++;
+ }
+ while (current != early_state.last);
}
void page_early_final(void)
@@ -30,7 +41,7 @@ void page_early_final(void)
current < early_state.last;
current++)
{
- while (current->size >= page_size(1))
+ while (current->type != RESERVED_MEMORY && current->size >= page_size(1))
{
current->size -= page_size(1);
@@ -44,7 +55,6 @@ void page_early_final(void)
switch (type)
{
- case RESERVED_MEMORY:
case SYSTEM_MEMORY:
page_set_present(page);
break;
diff --git a/kc/core/pic8259.c b/kc/core/pic8259.c
index bbcffc8..4ddd2e1 100644
--- a/kc/core/pic8259.c
+++ b/kc/core/pic8259.c
@@ -43,6 +43,7 @@ static void wait(void)
void pic8259_init(void)
{
+ kprintf("initializing legacy pic\n");
// basic init. not gonna fret with this too much
outb(PIC_PRI_CMD, ICW1_INIT|ICW1_ICW4);
wait();