replace nob with ms' build, move disk creation to build.bat, major comment cleanup, remove old and stupid tests, overhaul interrupt management with per-CPU vector allocation, affinity migration and safe teardown, add proper IOAPIC routing and PCI MSI/MSI-X/INTx support, migrate drivers to the new interrupt API, integrate ACPICA with a proper OS services layer, move ACPI firmware events, power button handling and S5 shutdown into acpi.sys, add parallel driver startup and atomic publication, replace PnP arrays with dynamic lists, redesign service startup again to be asynchronous, add delayed startup mode for services, allow omitting keys in services.ini, fix acpi ec deferred work handling, fix kernel threads having garbage exit code.
This commit is contained in:
1 parent
d36f19509c
commit
36eef8f58d
696 files changed
+147281
-7530
No files matched your search
@@ -129,7 +129,6 @@ bool KiSchedulerRefreshMutexDonation(MUTEX* mutex) {
|
||||
return changed;
|
||||
}
|
||||
|
||||
// Implements the default Thread Affinity Mask operation.
|
||||
static uint64_t KiDefaultThreadAffinityMask(void) {
|
||||
// Normal kernel, user, and driver-created threads are boot-processor-affine by
|
||||
// default. Code that is explicitly audited for AP execution can widen its
|
||||
@@ -137,14 +136,12 @@ static uint64_t KiDefaultThreadAffinityMask(void) {
|
||||
return 1ULL;
|
||||
}
|
||||
|
||||
// Implements the thread Is Killed Locked operation.
|
||||
static bool KiThreadIsKilledLocked(const THREAD* thread) {
|
||||
return thread && !thread->IsIdleThread && thread->Owner &&
|
||||
KeIsProcessTerminating(thread->Owner) &&
|
||||
!KeThreadTerminationDeferred(thread);
|
||||
}
|
||||
|
||||
// Implements the thread Can Run On Cpu Locked operation.
|
||||
static bool KiThreadCanRunOnCpuLocked(const THREAD* thread, const KCPU* cpu) {
|
||||
if (!thread || !cpu) return false;
|
||||
if (thread->IsIdleThread) return thread == cpu->IdleThread;
|
||||
@@ -152,7 +149,6 @@ static bool KiThreadCanRunOnCpuLocked(const THREAD* thread, const KCPU* cpu) {
|
||||
return (thread->AffinityMask & (1ULL << cpu->CpuIndex)) != 0;
|
||||
}
|
||||
|
||||
// Implements the cpu Is Idle Locked operation.
|
||||
static bool KiCpuIsIdleLocked(const KCPU* cpu) {
|
||||
if (!cpu || cpu->State != KeCpuOnline)
|
||||
return false;
|
||||
@@ -160,7 +156,6 @@ static bool KiCpuIsIdleLocked(const KCPU* cpu) {
|
||||
return (!cur || cur == cpu->IdleThread || cur->State != ThreadRunning);
|
||||
}
|
||||
|
||||
// Implements the any Idle Primary For Thread Locked operation.
|
||||
static bool KiAnyIdlePrimaryForThreadLocked(const THREAD* thread) {
|
||||
if (!thread || thread->IsIdleThread)
|
||||
return false;
|
||||
@@ -193,7 +188,6 @@ static bool KiShouldDeferToIdlePrimaryLocked(KCPU* cpu, const THREAD* thread) {
|
||||
return KiAnyIdlePrimaryForThreadLocked(thread);
|
||||
}
|
||||
|
||||
// Implements the request Reschedule Cpu Locked operation.
|
||||
static void KiRequestRescheduleCpuLocked(KCPU* target) {
|
||||
if (!target || target->State != KeCpuOnline)
|
||||
return;
|
||||
@@ -206,7 +200,6 @@ static void KiRequestRescheduleCpuLocked(KCPU* target) {
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the poke Runnable Cpus Locked operation.
|
||||
static void KiPokeRunnableCpusLocked(THREAD* thread) {
|
||||
if (!thread || thread->IsIdleThread)
|
||||
return;
|
||||
@@ -256,7 +249,6 @@ static void KiPokeRunnableCpusLocked(THREAD* thread) {
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the base Quantum For Priority operation.
|
||||
static uint32_t KiBaseQuantumForPriority(uint32_t priority) {
|
||||
switch ((THREAD_PRIORITY)priority) {
|
||||
case PriorityHigh: return SCHED_HIGH_QUANTUM_TICKS;
|
||||
@@ -266,7 +258,6 @@ static uint32_t KiBaseQuantumForPriority(uint32_t priority) {
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the compute Quantum Locked operation.
|
||||
static uint32_t KiComputeQuantumLocked(THREAD* thread) {
|
||||
if (!thread || thread == KeGetCurrentCpu()->IdleThread)
|
||||
return 1;
|
||||
@@ -288,7 +279,6 @@ static uint32_t KiComputeQuantumLocked(THREAD* thread) {
|
||||
return quantum ? quantum : 1;
|
||||
}
|
||||
|
||||
// Implements the refill Quantum Locked operation.
|
||||
static void KiRefillQuantumLocked(THREAD* thread) {
|
||||
if (!thread) return;
|
||||
thread->QuantumTicks = KiComputeQuantumLocked(thread);
|
||||
@@ -308,7 +298,6 @@ void KeGetSchedulerStats(KE_SCHED_STATS* out) {
|
||||
KeReleaseSpinlock(&gSchedLock, flags);
|
||||
}
|
||||
|
||||
// Implements the arm Post Switch Unlock operation.
|
||||
static void KiArmPostSwitchUnlock(THREAD* thread, uintptr_t cookie) {
|
||||
// The scheduler lock is intentionally held across KeSwitchContext(). The
|
||||
// unlock cookie belongs to the thread continuation that will resume after
|
||||
@@ -319,12 +308,10 @@ static void KiArmPostSwitchUnlock(THREAD* thread, uintptr_t cookie) {
|
||||
thread->SwitchLockCookie = cookie;
|
||||
}
|
||||
|
||||
// Implements the post Switch Unlock Cookie operation.
|
||||
static uintptr_t KiPostSwitchUnlockCookie(THREAD* thread) {
|
||||
return thread ? thread->SwitchLockCookie : 0x202ULL;
|
||||
}
|
||||
|
||||
// Implements the scheduler Bug operation.
|
||||
static void KiSchedulerBug(const char* where, THREAD* thread, const char* why) {
|
||||
KePanic(KE_PANIC_CODE_SCHEDULER,
|
||||
"scheduler invariant failed: %s: thread=0x%016llX tid=%u state=%u queued=%u runningCpu=%u idle=%u: %s\n",
|
||||
@@ -338,7 +325,6 @@ static void KiSchedulerBug(const char* where, THREAD* thread, const char* why) {
|
||||
why ? why : "?");
|
||||
}
|
||||
|
||||
// Implements the assert Ready Queue Candidate Locked operation.
|
||||
static void KiAssertReadyQueueCandidateLocked(const char* where, THREAD* thread) {
|
||||
if (!thread)
|
||||
KiSchedulerBug(where, thread, "null thread");
|
||||
@@ -352,7 +338,6 @@ static void KiAssertReadyQueueCandidateLocked(const char* where, THREAD* thread)
|
||||
KiSchedulerBug(where, thread, "thread still reserved/running on a CPU");
|
||||
}
|
||||
|
||||
// Implements the assert Picked Thread Locked operation.
|
||||
static void KiAssertPickedThreadLocked(const char* where, THREAD* thread) {
|
||||
if (!thread)
|
||||
KiSchedulerBug(where, thread, "null picked thread");
|
||||
@@ -694,7 +679,6 @@ KSTATUS KiSchedulerSetNormalPriority(THREAD* thread, THREAD_PRIORITY priority) {
|
||||
|
||||
static bool KiAnyRunnableForCpuLocked(KCPU* cpu);
|
||||
|
||||
// Implements the any Runnable For Current Cpu operation.
|
||||
static int KiAnyRunnableForCurrentCpu(void) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
uintptr_t flags = KeAcquireSpinlock(&gSchedLock);
|
||||
@@ -703,7 +687,6 @@ static int KiAnyRunnableForCurrentCpu(void) {
|
||||
return any;
|
||||
}
|
||||
|
||||
// Implements the idle Loop operation.
|
||||
static void KiIdleLoop(void) {
|
||||
while (true) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
@@ -900,7 +883,6 @@ uint64_t KeGetDefaultThreadAffinityMask(void) {
|
||||
return KiDefaultThreadAffinityMask();
|
||||
}
|
||||
|
||||
// Implements the ready Thread operation.
|
||||
void KeReadyThread(THREAD* thread) {
|
||||
if (!thread) return;
|
||||
|
||||
@@ -968,7 +950,6 @@ KSTATUS KeCancelSuspendedThread(THREAD* thread) {
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the unready Thread operation.
|
||||
void KeUnreadyThread(THREAD* thread) {
|
||||
if (!thread) return;
|
||||
uintptr_t flags = KeAcquireSpinlock(&gSchedLock);
|
||||
@@ -979,7 +960,6 @@ void KeUnreadyThread(THREAD* thread) {
|
||||
KeReleaseSpinlock(&gSchedLock, flags);
|
||||
}
|
||||
|
||||
// Implements the any Runnable For Cpu Locked operation.
|
||||
static bool KiAnyRunnableForCpuLocked(KCPU* cpu) {
|
||||
if (!cpu) cpu = KeGetCurrentCpu();
|
||||
|
||||
@@ -1028,7 +1008,6 @@ static THREAD* KiPickFromQueueLocked(KCPU* cpu, LIST_ENTRY* head) {
|
||||
return (THREAD*)0;
|
||||
}
|
||||
|
||||
// Implements the pick Next For Cpu operation.
|
||||
static THREAD* KiPickNextForCpu(KCPU* cpu) {
|
||||
if (!cpu) cpu = KeGetCurrentCpu();
|
||||
|
||||
@@ -1049,7 +1028,6 @@ static THREAD* KiPickNextForCpu(KCPU* cpu) {
|
||||
return cpu->IdleThread;
|
||||
}
|
||||
|
||||
// Implements the request Reschedule operation.
|
||||
void KiRequestReschedule(void) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
if (cpu)
|
||||
@@ -1062,7 +1040,6 @@ bool KiIsReschedulePending(void) {
|
||||
return cpu && NtlAtomicLoad32(&cpu->ReschedulePending) != 0;
|
||||
}
|
||||
|
||||
// Implements the schedule operation.
|
||||
static void KiSchedule(void) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
THREAD* cur = cpu->CurrentThread;
|
||||
@@ -1143,13 +1120,11 @@ static void KiSchedule(void) {
|
||||
KeSchedulerPostSwitch();
|
||||
}
|
||||
|
||||
// Implements the schedule From Interrupt operation.
|
||||
void KiScheduleFromInterrupt(void) {
|
||||
if (!KiIsReschedulePending()) return;
|
||||
KiSchedule();
|
||||
}
|
||||
|
||||
// Implements the scheduler Mark Thread Waiting operation.
|
||||
void KiSchedulerMarkThreadWaiting(THREAD* thread) {
|
||||
if (!thread) return;
|
||||
|
||||
@@ -1196,7 +1171,6 @@ static void KiCancelThreadTimeoutLocked(THREAD* thread) {
|
||||
thread->TimeoutStatus = NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the scheduler Note Voluntary Block operation.
|
||||
void KiSchedulerNoteVoluntaryBlock(THREAD* thread) {
|
||||
if (!thread) return;
|
||||
uintptr_t flags = KeAcquireSpinlock(&gSchedLock);
|
||||
@@ -1263,7 +1237,6 @@ void KeUnblockThreadFromWaitListWithStatus(THREAD* thread, KSTATUS status) {
|
||||
KeReleaseSpinlock(&gSchedLock, flags);
|
||||
}
|
||||
|
||||
// Implements the scheduler Wake Thread operation.
|
||||
void KiSchedulerWakeThread(THREAD* thread, KSTATUS status) {
|
||||
uintptr_t flags = KeAcquireSpinlock(&gSchedLock);
|
||||
KiWakeThreadLocked(thread, status);
|
||||
@@ -1430,7 +1403,6 @@ static int KiRunLocalSchedulerTickLocked(KCPU* cpu, THREAD* cur, THREAD* idle) {
|
||||
return requestReschedule;
|
||||
}
|
||||
|
||||
// Implements the scheduler Tick operation.
|
||||
void KeSchedulerTick(void) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
THREAD* cur = cpu->CurrentThread;
|
||||
@@ -1513,7 +1485,6 @@ KSTATUS KeArmCurrentThreadTimeout(uint64_t milliseconds, KSTATUS timeoutStatus)
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Implements the delay Thread operation.
|
||||
__declspec(dllexport) KSTATUS KeDelayThread(uint64_t milliseconds) {
|
||||
if (milliseconds == 0) {
|
||||
KeYield();
|
||||
@@ -1554,7 +1525,6 @@ __declspec(dllexport) KSTATUS KeDelayThread(uint64_t milliseconds) {
|
||||
return KeCommitBlockThread(self, 0);
|
||||
}
|
||||
|
||||
// Implements the yield operation.
|
||||
__declspec(dllexport) void KeYield(void) {
|
||||
KeAssertIrql(PASSIVE_LEVEL);
|
||||
KiSchedule();
|
||||
|
||||
Reference in new issue
Block a user