1132720Skan/******************************************************************************
2132720Skan *
3169691Skan * Module Name: hwxface - Public ACPICA hardware interfaces
4132720Skan *
5132720Skan *****************************************************************************/
6132720Skan
7132720Skan/******************************************************************************
8132720Skan *
9132720Skan * 1. Copyright Notice
10132720Skan *
11132720Skan * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp.
12132720Skan * All rights reserved.
13132720Skan *
14132720Skan * 2. License
15132720Skan *
16132720Skan * 2.1. This is your license from Intel Corp. under its intellectual property
17132720Skan * rights. You may have additional license terms from the party that provided
18132720Skan * you this software, covering your right to use that party's intellectual
19169691Skan * property rights.
20132720Skan *
21132720Skan * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22132720Skan * copy of the source code appearing in this file ("Covered Code") an
23132720Skan * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24132720Skan * base code distributed originally by Intel ("Original Intel Code") to copy,
25132720Skan * make derivatives, distribute, use and display any portion of the Covered
26132720Skan * Code in any form, with the right to sublicense such rights; and
27132720Skan *
28132720Skan * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29132720Skan * license (with the right to sublicense), under only those claims of Intel
30132720Skan * patents that are infringed by the Original Intel Code, to make, use, sell,
31132720Skan * offer to sell, and import the Covered Code and derivative works thereof
32132720Skan * solely to the minimum extent necessary to exercise the above copyright
33132720Skan * license, and in no event shall the patent license extend to any additions
34132720Skan * to or modifications of the Original Intel Code. No other license or right
35132720Skan * is granted directly or by implication, estoppel or otherwise;
36132720Skan *
37169691Skan * The above copyright and patent license is granted only if the following
38169691Skan * conditions are met:
39132720Skan *
40132720Skan * 3. Conditions
41132720Skan *
42132720Skan * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43132720Skan * Redistribution of source code of any substantial portion of the Covered
44132720Skan * Code or modification with rights to further distribute source must include
45132720Skan * the above Copyright Notice, the above License, this list of Conditions,
46132720Skan * and the following Disclaimer and Export Compliance provision. In addition,
47132720Skan * Licensee must cause all Covered Code to which Licensee contributes to
48169691Skan * contain a file documenting the changes Licensee made to create that Covered
49169691Skan * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************/
115
116#include "acpi.h"
117#include "accommon.h"
118#include "acnamesp.h"
119
120#define _COMPONENT          ACPI_HARDWARE
121        ACPI_MODULE_NAME    ("hwxface")
122
123
124/******************************************************************************
125 *
126 * FUNCTION:    AcpiReset
127 *
128 * PARAMETERS:  None
129 *
130 * RETURN:      Status
131 *
132 * DESCRIPTION: Set reset register in memory or IO space. Note: Does not
133 *              support reset register in PCI config space, this must be
134 *              handled separately.
135 *
136 ******************************************************************************/
137
138ACPI_STATUS
139AcpiReset (
140    void)
141{
142    ACPI_GENERIC_ADDRESS    *ResetReg;
143    ACPI_STATUS             Status;
144
145
146    ACPI_FUNCTION_TRACE (AcpiReset);
147
148
149    ResetReg = &AcpiGbl_FADT.ResetRegister;
150
151    /* Check if the reset register is supported */
152
153    if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) ||
154        !ResetReg->Address)
155    {
156        return_ACPI_STATUS (AE_NOT_EXIST);
157    }
158
159    if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO)
160    {
161        /*
162         * For I/O space, write directly to the OSL. This bypasses the port
163         * validation mechanism, which may block a valid write to the reset
164         * register.
165         */
166        Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address,
167                    AcpiGbl_FADT.ResetValue, ResetReg->BitWidth);
168    }
169    else
170    {
171        /* Write the reset value to the reset register */
172
173        Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg);
174    }
175
176    return_ACPI_STATUS (Status);
177}
178
179ACPI_EXPORT_SYMBOL (AcpiReset)
180
181
182/******************************************************************************
183 *
184 * FUNCTION:    AcpiRead
185 *
186 * PARAMETERS:  Value               - Where the value is returned
187 *              Reg                 - GAS register structure
188 *
189 * RETURN:      Status
190 *
191 * DESCRIPTION: Read from either memory or IO space.
192 *
193 * LIMITATIONS: <These limitations also apply to AcpiWrite>
194 *      BitWidth must be exactly 8, 16, 32, or 64.
195 *      SpaceID must be SystemMemory or SystemIO.
196 *      BitOffset and AccessWidth are currently ignored, as there has
197 *          not been a need to implement these.
198 *
199 ******************************************************************************/
200
201ACPI_STATUS
202AcpiRead (
203    UINT64                  *ReturnValue,
204    ACPI_GENERIC_ADDRESS    *Reg)
205{
206    UINT32                  Value;
207    UINT32                  Width;
208    UINT64                  Address;
209    ACPI_STATUS             Status;
210
211
212    ACPI_FUNCTION_NAME (AcpiRead);
213
214
215    if (!ReturnValue)
216    {
217        return (AE_BAD_PARAMETER);
218    }
219
220    /* Validate contents of the GAS register. Allow 64-bit transfers */
221
222    Status = AcpiHwValidateRegister (Reg, 64, &Address);
223    if (ACPI_FAILURE (Status))
224    {
225        return (Status);
226    }
227
228    /* Initialize entire 64-bit return value to zero */
229
230    *ReturnValue = 0;
231    Value = 0;
232
233    /*
234     * Two address spaces supported: Memory or IO. PCI_Config is
235     * not supported here because the GAS structure is insufficient
236     */
237    if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
238    {
239        Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
240                    Address, ReturnValue, Reg->BitWidth);
241        if (ACPI_FAILURE (Status))
242        {
243            return (Status);
244        }
245    }
246    else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
247    {
248        Width = Reg->BitWidth;
249        if (Width == 64)
250        {
251            Width = 32; /* Break into two 32-bit transfers */
252        }
253
254        Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
255                    Address, &Value, Width);
256        if (ACPI_FAILURE (Status))
257        {
258            return (Status);
259        }
260        *ReturnValue = Value;
261
262        if (Reg->BitWidth == 64)
263        {
264            /* Read the top 32 bits */
265
266            Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
267                        (Address + 4), &Value, 32);
268            if (ACPI_FAILURE (Status))
269            {
270                return (Status);
271            }
272            *ReturnValue |= ((UINT64) Value << 32);
273        }
274    }
275
276    ACPI_DEBUG_PRINT ((ACPI_DB_IO,
277        "Read:  %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n",
278        ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth,
279        ACPI_FORMAT_UINT64 (Address),
280        AcpiUtGetRegionName (Reg->SpaceId)));
281
282    return (Status);
283}
284
285ACPI_EXPORT_SYMBOL (AcpiRead)
286
287
288/******************************************************************************
289 *
290 * FUNCTION:    AcpiWrite
291 *
292 * PARAMETERS:  Value               - Value to be written
293 *              Reg                 - GAS register structure
294 *
295 * RETURN:      Status
296 *
297 * DESCRIPTION: Write to either memory or IO space.
298 *
299 ******************************************************************************/
300
301ACPI_STATUS
302AcpiWrite (
303    UINT64                  Value,
304    ACPI_GENERIC_ADDRESS    *Reg)
305{
306    UINT32                  Width;
307    UINT64                  Address;
308    ACPI_STATUS             Status;
309
310
311    ACPI_FUNCTION_NAME (AcpiWrite);
312
313
314    /* Validate contents of the GAS register. Allow 64-bit transfers */
315
316    Status = AcpiHwValidateRegister (Reg, 64, &Address);
317    if (ACPI_FAILURE (Status))
318    {
319        return (Status);
320    }
321
322    /*
323     * Two address spaces supported: Memory or IO. PCI_Config is
324     * not supported here because the GAS structure is insufficient
325     */
326    if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
327    {
328        Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
329                    Address, Value, Reg->BitWidth);
330        if (ACPI_FAILURE (Status))
331        {
332            return (Status);
333        }
334    }
335    else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
336    {
337        Width = Reg->BitWidth;
338        if (Width == 64)
339        {
340            Width = 32; /* Break into two 32-bit transfers */
341        }
342
343        Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
344                    Address, ACPI_LODWORD (Value), Width);
345        if (ACPI_FAILURE (Status))
346        {
347            return (Status);
348        }
349
350        if (Reg->BitWidth == 64)
351        {
352            Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
353                        (Address + 4), ACPI_HIDWORD (Value), 32);
354            if (ACPI_FAILURE (Status))
355            {
356                return (Status);
357            }
358        }
359    }
360
361    ACPI_DEBUG_PRINT ((ACPI_DB_IO,
362        "Wrote: %8.8X%8.8X width %2d   to %8.8X%8.8X (%s)\n",
363        ACPI_FORMAT_UINT64 (Value), Reg->BitWidth,
364        ACPI_FORMAT_UINT64 (Address),
365        AcpiUtGetRegionName (Reg->SpaceId)));
366
367    return (Status);
368}
369
370ACPI_EXPORT_SYMBOL (AcpiWrite)
371
372
373#if (!ACPI_REDUCED_HARDWARE)
374/*******************************************************************************
375 *
376 * FUNCTION:    AcpiReadBitRegister
377 *
378 * PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
379 *              ReturnValue     - Value that was read from the register,
380 *                                normalized to bit position zero.
381 *
382 * RETURN:      Status and the value read from the specified Register. Value
383 *              returned is normalized to bit0 (is shifted all the way right)
384 *
385 * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock.
386 *
387 * SUPPORTS:    Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
388 *              PM2 Control.
389 *
390 * Note: The hardware lock is not required when reading the ACPI bit registers
391 *       since almost all of them are single bit and it does not matter that
392 *       the parent hardware register can be split across two physical
393 *       registers. The only multi-bit field is SLP_TYP in the PM1 control
394 *       register, but this field does not cross an 8-bit boundary (nor does
395 *       it make much sense to actually read this field.)
396 *
397 ******************************************************************************/
398
399ACPI_STATUS
400AcpiReadBitRegister (
401    UINT32                  RegisterId,
402    UINT32                  *ReturnValue)
403{
404    ACPI_BIT_REGISTER_INFO  *BitRegInfo;
405    UINT32                  RegisterValue;
406    UINT32                  Value;
407    ACPI_STATUS             Status;
408
409
410    ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId);
411
412
413    /* Get the info structure corresponding to the requested ACPI Register */
414
415    BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
416    if (!BitRegInfo)
417    {
418        return_ACPI_STATUS (AE_BAD_PARAMETER);
419    }
420
421    /* Read the entire parent register */
422
423    Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
424                &RegisterValue);
425    if (ACPI_FAILURE (Status))
426    {
427        return_ACPI_STATUS (Status);
428    }
429
430    /* Normalize the value that was read, mask off other bits */
431
432    Value = ((RegisterValue & BitRegInfo->AccessBitMask)
433                >> BitRegInfo->BitPosition);
434
435    ACPI_DEBUG_PRINT ((ACPI_DB_IO,
436        "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
437        RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value));
438
439    *ReturnValue = Value;
440    return_ACPI_STATUS (AE_OK);
441}
442
443ACPI_EXPORT_SYMBOL (AcpiReadBitRegister)
444
445
446/*******************************************************************************
447 *
448 * FUNCTION:    AcpiWriteBitRegister
449 *
450 * PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
451 *              Value           - Value to write to the register, in bit
452 *                                position zero. The bit is automaticallly
453 *                                shifted to the correct position.
454 *
455 * RETURN:      Status
456 *
457 * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock
458 *              since most operations require a read/modify/write sequence.
459 *
460 * SUPPORTS:    Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
461 *              PM2 Control.
462 *
463 * Note that at this level, the fact that there may be actually two
464 * hardware registers (A and B - and B may not exist) is abstracted.
465 *
466 ******************************************************************************/
467
468ACPI_STATUS
469AcpiWriteBitRegister (
470    UINT32                  RegisterId,
471    UINT32                  Value)
472{
473    ACPI_BIT_REGISTER_INFO  *BitRegInfo;
474    ACPI_CPU_FLAGS          LockFlags;
475    UINT32                  RegisterValue;
476    ACPI_STATUS             Status = AE_OK;
477
478
479    ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId);
480
481
482    /* Get the info structure corresponding to the requested ACPI Register */
483
484    BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
485    if (!BitRegInfo)
486    {
487        return_ACPI_STATUS (AE_BAD_PARAMETER);
488    }
489
490    LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
491
492    /*
493     * At this point, we know that the parent register is one of the
494     * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
495     */
496    if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS)
497    {
498        /*
499         * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
500         *
501         * Perform a register read to preserve the bits that we are not
502         * interested in
503         */
504        Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
505                    &RegisterValue);
506        if (ACPI_FAILURE (Status))
507        {
508            goto UnlockAndExit;
509        }
510
511        /*
512         * Insert the input bit into the value that was just read
513         * and write the register
514         */
515        ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
516            BitRegInfo->AccessBitMask, Value);
517
518        Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister,
519                    RegisterValue);
520    }
521    else
522    {
523        /*
524         * 2) Case for PM1 Status
525         *
526         * The Status register is different from the rest. Clear an event
527         * by writing 1, writing 0 has no effect. So, the only relevant
528         * information is the single bit we're interested in, all others
529         * should be written as 0 so they will be left unchanged.
530         */
531        RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value,
532            BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
533
534        /* No need to write the register if value is all zeros */
535
536        if (RegisterValue)
537        {
538            Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
539                        RegisterValue);
540        }
541    }
542
543    ACPI_DEBUG_PRINT ((ACPI_DB_IO,
544        "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
545        RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue));
546
547
548UnlockAndExit:
549
550    AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
551    return_ACPI_STATUS (Status);
552}
553
554ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister)
555
556#endif /* !ACPI_REDUCED_HARDWARE */
557
558
559/*******************************************************************************
560 *
561 * FUNCTION:    AcpiGetSleepTypeData
562 *
563 * PARAMETERS:  SleepState          - Numeric sleep state
564 *              *SleepTypeA         - Where SLP_TYPa is returned
565 *              *SleepTypeB         - Where SLP_TYPb is returned
566 *
567 * RETURN:      Status - ACPI status
568 *
569 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
570 *              state.
571 *
572 ******************************************************************************/
573
574ACPI_STATUS
575AcpiGetSleepTypeData (
576    UINT8                   SleepState,
577    UINT8                   *SleepTypeA,
578    UINT8                   *SleepTypeB)
579{
580    ACPI_STATUS             Status = AE_OK;
581    ACPI_EVALUATE_INFO      *Info;
582
583
584    ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData);
585
586
587    /* Validate parameters */
588
589    if ((SleepState > ACPI_S_STATES_MAX) ||
590        !SleepTypeA ||
591        !SleepTypeB)
592    {
593        return_ACPI_STATUS (AE_BAD_PARAMETER);
594    }
595
596    /* Allocate the evaluation information block */
597
598    Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
599    if (!Info)
600    {
601        return_ACPI_STATUS (AE_NO_MEMORY);
602    }
603
604    Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]);
605
606    /* Evaluate the namespace object containing the values for this state */
607
608    Status = AcpiNsEvaluate (Info);
609    if (ACPI_FAILURE (Status))
610    {
611        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
612            "%s while evaluating SleepState [%s]\n",
613            AcpiFormatException (Status), Info->Pathname));
614
615        goto Cleanup;
616    }
617
618    /* Must have a return object */
619
620    if (!Info->ReturnObject)
621    {
622        ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]",
623            Info->Pathname));
624        Status = AE_NOT_EXIST;
625    }
626
627    /* It must be of type Package */
628
629    else if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
630    {
631        ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package"));
632        Status = AE_AML_OPERAND_TYPE;
633    }
634
635    /*
636     * The package must have at least two elements. NOTE (March 2005): This
637     * goes against the current ACPI spec which defines this object as a
638     * package with one encoded DWORD element. However, existing practice
639     * by BIOS vendors seems to be to have 2 or more elements, at least
640     * one per sleep type (A/B).
641     */
642    else if (Info->ReturnObject->Package.Count < 2)
643    {
644        ACPI_ERROR ((AE_INFO,
645            "Sleep State return package does not have at least two elements"));
646        Status = AE_AML_NO_OPERAND;
647    }
648
649    /* The first two elements must both be of type Integer */
650
651    else if (((Info->ReturnObject->Package.Elements[0])->Common.Type
652                != ACPI_TYPE_INTEGER) ||
653             ((Info->ReturnObject->Package.Elements[1])->Common.Type
654                != ACPI_TYPE_INTEGER))
655    {
656        ACPI_ERROR ((AE_INFO,
657            "Sleep State return package elements are not both Integers "
658            "(%s, %s)",
659            AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]),
660            AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1])));
661        Status = AE_AML_OPERAND_TYPE;
662    }
663    else
664    {
665        /* Valid _Sx_ package size, type, and value */
666
667        *SleepTypeA = (UINT8)
668            (Info->ReturnObject->Package.Elements[0])->Integer.Value;
669        *SleepTypeB = (UINT8)
670            (Info->ReturnObject->Package.Elements[1])->Integer.Value;
671    }
672
673    if (ACPI_FAILURE (Status))
674    {
675        ACPI_EXCEPTION ((AE_INFO, Status,
676            "While evaluating SleepState [%s], bad Sleep object %p type %s",
677            Info->Pathname, Info->ReturnObject,
678            AcpiUtGetObjectTypeName (Info->ReturnObject)));
679    }
680
681    AcpiUtRemoveReference (Info->ReturnObject);
682
683Cleanup:
684    ACPI_FREE (Info);
685    return_ACPI_STATUS (Status);
686}
687
688ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData)
689