diff options
Diffstat (limited to 'sys/contrib/dev/acpica/hwacpi.c')
-rw-r--r-- | sys/contrib/dev/acpica/hwacpi.c | 219 |
1 files changed, 53 insertions, 166 deletions
diff --git a/sys/contrib/dev/acpica/hwacpi.c b/sys/contrib/dev/acpica/hwacpi.c index 6f8e0b9..8139430 100644 --- a/sys/contrib/dev/acpica/hwacpi.c +++ b/sys/contrib/dev/acpica/hwacpi.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface - * $Revision: 46 $ + * $Revision: 47 $ * *****************************************************************************/ @@ -158,124 +158,76 @@ AcpiHwInitialize ( return_ACPI_STATUS (AE_NO_ACPI_TABLES); } - - /* Identify current ACPI/legacy mode */ - - switch (AcpiGbl_SystemFlags & SYS_MODES_MASK) + + /* + * Save the initial state of the ACPI event enable registers, so + * we can restore them when we exit. We probably won't exit, though. + * + * The location of the PM1aEvtBlk enable registers is defined as the + * base of PM1aEvtBlk + DIV_2(PM1aEvtBlkLength). Since the spec further + * fully defines the PM1aEvtBlk to be a total of 4 bytes, the offset + * for the enable registers is always 2 from the base. It is hard + * coded here. If this changes in the spec, this code will need to + * be modified. The PM1bEvtBlk behaves as expected. + */ + AcpiGbl_Pm1EnableRegisterSave = (UINT16) AcpiHwRegisterRead ( + ACPI_MTX_LOCK, PM1_EN); + + + /* + * The GPEs behave similarly, except that the length of the register + * block is not fixed, so the buffer must be allocated with malloc + */ + if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address) && + AcpiGbl_FADT->Gpe0BlkLen) { - case (SYS_MODE_ACPI): - - AcpiGbl_OriginalMode = SYS_MODE_ACPI; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "System supports ACPI mode only.\n")); - break; - - - case (SYS_MODE_LEGACY): - - AcpiGbl_OriginalMode = SYS_MODE_LEGACY; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Tables loaded from buffer, hardware assumed to support LEGACY mode only.\n")); - break; - + /* GPE0 specified in FADT */ - case (SYS_MODE_ACPI | SYS_MODE_LEGACY): - - if (AcpiHwGetMode () == SYS_MODE_ACPI) - { - AcpiGbl_OriginalMode = SYS_MODE_ACPI; - } - else + AcpiGbl_Gpe0EnableRegisterSave = ACPI_MEM_ALLOCATE ( + DIV_2 (AcpiGbl_FADT->Gpe0BlkLen)); + if (!AcpiGbl_Gpe0EnableRegisterSave) { - AcpiGbl_OriginalMode = SYS_MODE_LEGACY; + return_ACPI_STATUS (AE_NO_MEMORY); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "System supports both ACPI and LEGACY modes.\n")); + /* Save state of GPE0 enable bits */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "System is currently in %s mode.\n", - (AcpiGbl_OriginalMode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY")); - break; + for (Index = 0; Index < DIV_2 (AcpiGbl_FADT->Gpe0BlkLen); Index++) + { + AcpiGbl_Gpe0EnableRegisterSave[Index] = + (UINT8) AcpiHwRegisterRead (ACPI_MTX_LOCK, GPE0_EN_BLOCK | Index); + } } - - if (AcpiGbl_SystemFlags & SYS_MODE_ACPI) + else { - /* Target system supports ACPI mode */ - - /* - * The purpose of this code is to save the initial state - * of the ACPI event enable registers. An exit function will be - * registered which will restore this state when the application - * exits. The exit function will also clear all of the ACPI event - * status bits prior to restoring the original mode. - * - * The location of the PM1aEvtBlk enable registers is defined as the - * base of PM1aEvtBlk + DIV_2(PM1aEvtBlkLength). Since the spec further - * fully defines the PM1aEvtBlk to be a total of 4 bytes, the offset - * for the enable registers is always 2 from the base. It is hard - * coded here. If this changes in the spec, this code will need to - * be modified. The PM1bEvtBlk behaves as expected. - */ - AcpiGbl_Pm1EnableRegisterSave = (UINT16) AcpiHwRegisterRead ( - ACPI_MTX_LOCK, PM1_EN); + AcpiGbl_Gpe0EnableRegisterSave = NULL; + } + if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address) && + AcpiGbl_FADT->Gpe1BlkLen) + { + /* GPE1 defined */ - /* - * The GPEs behave similarly, except that the length of the register - * block is not fixed, so the buffer must be allocated with malloc - */ - if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address) && - AcpiGbl_FADT->Gpe0BlkLen) + AcpiGbl_Gpe1EnableRegisterSave = ACPI_MEM_ALLOCATE ( + DIV_2 (AcpiGbl_FADT->Gpe1BlkLen)); + if (!AcpiGbl_Gpe1EnableRegisterSave) { - /* GPE0 specified in FADT */ - - AcpiGbl_Gpe0EnableRegisterSave = ACPI_MEM_ALLOCATE ( - DIV_2 (AcpiGbl_FADT->Gpe0BlkLen)); - if (!AcpiGbl_Gpe0EnableRegisterSave) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Save state of GPE0 enable bits */ - - for (Index = 0; Index < DIV_2 (AcpiGbl_FADT->Gpe0BlkLen); Index++) - { - AcpiGbl_Gpe0EnableRegisterSave[Index] = - (UINT8) AcpiHwRegisterRead (ACPI_MTX_LOCK, GPE0_EN_BLOCK | Index); - } + return_ACPI_STATUS (AE_NO_MEMORY); } - else - { - AcpiGbl_Gpe0EnableRegisterSave = NULL; - } + /* save state of GPE1 enable bits */ - if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address) && - AcpiGbl_FADT->Gpe1BlkLen) + for (Index = 0; Index < DIV_2 (AcpiGbl_FADT->Gpe1BlkLen); Index++) { - /* GPE1 defined */ - - AcpiGbl_Gpe1EnableRegisterSave = ACPI_MEM_ALLOCATE ( - DIV_2 (AcpiGbl_FADT->Gpe1BlkLen)); - if (!AcpiGbl_Gpe1EnableRegisterSave) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* save state of GPE1 enable bits */ - - for (Index = 0; Index < DIV_2 (AcpiGbl_FADT->Gpe1BlkLen); Index++) - { - AcpiGbl_Gpe1EnableRegisterSave[Index] = - (UINT8) AcpiHwRegisterRead (ACPI_MTX_LOCK, GPE1_EN_BLOCK | Index); - } + AcpiGbl_Gpe1EnableRegisterSave[Index] = + (UINT8) AcpiHwRegisterRead (ACPI_MTX_LOCK, GPE1_EN_BLOCK | Index); } + } - else - { - AcpiGbl_Gpe1EnableRegisterSave = NULL; - } + else + { + AcpiGbl_Gpe1EnableRegisterSave = NULL; } return_ACPI_STATUS (Status); @@ -368,68 +320,3 @@ AcpiHwGetMode (void) return_VALUE (SYS_MODE_LEGACY); } } - - -/****************************************************************************** - * - * FUNCTION: AcpiHwGetModeCapabilities - * - * PARAMETERS: none - * - * RETURN: logical OR of SYS_MODE_ACPI and SYS_MODE_LEGACY determined at initial - * system state. - * - * DESCRIPTION: Returns capablities of system - * - ******************************************************************************/ - -UINT32 -AcpiHwGetModeCapabilities (void) -{ - - FUNCTION_TRACE ("HwGetModeCapabilities"); - - - if (!(AcpiGbl_SystemFlags & SYS_MODES_MASK)) - { - if (AcpiHwGetMode () == SYS_MODE_LEGACY) - { - /* - * Assume that if this call is being made, AcpiInit has been called - * and ACPI support has been established by the presence of the - * tables. Therefore since we're in SYS_MODE_LEGACY, the system - * must support both modes - */ - AcpiGbl_SystemFlags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY); - } - - else - { - /* TBD: [Investigate] !!! this may be unsafe... */ - /* - * system is is ACPI mode, so try to switch back to LEGACY to see if - * it is supported - */ - AcpiHwSetMode (SYS_MODE_LEGACY); - - if (AcpiHwGetMode () == SYS_MODE_LEGACY) - { - /* Now in SYS_MODE_LEGACY, so both are supported */ - - AcpiGbl_SystemFlags |= (SYS_MODE_ACPI | SYS_MODE_LEGACY); - AcpiHwSetMode (SYS_MODE_ACPI); - } - - else - { - /* Still in SYS_MODE_ACPI so this must be an ACPI only system */ - - AcpiGbl_SystemFlags |= SYS_MODE_ACPI; - } - } - } - - return_VALUE (AcpiGbl_SystemFlags & SYS_MODES_MASK); -} - - |