Fix emunand SMC behaviors

This commit is contained in:
Michael Scire
2019-05-28 13:25:12 -07:00
parent 40b838c896
commit 6dd366cb22
4 changed files with 13 additions and 4 deletions

View File

@@ -70,6 +70,13 @@ static inline uintptr_t get_physical_address(const void *vaddr) {
return (PAR & 1) ? 0ull : (PAR & MASK2L(40, 12)) | ((uintptr_t)vaddr & MASKL(12));
}
static inline uintptr_t get_physical_address_el0(const uintptr_t el0_vaddr) {
uintptr_t PAR;
__asm__ __volatile__ ("at s1e0r, %0" :: "r"(el0_vaddr));
__asm__ __volatile__ ("mrs %0, par_el1" : "=r"(PAR));
return (PAR & 1) ? 0ull : (PAR & MASK2L(40, 12)) | ((uintptr_t)el0_vaddr & MASKL(12));
}
static inline uint32_t read32le(const volatile void *dword, size_t offset) {
return *(uint32_t *)((uintptr_t)dword + offset);
}