MentOS  0.8.0
The Mentoring Operating System
Classes | Macros | Typedefs | Functions
vmem_map.h File Reference

Virtual memory mapping routines. More...

Go to the source code of this file.

Classes

struct  virt_map_page_manager_t
 Virtual mapping manager. More...
 
struct  virt_map_page_t
 Virtual mapping. More...
 

Macros

#define VIRTUAL_MEMORY_SIZE_MB   128
 Size of the virtual memory.
 

Typedefs

typedef struct virt_map_page_manager_t virt_map_page_manager_t
 Virtual mapping manager.
 
typedef struct virt_map_page_t virt_map_page_t
 Virtual mapping.
 

Functions

int virt_init (void)
 Initialize the virtual memory mapper. More...
 
uint32_t virt_map_physical_pages (page_t *page, int pfn_count)
 Maps physical pages to virtual memory. More...
 
virt_map_page_tvirt_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...
 

Detailed Description

Virtual memory mapping routines.

Function Documentation

◆ virt_init()

int virt_init ( void  )

Initialize the virtual memory mapper.

Returns
Returns 0 on success, or -1 if an error occurs.

◆ virt_map_alloc()

virt_map_page_t* virt_map_alloc ( uint32_t  size)

Allocates virtual pages for a given size.

Parameters
sizeThe size in bytes to allocate.
Returns
Pointer to the allocated virtual pages, or NULL on failure.

◆ virt_map_physical_pages()

uint32_t virt_map_physical_pages ( page_t page,
int  pfn_count 
)

Maps physical pages to virtual memory.

Parameters
pagePointer to the physical page.
pfn_countThe number of page frames to map.
Returns
The virtual address of the mapped pages, or 0 on failure.

◆ virt_map_vaddress()

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.

Parameters
mmPointer to the memory management structure.
vpagePointer to the virtual map page.
vaddrThe virtual address to map.
sizeThe size of the memory area to map.
Returns
The starting virtual address of the mapped area, or 0 on failure.

◆ virt_memcpy()

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.

Parameters
dst_mmThe destination memory struct
dst_vaddrThe destination memory address
src_mmThe source memory struct
src_vaddrThe source memory address
sizeThe size in bytes of the copy

◆ virt_unmap()

int virt_unmap ( uint32_t  addr)

Unmaps a virtual address from the virtual memory.

Parameters
addrThe virtual address to unmap.
Returns
Returns 0 on success, or -1 if an error occurs.

◆ virt_unmap_pg()

int virt_unmap_pg ( virt_map_page_t page)

Unmap a page.

Parameters
pagePointer to the page to unmap.
Returns
Returns 0 on success, or -1 if an error occurs.

◆ virtual_check_address()

int virtual_check_address ( uint32_t  addr)

Checks if an address belongs to the virtual memory mapping.

Parameters
addrThe address to check.
Returns
1 if it belongs to the virtual memory mapping, 0 otherwise.