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