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:
maksw committed 2026-10-12 18:17:43 +02:00
1 parent 899225f551
commit c0ad63c27f
226 files changed
+6562 -4147

No files matched your search

+36 -36
View File
@@ -13,7 +13,7 @@
#include <intrin.h>
#include <common/printf.h>
void HalScreenInitialize(void* (*AllocatePool)(size_t size), uintptr_t fb, int w, int h, int stride,
void HalScreenInitialize(void* (*AllocatePool)(size_t size), uintptr_t fb, int32_t w, int32_t h, int32_t stride,
HAL_SCREEN* out);
void HalPciInitialize(HAL_PCI* out);
void HalRtcInitialize(HAL_RTC* out);
@@ -215,15 +215,15 @@ static uint64_t AcpiReadU64(const void* table, uint32_t tableLen, uint32_t off)
}
// Decodes one ACPI Generic Address Structure used for fixed power registers.
static int AcpiReadGasRegister(const void* table, uint32_t tableLen, uint32_t off,
static bool AcpiReadGasRegister(const void* table, uint32_t tableLen, uint32_t off,
ACPI_FIXED_REGISTER* out) {
if (!out || off + sizeof(ACPI_GAS) > tableLen) return 0;
if (!out || off + sizeof(ACPI_GAS) > tableLen) return false;
ACPI_GAS gas;
memcpy(&gas, (const uint8_t*)table + off, sizeof(gas));
if (!gas.Address || gas.RegisterBitOffset != 0) return 0;
if (gas.AddressSpaceId != 0x00 && gas.AddressSpaceId != 0x01) return 0;
if (gas.AddressSpaceId == 0x01 && gas.Address > 0xFFFFu) return 0;
if (!gas.Address || gas.RegisterBitOffset != 0) return false;
if (gas.AddressSpaceId != 0x00 && gas.AddressSpaceId != 0x01) return false;
if (gas.AddressSpaceId == 0x01 && gas.Address > 0xFFFFu) return false;
uint8_t widthBytes = 0;
if (gas.AccessSize >= 1 && gas.AccessSize <= 3)
@@ -236,24 +236,24 @@ static int AcpiReadGasRegister(const void* table, uint32_t tableLen, uint32_t of
out->AddressSpaceId = gas.AddressSpaceId;
out->WidthBytes = widthBytes;
out->Address = gas.Address;
return 1;
return true;
}
// Decodes one byte-wide ACPI GAS used by the HW-reduced Sleep Control register.
static int AcpiReadByteGasRegister(const void* table, uint32_t tableLen, uint32_t off,
static bool AcpiReadByteGasRegister(const void* table, uint32_t tableLen, uint32_t off,
ACPI_FIXED_REGISTER* out) {
if (!out || off + sizeof(ACPI_GAS) > tableLen) return 0;
if (!out || off + sizeof(ACPI_GAS) > tableLen) return false;
ACPI_GAS gas;
memcpy(&gas, (const uint8_t*)table + off, sizeof(gas));
if (!gas.Address || gas.RegisterBitOffset != 0 || gas.RegisterBitWidth != 8) return 0;
if (gas.AddressSpaceId != 0x00 && gas.AddressSpaceId != 0x01) return 0;
if (gas.AddressSpaceId == 0x01 && gas.Address > 0xFFFFu) return 0;
if (!gas.Address || gas.RegisterBitOffset != 0 || gas.RegisterBitWidth != 8) return false;
if (gas.AddressSpaceId != 0x00 && gas.AddressSpaceId != 0x01) return false;
if (gas.AddressSpaceId == 0x01 && gas.Address > 0xFFFFu) return false;
out->AddressSpaceId = gas.AddressSpaceId;
out->WidthBytes = 1u;
out->Address = gas.Address;
return 1;
return true;
}
// Reads one ACPI fixed register while preserving the address-space distinction.
@@ -341,9 +341,9 @@ static KSTATUS AcpiEnableModeForShutdown(void) {
}
}
static int AmlParsePkgLength(const uint8_t* p, const uint8_t* end,
static bool AmlParsePkgLength(const uint8_t* p, const uint8_t* end,
const uint8_t** body, const uint8_t** pkgEnd) {
if (p >= end) return 0;
if (p >= end) return false;
const uint8_t* start = p;
uint8_t first = *p++;
@@ -355,21 +355,21 @@ static int AmlParsePkgLength(const uint8_t* p, const uint8_t* end,
} else {
length = first & 0x0F;
for (uint32_t i = 0; i < follow; i++) {
if (p >= end) return 0;
if (p >= end) return false;
length |= ((uint32_t)*p++) << (4 + i * 8);
}
}
if (start + length < p || start + length > end) return 0;
if (start + length < p || start + length > end) return false;
*body = p;
*pkgEnd = start + length;
return 1;
return true;
}
static const uint8_t* AmlParseNameString(const uint8_t* p, const uint8_t* end,
int* lastSegmentIsS5) {
bool* lastSegmentIsS5) {
uint32_t segments = 1;
*lastSegmentIsS5 = 0;
*lastSegmentIsS5 = false;
// Optional root or parent prefixes: '\\', '^', '^^', ...
while (p < end && (*p == 0x5C || *p == 0x5E)) p++;
@@ -389,7 +389,7 @@ static const uint8_t* AmlParseNameString(const uint8_t* p, const uint8_t* end,
for (uint32_t s = 0; s < segments; s++) {
if (p + 4 > end) return NULL;
if (s == segments - 1 && memcmp(p, "_S5_", 4) == 0)
*lastSegmentIsS5 = 1;
*lastSegmentIsS5 = true;
p += 4;
}
@@ -397,9 +397,9 @@ static const uint8_t* AmlParseNameString(const uint8_t* p, const uint8_t* end,
}
// Implements the aml Read Integer operation.
static int AmlReadInteger(const uint8_t** pp, const uint8_t* end, uint8_t* out) {
static bool AmlReadInteger(const uint8_t** pp, const uint8_t* end, uint8_t* out) {
const uint8_t* p = *pp;
if (p >= end) return 0;
if (p >= end) return false;
switch (*p++) {
case 0x00: // ZeroOp
@@ -409,43 +409,43 @@ static int AmlReadInteger(const uint8_t** pp, const uint8_t* end, uint8_t* out)
*out = 1;
break;
case 0x0A: // BytePrefix
if (p >= end) return 0;
if (p >= end) return false;
*out = *p++;
break;
case 0x0B: // WordPrefix
if (p + 2 > end) return 0;
if (p + 2 > end) return false;
*out = p[0];
p += 2;
break;
case 0x0C: // DWordPrefix
if (p + 4 > end) return 0;
if (p + 4 > end) return false;
*out = p[0];
p += 4;
break;
case 0x0E: // QWordPrefix
if (p + 8 > end) return 0;
if (p + 8 > end) return false;
*out = p[0];
p += 8;
break;
default:
return 0;
return false;
}
*pp = p;
return 1;
return true;
}
// Scan DSDT AML for the _S5_ Name object and extract SLP_TYP values. Real
// firmware commonly encodes the name as "\\_S5_" instead of just "_S5_", and
// package integers may be ZeroOp/OneOp/Byte/Word/DWord/QWord constants.
static int ScanAmlForS5(const uint8_t* aml, uint32_t len, const char* source) {
static bool ScanAmlForS5(const uint8_t* aml, uint32_t len, const char* source) {
const uint8_t* end = aml + len;
for (const uint8_t* cur = aml; cur < end; cur++) {
if (*cur != 0x08) continue; // NameOp
const uint8_t* p = cur + 1;
int isS5 = 0;
bool isS5 = false;
p = AmlParseNameString(p, end, &isS5);
if (!p || !isS5 || p >= end || *p != 0x12) continue; // PackageOp
@@ -467,14 +467,14 @@ static int ScanAmlForS5(const uint8_t* aml, uint32_t len, const char* source) {
HalDbgPrint("HAL: _S5_ source=%s SLP_TYP_A=0x%02x SLP_TYP_B=0x%02x\n",
source ? source : "AML", gSlpTypA, gSlpTypB);
return 1;
return true;
}
return 0;
return false;
}
// Validates checksum.
static int validate_checksum(void* table, uint32_t length) {
static bool validate_checksum(void* table, uint32_t length) {
uint8_t sum = 0;
uint8_t* bytes = (uint8_t*)table;
for (uint32_t i = 0; i < length; i++) {
@@ -627,7 +627,7 @@ static void WalkAcpi(uintptr_t rsdpPhys) {
ACPISDTHeader* sdtHeader = NULL;
uint32_t count = 0;
int isXsdt = 0;
bool isXsdt = false;
// Safely find and validate the XSDT (ACPI 2.0+).
if (rsdp->Revision >= 2 && rsdp->XsdtAddress != 0) {
@@ -639,7 +639,7 @@ static void WalkAcpi(uintptr_t rsdpPhys) {
sdtHeader = &xsdt->Header;
count = (xsdt->Header.Length - sizeof(ACPISDTHeader)) / 8;
isXsdt = 1;
isXsdt = true;
}
}