x86: add arch_mem_map()

This currently only supports identity paging; there's just
enough here for device_map() calls to work.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-07-08 12:19:02 -07:00 committed by Carles Cufí
commit e7376057ca
2 changed files with 38 additions and 0 deletions

View file

@ -186,6 +186,7 @@ config X86_VERY_EARLY_CONSOLE
config X86_MMU
bool "Enable Memory Management Unit"
select MEMORY_PROTECTION
select MMU
help
This options enables the memory management unit present in x86
and creates a set of page tables at boot time that is runtime-

View file

@ -834,6 +834,43 @@ void z_x86_add_mmu_region(uintptr_t addr, size_t size, uint64_t flags)
#endif
}
int arch_mem_map(void *dest, uintptr_t addr, size_t size, uint32_t flags)
{
uint64_t entry_flags = Z_X86_MMU_P;
__ASSERT((uintptr_t)dest == addr,
"only identity mapping supported");
switch (flags & K_MEM_CACHE_MASK) {
case K_MEM_CACHE_NONE:
entry_flags |= Z_X86_MMU_PCD;
break;
case K_MEM_CACHE_WT:
entry_flags |= Z_X86_MMU_PWT;
break;
case K_MEM_CACHE_WB:
break;
default:
return -ENOTSUP;
}
if ((flags & K_MEM_PERM_RW) != 0) {
entry_flags |= Z_X86_MMU_RW;
}
if ((flags & K_MEM_PERM_USER) != 0) {
/* TODO: user mode support
* entry_flags |= MMU_US;
*/
return -ENOTSUP;
}
if ((flags & K_MEM_PERM_EXEC) == 0) {
entry_flags |= Z_X86_MMU_XD;
}
z_x86_add_mmu_region(addr, size, entry_flags);
return 0;
}
void __weak z_x86_soc_add_mmu_regions(void)
{
}