1 /*
2 * Copyright 2014, Paweł Dziepak, pdziepak@quarnos.org.
3 * Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
4 * Distributed under the terms of the MIT License.
5 */
6
7
8 #include <arch_system_info.h>
9
10 #include <cpuid.h>
11
12
13 status_t
get_current_cpuid(cpuid_info * info,uint32 eax,uint32 ecx)14 get_current_cpuid(cpuid_info* info, uint32 eax, uint32 ecx)
15 {
16 __cpuid_count(eax, ecx, info->regs.eax, info->regs.ebx, info->regs.ecx,
17 info->regs.edx);
18 return B_OK;
19 }
20
21
22 uint32
get_eflags()23 get_eflags()
24 {
25 uint64_t flags;
26 __asm__("pushf; popq %0;" : "=r" (flags));
27 return flags;
28 }
29
30
31 void
set_eflags(uint32 value)32 set_eflags(uint32 value)
33 {
34 uint64_t flags = value;
35 __asm__("pushq %0; popf;" : : "r" (flags) : "cc");
36 }
37
38