Commit 7ad4babe by triazo

Comment out function and map everything.

parent ebfd2cc5
Showing with 32 additions and 29 deletions
...@@ -45,8 +45,7 @@ void load_elf(elf_header* elf_start) ...@@ -45,8 +45,7 @@ void load_elf(elf_header* elf_start)
size_t offset = (pg > ph->p_vaddr) ? 0 : ph->p_vaddr - pg; size_t offset = (pg > ph->p_vaddr) ? 0 : ph->p_vaddr - pg;
// do some memcpy stuff // do some memcpy stuff
serial_hexword((uint32_t)real_page); page_table_inspect(kernel_page_directory, real_page);
serial_writechar('\n');
memcpy(real_page + offset, start, size); memcpy(real_page + offset, start, size);
// save the highest start // save the highest start
......
...@@ -94,60 +94,64 @@ page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot ...@@ -94,60 +94,64 @@ page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot
page_allocate(); page_allocate();
} }
// Make a page directory structure easily // Initilize a directory mapped to everything
page_directory_entry* kern_page_dir = initiate_directory(); page_directory_entry* kern_page_dir = kernel_page_directory;
page_everything(kern_page_dir);
// _kern_end is defined in the linker script // _kern_end is defined in the linker script
/* page_table_entry* next_table = (page_table_entry*) &_kernel_end; */ /* page_table_entry* next_table = (page_table_entry*) &_kernel_end; */
int current_dir_entry = 0; //int current_dir_entry = 0;
uint32_t totalmem = 0;
// For each entry in the memory map // For each entry in the memory map
while (mmap < mmap_end) while (mmap < mmap_end)
{ {
void* next_table = page_allocate(); //void* next_table = page_allocate();
// Special case for the first memory segment - it gets its own directory entry // Special case for the first memory segment - it gets its own directory entry
if (mmap->base_addr == 0) if (mmap->base_addr == 0)
{ {
// Lower memory should be first in the page directory and // Lower memory should be first in the page directory and
// mapped one to one // mapped one to one
populate_page_table(next_table, 0, 1024, 0); /* populate_page_table(next_table, 0, 1024, 0); */
kern_page_dir[0] = (uint32_t) next_table; /* kern_page_dir[0] = (uint32_t) next_table; */
kern_page_dir[0] |= PAGE_WRITABLE | PAGE_PRESENT; /* kern_page_dir[0] |= PAGE_WRITABLE | PAGE_PRESENT; */
current_dir_entry = 1; /* current_dir_entry = 1; */
/* next_table += 0x1000; */ /* next_table += 0x1000; */
} }
else if (mmap->type == 1) else if (mmap->type == 1)
{ {
uint32_t i; totalmem += mmap->length;
for (i = 0; i+0x1000000 < mmap->length; i += 0x1000000) /* uint32_t i; */
{ /* for (i = 0; i+0x1000000 < mmap->length; i += 0x1000000) */
populate_page_table(next_table, (void*)(intptr_t) mmap->base_addr + i, 1024 ,0); /* { */
kern_page_dir[current_dir_entry] = (uint32_t) next_table; /* populate_page_table(next_table, (void*)(intptr_t) mmap->base_addr + i, 1024 ,0); */
kern_page_dir[current_dir_entry] |= PAGE_WRITABLE | PAGE_PRESENT; /* kern_page_dir[current_dir_entry] = (uint32_t) next_table; */
/* kern_page_dir[current_dir_entry] |= PAGE_WRITABLE | PAGE_PRESENT; */
current_dir_entry += 1;
/* next_table += 0x1000; */ /* current_dir_entry += 1; */
} /* /\* next_table += 0x1000; *\/ */
/* } */
// There will be an edge case where there is less than a // There will be an edge case where there is less than a
// full page table to be mapped. This handlis this case. // full page table to be mapped. This handlis this case.
if (i != mmap->length) /* if (i != mmap->length) */
{ /* { */
populate_page_table(next_table, (void*)(intptr_t) mmap->base_addr + i, (mmap->length - i) / 0x1000 ,0); /* populate_page_table(next_table, (void*)(intptr_t) mmap->base_addr + i, (mmap->length - i) / 0x1000 ,0); */
kern_page_dir[current_dir_entry] = (uint32_t) next_table; /* kern_page_dir[current_dir_entry] = (uint32_t) next_table; */
kern_page_dir[current_dir_entry] |= PAGE_WRITABLE | PAGE_PRESENT; /* kern_page_dir[current_dir_entry] |= PAGE_WRITABLE | PAGE_PRESENT; */
current_dir_entry += 1; /* current_dir_entry += 1; */
/* next_table += 0x1000; */ /* /\* next_table += 0x1000; *\/ */
} /* } */
} }
mmap = (multiboot_memory_map*)((uint32_t)mmap + mmap->size + sizeof(uint32_t)); mmap = (multiboot_memory_map*)((uint32_t)mmap + mmap->size + sizeof(uint32_t));
} }
// let the memory allocator work freely with all remaining memory // let the memory allocator work freely with all remaining memory
memory_mark = page_allocate(); /* memory_mark = page_allocate(); */
return kern_page_dir; return kern_page_dir;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment