Skip to content
Snippets Groups Projects
Commit f7ed5c0a authored by Avi Kivity's avatar Avi Kivity
Browse files

mmu: convert hardcoded pt_index() uses to calls to pt_index()

parent cd36c57b
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,8 @@
#include <alloca.h>
#include <string.h>
using namespace mmu;
struct multiboot_info_type {
u32 flags;
u32 mem_lower;
......@@ -63,8 +65,7 @@ void setup_temporary_phys_map()
// duplicate 1:1 mapping into phys_mem
u64 cr3 = processor::read_cr3();
auto pt = reinterpret_cast<u64*>(cr3);
// assumes phys_mem = 0xffffc00000000000
pt[256+128] = pt[0];
pt[pt_index(phys_mem, 3)] = pt[0];
}
void for_each_e820_entry(void* e820_buffer, unsigned size, void (*f)(e820ent e))
......
......@@ -176,12 +176,6 @@ phys virt_to_phys(void *virt)
return static_cast<char*>(virt) - phys_mem;
}
unsigned pt_index(void *virt, unsigned level)
{
auto v = reinterpret_cast<ulong>(virt);
return (v >> (12 + level * 9)) & 511;
}
void allocate_intermediate_level(hw_ptep ptep)
{
phys pt_page = virt_to_phys(memory::alloc_page());
......
......@@ -15,6 +15,12 @@ typedef uint64_t f_offset;
static constexpr char* phys_mem = reinterpret_cast<char*>(0xffffc00000000000);
inline unsigned pt_index(void *virt, unsigned level)
{
auto v = reinterpret_cast<ulong>(virt);
return (v >> (12 + level * 9)) & 511;
}
enum {
perm_read = 1,
perm_write = 2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment