1 /******************************************************************************
3 * Module Name: aeexec - Support routines for AcpiExec utility
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13 * All rights reserved.
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
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
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;
38 * The above copyright and patent license is granted only if the following
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.
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
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
73 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
81 * 4. Disclaimer and Export Compliance
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
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
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.
115 *****************************************************************************/
117 #include "aecommon.h"
119 #define _COMPONENT ACPI_TOOLS
120 ACPI_MODULE_NAME ("aeexec")
123 ACPI_PARSE_OBJECT
*root
;
127 UINT32 AcpiDsdtLength
;
129 DEBUG_REGIONS AeRegions
;
130 ACPI_TABLE_RSDP LocalRsdp
;
133 * Misc ACPI tables to be installed
135 unsigned char Ssdt1Code
[] =
137 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
138 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
139 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
140 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
141 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
142 0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "98.p..`." */
145 unsigned char Ssdt2Code
[] =
147 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
148 0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
149 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
150 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
151 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
152 0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "99.p..`." */
155 unsigned char Oem1Code
[] =
157 0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00, /* 00000000 "OEM18..." */
158 0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".KIntel." */
159 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
160 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
161 0x18,0x09,0x03,0x20,0x08,0x5F,0x58,0x54, /* 00000020 "... ._XT" */
162 0x32,0x0A,0x04,0x14,0x0C,0x5F,0x58,0x54, /* 00000028 "2...._XT" */
163 0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32, /* 00000030 "1.p._XT2" */
167 * We need a local FADT so that the hardware subcomponent will function,
168 * even though the underlying OSD HW access functions don't do
171 ACPI_TABLE_RSDP LocalRSDP
;
172 ACPI_TABLE_FADT LocalFADT
;
173 ACPI_TABLE_FACS LocalFACS
;
174 ACPI_TABLE_HEADER LocalDSDT
;
175 ACPI_TABLE_HEADER LocalTEST
;
176 ACPI_TABLE_HEADER LocalBADTABLE
;
178 ACPI_TABLE_RSDT
*LocalRSDT
;
180 #define RSDT_TABLES 7
181 #define RSDT_SIZE (sizeof (ACPI_TABLE_RSDT) + ((RSDT_TABLES -1) * sizeof (UINT32)))
183 #define ACPI_MAX_INIT_TABLES (16)
184 static ACPI_TABLE_DESC Tables
[ACPI_MAX_INIT_TABLES
];
186 UINT32 SigintCount
= 0;
188 /******************************************************************************
190 * FUNCTION: AeCtrlCHandler
196 * DESCRIPTION: Control-C handler. Abort running control method if any.
198 *****************************************************************************/
205 signal (SIGINT
, SIG_IGN
);
208 AcpiOsPrintf ("Caught a ctrl-c (#%d)\n\n", SigintCount
);
210 if (AcpiGbl_MethodExecuting
)
212 AcpiGbl_AbortMethod
= TRUE
;
213 signal (SIGINT
, AeCtrlCHandler
);
215 if (SigintCount
< 10)
225 /******************************************************************************
227 * FUNCTION: AeBuildLocalTables
235 *****************************************************************************/
239 ACPI_TABLE_HEADER
*UserTable
)
244 LocalRSDT
= AcpiOsAllocate (RSDT_SIZE
);
250 ACPI_MEMSET (LocalRSDT
, 0, RSDT_SIZE
);
251 ACPI_STRNCPY (LocalRSDT
->Header
.Signature
, ACPI_SIG_RSDT
, 4);
252 LocalRSDT
->Header
.Length
= RSDT_SIZE
;
254 LocalRSDT
->TableOffsetEntry
[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST
);
255 LocalRSDT
->TableOffsetEntry
[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE
);
256 LocalRSDT
->TableOffsetEntry
[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT
);
257 LocalRSDT
->TableOffsetEntry
[3] = ACPI_PTR_TO_PHYSADDR (&LocalTEST
); /* Just a placeholder for a user SSDT */
259 /* Install two SSDTs to test multiple table support */
261 LocalRSDT
->TableOffsetEntry
[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code
);
262 LocalRSDT
->TableOffsetEntry
[5] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code
);
264 /* Install the OEM1 table to test LoadTable */
266 LocalRSDT
->TableOffsetEntry
[6] = ACPI_PTR_TO_PHYSADDR (&Oem1Code
);
270 ACPI_MEMSET (&LocalRSDP
, 0, sizeof (ACPI_TABLE_RSDP
));
271 ACPI_MEMCPY (LocalRSDP
.Signature
, ACPI_SIG_RSDP
, 8);
272 LocalRSDP
.Revision
= 1;
273 LocalRSDP
.RsdtPhysicalAddress
= ACPI_PTR_TO_PHYSADDR (LocalRSDT
);
274 LocalRSDP
.Length
= sizeof (ACPI_TABLE_RSDT
);
275 ACPI_MEMCPY (LocalRSDP
.OemId
, "I_TEST", 6);
278 * Examine the incoming user table. At this point, it has been verified
279 * to be either a DSDT, SSDT, or a PSDT, but they must be handled differently
281 if (!ACPI_COMPARE_NAME (UserTable
->Signature
, ACPI_SIG_DSDT
))
283 /* Build a local DSDT because incoming table is an SSDT or PSDT */
285 ACPI_MEMSET (&LocalDSDT
, 0, sizeof (ACPI_TABLE_HEADER
));
286 ACPI_STRNCPY (LocalDSDT
.Signature
, ACPI_SIG_DSDT
, 4);
287 LocalDSDT
.Revision
= 1;
288 LocalDSDT
.Length
= sizeof (ACPI_TABLE_HEADER
);
289 LocalDSDT
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalDSDT
, LocalDSDT
.Length
);
291 /* Install incoming table (SSDT or PSDT) directly into the RSDT */
293 LocalRSDT
->TableOffsetEntry
[3] = ACPI_PTR_TO_PHYSADDR (UserTable
);
296 /* Set checksums for both RSDT and RSDP */
298 LocalRSDT
->Header
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) LocalRSDT
, LocalRSDT
->Header
.Length
);
299 LocalRSDP
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalRSDP
, ACPI_RSDP_CHECKSUM_LENGTH
);
301 /* Build a FADT so we can test the hardware/event init */
303 ACPI_MEMSET (&LocalFADT
, 0, sizeof (ACPI_TABLE_FADT
));
304 ACPI_STRNCPY (LocalFADT
.Header
.Signature
, ACPI_SIG_FADT
, 4);
306 LocalFADT
.Facs
= ACPI_PTR_TO_PHYSADDR (&LocalFACS
);
307 if (!ACPI_COMPARE_NAME (UserTable
->Signature
, ACPI_SIG_DSDT
))
309 LocalFADT
.Dsdt
= ACPI_PTR_TO_PHYSADDR (&LocalDSDT
);
313 LocalFADT
.Dsdt
= ACPI_PTR_TO_PHYSADDR (UserTable
);
316 /* Short (V1) FADT */
318 LocalFADT
.Header
.Revision
= 1;
319 LocalFADT
.Header
.Length
= ACPI_FADT_OFFSET (Flags
);
320 LocalFADT
.Gpe0BlockLength
= 16;
321 LocalFADT
.Gpe1BlockLength
= 6;
322 LocalFADT
.Gpe1Base
= 96;
324 LocalFADT
.Pm1EventLength
= 4;
325 LocalFADT
.Pm1ControlLength
= 4;
326 LocalFADT
.PmTimerLength
= 8;
328 LocalFADT
.Gpe0Block
= 0x12340000;
329 LocalFADT
.Gpe1Block
= 0x56780000;
331 LocalFADT
.Pm1aEventBlock
= 0x1aaa0000;
332 LocalFADT
.Pm1bEventBlock
= 0;
333 LocalFADT
.PmTimerBlock
= 0xA0;
334 LocalFADT
.Pm1aControlBlock
= 0xB0;
336 /* Complete the FADT with the checksum */
338 LocalFADT
.Header
.Checksum
= 0;
339 LocalFADT
.Header
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalFADT
, LocalFADT
.Header
.Length
);
343 ACPI_MEMSET (&LocalFACS
, 0, sizeof (ACPI_TABLE_FACS
));
344 ACPI_STRNCPY (LocalFACS
.Signature
, ACPI_SIG_FACS
, 4);
345 LocalFACS
.Length
= sizeof (ACPI_TABLE_FACS
);
346 LocalFACS
.GlobalLock
= 0x11AA0011;
348 /* Build a fake table [TEST] so that we make sure that the CA core ignores it */
350 ACPI_MEMSET (&LocalTEST
, 0, sizeof (ACPI_TABLE_HEADER
));
351 ACPI_STRNCPY (LocalTEST
.Signature
, "TEST", 4);
353 LocalTEST
.Revision
= 1;
354 LocalTEST
.Length
= sizeof (ACPI_TABLE_HEADER
);
355 LocalTEST
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalTEST
, LocalTEST
.Length
);
357 /* Build a fake table with a bad signature [BAD!] so that we make sure that the CA core ignores it */
359 ACPI_MEMSET (&LocalBADTABLE
, 0, sizeof (ACPI_TABLE_HEADER
));
360 ACPI_STRNCPY (LocalBADTABLE
.Signature
, "BAD!", 4);
362 LocalBADTABLE
.Revision
= 1;
363 LocalBADTABLE
.Length
= sizeof (ACPI_TABLE_HEADER
);
364 LocalBADTABLE
.Checksum
= (UINT8
) -AcpiTbChecksum ((void *) &LocalBADTABLE
, LocalBADTABLE
.Length
);
370 /******************************************************************************
372 * FUNCTION: AeInstallTables
378 * DESCRIPTION: Install the various ACPI tables
380 *****************************************************************************/
388 Status
= AcpiInitializeTables (Tables
, ACPI_MAX_INIT_TABLES
, TRUE
);
389 Status
= AcpiReallocateRootTable ();
390 Status
= AcpiLoadTables ();
395 /******************************************************************************
397 * FUNCTION: AeLocalGetRootPointer
399 * PARAMETERS: Flags - not used
400 * Address - Where the root pointer is returned
404 * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
405 * standard ACPI mechanism.
407 *****************************************************************************/
409 ACPI_PHYSICAL_ADDRESS
410 AeLocalGetRootPointer (
414 return ((ACPI_PHYSICAL_ADDRESS
) &LocalRSDP
);
418 /******************************************************************************
420 * FUNCTION: AeRegionHandler
422 * PARAMETERS: Standard region handler parameters
426 * DESCRIPTION: Test handler - Handles some dummy regions via memory that can
427 * be manipulated in Ring 3.
429 *****************************************************************************/
434 ACPI_PHYSICAL_ADDRESS Address
,
437 void *HandlerContext
,
441 ACPI_OPERAND_OBJECT
*RegionObject
= (ACPI_OPERAND_OBJECT
*) RegionContext
;
442 ACPI_PHYSICAL_ADDRESS BaseAddress
;
444 BOOLEAN BufferExists
;
445 REGION
*RegionElement
;
452 ACPI_FUNCTION_NAME (AeRegionHandler
);
455 * If the object is not a region, simply return
457 if (RegionObject
->Region
.Type
!= ACPI_TYPE_REGION
)
463 * Find the region's address space and length before searching
466 BaseAddress
= RegionObject
->Region
.Address
;
467 Length
= (ACPI_SIZE
) RegionObject
->Region
.Length
;
468 SpaceId
= RegionObject
->Region
.SpaceId
;
470 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION
, "Operation Region request on %s at 0x%X\n",
471 AcpiUtGetRegionName (RegionObject
->Region
.SpaceId
),
474 if (SpaceId
== ACPI_ADR_SPACE_SMBUS
)
478 switch (Function
& ACPI_IO_MASK
)
481 switch (Function
>> 16)
483 case AML_FIELD_ATTRIB_SMB_QUICK
:
484 case AML_FIELD_ATTRIB_SMB_SEND_RCV
:
485 case AML_FIELD_ATTRIB_SMB_BYTE
:
489 case AML_FIELD_ATTRIB_SMB_WORD
:
490 case AML_FIELD_ATTRIB_SMB_WORD_CALL
:
494 case AML_FIELD_ATTRIB_SMB_BLOCK
:
495 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL
:
505 switch (Function
>> 16)
507 case AML_FIELD_ATTRIB_SMB_QUICK
:
508 case AML_FIELD_ATTRIB_SMB_SEND_RCV
:
509 case AML_FIELD_ATTRIB_SMB_BYTE
:
510 case AML_FIELD_ATTRIB_SMB_WORD
:
511 case AML_FIELD_ATTRIB_SMB_BLOCK
:
515 case AML_FIELD_ATTRIB_SMB_WORD_CALL
:
519 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL
:
532 for (i
= 0; i
< Length
; i
++)
534 ((UINT8
*) Value
)[i
+2] = (UINT8
) (0xA0 + i
);
537 ((UINT8
*) Value
)[0] = 0x7A;
538 ((UINT8
*) Value
)[1] = (UINT8
) Length
;
544 * Search through the linked list for this region's buffer
546 BufferExists
= FALSE
;
547 RegionElement
= AeRegions
.RegionList
;
549 if (AeRegions
.NumberOfRegions
)
551 while (!BufferExists
&& RegionElement
)
553 if (RegionElement
->Address
== BaseAddress
&&
554 RegionElement
->Length
== Length
&&
555 RegionElement
->SpaceId
== SpaceId
)
561 RegionElement
= RegionElement
->NextRegion
;
567 * If the Region buffer does not exist, create it now
572 * Do the memory allocations first
574 RegionElement
= AcpiOsAllocate (sizeof (REGION
));
580 RegionElement
->Buffer
= AcpiOsAllocate (Length
);
581 if (!RegionElement
->Buffer
)
583 AcpiOsFree (RegionElement
);
587 ACPI_MEMSET (RegionElement
->Buffer
, 0, Length
);
588 RegionElement
->Address
= BaseAddress
;
589 RegionElement
->Length
= Length
;
590 RegionElement
->SpaceId
= SpaceId
;
591 RegionElement
->NextRegion
= NULL
;
594 * Increment the number of regions and put this one
595 * at the head of the list as it will probably get accessed
598 AeRegions
.NumberOfRegions
+= 1;
600 if (NULL
!= AeRegions
.RegionList
)
602 RegionElement
->NextRegion
= AeRegions
.RegionList
->NextRegion
;
605 AeRegions
.RegionList
= RegionElement
;
609 * Calculate the size of the memory copy
611 ByteWidth
= (BitWidth
/ 8);
619 * The buffer exists and is pointed to by RegionElement.
620 * We now need to verify the request is valid and perform the operation.
622 * NOTE: RegionElement->Length is in bytes, therefore it we compare against
623 * ByteWidth (see above)
625 if (((ACPI_INTEGER
) Address
+ ByteWidth
) >
626 ((ACPI_INTEGER
)(RegionElement
->Address
) + RegionElement
->Length
))
628 ACPI_WARNING ((AE_INFO
,
629 "Request on [%4.4s] is beyond region limit Req-%X+%X, Base=%X, Len-%X",
630 (RegionObject
->Region
.Node
)->Name
.Ascii
, (UINT32
) Address
,
631 ByteWidth
, (UINT32
)(RegionElement
->Address
),
632 RegionElement
->Length
));
634 return AE_AML_REGION_LIMIT
;
638 * Get BufferValue to point to the "address" in the buffer
640 BufferValue
= ((UINT8
*) RegionElement
->Buffer
+
641 ((ACPI_INTEGER
) Address
- (ACPI_INTEGER
) RegionElement
->Address
));
644 * Perform a read or write to the buffer space
650 * Set the pointer Value to whatever is in the buffer
652 ACPI_MEMCPY (Value
, BufferValue
, ByteWidth
);
657 * Write the contents of Value to the buffer
659 ACPI_MEMCPY (BufferValue
, Value
, ByteWidth
);
663 return AE_BAD_PARAMETER
;
669 /******************************************************************************
671 * FUNCTION: AeRegionInit
677 * DESCRIPTION: Opregion init function.
679 *****************************************************************************/
683 ACPI_HANDLE RegionHandle
,
685 void *HandlerContext
,
686 void **RegionContext
)
689 * Real simple, set the RegionContext to the RegionHandle
691 *RegionContext
= RegionHandle
;
697 /******************************************************************************
699 * FUNCTION: AeNotifyHandler
701 * PARAMETERS: Standard notify handler parameters
705 * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL
706 * test suite(s) to communicate errors and other information to
707 * this utility via the Notify() operator.
709 *****************************************************************************/
722 printf ("**** Method Error 0x%X: Results not equal\n", Value
);
723 if (AcpiGbl_DebugFile
)
725 AcpiOsPrintf ("**** Method Error: Results not equal\n");
731 printf ("**** Method Error: Incorrect numeric result\n");
732 if (AcpiGbl_DebugFile
)
734 AcpiOsPrintf ("**** Method Error: Incorrect numeric result\n");
740 printf ("**** Method Error: An operand was overwritten\n");
741 if (AcpiGbl_DebugFile
)
743 AcpiOsPrintf ("**** Method Error: An operand was overwritten\n");
750 printf ("**** Received a Notify on Device [%4.4s] %p value 0x%X\n",
751 AcpiUtGetNodeName (Device
), Device
, Value
);
752 if (AcpiGbl_DebugFile
)
754 AcpiOsPrintf ("**** Received a notify, value 0x%X\n", Value
);
762 /******************************************************************************
764 * FUNCTION: AeExceptionHandler
766 * PARAMETERS: Standard exception handler parameters
770 * DESCRIPTION: System exception handler for AcpiExec utility.
772 *****************************************************************************/
776 ACPI_STATUS AmlStatus
,
782 ACPI_STATUS NewAmlStatus
= AmlStatus
;
784 ACPI_BUFFER ReturnObj
;
785 ACPI_OBJECT_LIST ArgList
;
787 const char *Exception
;
790 Exception
= AcpiFormatException (AmlStatus
);
791 AcpiOsPrintf ("**** AcpiExec: Exception %s during execution ", Exception
);
794 AcpiOsPrintf ("of method [%4.4s]", (char *) &Name
);
798 AcpiOsPrintf ("at module level (table load)");
800 AcpiOsPrintf (" Opcode [%s] @%X\n", AcpiPsGetOpcodeName (Opcode
), AmlOffset
);
803 * Invoke the _ERR method if present
805 * Setup parameter object
808 ArgList
.Pointer
= Arg
;
810 Arg
[0].Type
= ACPI_TYPE_INTEGER
;
811 Arg
[0].Integer
.Value
= AmlStatus
;
813 Arg
[1].Type
= ACPI_TYPE_STRING
;
814 Arg
[1].String
.Pointer
= (char *) Exception
;
815 Arg
[1].String
.Length
= ACPI_STRLEN (Exception
);
817 /* Setup return buffer */
819 ReturnObj
.Pointer
= NULL
;
820 ReturnObj
.Length
= ACPI_ALLOCATE_BUFFER
;
822 Status
= AcpiEvaluateObject (NULL
, "\\_ERR", &ArgList
, &ReturnObj
);
823 if (ACPI_SUCCESS (Status
) &&
826 /* Override original status */
828 NewAmlStatus
= (ACPI_STATUS
)
829 ((ACPI_OBJECT
*) ReturnObj
.Pointer
)->Integer
.Value
;
831 AcpiOsFree (ReturnObj
.Pointer
);
834 /* Global override */
836 if (AcpiGbl_IgnoreErrors
)
838 NewAmlStatus
= AE_OK
;
841 if (NewAmlStatus
!= AmlStatus
)
843 AcpiOsPrintf ("**** AcpiExec: Exception override, new status %s\n",
844 AcpiFormatException (NewAmlStatus
));
847 return (NewAmlStatus
);
851 /******************************************************************************
853 * FUNCTION: AeInstallHandlers
859 * DESCRIPTION: Install handlers for the AcpiExec utility.
860 * NOTE: Currently only a system notify handler is installed.
862 *****************************************************************************/
864 ACPI_ADR_SPACE_TYPE SpaceId
[] = {0, 1, 2, 3, 4, 0x80};
865 #define AEXEC_NUM_REGIONS 6
868 AeInstallHandlers (void)
875 ACPI_FUNCTION_ENTRY ();
878 Status
= AcpiInstallExceptionHandler (AeExceptionHandler
);
879 if (ACPI_FAILURE (Status
))
881 printf ("Could not install exception handler, %s\n",
882 AcpiFormatException (Status
));
885 Status
= AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT
, ACPI_SYSTEM_NOTIFY
,
886 AeNotifyHandler
, NULL
);
887 if (ACPI_FAILURE (Status
))
889 printf ("Could not install a global notify handler, %s\n",
890 AcpiFormatException (Status
));
893 Status
= AcpiGetHandle (NULL
, "\\_SB", &Handle
);
894 if (ACPI_SUCCESS (Status
))
896 Status
= AcpiInstallNotifyHandler (Handle
, ACPI_SYSTEM_NOTIFY
,
897 AeNotifyHandler
, NULL
);
898 if (ACPI_FAILURE (Status
))
900 printf ("Could not install a notify handler, %s\n",
901 AcpiFormatException (Status
));
904 Status
= AcpiRemoveNotifyHandler (Handle
, ACPI_SYSTEM_NOTIFY
,
906 if (ACPI_FAILURE (Status
))
908 printf ("Could not remove a notify handler, %s\n",
909 AcpiFormatException (Status
));
912 Status
= AcpiInstallNotifyHandler (Handle
, ACPI_ALL_NOTIFY
,
913 AeNotifyHandler
, NULL
);
914 Status
= AcpiRemoveNotifyHandler (Handle
, ACPI_ALL_NOTIFY
,
916 Status
= AcpiInstallNotifyHandler (Handle
, ACPI_ALL_NOTIFY
,
917 AeNotifyHandler
, NULL
);
918 if (ACPI_FAILURE (Status
))
920 printf ("Could not install a notify handler, %s\n",
921 AcpiFormatException (Status
));
926 printf ("No _SB_ found, %s\n", AcpiFormatException (Status
));
929 for (i
= 0; i
< AEXEC_NUM_REGIONS
; i
++)
936 Status
= AcpiRemoveAddressSpaceHandler (AcpiGbl_RootNode
,
937 SpaceId
[i
], AeRegionHandler
);
939 /* Install handler at the root object.
940 * TBD: all default handlers should be installed here!
942 Status
= AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode
,
943 SpaceId
[i
], AeRegionHandler
, AeRegionInit
, NULL
);
944 if (ACPI_FAILURE (Status
))
946 ACPI_EXCEPTION ((AE_INFO
, Status
,
947 "Could not install an OpRegion handler for %s space(%d)",
948 AcpiUtGetRegionName((UINT8
) SpaceId
[i
]), SpaceId
[i
]));
954 * Initialize the global Region Handler space
957 AeRegions
.NumberOfRegions
= 0;
958 AeRegions
.RegionList
= NULL
;
964 /******************************************************************************
966 * FUNCTION: AeGpeHandler
968 * DESCRIPTION: GPE handler for acpiexec
970 *****************************************************************************/
978 AcpiOsPrintf ("Received a GPE at handler\n");
983 /******************************************************************************
985 * FUNCTION: AfInstallGpeBlock
991 * DESCRIPTION: Various GPE initialization
993 *****************************************************************************/
1001 ACPI_HANDLE Handle2
= NULL
;
1002 ACPI_HANDLE Handle3
= NULL
;
1003 ACPI_GENERIC_ADDRESS BlockAddress
;
1006 Status
= AcpiGetHandle (NULL
, "\\_GPE", &Handle
);
1007 if (ACPI_FAILURE (Status
))
1012 BlockAddress
.SpaceId
= 0;
1013 ACPI_STORE_ADDRESS (BlockAddress
.Address
, 0x76540000);
1015 // Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 4, 8);
1017 /* Above should fail, ignore */
1019 Status
= AcpiGetHandle (NULL
, "\\GPE2", &Handle2
);
1020 if (ACPI_SUCCESS (Status
))
1022 Status
= AcpiInstallGpeBlock (Handle2
, &BlockAddress
, 8, 8);
1024 AcpiInstallGpeHandler (Handle2
, 8, ACPI_GPE_LEVEL_TRIGGERED
, AeGpeHandler
, NULL
);
1025 AcpiSetGpeType (Handle2
, 8, ACPI_GPE_TYPE_WAKE
);
1026 AcpiEnableGpe (Handle2
, 8, 0);
1029 Status
= AcpiGetHandle (NULL
, "\\GPE3", &Handle3
);
1030 if (ACPI_SUCCESS (Status
))
1032 Status
= AcpiInstallGpeBlock (Handle3
, &BlockAddress
, 8, 11);
1035 // Status = AcpiRemoveGpeBlock (Handle);
1036 // Status = AcpiRemoveGpeBlock (Handle2);
1037 // Status = AcpiRemoveGpeBlock (Handle3);
1043 AeMiscellaneousTests (
1047 ACPI_BUFFER ReturnBuf
;
1049 ACPI_VENDOR_UUID Uuid
= {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}};
1054 ReturnBuf
.Length
= 32;
1055 ReturnBuf
.Pointer
= Buffer
;
1057 AcpiGetName (AcpiGbl_RootNode
, ACPI_FULL_PATHNAME
, &ReturnBuf
);
1058 AcpiEnableEvent (ACPI_EVENT_GLOBAL
, 0);
1060 AcpiInstallGpeHandler (NULL
, 0, ACPI_GPE_LEVEL_TRIGGERED
, AeGpeHandler
, NULL
);
1061 AcpiSetGpeType (NULL
, 0, ACPI_GPE_TYPE_WAKE_RUN
);
1062 AcpiEnableGpe (NULL
, 0, ACPI_NOT_ISR
);
1063 AcpiRemoveGpeHandler (NULL
, 0, AeGpeHandler
);
1065 AcpiInstallGpeHandler (NULL
, 0, ACPI_GPE_LEVEL_TRIGGERED
, AeGpeHandler
, NULL
);
1066 AcpiSetGpeType (NULL
, 0, ACPI_GPE_TYPE_WAKE_RUN
);
1067 AcpiEnableGpe (NULL
, 0, ACPI_NOT_ISR
);
1069 AcpiInstallGpeHandler (NULL
, 1, ACPI_GPE_EDGE_TRIGGERED
, AeGpeHandler
, NULL
);
1070 AcpiSetGpeType (NULL
, 1, ACPI_GPE_TYPE_RUNTIME
);
1071 AcpiEnableGpe (NULL
, 1, ACPI_NOT_ISR
);
1073 AcpiInstallGpeHandler (NULL
, 2, ACPI_GPE_LEVEL_TRIGGERED
, AeGpeHandler
, NULL
);
1074 AcpiSetGpeType (NULL
, 2, ACPI_GPE_TYPE_WAKE
);
1075 AcpiEnableGpe (NULL
, 2, ACPI_NOT_ISR
);
1077 AcpiInstallGpeHandler (NULL
, 3, ACPI_GPE_EDGE_TRIGGERED
, AeGpeHandler
, NULL
);
1078 AcpiSetGpeType (NULL
, 3, ACPI_GPE_TYPE_WAKE_RUN
);
1080 AcpiInstallGpeHandler (NULL
, 4, ACPI_GPE_LEVEL_TRIGGERED
, AeGpeHandler
, NULL
);
1081 AcpiSetGpeType (NULL
, 4, ACPI_GPE_TYPE_RUNTIME
);
1083 AcpiInstallGpeHandler (NULL
, 5, ACPI_GPE_EDGE_TRIGGERED
, AeGpeHandler
, NULL
);
1084 AcpiSetGpeType (NULL
, 5, ACPI_GPE_TYPE_WAKE
);
1086 AcpiInstallGpeHandler (NULL
, 0x19, ACPI_GPE_LEVEL_TRIGGERED
, AeGpeHandler
, NULL
);
1087 AcpiSetGpeType (NULL
, 0x19, ACPI_GPE_TYPE_WAKE_RUN
);
1088 AcpiEnableGpe (NULL
, 0x19, ACPI_NOT_ISR
);
1090 AfInstallGpeBlock ();
1093 Status
= AcpiGetHandle (NULL
, "RSRC", &Handle
);
1094 if (ACPI_SUCCESS (Status
))
1096 ReturnBuf
.Length
= ACPI_ALLOCATE_BUFFER
;
1098 Status
= AcpiGetVendorResource (Handle
, "_CRS", &Uuid
, &ReturnBuf
);
1099 if (ACPI_SUCCESS (Status
))
1101 AcpiOsFree (ReturnBuf
.Pointer
);
1105 /* Test global lock */
1107 Status
= AcpiAcquireGlobalLock (0xFFFF, &LockHandle
);
1108 if (ACPI_FAILURE (Status
))
1110 AcpiOsPrintf ("Could not get GlobalLock, %X\n", Status
);
1113 Status
= AcpiAcquireGlobalLock (0x5, &LockHandle
); /* Should fail */
1115 Status
= AcpiReleaseGlobalLock (LockHandle
);
1116 if (ACPI_FAILURE (Status
))
1118 AcpiOsPrintf ("Could not release GlobalLock, %X\n", Status
);