1 /******************************************************************************
3 * Module Name: aeexec - Support routines for AcpiExec utility
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2005, 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 *****************************************************************************/
119 #include "acparser.h"
121 #include "acnamesp.h"
123 #include "actables.h"
124 #include "aecommon.h"
130 #define _COMPONENT ACPI_TOOLS
131 ACPI_MODULE_NAME ("aeexec")
134 ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot;
135 ACPI_PARSE_OBJECT *root;
139 UINT32 AcpiDsdtLength;
141 DEBUG_REGIONS AeRegions;
142 RSDP_DESCRIPTOR LocalRsdp;
144 unsigned char Ssdt1Code[] =
146 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
147 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
148 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
149 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
150 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
151 0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "98.p..`." */
154 unsigned char Ssdt2Code[] =
156 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
157 0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
158 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
159 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
160 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
161 0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "99.p..`." */
164 unsigned char Oem1Code[] =
166 0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00, /* 00000000 "OEM18..." */
167 0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".KIntel." */
168 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
169 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
170 0x18,0x09,0x03,0x20,0x08,0x5F,0x58,0x54, /* 00000020 "... ._XT" */
171 0x32,0x0A,0x04,0x14,0x0C,0x5F,0x58,0x54, /* 00000028 "2...._XT" */
172 0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32, /* 00000030 "1.p._XT2" */
177 * We need a local FADT so that the hardware subcomponent will function,
178 * even though the underlying OSD HW access functions don't do
181 RSDP_DESCRIPTOR LocalRSDP;
182 FADT_DESCRIPTOR_REV1 LocalFADT;
183 FACS_DESCRIPTOR_REV1 LocalFACS;
184 ACPI_TABLE_HEADER LocalDSDT;
185 ACPI_TABLE_HEADER LocalTEST;
186 ACPI_TABLE_HEADER LocalBADTABLE;
188 RSDT_DESCRIPTOR_REV1 *LocalRSDT;
190 #define RSDT_TABLES 7
191 #define RSDT_SIZE (sizeof (RSDT_DESCRIPTOR_REV1) + ((RSDT_TABLES -1) * sizeof (UINT32)))
194 /******************************************************************************
196 * FUNCTION: AeCtrlCHandler
202 * DESCRIPTION: Control-C handler. Abort running control method if any.
204 *****************************************************************************/
211 signal (SIGINT, SIG_IGN);
213 AcpiOsPrintf ("Caught a ctrl-c\n\n");
215 if (AcpiGbl_MethodExecuting)
217 AcpiGbl_AbortMethod = TRUE;
218 signal (SIGINT, AeCtrlCHandler);
227 /******************************************************************************
229 * FUNCTION: AeBuildLocalTables
237 *****************************************************************************/
241 ACPI_TABLE_HEADER *UserTable)
247 LocalRSDT = AcpiOsAllocate (RSDT_SIZE);
253 ACPI_MEMSET (LocalRSDT, 0, RSDT_SIZE);
254 ACPI_STRNCPY (LocalRSDT->Signature, RSDT_SIG, 4);
255 LocalRSDT->Length = RSDT_SIZE;
257 LocalRSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST);
258 LocalRSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE);
259 LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT);
260 LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); /* Just a placeholder for a user SSDT */
262 /* Install two SSDTs to test multiple table support */
264 LocalRSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code);
265 LocalRSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code);
267 /* Install the OEM1 table to test LoadTable */
269 LocalRSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&Oem1Code);
273 ACPI_MEMSET (&LocalRSDP, 0, sizeof (RSDP_DESCRIPTOR));
274 ACPI_STRNCPY (LocalRSDP.Signature, RSDP_SIG, 8);
275 LocalRSDP.Revision = 1;
276 LocalRSDP.RsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalRSDT);
278 AcpiGbl_RSDP = &LocalRSDP;
281 * Examine the incoming user table. At this point, it has been verified
282 * to be either a DSDT, SSDT, or a PSDT, but they must be handled differently
284 if (!ACPI_STRNCMP ((char *) UserTable->Signature, DSDT_SIG, 4))
286 /* User DSDT is installed directly into the FADT */
288 AcpiGbl_DSDT = UserTable;
292 /* Build a local DSDT because incoming table is an SSDT or PSDT */
294 ACPI_MEMSET (&LocalDSDT, 0, sizeof (ACPI_TABLE_HEADER));
295 ACPI_STRNCPY (LocalDSDT.Signature, DSDT_SIG, 4);
296 LocalDSDT.Revision = 1;
297 LocalDSDT.Length = sizeof (ACPI_TABLE_HEADER);
298 LocalDSDT.Checksum = (UINT8) (0 - AcpiTbChecksum (&LocalDSDT, LocalDSDT.Length));
300 AcpiGbl_DSDT = &LocalDSDT;
302 /* Install incoming table (SSDT or PSDT) directly into the RSDT */
304 LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (UserTable);
307 /* Set checksums for both RSDT and RSDP */
309 LocalRSDT->Checksum = (UINT8) (0 - AcpiTbChecksum (LocalRSDT, LocalRSDT->Length));
310 LocalRSDP.Checksum = (UINT8) (0 - AcpiTbChecksum (&LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH));
312 /* Build a FADT so we can test the hardware/event init */
314 ACPI_MEMSET (&LocalFADT, 0, sizeof (FADT_DESCRIPTOR_REV1));
315 ACPI_STRNCPY (LocalFADT.Signature, FADT_SIG, 4);
317 LocalFADT.FirmwareCtrl = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
318 LocalFADT.Dsdt = ACPI_PTR_TO_PHYSADDR (AcpiGbl_DSDT);
319 LocalFADT.Revision = 1;
320 LocalFADT.Length = sizeof (FADT_DESCRIPTOR_REV1);
321 LocalFADT.Gpe0BlkLen = 16;
322 LocalFADT.Gpe1BlkLen = 6;
323 LocalFADT.Gpe1Base = 96;
325 LocalFADT.Pm1EvtLen = 4;
326 LocalFADT.Pm1CntLen = 4;
327 LocalFADT.PmTmLen = 8;
329 LocalFADT.Gpe0Blk = 0x12340000;
330 LocalFADT.Gpe1Blk = 0x56780000;
332 LocalFADT.Pm1aEvtBlk = 0x1aaa0000;
333 LocalFADT.Pm1bEvtBlk = 0;
334 LocalFADT.PmTmrBlk = 0xA0;
335 LocalFADT.Pm1aCntBlk = 0xB0;
337 /* Complete the FADT with the checksum */
339 LocalFADT.Checksum = (UINT8) (0 - AcpiTbChecksum (&LocalFADT, LocalFADT.Length));
343 ACPI_MEMSET (&LocalFACS, 0, sizeof (FACS_DESCRIPTOR_REV1));
344 ACPI_STRNCPY (LocalFACS.Signature, FACS_SIG, 4);
345 LocalFACS.Length = sizeof (FACS_DESCRIPTOR_REV1);
346 LocalFACS.GlobalLock = 0x11AA0011;
348 /* Build a fake table 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);
356 /* Build a fake table with a bad signature so that we make sure that the CA core ignores it */
358 ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER));
359 ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4);
361 LocalBADTABLE.Revision = 1;
362 LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);
368 /******************************************************************************
370 * FUNCTION: AeInstallTables
378 *****************************************************************************/
381 AeInstallTables (void)
386 Status = AcpiLoadTables ();
389 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) &LocalFADT);
390 if (ACPI_FAILURE (Status))
392 printf ("**** Could not load local FADT, %s\n", AcpiFormatException (Status));
396 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) &LocalFACS);
397 if (ACPI_FAILURE (Status))
399 printf ("**** Could not load local FACS, %s\n", AcpiFormatException (Status));
408 /******************************************************************************
410 * FUNCTION: AeLocalGetRootPointer
416 * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
417 * standard ACPI mechanism.
419 *****************************************************************************/
422 AeLocalGetRootPointer (
424 ACPI_POINTER *Address)
427 Address->PointerType = ACPI_LOGICAL_POINTER;
428 Address->Pointer.Logical = &LocalRSDP;
433 /******************************************************************************
435 * FUNCTION: AeRegionHandler
437 * PARAMETERS: Standard region handler parameters
441 * DESCRIPTION: Test handler - Handles some dummy regions via memory that can
442 * be manipulated in Ring 3.
444 *****************************************************************************/
449 ACPI_PHYSICAL_ADDRESS Address,
452 void *HandlerContext,
456 ACPI_OPERAND_OBJECT *RegionObject = (ACPI_OPERAND_OBJECT*) RegionContext;
457 ACPI_PHYSICAL_ADDRESS BaseAddress;
459 BOOLEAN BufferExists;
460 REGION *RegionElement;
466 ACPI_FUNCTION_NAME ("AeRegionHandler");
469 * If the object is not a region, simply return
471 if (RegionObject->Region.Type != ACPI_TYPE_REGION)
477 * Find the region's address space and length before searching
480 BaseAddress = RegionObject->Region.Address;
481 Length = (ACPI_SIZE) RegionObject->Region.Length;
483 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Operation Region request on %s at 0x%X\n",
484 AcpiUtGetRegionName (RegionObject->Region.SpaceId),
487 if (RegionObject->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
491 switch (Function & ACPI_IO_MASK)
494 switch (Function >> 16)
496 case AML_FIELD_ATTRIB_SMB_QUICK:
497 case AML_FIELD_ATTRIB_SMB_SEND_RCV:
498 case AML_FIELD_ATTRIB_SMB_BYTE:
502 case AML_FIELD_ATTRIB_SMB_WORD:
503 case AML_FIELD_ATTRIB_SMB_WORD_CALL:
507 case AML_FIELD_ATTRIB_SMB_BLOCK:
508 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
518 switch (Function >> 16)
520 case AML_FIELD_ATTRIB_SMB_QUICK:
521 case AML_FIELD_ATTRIB_SMB_SEND_RCV:
522 case AML_FIELD_ATTRIB_SMB_BYTE:
523 case AML_FIELD_ATTRIB_SMB_WORD:
524 case AML_FIELD_ATTRIB_SMB_BLOCK:
528 case AML_FIELD_ATTRIB_SMB_WORD_CALL:
532 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
545 for (i = 0; i < Length; i++)
547 ((UINT8 *) Value)[i+2] = (UINT8) (0xA0 + i);
550 ((UINT8 *) Value)[0] = 0x7A;
551 ((UINT8 *) Value)[1] = (UINT8) Length;
557 * Search through the linked list for this region's buffer
559 BufferExists = FALSE;
560 RegionElement = AeRegions.RegionList;
562 if (AeRegions.NumberOfRegions)
564 while (!BufferExists && RegionElement)
566 if (RegionElement->Address == BaseAddress &&
567 RegionElement->Length == Length)
573 RegionElement = RegionElement->NextRegion;
579 * If the Region buffer does not exist, create it now
584 * Do the memory allocations first
586 RegionElement = AcpiOsAllocate (sizeof (REGION));
592 RegionElement->Buffer = AcpiOsAllocate (Length);
593 if (!RegionElement->Buffer)
595 AcpiOsFree (RegionElement);
599 ACPI_MEMSET (RegionElement->Buffer, 0, Length);
600 RegionElement->Address = BaseAddress;
601 RegionElement->Length = Length;
602 RegionElement->NextRegion = NULL;
605 * Increment the number of regions and put this one
606 * at the head of the list as it will probably get accessed
609 AeRegions.NumberOfRegions += 1;
611 if (NULL != AeRegions.RegionList)
613 RegionElement->NextRegion = AeRegions.RegionList->NextRegion;
616 AeRegions.RegionList = RegionElement;
620 * Calculate the size of the memory copy
622 ByteWidth = (BitWidth / 8);
630 * The buffer exists and is pointed to by RegionElement.
631 * We now need to verify the request is valid and perform the operation.
633 * NOTE: RegionElement->Length is in bytes, therefore it we compare against
634 * ByteWidth (see above)
636 if (((ACPI_INTEGER) Address + ByteWidth) >
637 ((ACPI_INTEGER)(RegionElement->Address) + RegionElement->Length))
639 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Request on [%4.4s] is beyond region limit Req-%lX+%lX, Base=%lX, Len-%lX\n",
640 &((RegionObject->Region.Node)->Name), (UINT32) Address, ByteWidth, (UINT32)(RegionElement->Address),
641 RegionElement->Length));
643 return AE_AML_REGION_LIMIT;
647 * Get BufferValue to point to the "address" in the buffer
649 BufferValue = ((UINT8 *) RegionElement->Buffer +
650 ((ACPI_INTEGER) Address - (ACPI_INTEGER) RegionElement->Address));
653 * Perform a read or write to the buffer space
659 * Set the pointer Value to whatever is in the buffer
661 ACPI_MEMCPY (Value, BufferValue, ByteWidth);
666 * Write the contents of Value to the buffer
668 ACPI_MEMCPY (BufferValue, Value, ByteWidth);
672 return AE_BAD_PARAMETER;
678 /******************************************************************************
680 * FUNCTION: AeRegionInit
686 * DESCRIPTION: Opregion init function.
688 *****************************************************************************/
692 ACPI_HANDLE RegionHandle,
694 void *HandlerContext,
695 void **RegionContext)
698 * Real simple, set the RegionContext to the RegionHandle
700 *RegionContext = RegionHandle;
706 /******************************************************************************
708 * FUNCTION: AeNotifyHandler
710 * PARAMETERS: Standard notify handler parameters
714 * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL
715 * test suite(s) to communicate errors and other information to
716 * this utility via the Notify() operator.
718 *****************************************************************************/
731 printf ("**** Method Error 0x%X: Results not equal\n", Value);
732 if (AcpiGbl_DebugFile)
734 AcpiOsPrintf ("**** Method Error: Results not equal\n");
740 printf ("**** Method Error: Incorrect numeric result\n");
741 if (AcpiGbl_DebugFile)
743 AcpiOsPrintf ("**** Method Error: Incorrect numeric result\n");
749 printf ("**** Method Error: An operand was overwritten\n");
750 if (AcpiGbl_DebugFile)
752 AcpiOsPrintf ("**** Method Error: An operand was overwritten\n");
759 printf ("**** Received a Notify on Device [%4.4s] %p value 0x%X\n",
760 AcpiUtGetNodeName (Device), Device, Value);
761 if (AcpiGbl_DebugFile)
763 AcpiOsPrintf ("**** Received a notify, value 0x%X\n", Value);
771 /******************************************************************************
773 * FUNCTION: AeExceptionHandler
775 * PARAMETERS: Standard exception handler parameters
779 * DESCRIPTION: System exception handler for AcpiExec utility.
781 *****************************************************************************/
785 ACPI_STATUS AmlStatus,
792 ACPI_BUFFER ReturnObj;
793 ACPI_OBJECT_LIST ArgList;
795 const char *Exception;
798 Exception = AcpiFormatException (AmlStatus);
800 "**** AcpiExec Exception: %s during execution of method [%4.4s] Opcode [%s] @%X\n",
801 Exception, &Name, AcpiPsGetOpcodeName (Opcode), AmlOffset);
804 * Invoke the _ERR method if present
806 * Setup parameter object
809 ArgList.Pointer = Arg;
811 Arg[0].Type = ACPI_TYPE_INTEGER;
812 Arg[0].Integer.Value = AmlStatus;
814 Arg[1].Type = ACPI_TYPE_STRING;
815 Arg[1].String.Pointer = (char *) Exception;
816 Arg[1].String.Length = ACPI_STRLEN (Exception);
818 /* Setup return buffer */
820 ReturnObj.Pointer = NULL;
821 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
823 Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj);
824 if (ACPI_SUCCESS (Status) &&
827 /* Override original status */
829 AmlStatus = (ACPI_STATUS)
830 ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value;
832 AcpiOsFree (ReturnObj.Pointer);
838 /******************************************************************************
840 * FUNCTION: AeInstallHandlers
846 * DESCRIPTION: Install handlers for the AcpiExec utility.
847 * NOTE: Currently only a system notify handler is installed.
849 *****************************************************************************/
851 ACPI_ADR_SPACE_TYPE SpaceId[] = {0, 1, 2, 3, 4, 0x80};
852 #define AEXEC_NUM_REGIONS 6
855 AeInstallHandlers (void)
862 ACPI_FUNCTION_NAME ("AeInstallHandlers");
865 Status = AcpiInstallExceptionHandler (AeExceptionHandler);
866 if (ACPI_FAILURE (Status))
868 printf ("Could not install exception handler, %s\n",
869 AcpiFormatException (Status));
872 Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
873 AeNotifyHandler, NULL);
874 if (ACPI_FAILURE (Status))
876 printf ("Could not install a global notify handler, %s\n",
877 AcpiFormatException (Status));
880 Status = AcpiGetHandle (NULL, "\\_SB_", &Handle);
881 if (ACPI_SUCCESS (Status))
883 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
884 AeNotifyHandler, NULL);
885 if (ACPI_FAILURE (Status))
887 printf ("Could not install a notify handler, %s\n",
888 AcpiFormatException (Status));
891 Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
893 if (ACPI_FAILURE (Status))
895 printf ("Could not remove a notify handler, %s\n",
896 AcpiFormatException (Status));
899 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
900 AeNotifyHandler, NULL);
901 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
903 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
904 AeNotifyHandler, NULL);
905 if (ACPI_FAILURE (Status))
907 printf ("Could not install a notify handler, %s\n",
908 AcpiFormatException (Status));
913 for (i = 0; i < AEXEC_NUM_REGIONS; i++)
920 Status = AcpiRemoveAddressSpaceHandler (AcpiGbl_RootNode,
921 SpaceId[i], AeRegionHandler);
923 /* Install handler at the root object.
924 * TBD: all default handlers should be installed here!
926 Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode,
927 SpaceId[i], AeRegionHandler, AeRegionInit, NULL);
928 if (ACPI_FAILURE (Status))
930 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
931 "Could not install an OpRegion handler for %s space(%d), %s\n",
932 AcpiUtGetRegionName((UINT8) SpaceId[i]), SpaceId[i], AcpiFormatException (Status)));
939 * Initialize the global Region Handler space
942 AeRegions.NumberOfRegions = 0;
943 AeRegions.RegionList = NULL;