4 #define KERNEL_START 0xffffffff80000000
5 #define PHYSMEM_START 0xffff800000000000
8 #include <kern/types.h>
10 // GCC can't currently handle full 64-bit code relocations
11 // on x64, so the code is mapped separately from the
12 // all-of-RAM mapping. This means that there are two different
13 // kernel-virtual addresses for some physical addresses.
16 static inline ulong kvirt_to_phys(void *addr)
18 ulong ret = reinterpret_cast<ulong>(addr);
20 if (ret > KERNEL_START)
21 return ret - KERNEL_START;
23 return ret - PHYSMEM_START;
26 static inline void *phys_to_kvirt(ulong addr)
28 return reinterpret_cast<void *>(addr + PHYSMEM_START);
32 static const ulong max_ktext_map = 4 * 1024 * 1024;
34 static inline void *phys_to_ktext(ulong addr)
36 return reinterpret_cast<void *>(addr + KERNEL_START);