Work around buggy bochs ACPI tables

This commit is contained in:
Thomas Oltmann 2025-08-13 20:33:43 +02:00
parent deab1322c2
commit 83b6fba171
2 changed files with 6 additions and 2 deletions

View file

@ -29,6 +29,6 @@ debug: action=ignore, pci=report # report BX_DEBUG from module 'pci'
debugger_log: -
com1: enabled=1, mode=socket-server, dev=localhost:1111
#com1: enabled=1, mode=socket-server, dev=localhost:1111
port_e9_hack: enabled=1

View file

@ -10,7 +10,11 @@ extern BOOTBOOT bootboot;
void *acpi_find_table(const char *table_name)
{
struct SDT_Header *header = pa_to_pointer(pa_from_value(bootboot.arch.x86_64.acpi_ptr));
ASSERT((header->Signature[0] == 'R' || header->Signature[0] == 'X') && !memcmp(header->Signature + 1, "SDT", 3));
/* NOTE According to the ACPI spec, the root table should have one of the two signatures "RSDT" and "XSDT".
* For some weird reason (bug?), the ACPI tables provided under bochs start with a NUL character,
* meaning the signature is "\0SDT". We work around this issue by simply not checking the first character here.
*/
ASSERT(!memcmp(header->Signature+1, "SDT", 3));
bool extended = header->Signature[0] == 'X';
unsigned count = (header->Length - (unsigned)sizeof(struct SDT_Header));
count >>= extended ? 3 : 2;