From 4b75a1e2377d5380d6bea4319fc8f1bc2f595665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Dziepak?= Date: Mon, 25 Aug 2014 22:53:32 +0200 Subject: [PATCH] kernel/x86_64: implement x86_swap_pgdir in C++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No reason not to inline this function. Signed-off-by: Paweł Dziepak --- headers/private/kernel/arch/x86/64/cpu.h | 7 +++++++ headers/private/kernel/arch/x86/arch_cpu.h | 3 ++- src/system/kernel/arch/x86/64/arch.S | 7 ------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/headers/private/kernel/arch/x86/64/cpu.h b/headers/private/kernel/arch/x86/64/cpu.h index a5bb7e7be7..a29891d5de 100644 --- a/headers/private/kernel/arch/x86/64/cpu.h +++ b/headers/private/kernel/arch/x86/64/cpu.h @@ -45,4 +45,11 @@ x86_context_switch(arch_thread* oldState, arch_thread* newState) } +static inline void +x86_swap_pgdir(uintptr_t root) +{ + asm volatile("movq %0, %%cr3" : : "r" (root)); +} + + #endif // _KERNEL_ARCH_X86_64_CPU_H diff --git a/headers/private/kernel/arch/x86/arch_cpu.h b/headers/private/kernel/arch/x86/arch_cpu.h index 900f3c666b..88c5eb8e6a 100644 --- a/headers/private/kernel/arch/x86/arch_cpu.h +++ b/headers/private/kernel/arch/x86/arch_cpu.h @@ -455,7 +455,6 @@ void __x86_setup_system_time(uint32 conversionFactor, void x86_userspace_thread_exit(void); void x86_end_userspace_thread_exit(void); -void x86_swap_pgdir(addr_t newPageDir); void x86_fxsave(void* fpuState); void x86_fxrstor(const void* fpuState); void x86_noop_swap(void* oldFpuState, const void* newFpuState); @@ -480,6 +479,8 @@ void x86_page_fault_exception(iframe* iframe); #ifndef __x86_64__ +void x86_swap_pgdir(addr_t newPageDir); + uint64 x86_read_msr(uint32 registerNumber); void x86_write_msr(uint32 registerNumber, uint64 value); diff --git a/src/system/kernel/arch/x86/64/arch.S b/src/system/kernel/arch/x86/64/arch.S index 9bd3f16885..4cdd22af84 100644 --- a/src/system/kernel/arch/x86/64/arch.S +++ b/src/system/kernel/arch/x86/64/arch.S @@ -69,13 +69,6 @@ FUNCTION(x86_64_thread_entry): FUNCTION_END(x86_64_thread_entry) -/* void x86_swap_pgdir(uint64 newPageDir); */ -FUNCTION(x86_swap_pgdir): - movq %rdi, %cr3 - ret -FUNCTION_END(x86_swap_pgdir) - - /* thread exit stub */ .align 8 FUNCTION(x86_userspace_thread_exit):