 |
Xyris
0.5
|
◆ Type
Enumerator |
---|
Available | |
Reserved | |
ACPI | |
NVS | |
Bad | |
Bootloader | |
Kernel | |
Unknown | |
Definition at line 18 of file MemorySection.hpp.
◆ freePage()
void Memory::freePage |
( |
void * |
page, |
|
|
size_t |
size |
|
) |
| |
Frees pages starting at a given page address.
- Parameters
-
page | Starting location of page(s) to be freed |
size | Number of bytes to be freed |
Definition at line 246 of file paging.cpp.
250 Arch::Memory::Address addr((uintptr_t)page);
251 for (
size_t i = addr.page().tableIndex; i < addr.page().tableIndex + page_count; i++) {
252 mappedPages.
Reset(i);
258 memset(pte, 0,
sizeof(
struct Arch::Memory::TableEntry));
260 Arch::Memory::pageInvalidate(page);
◆ getPageDirPhysAddr()
uintptr_t Memory::getPageDirPhysAddr |
( |
| ) |
|
Gets the physical address of the current page directory.
- Returns
- the physical address of the current page directory.
Definition at line 272 of file paging.cpp.
274 return pageDirectoryAddress;
◆ init()
Sets up the environment, page directories etc and enables paging.
Definition at line 57 of file paging.cpp.
70 Arch::Memory::setPageDirectory(Arch::Memory::pageAlign(pageDirectoryAddress));
◆ isPresent()
bool Memory::isPresent |
( |
uintptr_t |
addr | ) |
|
Checks whether an address is mapped into memory.
- Parameters
-
addr | Address to be checked. |
- Returns
- true The address is mapped in and valid.
-
false The address is not mapped into memory.
Definition at line 264 of file paging.cpp.
◆ KERNEL_PARAM()
◆ mapKernelPage()
void Memory::mapKernelPage |
( |
Arch::Memory::Address |
vaddr, |
|
|
Arch::Memory::Address |
paddr |
|
) |
| |
Map a page into the kernel address space.
- Parameters
-
vaddr | Virtual address (in kernel space) |
paddr | Physical address |
Definition at line 147 of file paging.cpp.
150 size_t pde = vaddr.page().dirIndex;
151 size_t pte = vaddr.page().tableIndex;
154 if (is_mapping_output_enabled) {
155 Logger::Debug(__func__,
"map 0x%08lx to 0x%08lx, pde = 0x%08lx, pte = 0x%08lx", paddr.val(), vaddr.val(), pde, pte);
159 if (vaddr.page().offset) {
160 panicf(
"Attempted to map a non-page-aligned virtual address.\n(Address: 0x%08lX)\n", vaddr.val());
164 Arch::Memory::TableEntry* entry = &(pageTables[pde].pages[pte]);
165 if (entry->present) {
166 if (entry->frame == paddr.frame().index) {
171 panic(
"Attempted to map already mapped page.\n");
174 pageTables[pde].pages[pte] = {
185 .frame = paddr.frame().index,
189 mappedPages.
Set(vaddr.frame().index);
◆ mapKernelRangePhysical()
void Memory::mapKernelRangePhysical |
( |
Section |
sect | ) |
|
Map a kernel address range into physical memory.
- Parameters
-
Definition at line 199 of file paging.cpp.
201 for (Arch::Memory::Address a(sect.base()); a < sect.end(); a +=
ARCH_PAGE_SIZE) {
◆ mapKernelRangeVirtual()
void Memory::mapKernelRangeVirtual |
( |
Section |
sect | ) |
|
Map an address range into the kernel virtual address space.
- Parameters
-
Definition at line 192 of file paging.cpp.
194 for (Arch::Memory::Address a(sect.base()); a < sect.end(); a +=
ARCH_PAGE_SIZE) {
◆ newPage()
void * Memory::newPage |
( |
size_t |
size | ) |
|
Returns a new page in memory for use. If less than one page is requested, exactly one page will be allocated and returned.
- Parameters
-
- Returns
- void* Page memory address
Definition at line 228 of file paging.cpp.
232 size_t free_idx = findNextFreeVirtualAddress(page_count);
233 if (free_idx == SIZE_MAX)
235 for (
size_t i = free_idx; i < free_idx + page_count; i++) {
237 if (phys_page_idx == SIZE_MAX)
void pagingEnable()
Enable hardware paging.
void mapKernelPage(Arch::Memory::Address vaddr, Arch::Memory::Address paddr)
Map a page into the kernel address space.
void Set(size_t pos)
Set the bit for a given position.
#define ARCH_PAGE_TABLE_ENTRY_SHIFT
#define ARCH_PAGE_TABLE_ENTRIES
void setFree(Section §)
void registerHandler(uint8_t interrupt, InterruptHandler_t handler)
void panicf(const char *fmt,...)
Halt the system and print the provided message and arguments on the panic screen.
static void Debug(const char *tag, const char *fmt,...)
void panic(const char *msg)
Halt the system and print the provided message on the panic screen.
void setUsed(Section §)
void * memset(void *bufptr, int value, size_t size)
Sets the number of bytes in memory at ptr to the value.
#define KADDR_TO_PHYS(addr)
uintptr_t findNextFreePhysicalAddress()
void Reset(size_t pos)
Reset (clear) the bit at the given position.