I've made my heap, so I decided to move onto running processes, however I didn't have much idea about how to do it so I looked at the brokenthorn tutorial (http://www.brokenthorn.com/Resources/OSDev24.html).
Is anyone familiar with it? The virtual address creation is not used in his code, he just gives the process the kernel's address space. So I made it to actually use the address space creation, but the kernel mapping fails.
This is my kernel mapping function, which fails (Page fault error code 2):
Code: Select all
void vmm_map_kernel_space(page_directory_t * address_space)
{
uint32_t virtual_addr;
uint32_t phys_addr;
// User mode not set to pervent access
int flags = PTE_FLAG_PRESENT | PTE_FLAG_RW;
// Map kernel stack - don't need to, mapped with kernel
/*vmmr_map_physical_address (address_space, 0x8000, 0x8000, flags);
vmm_map_physical_address (address_space, 0x9000, 0x9000, flags);*/
// Kernel
virtual_addr = 0xc0000000;
phys_addr = 0x100000;
for (uint32_t i = 0; i < 32; i++)
{
vmm_map_physical_address(address_space, virtual_addr + (i * PAGE_SIZE), phys_addr+ (i * PAGE_SIZE), flags);
}
/*
map display memory for debug minidriver
idenitity mapped 0xa0000-0xBF000.
Note:
A better alternative is to have a driver associated
with the physical memory range map it. This should be automatic;
through an IO manager or driver manager.
*/
virtual_addr = 0xa0000;
phys_addr = 0xa0000;
for (uint32_t i = 0; i < 31; i++)
{
vmm_map_physical_address (address_space, virtual_addr + (i * PAGE_SIZE), phys_addr + (i * PAGE_SIZE), flags);
}
// Map page directory itself into it's address space
vmm_map_physical_address(address_space, (uint32_t) address_space, (uint32_t) address_space, PTE_FLAG_PRESENT | PTE_FLAG_RW);
}
(This problem is probably really simple but I haven't slept too much in the couple of last days, sorry for that )
Thank you!
Peter