xref: /haiku/src/system/kernel/arch/x86/64/cpuid.cpp (revision e3857211d305a595c2d0b58768f25623d5967675)
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 
11 status_t
12 get_current_cpuid(cpuid_info* info, uint32 eax, uint32 ecx)
13 {
14 	__asm__("cpuid"
15 		: "=a" (info->regs.eax), "=b" (info->regs.ebx), "=c" (info->regs.ecx),
16 			"=d" (info->regs.edx)
17 		: "a" (eax), "c" (ecx));
18 	return B_OK;
19 }
20 
21 
22 uint32
23 get_eflags()
24 {
25 	uint64_t flags;
26 	__asm__("pushf; popq %0;" : "=r" (flags));
27 	return flags;
28 }
29 
30 
31 void
32 set_eflags(uint32 value)
33 {
34 	uint64_t flags = value;
35 	__asm__("pushq %0; popf;" : : "r" (flags) : "cc");
36 }
37 
38