I don't think you fully setup ACPI correctly before enumeration. I do ALL this before calling enumeration:
Code: Select all
/* Initializes the full access and functionality
* of ACPICA / ACPI and allows for scanning of
* ACPI devices */
void AcpiInitialize(void)
{
ACPI_STATUS Status;
ACPI_OBJECT arg1;
ACPI_OBJECT_LIST args;
/* Debug */
LogInformation("ACPI", "Initializing");
LogInformation("ACPI", "Installing OSI Interface");
/* Install OSL Handler */
Status = AcpiInstallInterfaceHandler(AcpiOsi);
/* We fake Windows 7 */
AcpiOsiSetup("Windows 2009");
/* Install */
AcpiOsiInstall();
/* Initialize the ACPICA subsystem */
LogInformation("ACPI", "Installing Subsystems");
Status = AcpiInitializeSubsystem();
if (ACPI_FAILURE(Status))
{
LogFatal("ACPI", "Failed to initialize subsystems, %u!", Status);
for (;;);
}
/* Copy the root table list to dynamic memory */
LogInformation("ACPI", "Reallocating Tables");
Status = AcpiReallocateRootTable();
if (ACPI_FAILURE(Status))
{
LogFatal("ACPI", "Failed AcpiReallocateRootTable, %u!", Status);
for (;;);
}
/* Install the default address space handlers. */
Status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
ACPI_ADR_SPACE_SYSTEM_MEMORY, ACPI_DEFAULT_HANDLER, NULL, NULL);
if (ACPI_FAILURE(Status)) {
LogDebug("ACPI", "Could not initialise SystemMemory handler, %s!",
AcpiFormatException(Status));
}
Status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
ACPI_ADR_SPACE_SYSTEM_IO, ACPI_DEFAULT_HANDLER, NULL, NULL);
if (ACPI_FAILURE(Status)) {
LogDebug("ACPI", "Could not initialise SystemIO handler, %s!",
AcpiFormatException(Status));
}
Status = AcpiInstallAddressSpaceHandler(ACPI_ROOT_OBJECT,
ACPI_ADR_SPACE_PCI_CONFIG, ACPI_DEFAULT_HANDLER, NULL, NULL);
if (ACPI_FAILURE(Status)) {
LogDebug("ACPI", "Could not initialise PciConfig handler, %s!",
AcpiFormatException(Status));
}
/* Create the ACPI namespace from ACPI tables */
LogInformation("ACPI", "Loading Tables");
Status = AcpiLoadTables();
if (ACPI_FAILURE(Status))
{
LogFatal("ACPI", "Failed LoadTables, %u!", Status);
for (;;);
}
/* Initialize the ACPI hardware */
LogInformation("ACPI", "Enabling Subsystems");
Status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION);
if (ACPI_FAILURE(Status))
{
LogFatal("ACPI", "Failed AcpiEnableSubsystem, %u!", Status);
for (;;);
}
/* Probe for EC here */
/* Complete the ACPI namespace object initialization */
LogInformation("ACPI", "Initializing Objects");
Status = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION);
if (ACPI_FAILURE(Status))
{
LogFatal("ACPI", "Failed AcpiInitializeObjects, %u!", Status);
for (;;);
}
/* Run _OSC on root, it should always be run after InitializeObjects */
AcpiCheckBusOscSupport();
/* Set APIC Mode */
arg1.Type = ACPI_TYPE_INTEGER;
arg1.Integer.Value = 1; /* 0 - PIC, 1 - IOAPIC, 2 - IOSAPIC */
args.Count = 1;
args.Pointer = &arg1;
AcpiEvaluateObject(ACPI_ROOT_OBJECT, "_PIC", &args, NULL);
/* Info */
LogInformation("ACPI", "Installing Event Handlers");
/* Install a notify handler */
AcpiInstallNotifyHandler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, AcpiBusNotifyHandler, NULL);
/* Install a global event handler */
AcpiInstallGlobalEventHandler(AcpiEventHandler, NULL);
//AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON, acpi_shutdown, NULL);
//AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON, acpi_sleep, NULL);
//ACPI_BUTTON_TYPE_LID