MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / UnmapPage

Method UnmapPage

src/memory/virtual_memory.cpp:117–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117auto VirtualMemory::UnmapPage(void* page_dir, void* virtual_addr)
118 -> Expected<void> {
119 assert(page_dir != nullptr && "UnmapPage: page_dir is null");
120
121 auto pte_result = FindPageTableEntry(page_dir, virtual_addr, false);
122 if (!pte_result.has_value()) {
123 return std::unexpected(Error(ErrorCode::kVmPageNotMapped));
124 }
125
126 auto pte = pte_result.value();
127
128 if (!cpu_io::virtual_memory::IsPageTableEntryValid(*pte)) {
129 return std::unexpected(Error(ErrorCode::kVmPageNotMapped));
130 }
131
132 // 清除页表项
133 *pte = 0;
134
135 // 刷新 TLB
136 cpu_io::virtual_memory::FlushTLBAll();
137
138 return {};
139}
140
141auto VirtualMemory::GetMapping(void* page_dir, void* virtual_addr)
142 -> Expected<void*> {

Callers 2

virtual_memory_testFunction · 0.80
TEST_FFunction · 0.80

Calls 3

ErrorClass · 0.85
IsPageTableEntryValidFunction · 0.85
FlushTLBAllFunction · 0.85

Tested by 2

virtual_memory_testFunction · 0.64
TEST_FFunction · 0.64