add a realtime scheduler class and priority-inheritance mutexes with timeouts and abandonment, add an HDA audio driver and a SYS_AUDIO_* syscall family, flesh out kernel32 with Win32 threads, events, mutexes, critical sections, and condition variables, add SYS_RESUME_THREAD for suspended thread creation, add KeInitializeMemoryTypes to reprogram MTRRs and install a canonical PAT for WB/WC/UC control, rework the display pipeline with a pitched present path and console output flush, bring back disk.vhd with mtools since vvfat fucking sucks, harden AHCI with serialized cache flush, USB mass storage with SCSI sense-data decoding, and xHCI with cleaner DMA teardown, fix the last stray for(;;) in HalStopProcessor to while(true), pile on smoke tests for audio, win32 sync primitives, and thread suspend, implement AHCI timeout, kill readahead since it was desperetaly trying to murder me, fix doom sound x2.
This commit is contained in:
1 parent
8b254f84f4
commit
4add6789ba
177 files changed
+22565
-3070
No files matched your search
+56
-18
@@ -220,7 +220,29 @@ __declspec(dllexport) void DbgPrint(const char* fmt, ...) {
|
||||
line, length);
|
||||
}
|
||||
|
||||
// Flushes debug Log To File.
|
||||
// Writes one debug-log segment and rejects successful zero-progress writes.
|
||||
static KSTATUS KiDebugLogWriteAll(FILE_OBJECT* file,
|
||||
const char* data,
|
||||
size_t length,
|
||||
size_t* totalWritten) {
|
||||
if (!file || (!data && length) || !totalWritten)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
while (length != 0) {
|
||||
size_t written = 0;
|
||||
KSTATUS st = IoWriteFile(file, data, length, &written);
|
||||
if (!KSUCCESS(st))
|
||||
return st;
|
||||
if (written == 0)
|
||||
return NTLSTATUS_DEVICE_ERROR;
|
||||
data += written;
|
||||
length -= written;
|
||||
*totalWritten += written;
|
||||
}
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Persists the in-memory debug ring and flushes it through the storage stack.
|
||||
__declspec(dllexport) KSTATUS KeFlushDebugLogToFile(SYS_STRING_VIEW path) {
|
||||
if (!gDebugLogBuffer || gDebugLogSize == 0 || !SysSvIsValid(path) || path.Length == 0)
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
@@ -237,11 +259,6 @@ __declspec(dllexport) KSTATUS KeFlushDebugLogToFile(SYS_STRING_VIEW path) {
|
||||
start = (gDebugLogUsed == gDebugLogSize) ? gDebugLogWrite : 0;
|
||||
KeReleaseSpinlock(&gDebugPrintLock, flags);
|
||||
|
||||
if (used == 0) {
|
||||
_InterlockedExchange((volatile long*)&gDebugLogFlushing, 0);
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
(void)IoDeleteFile(path);
|
||||
|
||||
FILE_OBJECT* file = (FILE_OBJECT*)0;
|
||||
@@ -251,23 +268,32 @@ __declspec(dllexport) KSTATUS KeFlushDebugLogToFile(SYS_STRING_VIEW path) {
|
||||
return st;
|
||||
}
|
||||
|
||||
size_t written = 0;
|
||||
size_t totalWritten = 0;
|
||||
size_t first = gDebugLogSize - start;
|
||||
if (first > used) first = used;
|
||||
st = IoWriteFile(file, gDebugLogBuffer + start, first, &written);
|
||||
totalWritten += written;
|
||||
// Shutdown logging must not depend on deferred file-cache writeback. FAT
|
||||
// still updates the directory entry and cluster chain through its normal
|
||||
// write path, while IoFlushFile pushes metadata and the device cache.
|
||||
file->Flags |= IO_FILE_FLAG_NO_CACHE | IO_FILE_FLAG_SKIP_ZERO_EXTEND;
|
||||
|
||||
if (KSUCCESS(st) && used > first) {
|
||||
written = 0;
|
||||
st = IoWriteFile(file, gDebugLogBuffer, used - first, &written);
|
||||
totalWritten += written;
|
||||
size_t totalWritten = 0;
|
||||
if (used != 0) {
|
||||
size_t first = gDebugLogSize - start;
|
||||
if (first > used)
|
||||
first = used;
|
||||
|
||||
st = KiDebugLogWriteAll(file, gDebugLogBuffer + start, first, &totalWritten);
|
||||
if (KSUCCESS(st) && used > first) {
|
||||
st = KiDebugLogWriteAll(file, gDebugLogBuffer,
|
||||
used - first, &totalWritten);
|
||||
}
|
||||
}
|
||||
|
||||
IoCloseFile(file);
|
||||
if (KSUCCESS(st) && totalWritten != used)
|
||||
st = NTLSTATUS_DEVICE_ERROR;
|
||||
if (KSUCCESS(st))
|
||||
st = IoFlushFile(file);
|
||||
|
||||
IoCloseFile(file);
|
||||
_InterlockedExchange((volatile long*)&gDebugLogFlushing, 0);
|
||||
return (KSUCCESS(st) && totalWritten == used) ? NTLSTATUS_SUCCESS : st;
|
||||
return st;
|
||||
}
|
||||
|
||||
// Attempts to persist the debug log during a panic when the filesystem is usable.
|
||||
@@ -863,6 +889,18 @@ __declspec(dllexport) KSTATUS KeFaultDispatchFrame(KFAULT_FRAME* frame) {
|
||||
if (!KeFaultFrameFromUser(frame))
|
||||
KiPanicKernelFault(proc, thread, frame);
|
||||
|
||||
DbgPrint("USERFAULT: pid=%u tid=%u vector=%llu rip=0x%016llX rsp=0x%016llX cr2=0x%016llX error=0x%016llX rcx=0x%016llX rbx=0x%016llX rax=0x%016llX\n",
|
||||
proc ? proc->ProcessId : 0,
|
||||
thread ? thread->ThreadId : 0,
|
||||
frame->Vector,
|
||||
(uint64_t)frame->Rip,
|
||||
(uint64_t)frame->Rsp,
|
||||
(uint64_t)frame->Cr2,
|
||||
(uint64_t)frame->ErrorCode,
|
||||
(uint64_t)frame->Rcx,
|
||||
(uint64_t)frame->Rbx,
|
||||
(uint64_t)frame->Rax);
|
||||
|
||||
KSTATUS delivered = KeDeliverUserException(frame);
|
||||
if (KSUCCESS(delivered))
|
||||
return NTLSTATUS_SUCCESS;
|
||||
|
||||
Reference in new issue
Block a user