Index: drivers/bus/acpi/acpica/tables/tbutils.c =================================================================== --- drivers/bus/acpi/acpica/tables/tbutils.c (revision 74167) +++ drivers/bus/acpi/acpica/tables/tbutils.c (working copy) @@ -330,7 +330,14 @@ * so unmap the RSDP here before mapping other tables */ AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP)); - +#ifdef __REACTOS__ + /* + * ReactOS hack to add RSDT/XSDT as a regular table, so we can dump it + * later in registry without actually reparsing RSDP + */ + Status = AcpiTbInstallStandardTable(Address, + ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE, &TableIndex); +#endif /* Map the RSDT/XSDT table header to get the full table length */ Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); Index: drivers/bus/acpi/busmgr/utils.c =================================================================== --- drivers/bus/acpi/busmgr/utils.c (revision 74167) +++ drivers/bus/acpi/busmgr/utils.c (working copy) @@ -24,6 +24,7 @@ */ #include +#include #define NDEBUG #include @@ -369,4 +370,209 @@ return_ACPI_STATUS(status); } +NTSTATUS +acpi_dump_table_to_registry(HANDLE ParentKeyHandle, ACPI_STRING Signature, PCWSTR KeyName) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING HardwareKeyName, ValueName; + ANSI_STRING HardwareKeyNameA; + HANDLE KeyHandle = NULL, SubKeyHandle = NULL; + NTSTATUS Status; + ACPI_STATUS AcpiStatus; + ACPI_TABLE_HEADER *OutTable; + char OemId[7] = { 0 }; + char OemTableId[9] = { 0 }; + WCHAR OemRevision[9] = { 0 }; + /* Read requested table */ + AcpiStatus = AcpiGetTable(Signature, 0, &OutTable); + if (ACPI_FAILURE(AcpiStatus)) + { + DPRINT1("AcpiGetTable() for %ws failed (Status 0x%08lx)\n", KeyName, AcpiStatus); + return STATUS_UNSUCCESSFUL; + } + /* Copy OEM data from the table */ + RtlCopyMemory(OemId, OutTable->OemId, sizeof(OutTable->OemId)); + RtlCopyMemory(OemTableId, OutTable->OemTableId, sizeof(OutTable->OemTableId)); + /* Create table subkey */ + RtlInitUnicodeString(&HardwareKeyName, KeyName); + InitializeObjectAttributes(&ObjectAttributes, + &HardwareKeyName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + ParentKeyHandle, + NULL); + Status = ZwCreateKey(&KeyHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ZwCreateKey() for %ws failed (Status 0x%08lx)\n", KeyName, Status); + return Status; + } + + if (OutTable->OemRevision != 0) + { + /* We have OEM info in table, so create other OEM subkeys */ + RtlInitAnsiString(&HardwareKeyNameA, OemId); + RtlAnsiStringToUnicodeString(&HardwareKeyName, &HardwareKeyNameA, TRUE); + + InitializeObjectAttributes(&ObjectAttributes, + &HardwareKeyName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + KeyHandle, + NULL); + Status = ZwCreateKey(&SubKeyHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + RtlFreeUnicodeString(&HardwareKeyName); + ZwClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ZwCreateKey() for %ws failed (Status 0x%08lx)\n", KeyName, Status); + return Status; + } + KeyHandle = SubKeyHandle; + + RtlInitAnsiString(&HardwareKeyNameA, OemTableId); + RtlAnsiStringToUnicodeString(&HardwareKeyName, &HardwareKeyNameA, TRUE); + + InitializeObjectAttributes(&ObjectAttributes, + &HardwareKeyName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + KeyHandle, + NULL); + Status = ZwCreateKey(&SubKeyHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + RtlFreeUnicodeString(&HardwareKeyName); + ZwClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ZwCreateKey() for %ws failed (Status 0x%08lx)\n", KeyName, Status); + return Status; + } + KeyHandle = SubKeyHandle; + + RtlStringCbPrintfW(OemRevision, + sizeof(OemRevision), + L"%8.8X", + OutTable->OemRevision); + RtlInitUnicodeString(&HardwareKeyName, OemRevision); + + InitializeObjectAttributes(&ObjectAttributes, + &HardwareKeyName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + KeyHandle, + NULL); + Status = ZwCreateKey(&SubKeyHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + ZwClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ZwCreateKey() for %ws failed (Status 0x%08lx)\n", KeyName, Status); + return Status; + } + KeyHandle = SubKeyHandle; + } + /* Table reg value name is always '00000000' */ + RtlInitUnicodeString(&ValueName, + L"00000000"); + Status = ZwSetValueKey(KeyHandle, + &ValueName, + 0, + REG_BINARY, + OutTable, + OutTable->Length); + ZwClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ZwSetValueKey() failed (Status 0x%08lx)\n", Status); + return Status; + } + + return STATUS_SUCCESS; +} + +NTSTATUS +acpi_dump_registry() +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING HardwareKeyName; + HANDLE KeyHandle = NULL; + NTSTATUS Status; + + /* Create Main Hardware ACPI key*/ + RtlInitUnicodeString(&HardwareKeyName, + L"\\Registry\\Machine\\HARDWARE\\ACPI"); + InitializeObjectAttributes(&ObjectAttributes, + &HardwareKeyName, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + Status = ZwCreateKey(&KeyHandle, + KEY_READ | KEY_WRITE, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("ZwCreateKey() for ACPI failed (Status 0x%08lx)\n", Status); + return Status; + } + /* Dump DSDT table */ + Status = acpi_dump_table_to_registry(KeyHandle, ACPI_SIG_DSDT, L"DSDT"); + if (!NT_SUCCESS(Status)) + { + DPRINT1("acpi_dump_table_to_registry() for DSDT failed (Status 0x%08lx)\n", Status); + goto done; + } + /* Dump FACS table */ + Status = acpi_dump_table_to_registry(KeyHandle, ACPI_SIG_FACS, L"FACS"); + if (!NT_SUCCESS(Status)) + { + DPRINT1("acpi_dump_table_to_registry() for FACS failed (Status 0x%08lx)\n", Status); + goto done; + } + /* Dump FADT table */ + Status = acpi_dump_table_to_registry(KeyHandle, ACPI_SIG_FADT, L"FADT"); + if (!NT_SUCCESS(Status)) + { + DPRINT1("acpi_dump_table_to_registry() for FADT failed (Status 0x%08lx)\n", Status); + goto done; + } + /* Dump RSDT table */ + Status = acpi_dump_table_to_registry(KeyHandle, ACPI_SIG_RSDT, L"RSDT"); + if (!NT_SUCCESS(Status)) + { + DPRINT1("acpi_dump_table_to_registry() for RSDT failed (Status 0x%08lx)\n", Status); + /* Dump XSDT table if we are using it in place of RSDT, but use the same key */ + Status = acpi_dump_table_to_registry(KeyHandle, ACPI_SIG_XSDT, L"RSDT"); + if (!NT_SUCCESS(Status)) + { + DPRINT1("acpi_dump_table_to_registry() for XSDT failed (Status 0x%08lx)\n", Status); + } + } + +done: + ZwClose(KeyHandle); + return Status; +} Index: drivers/bus/acpi/include/acpi_bus.h =================================================================== --- drivers/bus/acpi/include/acpi_bus.h (revision 74167) +++ drivers/bus/acpi/include/acpi_bus.h (working copy) @@ -57,6 +57,8 @@ ACPI_STRING pathname, struct acpi_object_list *arguments, struct acpi_handle_list *list); +NTSTATUS +acpi_dump_registry(); enum acpi_bus_removal_type { ACPI_BUS_REMOVAL_NORMAL = 0, Index: drivers/bus/acpi/pnp.c =================================================================== --- drivers/bus/acpi/pnp.c (revision 74167) +++ drivers/bus/acpi/pnp.c (working copy) @@ -299,6 +299,12 @@ return STATUS_UNSUCCESSFUL; } + status = acpi_dump_registry(); + if (!NT_SUCCESS(status)) + { + DPRINT1("Unable to dump ACPI tables in registry\n"); + } + DPRINT("Acpi subsystem init\n"); /* Initialize ACPI bus manager */ AcpiStatus = acpi_init();