Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:02

0001 /******************************************************************************
0002  *
0003  * Module Name: hwxface - Public ACPICA hardware interfaces
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code. No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision. In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change. Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee. Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution. In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government. In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************
0115  *
0116  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #define EXPORT_ACPI_INTERFACES
0153 
0154 #include "acpi.h"
0155 #include "accommon.h"
0156 #include "acnamesp.h"
0157 
0158 #define _COMPONENT          ACPI_HARDWARE
0159         ACPI_MODULE_NAME    ("hwxface")
0160 
0161 
0162 /******************************************************************************
0163  *
0164  * FUNCTION:    AcpiReset
0165  *
0166  * PARAMETERS:  None
0167  *
0168  * RETURN:      Status
0169  *
0170  * DESCRIPTION: Set reset register in memory or IO space. Note: Does not
0171  *              support reset register in PCI config space, this must be
0172  *              handled separately.
0173  *
0174  ******************************************************************************/
0175 
0176 ACPI_STATUS
0177 AcpiReset (
0178     void)
0179 {
0180     ACPI_GENERIC_ADDRESS    *ResetReg;
0181     ACPI_STATUS             Status;
0182 
0183 
0184     ACPI_FUNCTION_TRACE (AcpiReset);
0185 
0186 
0187     ResetReg = &AcpiGbl_FADT.ResetRegister;
0188 
0189     /* Check if the reset register is supported */
0190 
0191     if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) ||
0192         !ResetReg->Address)
0193     {
0194         return_ACPI_STATUS (AE_NOT_EXIST);
0195     }
0196 
0197     if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO)
0198     {
0199         /*
0200          * For I/O space, write directly to the OSL. This bypasses the port
0201          * validation mechanism, which may block a valid write to the reset
0202          * register.
0203          *
0204          * NOTE:
0205          * The ACPI spec requires the reset register width to be 8, so we
0206          * hardcode it here and ignore the FADT value. This maintains
0207          * compatibility with other ACPI implementations that have allowed
0208          * BIOS code with bad register width values to go unnoticed.
0209          */
0210         Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address,
0211             AcpiGbl_FADT.ResetValue, ACPI_RESET_REGISTER_WIDTH);
0212     }
0213     else
0214     {
0215         /* Write the reset value to the reset register */
0216 
0217         Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg);
0218     }
0219 
0220     return_ACPI_STATUS (Status);
0221 }
0222 
0223 ACPI_EXPORT_SYMBOL (AcpiReset)
0224 
0225 
0226 /******************************************************************************
0227  *
0228  * FUNCTION:    AcpiRead
0229  *
0230  * PARAMETERS:  Value               - Where the value is returned
0231  *              Reg                 - GAS register structure
0232  *
0233  * RETURN:      Status
0234  *
0235  * DESCRIPTION: Read from either memory or IO space.
0236  *
0237  * LIMITATIONS: <These limitations also apply to AcpiWrite>
0238  *      BitWidth must be exactly 8, 16, 32, or 64.
0239  *      SpaceID must be SystemMemory or SystemIO.
0240  *      BitOffset and AccessWidth are currently ignored, as there has
0241  *          not been a need to implement these.
0242  *
0243  ******************************************************************************/
0244 
0245 ACPI_STATUS
0246 AcpiRead (
0247     UINT64                  *ReturnValue,
0248     ACPI_GENERIC_ADDRESS    *Reg)
0249 {
0250     ACPI_STATUS             Status;
0251 
0252 
0253     ACPI_FUNCTION_NAME (AcpiRead);
0254 
0255 
0256     Status = AcpiHwRead (ReturnValue, Reg);
0257     return (Status);
0258 }
0259 
0260 ACPI_EXPORT_SYMBOL (AcpiRead)
0261 
0262 
0263 /******************************************************************************
0264  *
0265  * FUNCTION:    AcpiWrite
0266  *
0267  * PARAMETERS:  Value               - Value to be written
0268  *              Reg                 - GAS register structure
0269  *
0270  * RETURN:      Status
0271  *
0272  * DESCRIPTION: Write to either memory or IO space.
0273  *
0274  ******************************************************************************/
0275 
0276 ACPI_STATUS
0277 AcpiWrite (
0278     UINT64                  Value,
0279     ACPI_GENERIC_ADDRESS    *Reg)
0280 {
0281     ACPI_STATUS             Status;
0282 
0283 
0284     ACPI_FUNCTION_NAME (AcpiWrite);
0285 
0286 
0287     Status = AcpiHwWrite (Value, Reg);
0288     return (Status);
0289 }
0290 
0291 ACPI_EXPORT_SYMBOL (AcpiWrite)
0292 
0293 
0294 #if (!ACPI_REDUCED_HARDWARE)
0295 /*******************************************************************************
0296  *
0297  * FUNCTION:    AcpiReadBitRegister
0298  *
0299  * PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
0300  *              ReturnValue     - Value that was read from the register,
0301  *                                normalized to bit position zero.
0302  *
0303  * RETURN:      Status and the value read from the specified Register. Value
0304  *              returned is normalized to bit0 (is shifted all the way right)
0305  *
0306  * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock.
0307  *
0308  * SUPPORTS:    Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
0309  *              PM2 Control.
0310  *
0311  * Note: The hardware lock is not required when reading the ACPI bit registers
0312  *       since almost all of them are single bit and it does not matter that
0313  *       the parent hardware register can be split across two physical
0314  *       registers. The only multi-bit field is SLP_TYP in the PM1 control
0315  *       register, but this field does not cross an 8-bit boundary (nor does
0316  *       it make much sense to actually read this field.)
0317  *
0318  ******************************************************************************/
0319 
0320 ACPI_STATUS
0321 AcpiReadBitRegister (
0322     UINT32                  RegisterId,
0323     UINT32                  *ReturnValue)
0324 {
0325     ACPI_BIT_REGISTER_INFO  *BitRegInfo;
0326     UINT32                  RegisterValue;
0327     UINT32                  Value;
0328     ACPI_STATUS             Status;
0329 
0330 
0331     ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId);
0332 
0333 
0334     /* Get the info structure corresponding to the requested ACPI Register */
0335 
0336     BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
0337     if (!BitRegInfo)
0338     {
0339         return_ACPI_STATUS (AE_BAD_PARAMETER);
0340     }
0341 
0342     /* Read the entire parent register */
0343 
0344     Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
0345         &RegisterValue);
0346     if (ACPI_FAILURE (Status))
0347     {
0348         return_ACPI_STATUS (Status);
0349     }
0350 
0351     /* Normalize the value that was read, mask off other bits */
0352 
0353     Value = ((RegisterValue & BitRegInfo->AccessBitMask)
0354         >> BitRegInfo->BitPosition);
0355 
0356     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
0357         "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
0358         RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value));
0359 
0360     *ReturnValue = Value;
0361     return_ACPI_STATUS (AE_OK);
0362 }
0363 
0364 ACPI_EXPORT_SYMBOL (AcpiReadBitRegister)
0365 
0366 
0367 /*******************************************************************************
0368  *
0369  * FUNCTION:    AcpiWriteBitRegister
0370  *
0371  * PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
0372  *              Value           - Value to write to the register, in bit
0373  *                                position zero. The bit is automatically
0374  *                                shifted to the correct position.
0375  *
0376  * RETURN:      Status
0377  *
0378  * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock
0379  *              since most operations require a read/modify/write sequence.
0380  *
0381  * SUPPORTS:    Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
0382  *              PM2 Control.
0383  *
0384  * Note that at this level, the fact that there may be actually two
0385  * hardware registers (A and B - and B may not exist) is abstracted.
0386  *
0387  ******************************************************************************/
0388 
0389 ACPI_STATUS
0390 AcpiWriteBitRegister (
0391     UINT32                  RegisterId,
0392     UINT32                  Value)
0393 {
0394     ACPI_BIT_REGISTER_INFO  *BitRegInfo;
0395     ACPI_CPU_FLAGS          LockFlags;
0396     UINT32                  RegisterValue;
0397     ACPI_STATUS             Status = AE_OK;
0398 
0399 
0400     ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId);
0401 
0402 
0403     /* Get the info structure corresponding to the requested ACPI Register */
0404 
0405     BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
0406     if (!BitRegInfo)
0407     {
0408         return_ACPI_STATUS (AE_BAD_PARAMETER);
0409     }
0410 
0411     LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
0412 
0413     /*
0414      * At this point, we know that the parent register is one of the
0415      * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
0416      */
0417     if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS)
0418     {
0419         /*
0420          * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
0421          *
0422          * Perform a register read to preserve the bits that we are not
0423          * interested in
0424          */
0425         Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
0426             &RegisterValue);
0427         if (ACPI_FAILURE (Status))
0428         {
0429             goto UnlockAndExit;
0430         }
0431 
0432         /*
0433          * Insert the input bit into the value that was just read
0434          * and write the register
0435          */
0436         ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
0437             BitRegInfo->AccessBitMask, Value);
0438 
0439         Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister,
0440             RegisterValue);
0441     }
0442     else
0443     {
0444         /*
0445          * 2) Case for PM1 Status
0446          *
0447          * The Status register is different from the rest. Clear an event
0448          * by writing 1, writing 0 has no effect. So, the only relevant
0449          * information is the single bit we're interested in, all others
0450          * should be written as 0 so they will be left unchanged.
0451          */
0452         RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value,
0453             BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
0454 
0455         /* No need to write the register if value is all zeros */
0456 
0457         if (RegisterValue)
0458         {
0459             Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
0460                 RegisterValue);
0461         }
0462     }
0463 
0464     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
0465         "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
0466         RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue));
0467 
0468 
0469 UnlockAndExit:
0470 
0471     AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
0472     return_ACPI_STATUS (Status);
0473 }
0474 
0475 ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister)
0476 
0477 #endif /* !ACPI_REDUCED_HARDWARE */
0478 
0479 
0480 /*******************************************************************************
0481  *
0482  * FUNCTION:    AcpiGetSleepTypeData
0483  *
0484  * PARAMETERS:  SleepState          - Numeric sleep state
0485  *              *SleepTypeA         - Where SLP_TYPa is returned
0486  *              *SleepTypeB         - Where SLP_TYPb is returned
0487  *
0488  * RETURN:      Status
0489  *
0490  * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested
0491  *              sleep state via the appropriate \_Sx object.
0492  *
0493  *  The sleep state package returned from the corresponding \_Sx_ object
0494  *  must contain at least one integer.
0495  *
0496  *  March 2005:
0497  *  Added support for a package that contains two integers. This
0498  *  goes against the ACPI specification which defines this object as a
0499  *  package with one encoded DWORD integer. However, existing practice
0500  *  by many BIOS vendors is to return a package with 2 or more integer
0501  *  elements, at least one per sleep type (A/B).
0502  *
0503  *  January 2013:
0504  *  Therefore, we must be prepared to accept a package with either a
0505  *  single integer or multiple integers.
0506  *
0507  *  The single integer DWORD format is as follows:
0508  *      BYTE 0 - Value for the PM1A SLP_TYP register
0509  *      BYTE 1 - Value for the PM1B SLP_TYP register
0510  *      BYTE 2-3 - Reserved
0511  *
0512  *  The dual integer format is as follows:
0513  *      Integer 0 - Value for the PM1A SLP_TYP register
0514  *      Integer 1 - Value for the PM1A SLP_TYP register
0515  *
0516  ******************************************************************************/
0517 
0518 ACPI_STATUS
0519 AcpiGetSleepTypeData (
0520     UINT8                   SleepState,
0521     UINT8                   *SleepTypeA,
0522     UINT8                   *SleepTypeB)
0523 {
0524     ACPI_STATUS             Status;
0525     ACPI_EVALUATE_INFO      *Info;
0526     ACPI_OPERAND_OBJECT     **Elements;
0527 
0528 
0529     ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData);
0530 
0531 
0532     /* Validate parameters */
0533 
0534     if ((SleepState > ACPI_S_STATES_MAX) ||
0535         !SleepTypeA || !SleepTypeB)
0536     {
0537         return_ACPI_STATUS (AE_BAD_PARAMETER);
0538     }
0539 
0540     /* Allocate the evaluation information block */
0541 
0542     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
0543     if (!Info)
0544     {
0545         return_ACPI_STATUS (AE_NO_MEMORY);
0546     }
0547 
0548     /*
0549      * Evaluate the \_Sx namespace object containing the register values
0550      * for this state
0551      */
0552     Info->RelativePathname = AcpiGbl_SleepStateNames[SleepState];
0553 
0554     Status = AcpiNsEvaluate (Info);
0555     if (ACPI_FAILURE (Status))
0556     {
0557         if (Status == AE_NOT_FOUND)
0558         {
0559             /* The _Sx states are optional, ignore NOT_FOUND */
0560 
0561             goto FinalCleanup;
0562         }
0563 
0564         goto WarningCleanup;
0565     }
0566 
0567     /* Must have a return object */
0568 
0569     if (!Info->ReturnObject)
0570     {
0571         ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]",
0572             Info->RelativePathname));
0573         Status = AE_AML_NO_RETURN_VALUE;
0574         goto WarningCleanup;
0575     }
0576 
0577     /* Return object must be of type Package */
0578 
0579     if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
0580     {
0581         ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package"));
0582         Status = AE_AML_OPERAND_TYPE;
0583         goto ReturnValueCleanup;
0584     }
0585 
0586     /*
0587      * Any warnings about the package length or the object types have
0588      * already been issued by the predefined name module -- there is no
0589      * need to repeat them here.
0590      */
0591     Elements = Info->ReturnObject->Package.Elements;
0592     switch (Info->ReturnObject->Package.Count)
0593     {
0594     case 0:
0595 
0596         Status = AE_AML_PACKAGE_LIMIT;
0597         break;
0598 
0599     case 1:
0600 
0601         if (Elements[0]->Common.Type != ACPI_TYPE_INTEGER)
0602         {
0603             Status = AE_AML_OPERAND_TYPE;
0604             break;
0605         }
0606 
0607         /* A valid _Sx_ package with one integer */
0608 
0609         *SleepTypeA = (UINT8) Elements[0]->Integer.Value;
0610         *SleepTypeB = (UINT8) (Elements[0]->Integer.Value >> 8);
0611         break;
0612 
0613     case 2:
0614     default:
0615 
0616         if ((Elements[0]->Common.Type != ACPI_TYPE_INTEGER) ||
0617             (Elements[1]->Common.Type != ACPI_TYPE_INTEGER))
0618         {
0619             Status = AE_AML_OPERAND_TYPE;
0620             break;
0621         }
0622 
0623         /* A valid _Sx_ package with two integers */
0624 
0625         *SleepTypeA = (UINT8) Elements[0]->Integer.Value;
0626         *SleepTypeB = (UINT8) Elements[1]->Integer.Value;
0627         break;
0628     }
0629 
0630 ReturnValueCleanup:
0631     AcpiUtRemoveReference (Info->ReturnObject);
0632 
0633 WarningCleanup:
0634     if (ACPI_FAILURE (Status))
0635     {
0636         ACPI_EXCEPTION ((AE_INFO, Status,
0637             "While evaluating Sleep State [%s]",
0638             Info->RelativePathname));
0639     }
0640 
0641 FinalCleanup:
0642     ACPI_FREE (Info);
0643     return_ACPI_STATUS (Status);
0644 }
0645 
0646 ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData)