Some monitor/mwait stuff I don't use yet..

上级 84ad98da
...@@ -77,3 +77,11 @@ ...@@ -77,3 +77,11 @@
#define PERF_SEL_INT (1ULL << 20) #define PERF_SEL_INT (1ULL << 20)
#define PERF_SEL_ENABLE (1ULL << 22) #define PERF_SEL_ENABLE (1ULL << 22)
#define PERF_SEL_INV (1ULL << 23) #define PERF_SEL_INV (1ULL << 23)
// CPUID function 0x00000001
#define CPUID_FEATURES 0x00000001
#define FEATURE_ECX_MWAIT (1 << 3)
// CPUID function 0x00000005
#define CPUID_MWAIT 0x00000005
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "wq.hh" #include "wq.hh"
#include "uwq.hh" #include "uwq.hh"
#include "kmtrace.hh" #include "kmtrace.hh"
#include "bits.hh"
struct idle { struct idle {
struct proc *cur; struct proc *cur;
...@@ -109,7 +110,7 @@ idleloop(void) ...@@ -109,7 +110,7 @@ idleloop(void)
p = proc::alloc(); p = proc::alloc();
if (p == nullptr) if (p == nullptr)
break; break;
snprintf(p->name, sizeof(p->name), "idleh_%u", mycpu()->id); snprintf(p->name, sizeof(p->name), "idle_%u", mycpu()->id);
p->cpuid = mycpu()->id; p->cpuid = mycpu()->id;
p->cpu_pin = 1; p->cpu_pin = 1;
p->context->rip = (u64)idleheir; p->context->rip = (u64)idleheir;
...@@ -137,6 +138,17 @@ initidle(void) ...@@ -137,6 +138,17 @@ initidle(void)
if (!p) if (!p)
panic("initidle proc::alloc"); panic("initidle proc::alloc");
if (myid() == mpbcpu()) {
u32 eax, ebx, ecx;
cpuid(CPUID_FEATURES, nullptr, nullptr, &ecx, nullptr);
if (ecx & FEATURE_ECX_MWAIT) {
// Check smallest and largest line sizes
cpuid(CPUID_MWAIT, &eax, &ebx, nullptr, nullptr);
assert((u16)eax == 0x40);
assert((u16)ebx == 0x40);
}
}
SLIST_INIT(&idlem[myid()].zombies); SLIST_INIT(&idlem[myid()].zombies);
initlock(&idlem[myid()].lock, "idle_lock", LOCKSTAT_IDLE); initlock(&idlem[myid()].lock, "idle_lock", LOCKSTAT_IDLE);
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论