diff --git a/src/system/kernel/arch/x86/64/cpuid.S b/src/system/kernel/arch/x86/64/cpuid.S deleted file mode 100644 index 1085359a1f..0000000000 --- a/src/system/kernel/arch/x86/64/cpuid.S +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. - * Distributed under the terms of the MIT License. - */ - - -#include - - -.text - - -/* status_t get_current_cpuid(cpuid_info* info, uint32 eaxRegister, - uint32 ecxRegister) */ -FUNCTION(get_current_cpuid): - push %rbx - movl %esi, %eax - movl %edx, %ecx - cpuid - movl %eax, 0(%rdi) - movl %ebx, 4(%rdi) - movl %edx, 8(%rdi) - movl %ecx, 12(%rdi) - xorl %eax, %eax - // B_OK - pop %rbx - ret -FUNCTION_END(get_current_cpuid) - - -/* uint32 get_eflags(void) */ -FUNCTION(get_eflags): - // The top 32 bits of RFLAGS are reserved, we can ignore them. - pushf - pop %rax - mov %eax, %eax - ret -FUNCTION_END(get_eflags) - - -/* void set_eflags(uint32 val) */ -FUNCTION(set_eflags): - mov %edi, %edi - push %rdi - popf - ret -FUNCTION_END(set_eflags) diff --git a/src/system/kernel/arch/x86/64/cpuid.cpp b/src/system/kernel/arch/x86/64/cpuid.cpp new file mode 100644 index 0000000000..7d14b71bbd --- /dev/null +++ b/src/system/kernel/arch/x86/64/cpuid.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2014, Paweł Dziepak, pdziepak@quarnos.org. + * Copyright 2012, Alex Smith, alex@alex-smith.me.uk. + * Distributed under the terms of the MIT License. + */ + + +#include + + +status_t +get_current_cpuid(cpuid_info* info, uint32 eax, uint32 ecx) +{ + __asm__("cpuid" + : "=a" (info->regs.eax), "=b" (info->regs.ebx), "=c" (info->regs.ecx), + "=d" (info->regs.edx) + : "a" (eax), "c" (ecx)); + return B_OK; +} + + +uint32 +get_eflags() +{ + uint64_t flags; + __asm__("pushf; popq %0;" : "=r" (flags)); + return flags; +} + + +void +set_eflags(uint32 value) +{ + uint64_t flags = value; + __asm__("pushq %0; popf;" : : "r" (flags) : "cc"); +} + diff --git a/src/system/kernel/arch/x86/Jamfile b/src/system/kernel/arch/x86/Jamfile index 773bc39153..c56cc50eec 100644 --- a/src/system/kernel/arch/x86/Jamfile +++ b/src/system/kernel/arch/x86/Jamfile @@ -22,7 +22,7 @@ if $(TARGET_ARCH) = x86_64 { archSpecificSources = arch.S - cpuid.S + cpuid.cpp descriptors.cpp interrupts.S signals.cpp