FreeNOS
ARM64FirstTable.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Ivan Tan
3 * Copyright (C) 2015 Niek Linnenbank
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __LIBARCH_ARM64_FIRSTTABLE_H
20#define __LIBARCH_ARM64_FIRSTTABLE_H
21
22#include <FreeNOS/System.h>
23#include <Types.h>
24#include <MemoryContext.h>
25#include "ARM64SecondTable.h"
26
28class SplitAllocator;
29
45{
46 public:
47
59 Address phys,
61 SplitAllocator *alloc);
62
74 SplitAllocator *alloc);
75
85 SplitAllocator *alloc);
86
97 Address *phys,
98 SplitAllocator *alloc) const;
99
111 SplitAllocator *alloc) const;
112
123 SplitAllocator *alloc,
124 const bool tablesOnly);
125
135 SplitAllocator *alloc);
136
137 static void initialize(ARM64FirstTable *firstTable);
138
139 private:
140
147 inline void releasePhysical(SplitAllocator *alloc,
148 const Address phys);
149
159 SplitAllocator *alloc) const;
160
169
180 u64 get_l2_entry(Address virt, SplitAllocator *alloc, u64 **tbl_l2, unsigned int *l2_idx) const;
181
182 private:
183
185 u64 m_tables_l1[512]; /* level 1 table, only maps to 0 - 4G */
186 u64 m_tables_l2[4][512]; /* virtual address 0-1/1-2/2-3/3-4 G */
187};
188
195#endif /* __LIBARCH_ARM64_FIRSTTABLE_H */
u32 flags
Definition IntelACPI.h:3
ARM64 first level page table.
MemoryContext::Result translate(Address virt, Address *phys, SplitAllocator *alloc) const
Translate virtual address to physical address.
MemoryContext::Result unmap(Address virt, SplitAllocator *alloc)
Remove virtual address mapping.
u64 m_tables_l2[4][512]
MemoryContext::Result map(Address virt, Address phys, Memory::Access access, SplitAllocator *alloc)
Map a virtual address to a physical address.
u64 get_l2_entry(Address virt, SplitAllocator *alloc, u64 **tbl_l2, unsigned int *l2_idx) const
Get entry of Level 2 table.
u64 m_tables_l1[512]
Array of page table entries.
MemoryContext::Result access(Address virt, Memory::Access *access, SplitAllocator *alloc) const
Get Access flags for a virtual address.
static void initialize(ARM64FirstTable *firstTable)
void releasePhysical(SplitAllocator *alloc, const Address phys)
Release a single physical page.
MemoryContext::Result releaseRange(const Memory::Range range, SplitAllocator *alloc)
Release range of memory.
ARM64SecondTable * getSecondTable(Address virt, SplitAllocator *alloc) const
Retrieve second level page table.
MemoryContext::Result releaseSection(const Memory::Range range, SplitAllocator *alloc, const bool tablesOnly)
Release memory sections.
MemoryContext::Result mapLarge(Memory::Range range, SplitAllocator *alloc)
Map a contigous range of virtual memory to physical memory.
ARM64 second level page table implementation.
Result
Result codes.
Allocator which separates kernel mapped memory at virtual and physical addresses.
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned long Address
A memory address.
Definition Types.h:131
unsigned long long u64
Unsigned 64-bit number.
Definition Types.h:50
Access
Memory access flags.
Definition Memory.h:39
Memory range.
Definition Memory.h:56