MyOS Kernel
|
#include "../../pmem.h"
#include "../../vga_err.h"
#include "../halt.h"
#include "../paging.h"
#include "arch_consts.h"
#include <klog.h>
#include <stdint.h>
#include <stdlib.h>
Functions | |
static char | is_page_present (size_t page) |
void | map_pages (void *virt_addr_ptr, void *phys_addr_ptr, int num_pages, char usr, char wr) |
void * | find_free_pages (int num_pages) |
void * | alloc_pages (int num_pages) |
void * | virt_to_phys (void *virt_addr_arg) |
void | alloc_pages_virt (int num_pages, void *addr) |
static void | invl_page (void *addr) |
void * | paging_new_address_space () |
void | load_address_space (void *cr3) |
void | unmap_pages (void *start_virt, int num_pages) |
void | paging_init () |
void * | get_cr3 () |
Variables | |
static uint32_t | page_directory [1024] |
The kernel process's page directory. | |
static uint32_t | kern_page_tables [NUM_KERN_FRAMES] |
The page tables where the kernel binary is mapped in. | |
static uint32_t | kstack_page_tables [218 *1024] |
Page tables for thread kernel stacks. | |
static uint32_t | kmalloc_page_tables [4 *1024] |
Page tables for the kmalloc heap. | |
static uint32_t * | pagdirmap =(uint32_t*)0xFFFFF000 |
Pointer to the page directory entries in the recursive mapping. | |
static uint32_t * | page_table_map =(uint32_t*)0xFFC00000 |
Pointer to the page table entries in the recursive mapping. | |
void* alloc_pages | ( | int | num_pages | ) |
Allocate virtual pages & map them to physical memory.
num_pages | The number of pages to allocate. |
void alloc_pages_virt | ( | int | num_pages, |
void * | addr | ||
) |
Allocate virtual pages at a specific address & map them to physical memory.
num_pages | The number of pages to allocate. |
addr | The adress to start allocation at. |
void* find_free_pages | ( | int | num_pages | ) |
Finds free virtual pages and returns the start address
num_pages | The minimum size of the free area |
void* get_cr3 | ( | ) |
Get the current address space
|
static |
Invalidates a page in the TLB,
addr | The address of the page to invalidate. |
|
static |
Checks whether a page is present
page | The page number to check |
void load_address_space | ( | void * | cr3 | ) |
Load an address space
cr3 | The address space to load |
void map_pages | ( | void * | virt_addr_ptr, |
void * | phys_addr_ptr, | ||
int | num_pages, | ||
char | usr, | ||
char | wr | ||
) |
Map virtual pages to physical frames.
virt_addr_ptr | The start of the virtual range to map. |
phys_addr_ptr | The start of the physical range to map. |
num_pages | The number of pages to map. |
usr | Are the pages acessible by user mode code |
wr | Are the pages writable by user mode code (kernel always has write permissions) |
void paging_init | ( | ) |
Initialize paging
void* paging_new_address_space | ( | ) |
Create a new address space
void unmap_pages | ( | void * | start_virt, |
int | num_pages | ||
) |
Unmap virtual pages,
start_virt | The start of the virtual range to unmap. |
num_pages | The number of pages to map. |
void* virt_to_phys | ( | void * | virt_addr | ) |
Convert a virtual address to a physical one.
virt_addr | The virtual address to convert |