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
+25
-8
@@ -1,13 +1,13 @@
|
||||
// Kernel IRQL model. This file owns the software interrupt-priority state used by IRQ and scheduler code.
|
||||
// Kernel IRQL model. This file synchronizes per-CPU IRQL with APIC task priority.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <kernel/ke_irql.h>
|
||||
#include <kernel/ke_cpu.h>
|
||||
#include <kernel/ke_hal.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_apc.h>
|
||||
#include <intrin.h>
|
||||
|
||||
// Implements the irql Name operation.
|
||||
__declspec(dllexport) const char* KeIrqlName(KIRQL irql) {
|
||||
switch (irql) {
|
||||
case PASSIVE_LEVEL: return "PASSIVE_LEVEL";
|
||||
@@ -26,7 +26,27 @@ __declspec(dllexport) KIRQL KeGetCurrentIrql(void) {
|
||||
return KeGetCurrentCpu()->CurrentIrql;
|
||||
}
|
||||
|
||||
// Implements the raise Irql operation.
|
||||
// IRQL classes 16-25 map to vectors 0x30-0xC0. The TPR masks the current
|
||||
// class and all lower-priority external interrupts. HIGH_LEVEL masks all.
|
||||
static uint8_t KiIrqlTaskPriority(KIRQL level) {
|
||||
if (level == HIGH_LEVEL) return 0xFFu;
|
||||
if (level >= 28u) return 0xF0u;
|
||||
if (level >= DIRQL_BASE) return (uint8_t)((level - DIRQL_BASE + 3u) << 4u);
|
||||
if (level >= DISPATCH_LEVEL) return 0x20u;
|
||||
if (level >= APC_LEVEL) return 0x10u;
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// Applies the priority before publishing a raised IRQL and after a lowered IRQL.
|
||||
static void KiSetIrql(KCPU* cpu, KIRQL level, bool raising) {
|
||||
const HAL_API* hal = KeGetHal();
|
||||
if (raising && hal && hal->InterruptController.SetTaskPriority)
|
||||
hal->InterruptController.SetTaskPriority(KiIrqlTaskPriority(level));
|
||||
cpu->CurrentIrql = level;
|
||||
if (!raising && hal && hal->InterruptController.SetTaskPriority)
|
||||
hal->InterruptController.SetTaskPriority(KiIrqlTaskPriority(level));
|
||||
}
|
||||
|
||||
__declspec(dllexport) KIRQL KeRaiseIrql(KIRQL newIrql) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
KIRQL oldIrql = cpu->CurrentIrql;
|
||||
@@ -41,11 +61,10 @@ __declspec(dllexport) KIRQL KeRaiseIrql(KIRQL newIrql) {
|
||||
KeIrqlName(newIrql), (unsigned)newIrql);
|
||||
}
|
||||
|
||||
cpu->CurrentIrql = newIrql;
|
||||
KiSetIrql(cpu, newIrql, true);
|
||||
return oldIrql;
|
||||
}
|
||||
|
||||
// Implements the lower Irql operation.
|
||||
__declspec(dllexport) void KeLowerIrql(KIRQL oldIrql) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
KIRQL currentIrql = cpu->CurrentIrql;
|
||||
@@ -60,14 +79,13 @@ __declspec(dllexport) void KeLowerIrql(KIRQL oldIrql) {
|
||||
KeIrqlName(oldIrql), (unsigned)oldIrql);
|
||||
}
|
||||
|
||||
cpu->CurrentIrql = oldIrql;
|
||||
KiSetIrql(cpu, oldIrql, false);
|
||||
|
||||
if (oldIrql == PASSIVE_LEVEL && currentIrql != PASSIVE_LEVEL &&
|
||||
(__readeflags() & 0x200u) != 0 && cpu->InterruptDepth == 0)
|
||||
KiDeliverKernelApcs();
|
||||
}
|
||||
|
||||
// Implements the assert Irql operation.
|
||||
__declspec(dllexport) void KeAssertIrql(KIRQL expected) {
|
||||
KIRQL currentIrql = KeGetCurrentIrql();
|
||||
if (currentIrql != expected) {
|
||||
@@ -77,7 +95,6 @@ __declspec(dllexport) void KeAssertIrql(KIRQL expected) {
|
||||
}
|
||||
}
|
||||
|
||||
// Implements the assert Irql At Or Below operation.
|
||||
__declspec(dllexport) void KeAssertIrqlAtOrBelow(KIRQL maxIrql) {
|
||||
KIRQL currentIrql = KeGetCurrentIrql();
|
||||
if (currentIrql > maxIrql) {
|
||||
|
||||
Reference in new issue
Block a user