clean up and standardize types across the codebase, unify atomic operations, improve UTF-8 handling throughout the system, remove obsolete input and named queue interfaces, redesign process preparation and creation, tighten IPC and service boundaries, improve error handling and reliability, minor documentation cleanup, fix doom surfaces, fix panic in ini parsing.
This commit is contained in:
1 parent
899225f551
commit
c0ad63c27f
226 files changed
+6562
-4147
No files matched your search
@@ -1,5 +1,6 @@
|
||||
// HAL output router. This file fans typed text streams out to registered physical and runtime endpoints.
|
||||
|
||||
#include <ntlite/atomic.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <intrin.h>
|
||||
@@ -10,26 +11,26 @@
|
||||
|
||||
typedef struct HAL_OUTPUT_SLOT {
|
||||
HAL_OUTPUT_ENDPOINT Endpoint;
|
||||
volatile long Published;
|
||||
volatile int32_t Published;
|
||||
} HAL_OUTPUT_SLOT;
|
||||
|
||||
static HAL_OUTPUT_SLOT gOutputSlots[HAL_OUTPUT_ENDPOINT_CAPACITY];
|
||||
static volatile long gOutputRegistrationLock;
|
||||
static volatile long long gOutputRecordCount;
|
||||
static volatile long long gOutputByteCount;
|
||||
static volatile long long gOutputEndpointWriteCount;
|
||||
static volatile long long gOutputEmergencyRecordCount;
|
||||
static volatile long gOutputEndpointCount;
|
||||
static volatile int32_t gOutputRegistrationLock;
|
||||
static volatile int64_t gOutputRecordCount;
|
||||
static volatile int64_t gOutputByteCount;
|
||||
static volatile int64_t gOutputEndpointWriteCount;
|
||||
static volatile int64_t gOutputEmergencyRecordCount;
|
||||
static volatile int32_t gOutputEndpointCount;
|
||||
|
||||
// Acquires the endpoint registration lock.
|
||||
static void HalOutputAcquireRegistrationLock(void) {
|
||||
while (_InterlockedCompareExchange(&gOutputRegistrationLock, 1, 0) != 0)
|
||||
while (NtlAtomicCompareExchange32(&gOutputRegistrationLock, 1, 0) != 0)
|
||||
_mm_pause();
|
||||
}
|
||||
|
||||
// Releases the endpoint registration lock.
|
||||
static void HalOutputReleaseRegistrationLock(void) {
|
||||
_InterlockedExchange(&gOutputRegistrationLock, 0);
|
||||
NtlAtomicExchange32(&gOutputRegistrationLock, 0);
|
||||
}
|
||||
|
||||
// Registers one output endpoint in the fixed endpoint table.
|
||||
@@ -42,13 +43,13 @@ static KSTATUS HalOutputRegisterEndpoint(const HAL_OUTPUT_ENDPOINT* endpoint, ui
|
||||
HalOutputAcquireRegistrationLock();
|
||||
for (uint32_t i = 0; i < HAL_OUTPUT_ENDPOINT_CAPACITY; i++) {
|
||||
HAL_OUTPUT_SLOT* slot = &gOutputSlots[i];
|
||||
if (_InterlockedCompareExchange(&slot->Published, 0, 0) != 0)
|
||||
if (NtlAtomicLoad32(&slot->Published) != 0)
|
||||
continue;
|
||||
|
||||
slot->Endpoint = *endpoint;
|
||||
_ReadWriteBarrier();
|
||||
_InterlockedExchange(&slot->Published, 1);
|
||||
_InterlockedIncrement(&gOutputEndpointCount);
|
||||
NtlAtomicExchange32(&slot->Published, 1);
|
||||
NtlAtomicIncrement32(&gOutputEndpointCount);
|
||||
*endpointIdOut = i;
|
||||
status = NTLSTATUS_SUCCESS;
|
||||
break;
|
||||
@@ -64,10 +65,10 @@ static KSTATUS HalOutputSetEndpointStreams(uint32_t endpointId, uint32_t streamM
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
|
||||
HAL_OUTPUT_SLOT* slot = &gOutputSlots[endpointId];
|
||||
if (_InterlockedCompareExchange(&slot->Published, 0, 0) == 0)
|
||||
if (NtlAtomicLoad32(&slot->Published) == 0)
|
||||
return NTLSTATUS_NOT_FOUND;
|
||||
|
||||
_InterlockedExchange((volatile long*)&slot->Endpoint.StreamMask, (long)streamMask);
|
||||
NtlAtomicExchangeU32(&slot->Endpoint.StreamMask, streamMask);
|
||||
return NTLSTATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -78,18 +79,17 @@ static void HalOutputWrite(const HAL_OUTPUT_RECORD* record) {
|
||||
(record->Stream & (record->Stream - 1u)) != 0)
|
||||
return;
|
||||
|
||||
_InterlockedIncrement64(&gOutputRecordCount);
|
||||
_InterlockedExchangeAdd64(&gOutputByteCount, (long long)record->Length);
|
||||
NtlAtomicIncrement64(&gOutputRecordCount);
|
||||
NtlAtomicExchangeAdd64(&gOutputByteCount, (int64_t)record->Length);
|
||||
if (record->Flags & HAL_OUTPUT_WRITE_EMERGENCY)
|
||||
_InterlockedIncrement64(&gOutputEmergencyRecordCount);
|
||||
NtlAtomicIncrement64(&gOutputEmergencyRecordCount);
|
||||
|
||||
for (uint32_t i = 0; i < HAL_OUTPUT_ENDPOINT_CAPACITY; i++) {
|
||||
HAL_OUTPUT_SLOT* slot = &gOutputSlots[i];
|
||||
if (_InterlockedCompareExchange(&slot->Published, 0, 0) == 0)
|
||||
if (NtlAtomicLoad32(&slot->Published) == 0)
|
||||
continue;
|
||||
|
||||
uint32_t streams = (uint32_t)_InterlockedCompareExchange(
|
||||
(volatile long*)&slot->Endpoint.StreamMask, 0, 0);
|
||||
uint32_t streams = NtlAtomicLoadU32(&slot->Endpoint.StreamMask);
|
||||
if ((streams & record->Stream) == 0)
|
||||
continue;
|
||||
if ((record->Flags & HAL_OUTPUT_WRITE_EMERGENCY) &&
|
||||
@@ -102,7 +102,7 @@ static void HalOutputWrite(const HAL_OUTPUT_RECORD* record) {
|
||||
continue;
|
||||
|
||||
write(context, record);
|
||||
_InterlockedIncrement64(&gOutputEndpointWriteCount);
|
||||
NtlAtomicIncrement64(&gOutputEndpointWriteCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ static void HalOutputQueryStats(HAL_OUTPUT_STATS* statsOut) {
|
||||
return;
|
||||
|
||||
memset(statsOut, 0, sizeof(*statsOut));
|
||||
statsOut->RecordCount = (uint64_t)_InterlockedCompareExchange64(&gOutputRecordCount, 0, 0);
|
||||
statsOut->ByteCount = (uint64_t)_InterlockedCompareExchange64(&gOutputByteCount, 0, 0);
|
||||
statsOut->EndpointWriteCount = (uint64_t)_InterlockedCompareExchange64(&gOutputEndpointWriteCount, 0, 0);
|
||||
statsOut->EmergencyRecordCount = (uint64_t)_InterlockedCompareExchange64(&gOutputEmergencyRecordCount, 0, 0);
|
||||
statsOut->EndpointCount = (uint32_t)_InterlockedCompareExchange(&gOutputEndpointCount, 0, 0);
|
||||
statsOut->RecordCount = (uint64_t)NtlAtomicLoad64(&gOutputRecordCount);
|
||||
statsOut->ByteCount = (uint64_t)NtlAtomicLoad64(&gOutputByteCount);
|
||||
statsOut->EndpointWriteCount = (uint64_t)NtlAtomicLoad64(&gOutputEndpointWriteCount);
|
||||
statsOut->EmergencyRecordCount = (uint64_t)NtlAtomicLoad64(&gOutputEmergencyRecordCount);
|
||||
statsOut->EndpointCount = (uint32_t)NtlAtomicLoad32(&gOutputEndpointCount);
|
||||
}
|
||||
|
||||
// Initializes the fixed HAL output endpoint table.
|
||||
|
||||
Reference in new issue
Block a user