From 44ace04b95a24464f67936d573dc55014e1ee516 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 28 Jan 2020 14:48:46 +0100 Subject: [PATCH] hw/x86: add cpuid register macro Issue #3623 --- .../include/hw/spec/x86_64/register_macros.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/repos/base-hw/src/include/hw/spec/x86_64/register_macros.h b/repos/base-hw/src/include/hw/spec/x86_64/register_macros.h index 15eec2296a..ba93e85be7 100644 --- a/repos/base-hw/src/include/hw/spec/x86_64/register_macros.h +++ b/repos/base-hw/src/include/hw/spec/x86_64/register_macros.h @@ -50,4 +50,22 @@ __VA_ARGS__; \ }; +#define X86_64_CPUID_REGISTER(name, id, reg, ...) \ + struct name : Genode::Register<64> \ + { \ + static access_t read() \ + { \ + Genode::uint32_t eax = id; \ + Genode::uint32_t ebx = 0; \ + Genode::uint32_t ecx = 0; \ + Genode::uint32_t edx = 0; \ + asm volatile ("cpuid" : "+a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)); \ + return reg; \ + } \ + \ + static void write(access_t const) { } \ + \ + __VA_ARGS__; \ + }; + #endif /* _SRC__LIB__HW__SPEC__X86_64__REGISTER_MACROS_H_ */