implement user mode catchable exceptions, refactor system status codes to use NTLSTATUS_ prefix, update build scripts to use shared literal macros for linker arguments, update named queue lifetime cleanup to include KeNamedQueueUnpublishHandle.

This commit is contained in:
maksw committed 2026-06-27 20:38:43 +02:00
1 parent 1f5477cf66
commit b7fcfce6f7
140 files changed
+7649 -3943

No files matched your search

+17 -17
View File
@@ -120,7 +120,7 @@ void KeSetApplicationProcessorTrampoline(uint64_t trampolinePhys) {
// Builds ap Trampoline.
static KSTATUS KiBuildApTrampoline(void) {
if (gApTrampolinePhys)
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
PHYSICAL_ADDRESS frame = gReservedApTrampolinePhys;
if (frame) {
@@ -155,7 +155,7 @@ static KSTATUS KiBuildApTrampoline(void) {
if (!frame) {
DbgPrint("SMP: no free PMM frame available below 0x%016llX for AP trampoline\n",
(uint64_t)AP_TRAMPOLINE_MAX_PHYS);
return STATUS_NO_MEMORY;
return NTLSTATUS_NO_MEMORY;
}
DbgPrint("SMP: AP trampoline frame 0x%016llX selected\n", (uint64_t)frame);
@@ -234,7 +234,7 @@ static KSTATUS KiBuildApTrampoline(void) {
KiEmit32(&p, physBase + gdtOff);
if ((uintptr_t)(p - page) >= AP_TRAMPOLINE_BOOT_OFF)
return STATUS_DEVICE_ERROR;
return NTLSTATUS_DEVICE_ERROR;
AP_BOOT_BLOCK* boot = (AP_BOOT_BLOCK*)(page + AP_TRAMPOLINE_BOOT_OFF);
memset(boot, 0, sizeof(*boot));
@@ -248,7 +248,7 @@ static KSTATUS KiBuildApTrampoline(void) {
gApTrampolinePhys = frame;
gApBootBlock = boot;
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
_Noreturn void KiApKernelEntry(KCPU* cpu) {
@@ -594,7 +594,7 @@ static KSTATUS KiAllocateApStack(KCPU* cpu) {
if (!stack) {
DbgPrint("SMP: AP%u stack allocation failed bytes=%llu\n",
cpu ? cpu->CpuIndex : 0xFFFFFFFFu, (uint64_t)stackBytes);
return STATUS_NO_MEMORY;
return NTLSTATUS_NO_MEMORY;
}
cpu->KernelStack = stack;
@@ -604,7 +604,7 @@ static KSTATUS KiAllocateApStack(KCPU* cpu) {
cpu->Tss.IoMapBase = sizeof(TSS64);
cpu->Tss.RSP0 = cpu->KernelStackTop;
KeInitializeGdtForCpu(cpu);
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
// Implements the ap Stage Name operation.
@@ -641,7 +641,7 @@ KSTATUS KeStartApplicationProcessors(void) {
if (!KSUCCESS(st)) return st;
if (topo.CpuCount == 0 || topo.CpuCount > KE_MAX_CPUS)
return STATUS_DEVICE_ERROR;
return NTLSTATUS_DEVICE_ERROR;
uint32_t bspLapic = HalGetBspLapicId();
KCPU* bsp = KeGetCurrentCpu();
@@ -683,14 +683,14 @@ KSTATUS KeStartApplicationProcessors(void) {
DbgPrint("SMP: discovered %u addressable CPU(s), BSP LAPIC=%u\n", gCpuCount, bspLapic);
if (gCpuCount <= 1) {
DbgPrint("SMP: no application processors present\n");
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
if ((__readcr3() >> 32) != 0) {
DbgPrint("SMP: disabled; bootstrap CR3 is above 4GiB (cr3=0x%016llX), AP trampoline cannot load it yet\n",
(uint64_t)__readcr3());
gCpuCount = 1;
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
DbgPrint("SMP: bootloader AP trampoline phys=0x%016llX\n",
@@ -699,7 +699,7 @@ KSTATUS KeStartApplicationProcessors(void) {
if (!KSUCCESS(st)) {
DbgPrint("SMP: disabled; AP trampoline allocation/build failed status=0x%x\n", st);
gCpuCount = 1;
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
uint8_t sipiVector = (uint8_t)(gApTrampolinePhys >> 12);
@@ -771,14 +771,14 @@ KSTATUS KeStartApplicationProcessors(void) {
KeBuildProcessorTopology();
DbgPrint("SMP: kernel claimed %u APs\n", claimed);
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
// Implements the admit Application Processors To Scheduler operation.
KSTATUS KeAdmitApplicationProcessorsToScheduler(void) {
if (gCpuCount <= 1) {
DbgPrint("SMP: no AP scheduler admission needed\n");
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
uint32_t admitted = 0;
@@ -828,7 +828,7 @@ KSTATUS KeAdmitApplicationProcessorsToScheduler(void) {
}
DbgPrint("SMP: scheduler admitted %u APs\n", admitted);
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
#define SMP_AP_WORKER_ROUNDS 64u
@@ -933,13 +933,13 @@ static int KiWaitForWorkerCounter(volatile long* counter, long expected, const c
KSTATUS KeRunApplicationProcessorSchedulerSelfTests(void) {
if (gCpuCount <= 1) {
DbgPrint("SMP scheduler selftest: SKIP, no APs\n");
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
DbgPrint("SMP scheduler selftest: begin AP-affine workers\n");
SMP_AP_WORK_TEST* test = (SMP_AP_WORK_TEST*)MmAllocatePool(sizeof(SMP_AP_WORK_TEST));
if (!test) return STATUS_NO_MEMORY;
if (!test) return NTLSTATUS_NO_MEMORY;
memset(test, 0, sizeof(*test));
test->Magic = SMP_AP_TEST_MAGIC;
@@ -982,7 +982,7 @@ KSTATUS KeRunApplicationProcessorSchedulerSelfTests(void) {
if (workerCount == 0) {
MmFreePool(test);
DbgPrint("SMP scheduler selftest: SKIP, no online AP workers\n");
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}
if (!KiWaitForWorkerCounter(&test->ReadyCount, (long)workerCount, "AP worker ready")) {
@@ -1041,5 +1041,5 @@ KSTATUS KeRunApplicationProcessorSchedulerSelfTests(void) {
DbgPrint("SMP scheduler selftest: PASS workers=%u rounds=%u\n",
workerCount, SMP_AP_WORKER_ROUNDS);
MmFreePool(test);
return STATUS_SUCCESS;
return NTLSTATUS_SUCCESS;
}