kernel/x86_64: rewrite cpuid.S -> cpuid.cpp

Just getting rid of some assembly, no functional change.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
This commit is contained in:
Paweł Dziepak 2014-08-25 22:51:46 +02:00
parent 721a07ac24
commit 1eba40776d
3 changed files with 38 additions and 48 deletions

View File

@ -1,47 +0,0 @@
/*
* Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
* Distributed under the terms of the MIT License.
*/
#include <asm_defs.h>
.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)

View File

@ -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 <arch_system_info.h>
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");
}

View File

@ -22,7 +22,7 @@ if $(TARGET_ARCH) = x86_64 {
archSpecificSources =
arch.S
cpuid.S
cpuid.cpp
descriptors.cpp
interrupts.S
signals.cpp