kernel/x86_64: rewrite cpuid.S -> cpuid.cpp
Just getting rid of some assembly, no functional change. Signed-off-by: Paweł Dziepak <[email protected]>
This commit is contained in:
@@ -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)
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014, Paweł Dziepak, [email protected].
|
||||||
|
* Copyright 2012, Alex Smith, [email protected].
|
||||||
|
* 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");
|
||||||
|
}
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ if $(TARGET_ARCH) = x86_64 {
|
|||||||
|
|
||||||
archSpecificSources =
|
archSpecificSources =
|
||||||
arch.S
|
arch.S
|
||||||
cpuid.S
|
cpuid.cpp
|
||||||
descriptors.cpp
|
descriptors.cpp
|
||||||
interrupts.S
|
interrupts.S
|
||||||
signals.cpp
|
signals.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user