From fcd2c1450007f511f26b360d700d9188d11b9d4b Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Mon, 29 Jul 2019 18:20:35 -0700 Subject: [PATCH] x86: add functions to get/set page tables Wrapper to assembly code working with CR3 register. Signed-off-by: Andrew Boie --- arch/x86/include/ia32/mmustructs.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/include/ia32/mmustructs.h b/arch/x86/include/ia32/mmustructs.h index bfd3b44befa..fcc8510ce5e 100644 --- a/arch/x86/include/ia32/mmustructs.h +++ b/arch/x86/include/ia32/mmustructs.h @@ -526,6 +526,19 @@ struct x86_mmu_pt { */ void z_x86_dump_page_tables(struct x86_mmu_pdpt *pdpt); +static inline void z_x86_page_tables_set(struct x86_mmu_pdpt *pdpt) +{ + __asm__ volatile("movl %0, %%cr3\n\t" : : "r" (pdpt)); +} + +static inline struct x86_mmu_pdpt *z_x86_page_tables_get(void) +{ + struct x86_mmu_pdpt *ret; + + __asm__ volatile("movl %%cr3, %0\n\t" : "=r" (ret)); + + return ret; +} #endif /* _ASMLANGUAGE */ #endif /* ZEPHYR_ARCH_X86_INCLUDE_IA32_MMUSTRUCTS_H_ */