XenevaOS
Loading...
Searching...
No Matches
Functions | Variables
vmmngr.c File Reference
#include <Mm/vmmngr.h>
#include <aucon.h>
#include <Mm/pmmngr.h>
#include <Hal/AA64/aa64lowlevel.h>
#include <string.h>
#include <kernelAA64.h>
#include <_null.h>
#include <Drivers/uart.h>
Include dependency graph for vmmngr.c:

Functions

void envmdebug ()
 
void AuVmmngrInitialize ()
 AuVmmngrInitialize – initialize the virtual memory manager.
 
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.
 
AuVPage * AuVmmngrGetPage (uint64_t virt_addr, uint8_t _flags, uint8_t mode)
 
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 AuUpdatePageFlags (uint64_t virt_addr, uint64_t flags)
 AuFreePages – frees up contiguous pages.
 
void * AuGetPhysicalAddress (uint64_t virt_addr)
 AuGetPhysicalAddress – returns the physical address from a virtual address.
 
uint64_tAuCreateVirtualAddressSpace ()
 AuCreateVirtualAddressSpace – create a new virtual address space.
 
uint64_tAuGetRootPageTable ()
 
void AuConsoleFlushFramebuffer ()
 
void AuVmmngrBootFree ()
 

Variables

uint64_t_RootPaging
 
uint64_t_RootPagingKe
 
uint64_t_MMIOBase
 
bool _vmdebug = 0
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2023-2025, 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.

Function Documentation

◆ AuConsoleFlushFramebuffer()

void AuConsoleFlushFramebuffer ( )
extern

◆ 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

◆ 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

◆ AuUpdatePageFlags()

void AuUpdatePageFlags ( uint64_t  virt_addr,
uint64_t  flags 
)

AuFreePages – frees up contiguous pages.

Parameters
virt_addr– starting virtual address
flags– flags to update

◆ AuVmmngrBootFree()

void AuVmmngrBootFree ( )

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

◆ 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.

◆ envmdebug()

void envmdebug ( )

Variable Documentation

◆ _MMIOBase

uint64_t* _MMIOBase

◆ _RootPaging

uint64_t* _RootPaging

◆ _RootPagingKe

uint64_t* _RootPagingKe

◆ _vmdebug

bool _vmdebug = 0