Skip to content

Commit b0fe03b

Browse files
authored
Merge pull request #842 from gurka/dev
Fixes incorrect cpuid call
2 parents 4887518 + 0268839 commit b0fe03b

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

api/kernel/cpuid.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
#define KERNEL_CPUID_HPP
2121

2222
struct CPUID {
23-
struct cpuid_t {
24-
unsigned int EAX;
25-
unsigned int EBX;
26-
unsigned int ECX;
27-
unsigned int EDX;
28-
};
29-
3023
static bool isAmdCpu();
3124
static bool isIntelCpu();
3225
static bool hasRDRAND();

src/kernel/cpuid.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@
8787
#define EDX_RDTSCP (1 << 27) // RDTSCP and IA32_TSC_AUX
8888
#define EDX_64_BIT (1 << 29) // 64-bit Architecture
8989

90-
using cpuid_t = CPUID::cpuid_t;
90+
struct cpuid_t {
91+
unsigned int EAX;
92+
unsigned int EBX;
93+
unsigned int ECX;
94+
unsigned int EDX;
95+
}; //< cpuid_t
9196

9297
// EBX/RBX needs to be preserved depending on the memory model and use of PIC
9398
static cpuid_t
@@ -119,7 +124,7 @@ bool CPUID::hasRDRAND() {
119124
if (!isAmdCpu() && !isIntelCpu()) {
120125
return false;
121126
}
122-
123-
cpuid_t info = cpuid_info(0, 0);
127+
128+
cpuid_t info = cpuid_info(1, 0);
124129
return (info.ECX & ECX_RDRAND) != 0;
125130
}

0 commit comments

Comments
 (0)