XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
pmmngr.c File Reference
#include <Mm/pmmngr.h>
#include <Hal/AA64/aa64lowlevel.h>
#include <Mm/vmmngr.h>
#include <Drivers/uart.h>
#include <efi.h>
#include <Hal/AA64/profile.h>
Include dependency graph for pmmngr.c:

Classes

struct  _lb_mem_rgn_
 

Macros

#define PAGE_SHIFT   12
 

Typedefs

typedef struct _lb_mem_rgn_ LBMemoryRegion
 

Functions

void AuPmmngrInitBitmap (size_t BSize, void *Buffer)
 AuPmmngrInitBitmap – Initialize the Ram bitmap with all zeros.
 
bool AuPmmngrBitmapCheck (uint64_t index)
 
bool AuPmmngrBitmapSet (uint64_t index, bool value)
 
void AuPmmngrLockPage (uint64_t Address)
 AuPmmngrLockPage – Lock a given page.
 
void AuPmmngrLockPages (void *Address, size_t Size)
 AuPmmngrLockPage – locks a set of pages.
 
void AuPmmngrUnreservePage (void *Address)
 AuPmmngrUnreservePage – Marks a page as free.
 
void AuPmmngrInitialize (KERNEL_BOOT_INFO *info)
 AuPmmngrInitialise – initialise the physical memory manager.
 
bool AuPmmngrAllocCheck (uint64_t address)
 
void * AuPmmngrAlloc ()
 AuPmmngrAlloc – Allocate a single physical page frame and return it to the caller.
 
void * AuPmmngrAllocBlocks (int num)
 AuPmmngrAllocBlocks – Allocate multiple physical page frames and return the first page pointer to the caller.
 
void AuPmmngrFree (void *Address)
 AuPmmngrFree – Free a physical page frame.
 
void AuPmmngrFreeBlocks (void *Addr, int Count)
 AuPmmngrFreeBlocks – Free multiple page frames.
 
uint64_t P2V (uint64_t addr)
 P2V – Physical to Virtual conversion.
 
uint64_t V2P (uint64_t vaddr)
 V2P – Virtual to Physical conversion.
 
void AuPmmngrMoveHigher ()
 AuPmmngrMoveHigher – moves the kernel to higher half of memory.
 
uint64_t AuPmmngrGetFreeMem ()
 AuPmmngrGetFreeMem – returns the total free amount of RAM.
 
uint64_t AuPmmngrGetTotalMem ()
 AuPmmngrGetTotalMem – returns the total amount of RAM.
 
void AuPmmngrAddRefcount (uint64_t physaddr, uint16_t count)
 AuPmmngrAddRefcount – increment reference count of given page.
 
uint16_t AuPmmngrGetRefcount (uint64_t physaddr)
 AuPmmngrGetRefcount – returns the number of reference count for given physical address.
 
AuPageDescAuPmmngrGetPageDesc (uint64_t physaddr)
 AuPmmngrGetPageDesc – return the correct page descriptor of given physical address.
 
void AuPmmngrSetPageType (uint64_t physaddr, uint8_t flags)
 AuPmmngrSetPageType – set page type.
 
void AuPmmngrDebugInfo ()
 

Variables

bool debugon
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-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.

Macro Definition Documentation

◆ PAGE_SHIFT

#define PAGE_SHIFT   12

Typedef Documentation

◆ LBMemoryRegion

typedef struct _lb_mem_rgn_ LBMemoryRegion

Function Documentation

◆ AuPmmngrAddRefcount()

void AuPmmngrAddRefcount ( uint64_t  physaddr,
uint16_t  count 
)

AuPmmngrAddRefcount – increment reference count of given page.

Parameters
physaddr– Physical address to increase reference count of
count– number of count to increase

◆ AuPmmngrAlloc()

void * AuPmmngrAlloc ( )

AuPmmngrAlloc – Allocate a single physical page frame and return it to the caller.

◆ AuPmmngrAllocBlocks()

void * AuPmmngrAllocBlocks ( int  num)

AuPmmngrAllocBlocks – Allocate multiple physical page frames and return the first page pointer to the caller.

Parameters
size– Number of blocks to allocate

◆ AuPmmngrAllocCheck()

bool AuPmmngrAllocCheck ( uint64_t  address)

◆ AuPmmngrBitmapCheck()

bool AuPmmngrBitmapCheck ( uint64_t  index)

◆ AuPmmngrBitmapSet()

bool AuPmmngrBitmapSet ( uint64_t  index,
bool  value 
)

◆ AuPmmngrDebugInfo()

void AuPmmngrDebugInfo ( )

◆ AuPmmngrFree()

void AuPmmngrFree ( void *  Address)

AuPmmngrFree – Free a physical page frame.

Parameters
Address– Pointer to physical page

◆ AuPmmngrFreeBlocks()

void AuPmmngrFreeBlocks ( void *  Addr,
int  Count 
)

AuPmmngrFreeBlocks – Free multiple page frames.

Parameters
Addr– Address of the first page frame
Count– Number of blocks to be freed

◆ AuPmmngrGetFreeMem()

uint64_t AuPmmngrGetFreeMem ( )

AuPmmngrGetFreeMem – returns the total free amount of RAM.

◆ AuPmmngrGetPageDesc()

AuPageDesc * AuPmmngrGetPageDesc ( uint64_t  physaddr)

AuPmmngrGetPageDesc – return the correct page descriptor of given physical address.

Parameters
physaddr– physical address number

◆ AuPmmngrGetRefcount()

uint16_t AuPmmngrGetRefcount ( uint64_t  physaddr)

AuPmmngrGetRefcount – returns the number of reference count for given physical address.

Parameters
physaddr– physical address to check for reference count
Returns
number of reference count

◆ AuPmmngrGetTotalMem()

uint64_t AuPmmngrGetTotalMem ( )

AuPmmngrGetTotalMem – returns the total amount of RAM.

◆ AuPmmngrInitBitmap()

void AuPmmngrInitBitmap ( size_t  BSize,
void *  Buffer 
)

AuPmmngrInitBitmap – Initialize the Ram bitmap with all zeros.

Parameters
BitmapSize– total bitmap size
Buffer– Pointer to bitmap buffer

◆ AuPmmngrInitialize()

void AuPmmngrInitialize ( KERNEL_BOOT_INFO info)

AuPmmngrInitialise – initialise the physical memory manager.

Parameters
info– Pointer to kernel boot info structure

◆ AuPmmngrLockPage()

void AuPmmngrLockPage ( uint64_t  Address)

AuPmmngrLockPage – Lock a given page.

Parameters
Address– Pointer to page

◆ AuPmmngrLockPages()

void AuPmmngrLockPages ( void *  Address,
size_t  Size 
)

AuPmmngrLockPage – locks a set of pages.

Parameters
Address– Starting address of the first page
Size– Size of the set

◆ AuPmmngrMoveHigher()

void AuPmmngrMoveHigher ( )

AuPmmngrMoveHigher – moves the kernel to higher half of memory.

◆ AuPmmngrSetPageType()

void AuPmmngrSetPageType ( uint64_t  physaddr,
uint8_t  flags 
)

AuPmmngrSetPageType – set page type.

Parameters
physaddr– Physical address to treat
flags– type flags

check if page is kernel or dma, if yes then normal bit should be removed, because kernel will treat kernel or dma pages differently

◆ AuPmmngrUnreservePage()

void AuPmmngrUnreservePage ( void *  Address)

AuPmmngrUnreservePage – Marks a page as free.

Parameters
Address– Pointer to the page

◆ P2V()

uint64_t P2V ( uint64_t  addr)

P2V – Physical to Virtual conversion.

Parameters
addr– Address to convert

◆ V2P()

uint64_t V2P ( uint64_t  vaddr)

V2P – Virtual to Physical conversion.

Parameters
vaddr– Address to convert

Variable Documentation

◆ debugon

bool debugon