Xyris  0.5
Memory::Physical::PhysicalManager Class Reference

#include <Physical.hpp>

+ Collaboration diagram for Memory::Physical::PhysicalManager:

Public Member Functions

void setFree (Section &sect)
 
void setUsed (Section &sect)
 
void setFree (Arch::Memory::Address addr)
 
void setUsed (Arch::Memory::Address addr)
 
void setFree (uintptr_t addr)
 
void setUsed (uintptr_t addr)
 
bool isFree (uintptr_t addr)
 
bool isFree (Section &sect)
 
uintptr_t findNextFreePhysicalAddress ()
 

Private Attributes

Bitset< MEM_BITMAP_SIZEm_memory
 

Detailed Description

Definition at line 24 of file Physical.hpp.

Member Function Documentation

◆ findNextFreePhysicalAddress()

uintptr_t Memory::Physical::PhysicalManager::findNextFreePhysicalAddress ( )
inline

Definition at line 100 of file Physical.hpp.

101  {
102  return m_memory.FindFirstBit(false);
103  }
+ Here is the call graph for this function:

◆ isFree() [1/2]

bool Memory::Physical::PhysicalManager::isFree ( Section sect)
inline

Definition at line 89 of file Physical.hpp.

90  {
91  // TODO: Optimize bitmap library to take number of bits to set
92  for (size_t i = 0; i < sect.pages(); i++) {
93  if (!isFree(ADDRESS_TO_PAGE_IDX(sect.base()) + i)) {
94  return false;
95  }
96  }
97  return true;
98  }
+ Here is the call graph for this function:

◆ isFree() [2/2]

bool Memory::Physical::PhysicalManager::isFree ( uintptr_t  addr)
inline

Definition at line 84 of file Physical.hpp.

85  {
86  return m_memory.Test(ADDRESS_TO_PAGE_IDX(addr)) == 0;
87  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFree() [1/3]

void Memory::Physical::PhysicalManager::setFree ( Arch::Memory::Address  addr)
inline

Definition at line 56 of file Physical.hpp.

57  {
58  if (!isFree(addr)) {
60  }
61  }
+ Here is the call graph for this function:

◆ setFree() [2/3]

void Memory::Physical::PhysicalManager::setFree ( Section sect)
inline

Definition at line 33 of file Physical.hpp.

34  {
35  for (size_t i = 0; i < sect.pages(); i++) {
36  setFree(ADDRESS_TO_PAGE_IDX(sect.base()) + i);
37  }
38  }
+ Here is the call graph for this function:

◆ setFree() [3/3]

void Memory::Physical::PhysicalManager::setFree ( uintptr_t  addr)
inline

Definition at line 70 of file Physical.hpp.

71  {
72  if (!isFree(addr)) {
74  }
75  }
+ Here is the call graph for this function:

◆ setUsed() [1/3]

void Memory::Physical::PhysicalManager::setUsed ( Arch::Memory::Address  addr)
inline

Definition at line 63 of file Physical.hpp.

64  {
65  if (isFree(addr)) {
67  }
68  }
+ Here is the call graph for this function:

◆ setUsed() [2/3]

void Memory::Physical::PhysicalManager::setUsed ( Section sect)
inline

Definition at line 40 of file Physical.hpp.

41  {
43  __func__,
44  "0x%08zX-0x%08zX 0x%08zX [%zu] [%s]",
45  sect.base(),
46  sect.end(),
47  sect.size(),
48  sect.pages(),
49  sect.typeString());
50  // TODO: Optimize bitmap library to take number of bits to set
51  for (size_t i = 0; i < sect.pages(); i++) {
52  setUsed(ADDRESS_TO_PAGE_IDX(sect.base()) + i);
53  }
54  }
+ Here is the call graph for this function:

◆ setUsed() [3/3]

void Memory::Physical::PhysicalManager::setUsed ( uintptr_t  addr)
inline

Definition at line 77 of file Physical.hpp.

78  {
79  if (isFree(addr)) {
81  }
82  }
+ Here is the call graph for this function:

Field Documentation

◆ m_memory

Bitset<MEM_BITMAP_SIZE> Memory::Physical::PhysicalManager::m_memory
private

Definition at line 106 of file Physical.hpp.


The documentation for this class was generated from the following file:
Memory::Physical::PhysicalManager::isFree
bool isFree(uintptr_t addr)
Definition: Physical.hpp:84
Bitset::Test
bool Test(size_t pos)
Return the value of the bit at the given position.
Definition: Bitset.hpp:91
Bitset::Set
void Set(size_t pos)
Set the bit for a given position.
Definition: Bitset.hpp:60
Memory::Physical::PhysicalManager::m_memory
Bitset< MEM_BITMAP_SIZE > m_memory
Definition: Physical.hpp:106
Bitset::FindFirstBit
size_t FindFirstBit(bool isSet)
Finds and returns the position of the first clear bit.
Definition: Bitset.hpp:116
Memory::Physical::PhysicalManager::setFree
void setFree(Section &sect)
Definition: Physical.hpp:33
Logger::Debug
static void Debug(const char *tag, const char *fmt,...)
Definition: Logger.cpp:71
Memory::Physical::PhysicalManager::setUsed
void setUsed(Section &sect)
Definition: Physical.hpp:40
ADDRESS_TO_PAGE_IDX
#define ADDRESS_TO_PAGE_IDX(addr)
Definition: Memory.hpp:28
Bitset::Reset
void Reset(size_t pos)
Reset (clear) the bit at the given position.
Definition: Bitset.hpp:70