1 /******************************************************************************
3 * Module Name: aehandlers - Various handlers for acpiexec
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
12 * All rights reserved.
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
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
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;
37 * The above copyright and patent license is granted only if the following
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.
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
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
72 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
80 * 4. Disclaimer and Export Compliance
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
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
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.
114 *****************************************************************************/
116 #include "aecommon.h"
118 #define _COMPONENT ACPI_TOOLS
119 ACPI_MODULE_NAME ("aehandlers")
121 /* Local prototypes */
130 AeDeviceNotifyHandler (
137 ACPI_STATUS AmlStatus,
151 ACPI_HANDLE RegionHandle,
153 void *HandlerContext,
154 void **RegionContext);
157 AeAttachedDataHandler (
163 ACPI_STRING InterfaceName,
170 static UINT32 SigintCount = 0;
171 static AE_DEBUG_REGIONS AeRegions;
175 * We will override default region handlers for memory and I/O. Especially
176 * the SystemMemory handler, which must be implemented locally to simulate
177 * memory operation regions. Do not override the PCI_Config handler since
178 * we would like to exercise the default handler code. Do not override
179 * DataTable handler, since the default handler works correctly under
180 * acpiexec (and is used by the test suites.)
182 static ACPI_ADR_SPACE_TYPE DefaultSpaceIdList[] =
184 ACPI_ADR_SPACE_SYSTEM_MEMORY,
185 ACPI_ADR_SPACE_SYSTEM_IO
189 * We will install handlers for some of the various address space IDs
191 static ACPI_ADR_SPACE_TYPE SpaceIdList[] =
194 ACPI_ADR_SPACE_SMBUS,
195 ACPI_ADR_SPACE_PCI_BAR_TARGET,
197 ACPI_ADR_SPACE_FIXED_HARDWARE
201 /******************************************************************************
203 * FUNCTION: AeCtrlCHandler
209 * DESCRIPTION: Control-C handler. Abort running control method if any.
211 *****************************************************************************/
213 void ACPI_SYSTEM_XFACE
218 signal (SIGINT, SIG_IGN);
221 AcpiOsPrintf ("Caught a ctrl-c (#%u)\n\n", SigintCount);
223 if (AcpiGbl_MethodExecuting)
225 AcpiGbl_AbortMethod = TRUE;
226 signal (SIGINT, AeCtrlCHandler);
228 if (SigintCount < 10)
238 /******************************************************************************
240 * FUNCTION: AeNotifyHandler
242 * PARAMETERS: Standard notify handler parameters
246 * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL
247 * test suite(s) to communicate errors and other information to
248 * this utility via the Notify() operator.
250 *****************************************************************************/
263 printf ("[AcpiExec] Method Error 0x%X: Results not equal\n", Value);
264 if (AcpiGbl_DebugFile)
266 AcpiOsPrintf ("[AcpiExec] Method Error: Results not equal\n");
272 printf ("[AcpiExec] Method Error: Incorrect numeric result\n");
273 if (AcpiGbl_DebugFile)
275 AcpiOsPrintf ("[AcpiExec] Method Error: Incorrect numeric result\n");
281 printf ("[AcpiExec] Method Error: An operand was overwritten\n");
282 if (AcpiGbl_DebugFile)
284 AcpiOsPrintf ("[AcpiExec] Method Error: An operand was overwritten\n");
291 printf ("[AcpiExec] Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
292 AcpiUtGetNodeName (Device), Device, Value,
293 AcpiUtGetNotifyName (Value));
294 if (AcpiGbl_DebugFile)
296 AcpiOsPrintf ("[AcpiExec] Received a system notify, Value 0x%2.2X\n", Value);
299 (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL);
305 /******************************************************************************
307 * FUNCTION: AeDeviceNotifyHandler
309 * PARAMETERS: Standard notify handler parameters
313 * DESCRIPTION: Device notify handler for AcpiExec utility. Used by the ASL
314 * test suite(s) to communicate errors and other information to
315 * this utility via the Notify() operator.
317 *****************************************************************************/
320 AeDeviceNotifyHandler (
326 printf ("[AcpiExec] Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
327 AcpiUtGetNodeName (Device), Device, Value,
328 AcpiUtGetNotifyName (Value));
329 if (AcpiGbl_DebugFile)
331 AcpiOsPrintf ("[AcpiExec] Received a device notify, Value 0x%2.2X\n", Value);
334 (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL);
338 /******************************************************************************
340 * FUNCTION: AeExceptionHandler
342 * PARAMETERS: Standard exception handler parameters
346 * DESCRIPTION: System exception handler for AcpiExec utility.
348 *****************************************************************************/
352 ACPI_STATUS AmlStatus,
358 ACPI_STATUS NewAmlStatus = AmlStatus;
360 ACPI_BUFFER ReturnObj;
361 ACPI_OBJECT_LIST ArgList;
363 const char *Exception;
366 Exception = AcpiFormatException (AmlStatus);
367 AcpiOsPrintf ("[AcpiExec] Exception %s during execution ", Exception);
370 AcpiOsPrintf ("of method [%4.4s]", (char *) &Name);
374 AcpiOsPrintf ("at module level (table load)");
376 AcpiOsPrintf (" Opcode [%s] @%X\n", AcpiPsGetOpcodeName (Opcode), AmlOffset);
379 * Invoke the _ERR method if present
381 * Setup parameter object
384 ArgList.Pointer = Arg;
386 Arg[0].Type = ACPI_TYPE_INTEGER;
387 Arg[0].Integer.Value = AmlStatus;
389 Arg[1].Type = ACPI_TYPE_STRING;
390 Arg[1].String.Pointer = ACPI_CAST_PTR (char, Exception);
391 Arg[1].String.Length = ACPI_STRLEN (Exception);
393 Arg[2].Type = ACPI_TYPE_INTEGER;
394 Arg[2].Integer.Value = AcpiOsGetThreadId();
396 /* Setup return buffer */
398 ReturnObj.Pointer = NULL;
399 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
401 Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj);
402 if (ACPI_SUCCESS (Status))
404 if (ReturnObj.Pointer)
406 /* Override original status */
408 NewAmlStatus = (ACPI_STATUS)
409 ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value;
411 AcpiOsFree (ReturnObj.Pointer);
414 else if (Status != AE_NOT_FOUND)
416 AcpiOsPrintf ("[AcpiExec] Could not execute _ERR method, %s\n",
417 AcpiFormatException (Status));
420 /* Global override */
422 if (AcpiGbl_IgnoreErrors)
424 NewAmlStatus = AE_OK;
427 if (NewAmlStatus != AmlStatus)
429 AcpiOsPrintf ("[AcpiExec] Exception override, new status %s\n",
430 AcpiFormatException (NewAmlStatus));
433 return (NewAmlStatus);
437 /******************************************************************************
439 * FUNCTION: AeTableHandler
441 * PARAMETERS: Table handler
445 * DESCRIPTION: System table handler for AcpiExec utility.
447 *****************************************************************************/
449 static char *TableEvents[] =
465 if (Event > ACPI_NUM_TABLE_EVENTS)
467 Event = ACPI_NUM_TABLE_EVENTS;
470 /* Enable any GPEs associated with newly-loaded GPE methods */
472 Status = AcpiUpdateAllGpes ();
473 AE_CHECK_OK (AcpiUpdateAllGpes, Status);
475 printf ("[AcpiExec] Table Event %s, [%4.4s] %p\n",
476 TableEvents[Event], ((ACPI_TABLE_HEADER *) Table)->Signature, Table);
481 /******************************************************************************
483 * FUNCTION: AeGpeHandler
485 * DESCRIPTION: Common GPE handler for acpiexec
487 *****************************************************************************/
491 ACPI_HANDLE GpeDevice,
495 ACPI_NAMESPACE_NODE *DeviceNode = (ACPI_NAMESPACE_NODE *) GpeDevice;
498 AcpiOsPrintf ("[AcpiExec] GPE Handler received GPE%02X (GPE block %4.4s)\n",
499 GpeNumber, GpeDevice ? DeviceNode->Name.Ascii : "FADT");
501 return (ACPI_REENABLE_GPE);
505 /******************************************************************************
507 * FUNCTION: AeGlobalEventHandler
509 * DESCRIPTION: Global GPE/Fixed event handler
511 *****************************************************************************/
514 AeGlobalEventHandler (
525 case ACPI_EVENT_TYPE_GPE:
529 case ACPI_EVENT_TYPE_FIXED:
530 TypeName = "FixedEvent";
534 TypeName = "UNKNOWN";
538 AcpiOsPrintf ("[AcpiExec] Global Event Handler received: Type %s Number %.2X Dev %p\n",
539 TypeName, EventNumber, Device);
543 /******************************************************************************
545 * FUNCTION: AeAttachedDataHandler
547 * DESCRIPTION: Handler for deletion of nodes with attached data (attached via
550 *****************************************************************************/
553 AeAttachedDataHandler (
557 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data);
560 AcpiOsPrintf ("Received an attached data deletion on %4.4s\n",
565 /******************************************************************************
567 * FUNCTION: AeInterfaceHandler
569 * DESCRIPTION: Handler for _OSI invocations
571 *****************************************************************************/
575 ACPI_STRING InterfaceName,
578 ACPI_FUNCTION_NAME (AeInterfaceHandler);
581 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
582 "Received _OSI (\"%s\"), is %ssupported\n",
583 InterfaceName, Supported == 0 ? "not " : ""));
589 /******************************************************************************
591 * FUNCTION: AeEventHandler
593 * DESCRIPTION: Handler for Fixed Events
595 *****************************************************************************/
605 /******************************************************************************
607 * FUNCTION: AeRegionInit
613 * DESCRIPTION: Opregion init function.
615 *****************************************************************************/
619 ACPI_HANDLE RegionHandle,
621 void *HandlerContext,
622 void **RegionContext)
625 * Real simple, set the RegionContext to the RegionHandle
627 *RegionContext = RegionHandle;
633 /******************************************************************************
635 * FUNCTION: AeInstallLateHandlers
641 * DESCRIPTION: Install handlers for the AcpiExec utility.
643 *****************************************************************************/
646 AeInstallLateHandlers (
653 /* Install some fixed event handlers */
655 Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, AeEventHandler, NULL);
656 AE_CHECK_OK (AcpiInstallFixedEventHandler, Status);
658 Status = AcpiInstallFixedEventHandler (ACPI_EVENT_RTC, AeEventHandler, NULL);
659 AE_CHECK_OK (AcpiInstallFixedEventHandler, Status);
662 * Install handlers for some of the "device driver" address spaces
663 * such as EC, SMBus, etc.
665 for (i = 0; i < ACPI_ARRAY_LENGTH (SpaceIdList); i++)
667 /* Install handler at the root object */
669 Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode,
670 SpaceIdList[i], AeRegionHandler, AeRegionInit, NULL);
671 if (ACPI_FAILURE (Status))
673 ACPI_EXCEPTION ((AE_INFO, Status,
674 "Could not install an OpRegion handler for %s space(%u)",
675 AcpiUtGetRegionName((UINT8) SpaceIdList[i]), SpaceIdList[i]));
684 /******************************************************************************
686 * FUNCTION: AeInstallEarlyHandlers
692 * DESCRIPTION: Install handlers for the AcpiExec utility.
694 * Notes: Don't install handler for PCI_Config, we want to use the
695 * default handler to exercise that code.
697 *****************************************************************************/
700 AeInstallEarlyHandlers (
708 ACPI_FUNCTION_ENTRY ();
711 Status = AcpiInstallInterfaceHandler (AeInterfaceHandler);
712 if (ACPI_FAILURE (Status))
714 printf ("Could not install interface handler, %s\n",
715 AcpiFormatException (Status));
718 Status = AcpiInstallTableHandler (AeTableHandler, NULL);
719 if (ACPI_FAILURE (Status))
721 printf ("Could not install table handler, %s\n",
722 AcpiFormatException (Status));
725 Status = AcpiInstallExceptionHandler (AeExceptionHandler);
726 if (ACPI_FAILURE (Status))
728 printf ("Could not install exception handler, %s\n",
729 AcpiFormatException (Status));
732 /* Install global notify handler */
734 Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
735 AeNotifyHandler, NULL);
736 if (ACPI_FAILURE (Status))
738 printf ("Could not install a global notify handler, %s\n",
739 AcpiFormatException (Status));
742 Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY,
743 AeDeviceNotifyHandler, NULL);
744 if (ACPI_FAILURE (Status))
746 printf ("Could not install a global notify handler, %s\n",
747 AcpiFormatException (Status));
750 Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
751 if (ACPI_SUCCESS (Status))
753 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
754 AeNotifyHandler, NULL);
755 if (ACPI_FAILURE (Status))
757 printf ("Could not install a notify handler, %s\n",
758 AcpiFormatException (Status));
761 Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
763 if (ACPI_FAILURE (Status))
765 printf ("Could not remove a notify handler, %s\n",
766 AcpiFormatException (Status));
769 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
770 AeNotifyHandler, NULL);
771 AE_CHECK_OK (AcpiInstallNotifyHandler, Status);
773 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
775 AE_CHECK_OK (AcpiRemoveNotifyHandler, Status);
777 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
778 AeNotifyHandler, NULL);
779 if (ACPI_FAILURE (Status))
781 printf ("Could not install a notify handler, %s\n",
782 AcpiFormatException (Status));
785 Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
786 AE_CHECK_OK (AcpiAttachData, Status);
788 Status = AcpiDetachData (Handle, AeAttachedDataHandler);
789 AE_CHECK_OK (AcpiDetachData, Status);
791 Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
792 AE_CHECK_OK (AcpiAttachData, Status);
796 printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
801 * Install handlers that will override the default handlers for some of
804 for (i = 0; i < ACPI_ARRAY_LENGTH (DefaultSpaceIdList); i++)
806 /* Install handler at the root object */
808 Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode,
809 DefaultSpaceIdList[i], AeRegionHandler,
811 if (ACPI_FAILURE (Status))
813 ACPI_EXCEPTION ((AE_INFO, Status,
814 "Could not install a default OpRegion handler for %s space(%u)",
815 AcpiUtGetRegionName ((UINT8) DefaultSpaceIdList[i]),
816 DefaultSpaceIdList[i]));
822 * Initialize the global Region Handler space
825 AeRegions.NumberOfRegions = 0;
826 AeRegions.RegionList = NULL;
831 /******************************************************************************
833 * FUNCTION: AeRegionHandler
835 * PARAMETERS: Standard region handler parameters
839 * DESCRIPTION: Test handler - Handles some dummy regions via memory that can
840 * be manipulated in Ring 3. Simulates actual reads and writes.
842 *****************************************************************************/
847 ACPI_PHYSICAL_ADDRESS Address,
850 void *HandlerContext,
854 ACPI_OPERAND_OBJECT *RegionObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, RegionContext);
855 UINT8 *Buffer = ACPI_CAST_PTR (UINT8, Value);
856 ACPI_PHYSICAL_ADDRESS BaseAddress;
858 BOOLEAN BufferExists;
859 AE_REGION *RegionElement;
867 ACPI_FUNCTION_NAME (AeRegionHandler);
870 * If the object is not a region, simply return
872 if (RegionObject->Region.Type != ACPI_TYPE_REGION)
878 * Region support can be disabled with the -r option.
879 * We use this to support dynamically loaded tables where we pass a valid
880 * address to the AML.
882 if (AcpiGbl_DbOpt_NoRegionSupport)
884 BufferValue = ACPI_TO_POINTER (Address);
885 ByteWidth = (BitWidth / 8);
895 * Find the region's address space and length before searching
898 BaseAddress = RegionObject->Region.Address;
899 Length = (ACPI_SIZE) RegionObject->Region.Length;
900 SpaceId = RegionObject->Region.SpaceId;
902 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Operation Region request on %s at 0x%X\n",
903 AcpiUtGetRegionName (RegionObject->Region.SpaceId),
908 case ACPI_ADR_SPACE_SYSTEM_IO:
910 * For I/O space, exercise the port validation
912 switch (Function & ACPI_IO_MASK)
915 Status = AcpiHwReadPort (Address, (UINT32 *) Value, BitWidth);
916 AE_CHECK_OK (AcpiHwReadPort, Status);
920 Status = AcpiHwWritePort (Address, (UINT32) *Value, BitWidth);
921 AE_CHECK_OK (AcpiHwWritePort, Status);
925 Status = AE_BAD_PARAMETER;
929 if (ACPI_FAILURE (Status))
934 /* Now go ahead and simulate the hardware */
938 case ACPI_ADR_SPACE_SMBUS:
942 switch (Function & ACPI_IO_MASK)
945 switch (Function >> 16)
947 case AML_FIELD_ATTRIB_SMB_QUICK:
948 case AML_FIELD_ATTRIB_SMB_SEND_RCV:
949 case AML_FIELD_ATTRIB_SMB_BYTE:
953 case AML_FIELD_ATTRIB_SMB_WORD:
954 case AML_FIELD_ATTRIB_SMB_WORD_CALL:
958 case AML_FIELD_ATTRIB_SMB_BLOCK:
959 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
969 switch (Function >> 16)
971 case AML_FIELD_ATTRIB_SMB_QUICK:
972 case AML_FIELD_ATTRIB_SMB_SEND_RCV:
973 case AML_FIELD_ATTRIB_SMB_BYTE:
974 case AML_FIELD_ATTRIB_SMB_WORD:
975 case AML_FIELD_ATTRIB_SMB_BLOCK:
979 case AML_FIELD_ATTRIB_SMB_WORD_CALL:
983 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
996 for (i = 0; i < Length; i++)
998 Buffer[i+2] = (UINT8) (0xA0 + i);
1002 Buffer[1] = (UINT8) Length;
1006 case ACPI_ADR_SPACE_IPMI: /* ACPI 4.0 */
1008 AcpiOsPrintf ("AcpiExec: Received IPMI request: "
1009 "Address %X BaseAddress %X Length %X Width %X BufferLength %u\n",
1010 (UINT32) Address, (UINT32) BaseAddress,
1011 Length, BitWidth, Buffer[1]);
1014 * Regardless of a READ or WRITE, this handler is passed a 66-byte
1015 * buffer in which to return the IPMI status/length/data.
1017 * Return some example data to show use of the bidirectional buffer
1019 Buffer[0] = 0; /* Status byte */
1020 Buffer[1] = 64; /* Return buffer data length */
1021 Buffer[2] = 0; /* Completion code */
1022 Buffer[3] = 0x34; /* Power measurement */
1023 Buffer[4] = 0x12; /* Power measurement */
1024 Buffer[65] = 0xEE; /* last buffer byte */
1032 * Search through the linked list for this region's buffer
1034 BufferExists = FALSE;
1035 RegionElement = AeRegions.RegionList;
1037 if (AeRegions.NumberOfRegions)
1039 while (!BufferExists && RegionElement)
1041 if (RegionElement->Address == BaseAddress &&
1042 RegionElement->Length == Length &&
1043 RegionElement->SpaceId == SpaceId)
1045 BufferExists = TRUE;
1049 RegionElement = RegionElement->NextRegion;
1055 * If the Region buffer does not exist, create it now
1060 * Do the memory allocations first
1062 RegionElement = AcpiOsAllocate (sizeof (AE_REGION));
1065 return (AE_NO_MEMORY);
1068 RegionElement->Buffer = AcpiOsAllocate (Length);
1069 if (!RegionElement->Buffer)
1071 AcpiOsFree (RegionElement);
1072 return (AE_NO_MEMORY);
1075 /* Initialize the region with the default fill value */
1077 ACPI_MEMSET (RegionElement->Buffer, AcpiGbl_RegionFillValue, Length);
1079 RegionElement->Address = BaseAddress;
1080 RegionElement->Length = Length;
1081 RegionElement->SpaceId = SpaceId;
1082 RegionElement->NextRegion = NULL;
1085 * Increment the number of regions and put this one
1086 * at the head of the list as it will probably get accessed
1087 * more often anyway.
1089 AeRegions.NumberOfRegions += 1;
1091 if (AeRegions.RegionList)
1093 RegionElement->NextRegion = AeRegions.RegionList;
1096 AeRegions.RegionList = RegionElement;
1100 * Calculate the size of the memory copy
1102 ByteWidth = (BitWidth / 8);
1110 * The buffer exists and is pointed to by RegionElement.
1111 * We now need to verify the request is valid and perform the operation.
1113 * NOTE: RegionElement->Length is in bytes, therefore it we compare against
1114 * ByteWidth (see above)
1116 if (((UINT64) Address + ByteWidth) >
1117 ((UINT64)(RegionElement->Address) + RegionElement->Length))
1119 ACPI_WARNING ((AE_INFO,
1120 "Request on [%4.4s] is beyond region limit Req-0x%X+0x%X, Base=0x%X, Len-0x%X",
1121 (RegionObject->Region.Node)->Name.Ascii, (UINT32) Address,
1122 ByteWidth, (UINT32)(RegionElement->Address),
1123 RegionElement->Length));
1125 return (AE_AML_REGION_LIMIT);
1129 * Get BufferValue to point to the "address" in the buffer
1131 BufferValue = ((UINT8 *) RegionElement->Buffer +
1132 ((UINT64) Address - (UINT64) RegionElement->Address));
1137 * Perform a read or write to the buffer space
1143 * Set the pointer Value to whatever is in the buffer
1145 ACPI_MEMCPY (Value, BufferValue, ByteWidth);
1150 * Write the contents of Value to the buffer
1152 ACPI_MEMCPY (BufferValue, Value, ByteWidth);
1156 return (AE_BAD_PARAMETER);