ein
0.0.1
一呼百應, "one call, a hundred responses"
Loading...
Searching...
No Matches
cpuid.cpp
Go to the documentation of this file.
1
9
#include <array>
10
#include <cstdint>
11
#include <string_view>
12
#include <cpuid.h>
13
#include "
attributes/common.hpp
"
14
#include "
cpuid.hpp
"
15
16
namespace
ein
{
17
19
ein_pure
cpuid_t
cpuid
(int32_t eax, int32_t ecx)
noexcept
{
20
cpuid_t
result;
21
__cpuid_count(eax, ecx, result.
eax
, result.
ebx
, result.
ecx
, result.
edx
);
22
return
result;
23
}
24
26
const
enum
cpu_vendor
cpu_vendor
= []
static
noexcept
{
27
auto
result =
cpuid
(0, 0);
28
std::array<int32_t, 3> data = { result.ebx, result.edx, result.ecx };
29
std::string_view vendor {
reinterpret_cast<
char
const
*
>
(begin(data)), 12};
30
using
enum
cpu_vendor
;
31
if
(vendor ==
"GenuineIntel"
)
return
intel
;
32
else
if
(vendor ==
"AuthenticAMD"
)
return
amd
;
33
else
return
unknown
;
34
}();
35
36
}
// end namespace ein
common.hpp
cpuid.hpp
ein_pure
#define ein_pure
[[pure]]
Definition
common.hpp:102
ein
Definition
cpuid.cpp:16
ein::cpu_vendor
cpu_vendor
CPU vendor id.
Definition
cpuid.hpp:34
ein::cpu_vendor::intel
@ intel
CPUID reported "GenuineIntel"
ein::cpu_vendor::amd
@ amd
CPUID reported "AuthenticAMD"
ein::cpu_vendor::unknown
@ unknown
CPUID reported something else
ein::cpuid_t::ebx
int32_t ebx
Definition
cpuid.hpp:20
ein::cpuid_t::eax
int32_t eax
Definition
cpuid.hpp:20
ein::cpuid_t::ecx
int32_t ecx
Definition
cpuid.hpp:20
ein::cpuid
cpuid_t cpuid(int32_t eax, int32_t ecx) noexcept
calls CPUID and returns all of the registers that it responds with.
Definition
cpuid.cpp:19
ein::cpuid_t::edx
int32_t edx
Definition
cpuid.hpp:20
ein::cpuid_t
result from calling the CPUID instruction
Definition
cpuid.hpp:19
src
ein
cpuid.cpp
© 2024 Edward Kmett. All rights reserved.