MentOS
0.8.0
The Mentoring Operating System
|
Virtual memory mapping routines. More...
Macros | |
#define | __DEBUG_HEADER__ "[VMEM ]" |
Change header. | |
#define | __DEBUG_LEVEL__ LOGLEVEL_NOTICE |
Set log level. | |
#define | VIRTUAL_MEMORY_PAGES_COUNT (VIRTUAL_MEMORY_SIZE_MB * 256) |
Number of virtual memory pages. | |
#define | VIRTUAL_MAPPING_BASE (PROCAREA_END_ADDR + 0x38000000) |
Base address for virtual memory mapping. | |
#define | VIRT_PAGE_TO_ADDRESS(page) ((((page) - virt_pages) * PAGE_SIZE) + VIRTUAL_MAPPING_BASE) |
Converts a virtual page to its address. | |
#define | VIRT_ADDRESS_TO_PAGE(addr) ((((addr) - VIRTUAL_MAPPING_BASE) / PAGE_SIZE) + virt_pages) |
Converts an address to its corresponding virtual page. | |
Functions | |
int | virt_init (void) |
Initialize the virtual memory mapper. More... | |
static virt_map_page_t * | _alloc_virt_pages (uint32_t pfn_count) |
Allocates a virtual page, given the page frame count. More... | |
uint32_t | virt_map_physical_pages (page_t *page, int pfn_count) |
Maps physical pages to virtual memory. More... | |
virt_map_page_t * | virt_map_alloc (uint32_t size) |
Allocates virtual pages for a given size. More... | |
uint32_t | virt_map_vaddress (mm_struct_t *mm, virt_map_page_t *vpage, uint32_t vaddr, uint32_t size) |
Maps a virtual address to a virtual memory area. More... | |
int | virtual_check_address (uint32_t addr) |
Checks if an address belongs to the virtual memory mapping. More... | |
int | virt_unmap (uint32_t addr) |
Unmaps a virtual address from the virtual memory. More... | |
int | virt_unmap_pg (virt_map_page_t *page) |
Unmap a page. More... | |
void | virt_memcpy (mm_struct_t *dst_mm, uint32_t dst_vaddr, mm_struct_t *src_mm, uint32_t src_vaddr, uint32_t size) |
Memcpy from different processes virtual addresses. More... | |
Variables | |
static virt_map_page_manager_t | virt_default_mapping |
Virtual addresses manager. | |
virt_map_page_t | virt_pages [VIRTUAL_MEMORY_PAGES_COUNT] |
Array of virtual pages. | |
Virtual memory mapping routines.
|
static |
Allocates a virtual page, given the page frame count.
pfn_count | the page frame count. |
int virt_init | ( | void | ) |
Initialize the virtual memory mapper.
virt_map_page_t* virt_map_alloc | ( | uint32_t | size | ) |
Allocates virtual pages for a given size.
size | The size in bytes to allocate. |
Maps physical pages to virtual memory.
page | Pointer to the physical page. |
pfn_count | The number of page frames to map. |
uint32_t virt_map_vaddress | ( | mm_struct_t * | mm, |
virt_map_page_t * | vpage, | ||
uint32_t | vaddr, | ||
uint32_t | size | ||
) |
Maps a virtual address to a virtual memory area.
mm | Pointer to the memory management structure. |
vpage | Pointer to the virtual map page. |
vaddr | The virtual address to map. |
size | The size of the memory area to map. |
void virt_memcpy | ( | mm_struct_t * | dst_mm, |
uint32_t | dst_vaddr, | ||
mm_struct_t * | src_mm, | ||
uint32_t | src_vaddr, | ||
uint32_t | size | ||
) |
Memcpy from different processes virtual addresses.
dst_mm | The destination memory struct |
dst_vaddr | The destination memory address |
src_mm | The source memory struct |
src_vaddr | The source memory address |
size | The size in bytes of the copy |
int virt_unmap | ( | uint32_t | addr | ) |
Unmaps a virtual address from the virtual memory.
addr | The virtual address to unmap. |
int virt_unmap_pg | ( | virt_map_page_t * | page | ) |
Unmap a page.
page | Pointer to the page to unmap. |
int virtual_check_address | ( | uint32_t | addr | ) |
Checks if an address belongs to the virtual memory mapping.
addr | The address to check. |