* Sync up to trunk head (r65394).
[reactos.git] / drivers / bus / acpi / acpica / hardware / hwxface.c
1 /******************************************************************************
2 *
3 * Module Name: hwxface - Public ACPICA hardware interfaces
4 *
5 *****************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * 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 #define EXPORT_ACPI_INTERFACES
117
118 #include "acpi.h"
119 #include "accommon.h"
120 #include "acnamesp.h"
121
122 #define _COMPONENT ACPI_HARDWARE
123 ACPI_MODULE_NAME ("hwxface")
124
125
126 /******************************************************************************
127 *
128 * FUNCTION: AcpiReset
129 *
130 * PARAMETERS: None
131 *
132 * RETURN: Status
133 *
134 * DESCRIPTION: Set reset register in memory or IO space. Note: Does not
135 * support reset register in PCI config space, this must be
136 * handled separately.
137 *
138 ******************************************************************************/
139
140 ACPI_STATUS
141 AcpiReset (
142 void)
143 {
144 ACPI_GENERIC_ADDRESS *ResetReg;
145 ACPI_STATUS Status;
146
147
148 ACPI_FUNCTION_TRACE (AcpiReset);
149
150
151 ResetReg = &AcpiGbl_FADT.ResetRegister;
152
153 /* Check if the reset register is supported */
154
155 if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) ||
156 !ResetReg->Address)
157 {
158 return_ACPI_STATUS (AE_NOT_EXIST);
159 }
160
161 if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO)
162 {
163 /*
164 * For I/O space, write directly to the OSL. This bypasses the port
165 * validation mechanism, which may block a valid write to the reset
166 * register.
167 *
168 * NOTE:
169 * The ACPI spec requires the reset register width to be 8, so we
170 * hardcode it here and ignore the FADT value. This maintains
171 * compatibility with other ACPI implementations that have allowed
172 * BIOS code with bad register width values to go unnoticed.
173 */
174 Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address,
175 AcpiGbl_FADT.ResetValue, ACPI_RESET_REGISTER_WIDTH);
176 }
177 else
178 {
179 /* Write the reset value to the reset register */
180
181 Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg);
182 }
183
184 return_ACPI_STATUS (Status);
185 }
186
187 ACPI_EXPORT_SYMBOL (AcpiReset)
188
189
190 /******************************************************************************
191 *
192 * FUNCTION: AcpiRead
193 *
194 * PARAMETERS: Value - Where the value is returned
195 * Reg - GAS register structure
196 *
197 * RETURN: Status
198 *
199 * DESCRIPTION: Read from either memory or IO space.
200 *
201 * LIMITATIONS: <These limitations also apply to AcpiWrite>
202 * BitWidth must be exactly 8, 16, 32, or 64.
203 * SpaceID must be SystemMemory or SystemIO.
204 * BitOffset and AccessWidth are currently ignored, as there has
205 * not been a need to implement these.
206 *
207 ******************************************************************************/
208
209 ACPI_STATUS
210 AcpiRead (
211 UINT64 *ReturnValue,
212 ACPI_GENERIC_ADDRESS *Reg)
213 {
214 UINT32 ValueLo;
215 UINT32 ValueHi;
216 UINT32 Width;
217 UINT64 Address;
218 ACPI_STATUS Status;
219
220
221 ACPI_FUNCTION_NAME (AcpiRead);
222
223
224 if (!ReturnValue)
225 {
226 return (AE_BAD_PARAMETER);
227 }
228
229 /* Validate contents of the GAS register. Allow 64-bit transfers */
230
231 Status = AcpiHwValidateRegister (Reg, 64, &Address);
232 if (ACPI_FAILURE (Status))
233 {
234 return (Status);
235 }
236
237 /*
238 * Two address spaces supported: Memory or I/O. PCI_Config is
239 * not supported here because the GAS structure is insufficient
240 */
241 if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
242 {
243 Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
244 Address, ReturnValue, Reg->BitWidth);
245 if (ACPI_FAILURE (Status))
246 {
247 return (Status);
248 }
249 }
250 else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
251 {
252 ValueLo = 0;
253 ValueHi = 0;
254
255 Width = Reg->BitWidth;
256 if (Width == 64)
257 {
258 Width = 32; /* Break into two 32-bit transfers */
259 }
260
261 Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
262 Address, &ValueLo, Width);
263 if (ACPI_FAILURE (Status))
264 {
265 return (Status);
266 }
267
268 if (Reg->BitWidth == 64)
269 {
270 /* Read the top 32 bits */
271
272 Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
273 (Address + 4), &ValueHi, 32);
274 if (ACPI_FAILURE (Status))
275 {
276 return (Status);
277 }
278 }
279
280 /* Set the return value only if status is AE_OK */
281
282 *ReturnValue = (ValueLo | ((UINT64) ValueHi << 32));
283 }
284
285 ACPI_DEBUG_PRINT ((ACPI_DB_IO,
286 "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n",
287 ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth,
288 ACPI_FORMAT_UINT64 (Address),
289 AcpiUtGetRegionName (Reg->SpaceId)));
290
291 return (AE_OK);
292 }
293
294 ACPI_EXPORT_SYMBOL (AcpiRead)
295
296
297 /******************************************************************************
298 *
299 * FUNCTION: AcpiWrite
300 *
301 * PARAMETERS: Value - Value to be written
302 * Reg - GAS register structure
303 *
304 * RETURN: Status
305 *
306 * DESCRIPTION: Write to either memory or IO space.
307 *
308 ******************************************************************************/
309
310 ACPI_STATUS
311 AcpiWrite (
312 UINT64 Value,
313 ACPI_GENERIC_ADDRESS *Reg)
314 {
315 UINT32 Width;
316 UINT64 Address;
317 ACPI_STATUS Status;
318
319
320 ACPI_FUNCTION_NAME (AcpiWrite);
321
322
323 /* Validate contents of the GAS register. Allow 64-bit transfers */
324
325 Status = AcpiHwValidateRegister (Reg, 64, &Address);
326 if (ACPI_FAILURE (Status))
327 {
328 return (Status);
329 }
330
331 /*
332 * Two address spaces supported: Memory or IO. PCI_Config is
333 * not supported here because the GAS structure is insufficient
334 */
335 if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
336 {
337 Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
338 Address, Value, Reg->BitWidth);
339 if (ACPI_FAILURE (Status))
340 {
341 return (Status);
342 }
343 }
344 else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
345 {
346 Width = Reg->BitWidth;
347 if (Width == 64)
348 {
349 Width = 32; /* Break into two 32-bit transfers */
350 }
351
352 Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
353 Address, ACPI_LODWORD (Value), Width);
354 if (ACPI_FAILURE (Status))
355 {
356 return (Status);
357 }
358
359 if (Reg->BitWidth == 64)
360 {
361 Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
362 (Address + 4), ACPI_HIDWORD (Value), 32);
363 if (ACPI_FAILURE (Status))
364 {
365 return (Status);
366 }
367 }
368 }
369
370 ACPI_DEBUG_PRINT ((ACPI_DB_IO,
371 "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n",
372 ACPI_FORMAT_UINT64 (Value), Reg->BitWidth,
373 ACPI_FORMAT_UINT64 (Address),
374 AcpiUtGetRegionName (Reg->SpaceId)));
375
376 return (Status);
377 }
378
379 ACPI_EXPORT_SYMBOL (AcpiWrite)
380
381
382 #if (!ACPI_REDUCED_HARDWARE)
383 /*******************************************************************************
384 *
385 * FUNCTION: AcpiReadBitRegister
386 *
387 * PARAMETERS: RegisterId - ID of ACPI Bit Register to access
388 * ReturnValue - Value that was read from the register,
389 * normalized to bit position zero.
390 *
391 * RETURN: Status and the value read from the specified Register. Value
392 * returned is normalized to bit0 (is shifted all the way right)
393 *
394 * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock.
395 *
396 * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
397 * PM2 Control.
398 *
399 * Note: The hardware lock is not required when reading the ACPI bit registers
400 * since almost all of them are single bit and it does not matter that
401 * the parent hardware register can be split across two physical
402 * registers. The only multi-bit field is SLP_TYP in the PM1 control
403 * register, but this field does not cross an 8-bit boundary (nor does
404 * it make much sense to actually read this field.)
405 *
406 ******************************************************************************/
407
408 ACPI_STATUS
409 AcpiReadBitRegister (
410 UINT32 RegisterId,
411 UINT32 *ReturnValue)
412 {
413 ACPI_BIT_REGISTER_INFO *BitRegInfo;
414 UINT32 RegisterValue;
415 UINT32 Value;
416 ACPI_STATUS Status;
417
418
419 ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId);
420
421
422 /* Get the info structure corresponding to the requested ACPI Register */
423
424 BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
425 if (!BitRegInfo)
426 {
427 return_ACPI_STATUS (AE_BAD_PARAMETER);
428 }
429
430 /* Read the entire parent register */
431
432 Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
433 &RegisterValue);
434 if (ACPI_FAILURE (Status))
435 {
436 return_ACPI_STATUS (Status);
437 }
438
439 /* Normalize the value that was read, mask off other bits */
440
441 Value = ((RegisterValue & BitRegInfo->AccessBitMask)
442 >> BitRegInfo->BitPosition);
443
444 ACPI_DEBUG_PRINT ((ACPI_DB_IO,
445 "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
446 RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value));
447
448 *ReturnValue = Value;
449 return_ACPI_STATUS (AE_OK);
450 }
451
452 ACPI_EXPORT_SYMBOL (AcpiReadBitRegister)
453
454
455 /*******************************************************************************
456 *
457 * FUNCTION: AcpiWriteBitRegister
458 *
459 * PARAMETERS: RegisterId - ID of ACPI Bit Register to access
460 * Value - Value to write to the register, in bit
461 * position zero. The bit is automatically
462 * shifted to the correct position.
463 *
464 * RETURN: Status
465 *
466 * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock
467 * since most operations require a read/modify/write sequence.
468 *
469 * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
470 * PM2 Control.
471 *
472 * Note that at this level, the fact that there may be actually two
473 * hardware registers (A and B - and B may not exist) is abstracted.
474 *
475 ******************************************************************************/
476
477 ACPI_STATUS
478 AcpiWriteBitRegister (
479 UINT32 RegisterId,
480 UINT32 Value)
481 {
482 ACPI_BIT_REGISTER_INFO *BitRegInfo;
483 ACPI_CPU_FLAGS LockFlags;
484 UINT32 RegisterValue;
485 ACPI_STATUS Status = AE_OK;
486
487
488 ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId);
489
490
491 /* Get the info structure corresponding to the requested ACPI Register */
492
493 BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
494 if (!BitRegInfo)
495 {
496 return_ACPI_STATUS (AE_BAD_PARAMETER);
497 }
498
499 LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
500
501 /*
502 * At this point, we know that the parent register is one of the
503 * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
504 */
505 if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS)
506 {
507 /*
508 * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
509 *
510 * Perform a register read to preserve the bits that we are not
511 * interested in
512 */
513 Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
514 &RegisterValue);
515 if (ACPI_FAILURE (Status))
516 {
517 goto UnlockAndExit;
518 }
519
520 /*
521 * Insert the input bit into the value that was just read
522 * and write the register
523 */
524 ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
525 BitRegInfo->AccessBitMask, Value);
526
527 Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister,
528 RegisterValue);
529 }
530 else
531 {
532 /*
533 * 2) Case for PM1 Status
534 *
535 * The Status register is different from the rest. Clear an event
536 * by writing 1, writing 0 has no effect. So, the only relevant
537 * information is the single bit we're interested in, all others
538 * should be written as 0 so they will be left unchanged.
539 */
540 RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value,
541 BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
542
543 /* No need to write the register if value is all zeros */
544
545 if (RegisterValue)
546 {
547 Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
548 RegisterValue);
549 }
550 }
551
552 ACPI_DEBUG_PRINT ((ACPI_DB_IO,
553 "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
554 RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue));
555
556
557 UnlockAndExit:
558
559 AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
560 return_ACPI_STATUS (Status);
561 }
562
563 ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister)
564
565 #endif /* !ACPI_REDUCED_HARDWARE */
566
567
568 /*******************************************************************************
569 *
570 * FUNCTION: AcpiGetSleepTypeData
571 *
572 * PARAMETERS: SleepState - Numeric sleep state
573 * *SleepTypeA - Where SLP_TYPa is returned
574 * *SleepTypeB - Where SLP_TYPb is returned
575 *
576 * RETURN: Status
577 *
578 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested
579 * sleep state via the appropriate \_Sx object.
580 *
581 * The sleep state package returned from the corresponding \_Sx_ object
582 * must contain at least one integer.
583 *
584 * March 2005:
585 * Added support for a package that contains two integers. This
586 * goes against the ACPI specification which defines this object as a
587 * package with one encoded DWORD integer. However, existing practice
588 * by many BIOS vendors is to return a package with 2 or more integer
589 * elements, at least one per sleep type (A/B).
590 *
591 * January 2013:
592 * Therefore, we must be prepared to accept a package with either a
593 * single integer or multiple integers.
594 *
595 * The single integer DWORD format is as follows:
596 * BYTE 0 - Value for the PM1A SLP_TYP register
597 * BYTE 1 - Value for the PM1B SLP_TYP register
598 * BYTE 2-3 - Reserved
599 *
600 * The dual integer format is as follows:
601 * Integer 0 - Value for the PM1A SLP_TYP register
602 * Integer 1 - Value for the PM1A SLP_TYP register
603 *
604 ******************************************************************************/
605
606 ACPI_STATUS
607 AcpiGetSleepTypeData (
608 UINT8 SleepState,
609 UINT8 *SleepTypeA,
610 UINT8 *SleepTypeB)
611 {
612 ACPI_STATUS Status;
613 ACPI_EVALUATE_INFO *Info;
614 ACPI_OPERAND_OBJECT **Elements;
615
616
617 ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData);
618
619
620 /* Validate parameters */
621
622 if ((SleepState > ACPI_S_STATES_MAX) ||
623 !SleepTypeA || !SleepTypeB)
624 {
625 return_ACPI_STATUS (AE_BAD_PARAMETER);
626 }
627
628 /* Allocate the evaluation information block */
629
630 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
631 if (!Info)
632 {
633 return_ACPI_STATUS (AE_NO_MEMORY);
634 }
635
636 /*
637 * Evaluate the \_Sx namespace object containing the register values
638 * for this state
639 */
640 Info->RelativePathname = ACPI_CAST_PTR (
641 char, AcpiGbl_SleepStateNames[SleepState]);
642 Status = AcpiNsEvaluate (Info);
643 if (ACPI_FAILURE (Status))
644 {
645 goto Cleanup;
646 }
647
648 /* Must have a return object */
649
650 if (!Info->ReturnObject)
651 {
652 ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]",
653 Info->RelativePathname));
654 Status = AE_AML_NO_RETURN_VALUE;
655 goto Cleanup;
656 }
657
658 /* Return object must be of type Package */
659
660 if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
661 {
662 ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package"));
663 Status = AE_AML_OPERAND_TYPE;
664 goto Cleanup1;
665 }
666
667 /*
668 * Any warnings about the package length or the object types have
669 * already been issued by the predefined name module -- there is no
670 * need to repeat them here.
671 */
672 Elements = Info->ReturnObject->Package.Elements;
673 switch (Info->ReturnObject->Package.Count)
674 {
675 case 0:
676
677 Status = AE_AML_PACKAGE_LIMIT;
678 break;
679
680 case 1:
681
682 if (Elements[0]->Common.Type != ACPI_TYPE_INTEGER)
683 {
684 Status = AE_AML_OPERAND_TYPE;
685 break;
686 }
687
688 /* A valid _Sx_ package with one integer */
689
690 *SleepTypeA = (UINT8) Elements[0]->Integer.Value;
691 *SleepTypeB = (UINT8) (Elements[0]->Integer.Value >> 8);
692 break;
693
694 case 2:
695 default:
696
697 if ((Elements[0]->Common.Type != ACPI_TYPE_INTEGER) ||
698 (Elements[1]->Common.Type != ACPI_TYPE_INTEGER))
699 {
700 Status = AE_AML_OPERAND_TYPE;
701 break;
702 }
703
704 /* A valid _Sx_ package with two integers */
705
706 *SleepTypeA = (UINT8) Elements[0]->Integer.Value;
707 *SleepTypeB = (UINT8) Elements[1]->Integer.Value;
708 break;
709 }
710
711 Cleanup1:
712 AcpiUtRemoveReference (Info->ReturnObject);
713
714 Cleanup:
715 if (ACPI_FAILURE (Status))
716 {
717 ACPI_EXCEPTION ((AE_INFO, Status,
718 "While evaluating Sleep State [%s]", Info->RelativePathname));
719 }
720
721 ACPI_FREE (Info);
722 return_ACPI_STATUS (Status);
723 }
724
725 ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData)