did some restructuring, got multitasking almost working

This commit is contained in:
2026-06-26 20:05:01 -05:00
parent 57d7d34c6d
commit 43bc0df81a
35 changed files with 481 additions and 307 deletions

View File

@@ -18,7 +18,7 @@ extern void disable_pae();
#define PAGE_TABLES 0xFFC00000
#define PAGE_DIRECTORY 0xFFFFF000
#define TEMP_MAPPING_VADDR 0xE0000000
#define TEMP_MAPPING_VADDR 0xDFFF0000
static uint32_t max_address = 0;
static uint32_t total_available_memory = 0;
@@ -141,8 +141,6 @@ void init_pmm(void* mmap_base, uint32_t mmap_limit) {
if (mmap_base != NULL && mmap_limit > 0) {
parse_multiboot_mmap(mmap_base, mmap_limit);
}
kprintf("total free memory: %dMB\n", total_available_memory / 1024 / 1024);
}
void init_page_tables() {
@@ -165,7 +163,7 @@ uint32_t total_free_memory() {
return total_available_memory;
}
void* create_user_pd() {
void* create_task_pd() {
uint32_t pd_address = (uint32_t)p_alloc_frame();
if (pd_address == 0) {
return 0;
@@ -173,18 +171,18 @@ void* create_user_pd() {
map_page(TEMP_MAPPING_VADDR, pd_address, PAGE_PRESENT | PAGE_WRITABLE);
uint32_t* user_pd = (uint32_t*)TEMP_MAPPING_VADDR;
uint32_t* task_pd = (uint32_t*)TEMP_MAPPING_VADDR;
uint32_t* kernel_pd = (uint32_t*)PAGE_DIRECTORY;
for(int i = 0; i < 768; i++) {
user_pd[i] = 0;
task_pd[i] = 0;
}
for(int i = 768; i < 1023; i++) {
user_pd[i] = kernel_pd[i];
task_pd[i] = kernel_pd[i];
}
user_pd[1023] = (uint32_t)pd_address | PAGE_PRESENT | PAGE_WRITABLE;
task_pd[1023] = (uint32_t)pd_address | PAGE_PRESENT | PAGE_WRITABLE;
uint32_t pde = TEMP_MAPPING_VADDR >> 22;
uint32_t pte = (TEMP_MAPPING_VADDR >> 12) & 0x3FF;

View File

@@ -20,7 +20,7 @@ void* p_alloc_frame();
uint32_t total_free_memory();
void* create_user_pd();
void* create_task_pd();
void map_page(uint32_t vaddr, uint32_t paddr, uint32_t flags);