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 *****************************************************************************/
117 #include <contrib/dev/acpica/aecommon.h>
119 #define _COMPONENT ACPI_TOOLS
120 ACPI_MODULE_NAME ("aeexec")
123 ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot;
124 ACPI_PARSE_OBJECT *root;
128 UINT32 AcpiDsdtLength;
130 DEBUG_REGIONS AeRegions;
131 RSDP_DESCRIPTOR LocalRsdp;
134 * Misc ACPI tables to be installed
136 unsigned char Ssdt1Code[] =
138 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
139 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
140 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
141 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
142 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
143 0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "98.p..`." */
146 unsigned char Ssdt2Code[] =
148 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
149 0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
150 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
151 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
152 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
153 0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "99.p..`." */
156 unsigned char Oem1Code[] =
158 0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00, /* 00000000 "OEM18..." */
159 0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".KIntel." */
160 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
161 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
162 0x18,0x09,0x03,0x20,0x08,0x5F,0x58,0x54, /* 00000020 "... ._XT" */
163 0x32,0x0A,0x04,0x14,0x0C,0x5F,0x58,0x54, /* 00000028 "2...._XT" */
164 0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32, /* 00000030 "1.p._XT2" */
169 * We need a local FADT so that the hardware subcomponent will function,
170 * even though the underlying OSD HW access functions don't do
173 RSDP_DESCRIPTOR LocalRSDP;
174 FADT_DESCRIPTOR_REV1 LocalFADT;
175 FACS_DESCRIPTOR_REV1 LocalFACS;
176 ACPI_TABLE_HEADER LocalDSDT;
177 ACPI_TABLE_HEADER LocalTEST;
178 ACPI_TABLE_HEADER LocalBADTABLE;
180 RSDT_DESCRIPTOR_REV1 *LocalRSDT;
182 #define RSDT_TABLES 7
183 #define RSDT_SIZE (sizeof (RSDT_DESCRIPTOR_REV1) + ((RSDT_TABLES -1) * sizeof (UINT32)))
186 /******************************************************************************
188 * FUNCTION: AeCtrlCHandler
194 * DESCRIPTION: Control-C handler. Abort running control method if any.
196 *****************************************************************************/
203 signal (SIGINT, SIG_IGN);
205 AcpiOsPrintf ("Caught a ctrl-c\n\n");
207 if (AcpiGbl_MethodExecuting)
209 AcpiGbl_AbortMethod = TRUE;
210 signal (SIGINT, AeCtrlCHandler);
219 /******************************************************************************
221 * FUNCTION: AeBuildLocalTables
229 *****************************************************************************/
233 ACPI_TABLE_HEADER *UserTable)
239 LocalRSDT = AcpiOsAllocate (RSDT_SIZE);
245 ACPI_MEMSET (LocalRSDT, 0, RSDT_SIZE);
246 ACPI_STRNCPY (LocalRSDT->Signature, RSDT_SIG, 4);
247 LocalRSDT->Length = RSDT_SIZE;
249 LocalRSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST);
250 LocalRSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE);
251 LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT);
252 LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); /* Just a placeholder for a user SSDT */
254 /* Install two SSDTs to test multiple table support */
256 LocalRSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code);
257 LocalRSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code);
259 /* Install the OEM1 table to test LoadTable */
261 LocalRSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&Oem1Code);
265 ACPI_MEMSET (&LocalRSDP, 0, sizeof (RSDP_DESCRIPTOR));
266 ACPI_STRNCPY (LocalRSDP.Signature, RSDP_SIG, 8);
267 LocalRSDP.Revision = 1;
268 LocalRSDP.RsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalRSDT);
270 AcpiGbl_RSDP = &LocalRSDP;
273 * Examine the incoming user table. At this point, it has been verified
274 * to be either a DSDT, SSDT, or a PSDT, but they must be handled differently
276 if (!ACPI_STRNCMP ((char *) UserTable->Signature, DSDT_SIG, 4))
278 /* User DSDT is installed directly into the FADT */
280 AcpiGbl_DSDT = UserTable;
284 /* Build a local DSDT because incoming table is an SSDT or PSDT */
286 ACPI_MEMSET (&LocalDSDT, 0, sizeof (ACPI_TABLE_HEADER));
287 ACPI_STRNCPY (LocalDSDT.Signature, DSDT_SIG, 4);
288 LocalDSDT.Revision = 1;
289 LocalDSDT.Length = sizeof (ACPI_TABLE_HEADER);
290 LocalDSDT.Checksum = (UINT8) (0 - AcpiTbGenerateChecksum (&LocalDSDT, LocalDSDT.Length));
292 AcpiGbl_DSDT = &LocalDSDT;
294 /* Install incoming table (SSDT or PSDT) directly into the RSDT */
296 LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (UserTable);
299 /* Set checksums for both RSDT and RSDP */
301 LocalRSDT->Checksum = (UINT8) (0 - AcpiTbGenerateChecksum (LocalRSDT, LocalRSDT->Length));
302 LocalRSDP.Checksum = (UINT8) (0 - AcpiTbGenerateChecksum (&LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH));
304 /* Build a FADT so we can test the hardware/event init */
306 ACPI_MEMSET (&LocalFADT, 0, sizeof (FADT_DESCRIPTOR_REV1));
307 ACPI_STRNCPY (LocalFADT.Signature, FADT_SIG, 4);
309 LocalFADT.FirmwareCtrl = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
310 LocalFADT.Dsdt = ACPI_PTR_TO_PHYSADDR (AcpiGbl_DSDT);
311 LocalFADT.Revision = 1;
312 LocalFADT.Length = sizeof (FADT_DESCRIPTOR_REV1);
313 LocalFADT.Gpe0BlkLen = 16;
314 LocalFADT.Gpe1BlkLen = 6;
315 LocalFADT.Gpe1Base = 96;
317 LocalFADT.Pm1EvtLen = 4;
318 LocalFADT.Pm1CntLen = 4;
319 LocalFADT.PmTmLen = 8;
321 LocalFADT.Gpe0Blk = 0x12340000;
322 LocalFADT.Gpe1Blk = 0x56780000;
324 LocalFADT.Pm1aEvtBlk = 0x1aaa0000;
325 LocalFADT.Pm1bEvtBlk = 0;
326 LocalFADT.PmTmrBlk = 0xA0;
327 LocalFADT.Pm1aCntBlk = 0xB0;
329 /* Complete the FADT with the checksum */
331 LocalFADT.Checksum = (UINT8) (0 - AcpiTbGenerateChecksum (&LocalFADT, LocalFADT.Length));
335 ACPI_MEMSET (&LocalFACS, 0, sizeof (FACS_DESCRIPTOR_REV1));
336 ACPI_STRNCPY (LocalFACS.Signature, FACS_SIG, 4);
337 LocalFACS.Length = sizeof (FACS_DESCRIPTOR_REV1);
338 LocalFACS.GlobalLock = 0x11AA0011;
340 /* Build a fake table so that we make sure that the CA core ignores it */
342 ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER));
343 ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4);
345 LocalTEST.Revision = 1;
346 LocalTEST.Length = sizeof (ACPI_TABLE_HEADER);
348 /* Build a fake table with a bad signature so that we make sure that the CA core ignores it */
350 ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER));
351 ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4);
353 LocalBADTABLE.Revision = 1;
354 LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);
360 /******************************************************************************
362 * FUNCTION: AeInstallTables
368 * DESCRIPTION: Install the various ACPI tables
370 *****************************************************************************/
373 AeInstallTables (void)
378 Status = AcpiLoadTables ();
380 /* Test the code that ignores multiple loads of same SSDT */
382 (void) AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt1Code);
385 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) &LocalFADT);
386 if (ACPI_FAILURE (Status))
388 printf ("**** Could not load local FADT, %s\n", AcpiFormatException (Status));
392 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) &LocalFACS);
393 if (ACPI_FAILURE (Status))
395 printf ("**** Could not load local FACS, %s\n", AcpiFormatException (Status));
404 /******************************************************************************
406 * FUNCTION: AeLocalGetRootPointer
408 * PARAMETERS: Flags - not used
409 * Address - Where the root pointer is returned
413 * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
414 * standard ACPI mechanism.
416 *****************************************************************************/
419 AeLocalGetRootPointer (
421 ACPI_POINTER *Address)
424 Address->PointerType = ACPI_LOGICAL_POINTER;
425 Address->Pointer.Logical = &LocalRSDP;
430 /******************************************************************************
432 * FUNCTION: AeRegionHandler
434 * PARAMETERS: Standard region handler parameters
438 * DESCRIPTION: Test handler - Handles some dummy regions via memory that can
439 * be manipulated in Ring 3.
441 *****************************************************************************/
446 ACPI_PHYSICAL_ADDRESS Address,
449 void *HandlerContext,
453 ACPI_OPERAND_OBJECT *RegionObject = (ACPI_OPERAND_OBJECT*) RegionContext;
454 ACPI_PHYSICAL_ADDRESS BaseAddress;
456 BOOLEAN BufferExists;
457 REGION *RegionElement;
463 ACPI_FUNCTION_NAME ("AeRegionHandler");
466 * If the object is not a region, simply return
468 if (RegionObject->Region.Type != ACPI_TYPE_REGION)
474 * Find the region's address space and length before searching
477 BaseAddress = RegionObject->Region.Address;
478 Length = (ACPI_SIZE) RegionObject->Region.Length;
480 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Operation Region request on %s at 0x%X\n",
481 AcpiUtGetRegionName (RegionObject->Region.SpaceId),
484 if (RegionObject->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
488 switch (Function & ACPI_IO_MASK)
491 switch (Function >> 16)
493 case AML_FIELD_ATTRIB_SMB_QUICK:
494 case AML_FIELD_ATTRIB_SMB_SEND_RCV:
495 case AML_FIELD_ATTRIB_SMB_BYTE:
499 case AML_FIELD_ATTRIB_SMB_WORD:
500 case AML_FIELD_ATTRIB_SMB_WORD_CALL:
504 case AML_FIELD_ATTRIB_SMB_BLOCK:
505 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
515 switch (Function >> 16)
517 case AML_FIELD_ATTRIB_SMB_QUICK:
518 case AML_FIELD_ATTRIB_SMB_SEND_RCV:
519 case AML_FIELD_ATTRIB_SMB_BYTE:
520 case AML_FIELD_ATTRIB_SMB_WORD:
521 case AML_FIELD_ATTRIB_SMB_BLOCK:
525 case AML_FIELD_ATTRIB_SMB_WORD_CALL:
529 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
542 for (i = 0; i < Length; i++)
544 ((UINT8 *) Value)[i+2] = (UINT8) (0xA0 + i);
547 ((UINT8 *) Value)[0] = 0x7A;
548 ((UINT8 *) Value)[1] = (UINT8) Length;
554 * Search through the linked list for this region's buffer
556 BufferExists = FALSE;
557 RegionElement = AeRegions.RegionList;
559 if (AeRegions.NumberOfRegions)
561 while (!BufferExists && RegionElement)
563 if (RegionElement->Address == BaseAddress &&
564 RegionElement->Length == Length)
570 RegionElement = RegionElement->NextRegion;
576 * If the Region buffer does not exist, create it now
581 * Do the memory allocations first
583 RegionElement = AcpiOsAllocate (sizeof (REGION));
589 RegionElement->Buffer = AcpiOsAllocate (Length);
590 if (!RegionElement->Buffer)
592 AcpiOsFree (RegionElement);
596 ACPI_MEMSET (RegionElement->Buffer, 0, Length);
597 RegionElement->Address = BaseAddress;
598 RegionElement->Length = Length;
599 RegionElement->NextRegion = NULL;
602 * Increment the number of regions and put this one
603 * at the head of the list as it will probably get accessed
606 AeRegions.NumberOfRegions += 1;
608 if (NULL != AeRegions.RegionList)
610 RegionElement->NextRegion = AeRegions.RegionList->NextRegion;
613 AeRegions.RegionList = RegionElement;
617 * Calculate the size of the memory copy
619 ByteWidth = (BitWidth / 8);
627 * The buffer exists and is pointed to by RegionElement.
628 * We now need to verify the request is valid and perform the operation.
630 * NOTE: RegionElement->Length is in bytes, therefore it we compare against
631 * ByteWidth (see above)
633 if (((ACPI_INTEGER) Address + ByteWidth) >
634 ((ACPI_INTEGER)(RegionElement->Address) + RegionElement->Length))
636 ACPI_DEBUG_PRINT ((ACPI_DB_WARN,
637 "Request on [%4.4s] is beyond region limit Req-%X+%X, Base=%X, Len-%X\n",
638 (RegionObject->Region.Node)->Name.Ascii, (UINT32) Address,
639 ByteWidth, (UINT32)(RegionElement->Address),
640 RegionElement->Length));
642 return AE_AML_REGION_LIMIT;
646 * Get BufferValue to point to the "address" in the buffer
648 BufferValue = ((UINT8 *) RegionElement->Buffer +
649 ((ACPI_INTEGER) Address - (ACPI_INTEGER) RegionElement->Address));
652 * Perform a read or write to the buffer space
658 * Set the pointer Value to whatever is in the buffer
660 ACPI_MEMCPY (Value, BufferValue, ByteWidth);
665 * Write the contents of Value to the buffer
667 ACPI_MEMCPY (BufferValue, Value, ByteWidth);
671 return AE_BAD_PARAMETER;
677 /******************************************************************************
679 * FUNCTION: AeRegionInit
685 * DESCRIPTION: Opregion init function.
687 *****************************************************************************/
691 ACPI_HANDLE RegionHandle,
693 void *HandlerContext,
694 void **RegionContext)
697 * Real simple, set the RegionContext to the RegionHandle
699 *RegionContext = RegionHandle;
705 /******************************************************************************
707 * FUNCTION: AeNotifyHandler
709 * PARAMETERS: Standard notify handler parameters
713 * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL
714 * test suite(s) to communicate errors and other information to
715 * this utility via the Notify() operator.
717 *****************************************************************************/
730 printf ("**** Method Error 0x%X: Results not equal\n", Value);
731 if (AcpiGbl_DebugFile)
733 AcpiOsPrintf ("**** Method Error: Results not equal\n");
739 printf ("**** Method Error: Incorrect numeric result\n");
740 if (AcpiGbl_DebugFile)
742 AcpiOsPrintf ("**** Method Error: Incorrect numeric result\n");
748 printf ("**** Method Error: An operand was overwritten\n");
749 if (AcpiGbl_DebugFile)
751 AcpiOsPrintf ("**** Method Error: An operand was overwritten\n");
758 printf ("**** Received a Notify on Device [%4.4s] %p value 0x%X\n",
759 AcpiUtGetNodeName (Device), Device, Value);
760 if (AcpiGbl_DebugFile)
762 AcpiOsPrintf ("**** Received a notify, value 0x%X\n", Value);
770 /******************************************************************************
772 * FUNCTION: AeExceptionHandler
774 * PARAMETERS: Standard exception handler parameters
778 * DESCRIPTION: System exception handler for AcpiExec utility.
780 *****************************************************************************/
784 ACPI_STATUS AmlStatus,
791 ACPI_BUFFER ReturnObj;
792 ACPI_OBJECT_LIST ArgList;
794 const char *Exception;
797 Exception = AcpiFormatException (AmlStatus);
799 "**** AcpiExec Exception: %s during execution of method [%4.4s] Opcode [%s] @%X\n",
800 Exception, (char *) &Name, 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 AmlStatus = (ACPI_STATUS)
829 ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value;
831 AcpiOsFree (ReturnObj.Pointer);
837 /******************************************************************************
839 * FUNCTION: AeInstallHandlers
845 * DESCRIPTION: Install handlers for the AcpiExec utility.
846 * NOTE: Currently only a system notify handler is installed.
848 *****************************************************************************/
850 ACPI_ADR_SPACE_TYPE SpaceId[] = {0, 1, 2, 3, 4, 0x80};
851 #define AEXEC_NUM_REGIONS 6
854 AeInstallHandlers (void)
861 ACPI_FUNCTION_NAME ("AeInstallHandlers");
864 Status = AcpiInstallExceptionHandler (AeExceptionHandler);
865 if (ACPI_FAILURE (Status))
867 printf ("Could not install exception handler, %s\n",
868 AcpiFormatException (Status));
871 Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
872 AeNotifyHandler, NULL);
873 if (ACPI_FAILURE (Status))
875 printf ("Could not install a global notify handler, %s\n",
876 AcpiFormatException (Status));
879 Status = AcpiGetHandle (NULL, "\\_SB_", &Handle);
880 if (ACPI_SUCCESS (Status))
882 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
883 AeNotifyHandler, NULL);
884 if (ACPI_FAILURE (Status))
886 printf ("Could not install a notify handler, %s\n",
887 AcpiFormatException (Status));
890 Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
892 if (ACPI_FAILURE (Status))
894 printf ("Could not remove a notify handler, %s\n",
895 AcpiFormatException (Status));
898 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
899 AeNotifyHandler, NULL);
900 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
902 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
903 AeNotifyHandler, NULL);
904 if (ACPI_FAILURE (Status))
906 printf ("Could not install a notify handler, %s\n",
907 AcpiFormatException (Status));
912 for (i = 0; i < AEXEC_NUM_REGIONS; i++)
919 Status = AcpiRemoveAddressSpaceHandler (AcpiGbl_RootNode,
920 SpaceId[i], AeRegionHandler);
922 /* Install handler at the root object.
923 * TBD: all default handlers should be installed here!
925 Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode,
926 SpaceId[i], AeRegionHandler, AeRegionInit, NULL);
927 if (ACPI_FAILURE (Status))
929 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
930 "Could not install an OpRegion handler for %s space(%d), %s\n",
931 AcpiUtGetRegionName((UINT8) SpaceId[i]), SpaceId[i],
932 AcpiFormatException (Status)));
938 * Initialize the global Region Handler space
941 AeRegions.NumberOfRegions = 0;
942 AeRegions.RegionList = NULL;