summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/proc/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/proc/init.c')
-rw-r--r--arch/x86_64/proc/init.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/arch/x86_64/proc/init.c b/arch/x86_64/proc/init.c
index be1d556..3787c7b 100644
--- a/arch/x86_64/proc/init.c
+++ b/arch/x86_64/proc/init.c
@@ -1,4 +1,4 @@
-#include "init.h"
+#include "proc/init.h"
#include "arch/x86_64/hal/msr.h"
#include "config.h"
#include "proc/process.h"
@@ -12,10 +12,6 @@
#include "boot/cmdline.h"
#include "boot/initrd.h"
-PAGEALIGN static uint8_t s_init_program_pages[INIT_PROGRAM_PAGES_MAX][0x1000];
-PAGEALIGN static uint8_t s_init_stack_pages[INIT_STACK_PAGES + 3][0x1000];
-PAGEALIGN static uint8_t s_init_message_page[0x1000];
-
static int
elf_is_valid(struct elf_header *ehdr)
{
@@ -78,7 +74,6 @@ init_setup(void)
size_t last_base = 0;
//Load the init ELF
- size_t last_page = 0;
for(size_t i = 0; i < init_ehdr->e_phnum; i++) {
struct elf_phdr *phdr = init_data + init_ehdr->e_phoff + i * init_ehdr->e_phentsize;
if(phdr->p_type != PT_LOAD) continue;
@@ -93,18 +88,15 @@ init_setup(void)
for(size_t i = 0; i < pages; i++) {
uintptr_t page_virt = page_base + (i << 12);
- if(last_page >= INIT_PROGRAM_PAGES_MAX) {
- kpanic("Program exceeds size limit! (%i > %i)\n", last_page, INIT_PROGRAM_PAGES_MAX);
- }
int tblres = 0;
+ jove_owned_obj_t page_frame;
do {
- uintptr_t tbl_frame = KPTR_TOPHYS(&s_init_program_pages[last_page++]);
- tblres = pagedir_map_table(pml4, tbl_frame, page_virt);
- if(tblres == EHASMAP) last_page--;
- }while(!tblres);
+ page_frame = init_pop_alloc();
+ tblres = pagedir_map_table(pml4, obj_getvalue(&page_frame), page_virt);
+ }while(tblres == 0);
- pagedir_map_frame(pml4, KPTR_TOPHYS(&s_init_program_pages[last_page++]), page_virt,
+ pagedir_map_frame(pml4, obj_getvalue(&page_frame), page_virt,
PAGE_WRITEABLE | PAGE_USER);
}
@@ -116,25 +108,24 @@ init_setup(void)
size_t stack_base = 0x00007FFFFFFFF000;
int stack_mapres = 0;
- last_page = 0;
for(size_t i = 0; i < INIT_STACK_PAGES; i++) {
uintptr_t page_virt = stack_base - (i << 12);
int tblres = 0;
+ jove_owned_obj_t page_frame;
do {
- uintptr_t tbl_frame = KPTR_TOPHYS(&s_init_stack_pages[last_page++]);
- tblres = pagedir_map_table(pml4, tbl_frame, page_virt);
- if(tblres == EHASMAP) last_page--;
+ page_frame = init_pop_alloc();
+ tblres = pagedir_map_table(pml4, obj_getvalue(&page_frame), page_virt);
}while(!tblres);
- pagedir_map_frame(pml4, KPTR_TOPHYS(&s_init_stack_pages[last_page++]), page_virt,
+ pagedir_map_frame(pml4, obj_getvalue(&page_frame), page_virt,
PAGE_WRITEABLE | PAGE_USER | PAGE_XD);
}
//Map the syscall message.
last_base = (last_base + 0xFFF) & ~0xFFF;
- uintptr_t message_pptr = KPTR_TOPHYS(s_init_message_page);
- pagedir_map_frame(pml4, message_pptr, last_base,
+ jove_owned_obj_t message_frame = init_pop_alloc();
+ pagedir_map_frame(pml4, obj_getvalue(&message_frame), last_base,
PAGE_WRITEABLE | PAGE_USER | PAGE_XD);
extern struct init_payload _init_payload;