XenevaOS
Loading...
Searching...
No Matches
Macros | Functions | Variables
vmmngr.cpp File Reference
#include <Mm\vmmngr.h>
#include <Mm\pmmngr.h>
#include <aucon.h>
#include <Hal\x86_64_lowlevel.h>
#include <Hal\x86_64_cpu.h>
#include <string.h>
#include <_null.h>
#include <Hal\serial.h>
Include dependency graph for vmmngr.cpp:

Macros

#define CANONICAL_MASK   0xFFFFffffFFFFUL
 

Functions

size_t x86_64_pml4_index (uint64_t addr)
 
size_t x86_64_pdp_index (uint64_t addr)
 
size_t x86_64_pd_index (uint64_t addr)
 
size_t x86_64_pt_index (uint64_t addr)
 
size_t x86_64_p_index (uint64_t addr)
 
void Au_x86_64_Paging_Init ()
 
AuVPage * AuVmmngrGetPage (uint64_t virt_addr, uint8_t _flags, uint8_t mode)
 
bool AuMapPage (uint64_t phys_addr, uint64_t virt_addr, uint8_t attrib)
 AuMapPage – Maps a virtual page to physical frame.
 
bool AuMapPageEx (uint64_t *pml4i, uint64_t phys_addr, uint64_t virt_addr, uint8_t attrib)
 AuMapPageEx – Maps a virtual page to physical frame in given page level.
 
void * AuMapMMIO (uint64_t phys_addr, size_t page_count)
 AuMapMMIO – Maps Memory Mapped I/O addresses.
 
uint64_tAuGetFreePage (bool user, void *ptr)
 AuGetFreePage – Checks for free page.
 
void AuFreePages (uint64_t virt_addr, bool free_physical, size_t s)
 AuFreePages – frees up contiguous pages.
 
void * AuGetPhysicalAddress (uint64_t virt_addr)
 AuGetPhysicalAddress – returns the physical address from a virtual address.
 
void * AuGetPhysicalAddressEx (uint64_t *cr3, uint64_t virt_addr)
 
uint64_tAuCreateVirtualAddressSpace ()
 AuCreateVirtualAddressSpace – create a new virtual address space.
 
uint64_tAuGetRootPageTable ()
 
void AuVmmngrInitialize ()
 AuVmmngrInitialize – initialize the virtual memory manager.
 
void AuVmmngrBootFree ()
 
void AuVmmngrCloneAddressSpace (uint64_t *destcr3, uint64_t *srccr3)
 AuVmmngrCloneAddressSpace – clones a given address space.
 

Variables

uint64_t_RootPaging
 
uint64_t_MmioBase
 

Macro Definition Documentation

◆ CANONICAL_MASK

#define CANONICAL_MASK   0xFFFFffffFFFFUL

Function Documentation

◆ Au_x86_64_Paging_Init()

void Au_x86_64_Paging_Init ( )

◆ AuCreateVirtualAddressSpace()

uint64_t * AuCreateVirtualAddressSpace ( )

AuCreateVirtualAddressSpace – create a new virtual address space.

Returns
pointer to newly created address space

◆ AuFreePages()

void AuFreePages ( uint64_t  virt_addr,
bool  free_physical,
size_t  s 
)

AuFreePages – frees up contiguous pages.

Parameters
virt_addr– starting virtual address
free_physical– free up physical frame
size_ts – size of area to be freed

◆ AuGetFreePage()

uint64_t * AuGetFreePage ( bool  user,
void *  ptr 
)

AuGetFreePage – Checks for free page.

Parameters
user– specifies if it needs to look from user base address
ptr– if it is non-null, than lookup begins from given pointer
Returns
pointer to free virtual page

◆ AuGetPhysicalAddress()

void * AuGetPhysicalAddress ( uint64_t  virt_addr)

AuGetPhysicalAddress – returns the physical address from a virtual address.

Parameters
virt_addr– Virtual address
Returns
the physical address of respected virtual address

◆ AuGetPhysicalAddressEx()

void * AuGetPhysicalAddressEx ( uint64_t cr3,
uint64_t  virt_addr 
)

◆ AuGetRootPageTable()

uint64_t * AuGetRootPageTable ( )

◆ AuMapMMIO()

void * AuMapMMIO ( uint64_t  phys_addr,
size_t  page_count 
)

AuMapMMIO – Maps Memory Mapped I/O addresses.

Parameters
phys_addr– MMIO physical address
page_count– number of pages
Returns
Pointer to newly mapped virtual mmio address

◆ AuMapPage()

bool AuMapPage ( uint64_t  phys_addr,
uint64_t  virt_addr,
uint8_t  attrib 
)

AuMapPage – Maps a virtual page to physical frame.

Parameters
phys_addr– physical address
virt_addr– virtual address
attrib– Page attributes
Returns
1 on success 0 on failure

◆ AuMapPageEx()

bool AuMapPageEx ( uint64_t pml4i,
uint64_t  phys_addr,
uint64_t  virt_addr,
uint8_t  attrib 
)

AuMapPageEx – Maps a virtual page to physical frame in given page level.

Parameters
pml4i– root page level pointer
phys_addr– physical address
virt_addr– virtual address
attrib– Page attributes
Returns
1 on success, 0 on failure

◆ AuVmmngrBootFree()

void AuVmmngrBootFree ( )

@breif AuVmmngrBootFree – free up the lower half of kernel address space

◆ AuVmmngrCloneAddressSpace()

void AuVmmngrCloneAddressSpace ( uint64_t destcr3,
uint64_t srccr3 
)

AuVmmngrCloneAddressSpace – clones a given address space.

Parameters
destcr3– destination cr3
srccr3– source cr3

◆ AuVmmngrGetPage()

AuVPage * AuVmmngrGetPage ( uint64_t  virt_addr,
uint8_t  flags,
uint8_t  mode 
)

@breif AuVmmngrGetPage – Returns virtual page from virtual address in AuVPage format

Parameters
virt_addr– Virtual address
_flags– extra virtual page flags, this is set only if mode is set to VMMNGR_GETPAGE_CREATE
mode– specifies whether to create a virtual page if its not present
Returns
virtual page from virtual address in AuVPage format

◆ AuVmmngrInitialize()

void AuVmmngrInitialize ( )

AuVmmngrInitialize – initialize the virtual memory manager.

◆ x86_64_p_index()

size_t x86_64_p_index ( uint64_t  addr)

◆ x86_64_pd_index()

size_t x86_64_pd_index ( uint64_t  addr)

◆ x86_64_pdp_index()

size_t x86_64_pdp_index ( uint64_t  addr)

◆ x86_64_pml4_index()

size_t x86_64_pml4_index ( uint64_t  addr)

◆ x86_64_pt_index()

size_t x86_64_pt_index ( uint64_t  addr)

Variable Documentation

◆ _MmioBase

uint64_t* _MmioBase

◆ _RootPaging

uint64_t* _RootPaging

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.