1 /*******************************************************************************
3 * Module Name: dbtest - Various debug-related tests
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2015, 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 *****************************************************************************/
117 #include "accommon.h"
119 #include "acnamesp.h"
120 #include "acpredef.h"
124 #define _COMPONENT ACPI_CA_DEBUGGER
125 ACPI_MODULE_NAME ("dbtest")
128 /* Local prototypes */
131 AcpiDbTestAllObjects (
135 AcpiDbTestOneObject (
136 ACPI_HANDLE ObjHandle,
142 AcpiDbTestIntegerType (
143 ACPI_NAMESPACE_NODE *Node,
147 AcpiDbTestBufferType (
148 ACPI_NAMESPACE_NODE *Node,
152 AcpiDbTestStringType (
153 ACPI_NAMESPACE_NODE *Node,
157 AcpiDbReadFromObject (
158 ACPI_NAMESPACE_NODE *Node,
159 ACPI_OBJECT_TYPE ExpectedType,
160 ACPI_OBJECT **Value);
163 AcpiDbWriteToObject (
164 ACPI_NAMESPACE_NODE *Node,
168 AcpiDbEvaluateAllPredefinedNames (
172 AcpiDbEvaluateOnePredefinedName (
173 ACPI_HANDLE ObjHandle,
181 static ACPI_DB_ARGUMENT_INFO AcpiDbTestTypes [] =
185 {NULL} /* Must be null terminated */
188 #define CMD_TEST_OBJECTS 0
189 #define CMD_TEST_PREDEFINED 1
191 #define BUFFER_FILL_VALUE 0xFF
194 * Support for the special debugger read/write control methods.
195 * These methods are installed into the current namespace and are
196 * used to read and write the various namespace objects. The point
197 * is to force the AML interpreter do all of the work.
199 #define ACPI_DB_READ_METHOD "\\_T98"
200 #define ACPI_DB_WRITE_METHOD "\\_T99"
202 static ACPI_HANDLE ReadHandle = NULL;
203 static ACPI_HANDLE WriteHandle = NULL;
205 /* ASL Definitions of the debugger read/write control methods */
208 DefinitionBlock ("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
210 Method (_T98, 1, NotSerialized) /* Read */
212 Return (DeRefOf (Arg0))
215 DefinitionBlock ("ssdt2.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
217 Method (_T99, 2, NotSerialized) /* Write */
224 static unsigned char ReadMethodCode[] =
226 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */
227 0x02,0xC9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
228 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */
229 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
230 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */
231 0x39,0x38,0x01,0xA4,0x83,0x68 /* 00000028 "98...h" */
234 static unsigned char WriteMethodCode[] =
236 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */
237 0x02,0x15,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
238 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */
239 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
240 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */
241 0x39,0x39,0x02,0x70,0x69,0x68 /* 00000028 "99.pih" */
245 /*******************************************************************************
247 * FUNCTION: AcpiDbExecuteTest
249 * PARAMETERS: TypeArg - Subcommand
253 * DESCRIPTION: Execute various debug tests.
255 * Note: Code is prepared for future expansion of the TEST command.
257 ******************************************************************************/
266 AcpiUtStrupr (TypeArg);
267 Temp = AcpiDbMatchArgument (TypeArg, AcpiDbTestTypes);
268 if (Temp == ACPI_TYPE_NOT_FOUND)
270 AcpiOsPrintf ("Invalid or unsupported argument\n");
276 case CMD_TEST_OBJECTS:
278 AcpiDbTestAllObjects ();
281 case CMD_TEST_PREDEFINED:
283 AcpiDbEvaluateAllPredefinedNames (NULL);
292 /*******************************************************************************
294 * FUNCTION: AcpiDbTestAllObjects
300 * DESCRIPTION: This test implements the OBJECTS subcommand. It exercises the
301 * namespace by reading/writing/comparing all data objects such
302 * as integers, strings, buffers, fields, buffer fields, etc.
304 ******************************************************************************/
307 AcpiDbTestAllObjects (
313 /* Install the debugger read-object control method if necessary */
317 Status = AcpiInstallMethod (ReadMethodCode);
318 if (ACPI_FAILURE (Status))
320 AcpiOsPrintf ("%s, Could not install debugger read method\n",
321 AcpiFormatException (Status));
325 Status = AcpiGetHandle (NULL, ACPI_DB_READ_METHOD, &ReadHandle);
326 if (ACPI_FAILURE (Status))
328 AcpiOsPrintf ("Could not obtain handle for debug method %s\n",
329 ACPI_DB_READ_METHOD);
334 /* Install the debugger write-object control method if necessary */
338 Status = AcpiInstallMethod (WriteMethodCode);
339 if (ACPI_FAILURE (Status))
341 AcpiOsPrintf ("%s, Could not install debugger write method\n",
342 AcpiFormatException (Status));
346 Status = AcpiGetHandle (NULL, ACPI_DB_WRITE_METHOD, &WriteHandle);
347 if (ACPI_FAILURE (Status))
349 AcpiOsPrintf ("Could not obtain handle for debug method %s\n",
350 ACPI_DB_WRITE_METHOD);
355 /* Walk the entire namespace, testing each supported named data object */
357 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
358 ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL);
362 /*******************************************************************************
364 * FUNCTION: AcpiDbTestOneObject
366 * PARAMETERS: ACPI_WALK_CALLBACK
370 * DESCRIPTION: Test one namespace object. Supported types are Integer,
371 * String, Buffer, BufferField, and FieldUnit. All other object
372 * types are simply ignored.
374 * Note: Support for Packages is not implemented.
376 ******************************************************************************/
379 AcpiDbTestOneObject (
380 ACPI_HANDLE ObjHandle,
385 ACPI_NAMESPACE_NODE *Node;
386 ACPI_OPERAND_OBJECT *ObjDesc;
387 ACPI_OPERAND_OBJECT *RegionObj;
388 ACPI_OBJECT_TYPE LocalType;
389 UINT32 BitLength = 0;
390 UINT32 ByteLength = 0;
391 ACPI_STATUS Status = AE_OK;
394 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
395 ObjDesc = Node->Object;
398 * For the supported types, get the actual bit length or
399 * byte length. Map the type to one of Integer/String/Buffer.
403 case ACPI_TYPE_INTEGER:
405 /* Integer width is either 32 or 64 */
407 LocalType = ACPI_TYPE_INTEGER;
408 BitLength = AcpiGbl_IntegerBitWidth;
411 case ACPI_TYPE_STRING:
413 LocalType = ACPI_TYPE_STRING;
414 ByteLength = ObjDesc->String.Length;
417 case ACPI_TYPE_BUFFER:
419 LocalType = ACPI_TYPE_BUFFER;
420 ByteLength = ObjDesc->Buffer.Length;
421 BitLength = ByteLength * 8;
424 case ACPI_TYPE_FIELD_UNIT:
425 case ACPI_TYPE_BUFFER_FIELD:
426 case ACPI_TYPE_LOCAL_REGION_FIELD:
427 case ACPI_TYPE_LOCAL_INDEX_FIELD:
428 case ACPI_TYPE_LOCAL_BANK_FIELD:
430 LocalType = ACPI_TYPE_INTEGER;
434 * Returned object will be a Buffer if the field length
435 * is larger than the size of an Integer (32 or 64 bits
436 * depending on the DSDT version).
438 BitLength = ObjDesc->CommonField.BitLength;
439 ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
440 if (BitLength > AcpiGbl_IntegerBitWidth)
442 LocalType = ACPI_TYPE_BUFFER;
449 /* Ignore all other types */
454 /* Emit the common prefix: Type:Name */
456 AcpiOsPrintf ("%14s: %4.4s",
457 AcpiUtGetTypeName (Node->Type), Node->Name.Ascii);
460 AcpiOsPrintf (" Ignoring, no attached object\n");
465 * Check for unsupported region types. Note: AcpiExec simulates
466 * access to SystemMemory, SystemIO, PCI_Config, and EC.
470 case ACPI_TYPE_LOCAL_REGION_FIELD:
472 RegionObj = ObjDesc->Field.RegionObj;
473 switch (RegionObj->Region.SpaceId)
475 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
476 case ACPI_ADR_SPACE_SYSTEM_IO:
477 case ACPI_ADR_SPACE_PCI_CONFIG:
478 case ACPI_ADR_SPACE_EC:
484 AcpiOsPrintf (" %s space is not supported [%4.4s]\n",
485 AcpiUtGetRegionName (RegionObj->Region.SpaceId),
486 RegionObj->Region.Node->Name.Ascii);
495 /* At this point, we have resolved the object to one of the major types */
499 case ACPI_TYPE_INTEGER:
501 Status = AcpiDbTestIntegerType (Node, BitLength);
504 case ACPI_TYPE_STRING:
506 Status = AcpiDbTestStringType (Node, ByteLength);
509 case ACPI_TYPE_BUFFER:
511 Status = AcpiDbTestBufferType (Node, BitLength);
516 AcpiOsPrintf (" Ignoring, type not implemented (%2.2X)",
523 case ACPI_TYPE_LOCAL_REGION_FIELD:
525 RegionObj = ObjDesc->Field.RegionObj;
526 AcpiOsPrintf (" (%s)",
527 AcpiUtGetRegionName (RegionObj->Region.SpaceId));
539 /*******************************************************************************
541 * FUNCTION: AcpiDbTestIntegerType
543 * PARAMETERS: Node - Parent NS node for the object
544 * BitLength - Actual length of the object. Used for
545 * support of arbitrary length FieldUnit
546 * and BufferField objects.
550 * DESCRIPTION: Test read/write for an Integer-valued object. Performs a
551 * write/read/compare of an arbitrary new value, then performs
552 * a write/read/compare of the original value.
554 ******************************************************************************/
557 AcpiDbTestIntegerType (
558 ACPI_NAMESPACE_NODE *Node,
561 ACPI_OBJECT *Temp1 = NULL;
562 ACPI_OBJECT *Temp2 = NULL;
563 ACPI_OBJECT *Temp3 = NULL;
564 ACPI_OBJECT WriteValue;
571 AcpiOsPrintf (" Invalid length for an Integer: %u", BitLength);
575 /* Read the original value */
577 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp1);
578 if (ACPI_FAILURE (Status))
583 AcpiOsPrintf (" (%4.4X/%3.3X) %8.8X%8.8X",
584 BitLength, ACPI_ROUND_BITS_UP_TO_BYTES (BitLength),
585 ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
587 ValueToWrite = ACPI_UINT64_MAX >> (64 - BitLength);
588 if (Temp1->Integer.Value == ValueToWrite)
593 /* Write a new value */
595 WriteValue.Type = ACPI_TYPE_INTEGER;
596 WriteValue.Integer.Value = ValueToWrite;
597 Status = AcpiDbWriteToObject (Node, &WriteValue);
598 if (ACPI_FAILURE (Status))
603 /* Ensure that we can read back the new value */
605 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp2);
606 if (ACPI_FAILURE (Status))
611 if (Temp2->Integer.Value != ValueToWrite)
613 AcpiOsPrintf (" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
614 ACPI_FORMAT_UINT64 (Temp2->Integer.Value),
615 ACPI_FORMAT_UINT64 (ValueToWrite));
618 /* Write back the original value */
620 WriteValue.Integer.Value = Temp1->Integer.Value;
621 Status = AcpiDbWriteToObject (Node, &WriteValue);
622 if (ACPI_FAILURE (Status))
627 /* Ensure that we can read back the original value */
629 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp3);
630 if (ACPI_FAILURE (Status))
635 if (Temp3->Integer.Value != Temp1->Integer.Value)
637 AcpiOsPrintf (" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
638 ACPI_FORMAT_UINT64 (Temp3->Integer.Value),
639 ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
643 if (Temp1) {AcpiOsFree (Temp1);}
644 if (Temp2) {AcpiOsFree (Temp2);}
645 if (Temp3) {AcpiOsFree (Temp3);}
650 /*******************************************************************************
652 * FUNCTION: AcpiDbTestBufferType
654 * PARAMETERS: Node - Parent NS node for the object
655 * BitLength - Actual length of the object.
659 * DESCRIPTION: Test read/write for an Buffer-valued object. Performs a
660 * write/read/compare of an arbitrary new value, then performs
661 * a write/read/compare of the original value.
663 ******************************************************************************/
666 AcpiDbTestBufferType (
667 ACPI_NAMESPACE_NODE *Node,
670 ACPI_OBJECT *Temp1 = NULL;
671 ACPI_OBJECT *Temp2 = NULL;
672 ACPI_OBJECT *Temp3 = NULL;
674 ACPI_OBJECT WriteValue;
681 ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
684 AcpiOsPrintf (" Ignoring zero length buffer");
688 /* Allocate a local buffer */
690 Buffer = ACPI_ALLOCATE_ZEROED (ByteLength);
693 return (AE_NO_MEMORY);
696 /* Read the original value */
698 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp1);
699 if (ACPI_FAILURE (Status))
704 /* Emit a few bytes of the buffer */
706 AcpiOsPrintf (" (%4.4X/%3.3X)", BitLength, Temp1->Buffer.Length);
707 for (i = 0; ((i < 4) && (i < ByteLength)); i++)
709 AcpiOsPrintf (" %2.2X", Temp1->Buffer.Pointer[i]);
711 AcpiOsPrintf ("... ");
716 * Handle possible extra bits at the end of the buffer. Can
717 * happen for FieldUnits larger than an integer, but the bit
718 * count is not an integral number of bytes. Zero out the
721 ACPI_MEMSET (Buffer, BUFFER_FILL_VALUE, ByteLength);
722 ExtraBits = BitLength % 8;
725 Buffer [ByteLength - 1] = ACPI_MASK_BITS_ABOVE (ExtraBits);
728 WriteValue.Type = ACPI_TYPE_BUFFER;
729 WriteValue.Buffer.Length = ByteLength;
730 WriteValue.Buffer.Pointer = Buffer;
732 Status = AcpiDbWriteToObject (Node, &WriteValue);
733 if (ACPI_FAILURE (Status))
738 /* Ensure that we can read back the new value */
740 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp2);
741 if (ACPI_FAILURE (Status))
746 if (ACPI_MEMCMP (Temp2->Buffer.Pointer, Buffer, ByteLength))
748 AcpiOsPrintf (" MISMATCH 2: New buffer value");
751 /* Write back the original value */
753 WriteValue.Buffer.Length = ByteLength;
754 WriteValue.Buffer.Pointer = Temp1->Buffer.Pointer;
756 Status = AcpiDbWriteToObject (Node, &WriteValue);
757 if (ACPI_FAILURE (Status))
762 /* Ensure that we can read back the original value */
764 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp3);
765 if (ACPI_FAILURE (Status))
770 if (ACPI_MEMCMP (Temp1->Buffer.Pointer, Temp3->Buffer.Pointer, ByteLength))
772 AcpiOsPrintf (" MISMATCH 3: While restoring original buffer");
777 if (Temp1) {AcpiOsFree (Temp1);}
778 if (Temp2) {AcpiOsFree (Temp2);}
779 if (Temp3) {AcpiOsFree (Temp3);}
784 /*******************************************************************************
786 * FUNCTION: AcpiDbTestStringType
788 * PARAMETERS: Node - Parent NS node for the object
789 * ByteLength - Actual length of the object.
793 * DESCRIPTION: Test read/write for an String-valued object. Performs a
794 * write/read/compare of an arbitrary new value, then performs
795 * a write/read/compare of the original value.
797 ******************************************************************************/
800 AcpiDbTestStringType (
801 ACPI_NAMESPACE_NODE *Node,
804 ACPI_OBJECT *Temp1 = NULL;
805 ACPI_OBJECT *Temp2 = NULL;
806 ACPI_OBJECT *Temp3 = NULL;
807 char *ValueToWrite = "Test String from AML Debugger";
808 ACPI_OBJECT WriteValue;
812 /* Read the original value */
814 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp1);
815 if (ACPI_FAILURE (Status))
820 AcpiOsPrintf (" (%4.4X/%3.3X) \"%s\"", (Temp1->String.Length * 8),
821 Temp1->String.Length, Temp1->String.Pointer);
823 /* Write a new value */
825 WriteValue.Type = ACPI_TYPE_STRING;
826 WriteValue.String.Length = ACPI_STRLEN (ValueToWrite);
827 WriteValue.String.Pointer = ValueToWrite;
829 Status = AcpiDbWriteToObject (Node, &WriteValue);
830 if (ACPI_FAILURE (Status))
835 /* Ensure that we can read back the new value */
837 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp2);
838 if (ACPI_FAILURE (Status))
843 if (ACPI_STRCMP (Temp2->String.Pointer, ValueToWrite))
845 AcpiOsPrintf (" MISMATCH 2: %s, expecting %s",
846 Temp2->String.Pointer, ValueToWrite);
849 /* Write back the original value */
851 WriteValue.String.Length = ACPI_STRLEN (Temp1->String.Pointer);
852 WriteValue.String.Pointer = Temp1->String.Pointer;
854 Status = AcpiDbWriteToObject (Node, &WriteValue);
855 if (ACPI_FAILURE (Status))
860 /* Ensure that we can read back the original value */
862 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp3);
863 if (ACPI_FAILURE (Status))
868 if (ACPI_STRCMP (Temp1->String.Pointer, Temp3->String.Pointer))
870 AcpiOsPrintf (" MISMATCH 3: %s, expecting %s",
871 Temp3->String.Pointer, Temp1->String.Pointer);
875 if (Temp1) {AcpiOsFree (Temp1);}
876 if (Temp2) {AcpiOsFree (Temp2);}
877 if (Temp3) {AcpiOsFree (Temp3);}
882 /*******************************************************************************
884 * FUNCTION: AcpiDbReadFromObject
886 * PARAMETERS: Node - Parent NS node for the object
887 * ExpectedType - Object type expected from the read
888 * Value - Where the value read is returned
892 * DESCRIPTION: Performs a read from the specified object by invoking the
893 * special debugger control method that reads the object. Thus,
894 * the AML interpreter is doing all of the work, increasing the
895 * validity of the test.
897 ******************************************************************************/
900 AcpiDbReadFromObject (
901 ACPI_NAMESPACE_NODE *Node,
902 ACPI_OBJECT_TYPE ExpectedType,
905 ACPI_OBJECT *RetValue;
906 ACPI_OBJECT_LIST ParamObjects;
907 ACPI_OBJECT Params[2];
908 ACPI_BUFFER ReturnObj;
912 Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
913 Params[0].Reference.ActualType = Node->Type;
914 Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
916 ParamObjects.Count = 1;
917 ParamObjects.Pointer = Params;
919 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
921 AcpiGbl_MethodExecuting = TRUE;
922 Status = AcpiEvaluateObject (ReadHandle, NULL, &ParamObjects, &ReturnObj);
923 AcpiGbl_MethodExecuting = FALSE;
925 if (ACPI_FAILURE (Status))
927 AcpiOsPrintf ("Could not read from object, %s",
928 AcpiFormatException (Status));
932 RetValue = (ACPI_OBJECT *) ReturnObj.Pointer;
934 switch (RetValue->Type)
936 case ACPI_TYPE_INTEGER:
937 case ACPI_TYPE_BUFFER:
938 case ACPI_TYPE_STRING:
940 * Did we receive the type we wanted? Most important for the
941 * Integer/Buffer case (when a field is larger than an Integer,
942 * it should return a Buffer).
944 if (RetValue->Type != ExpectedType)
946 AcpiOsPrintf (" Type mismatch: Expected %s, Received %s",
947 AcpiUtGetTypeName (ExpectedType),
948 AcpiUtGetTypeName (RetValue->Type));
958 AcpiOsPrintf (" Unsupported return object type, %s",
959 AcpiUtGetTypeName (RetValue->Type));
960 AcpiOsFree (ReturnObj.Pointer);
969 /*******************************************************************************
971 * FUNCTION: AcpiDbWriteToObject
973 * PARAMETERS: Node - Parent NS node for the object
974 * Value - Value to be written
978 * DESCRIPTION: Performs a write to the specified object by invoking the
979 * special debugger control method that writes the object. Thus,
980 * the AML interpreter is doing all of the work, increasing the
981 * validity of the test.
983 ******************************************************************************/
986 AcpiDbWriteToObject (
987 ACPI_NAMESPACE_NODE *Node,
990 ACPI_OBJECT_LIST ParamObjects;
991 ACPI_OBJECT Params[2];
995 Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
996 Params[0].Reference.ActualType = Node->Type;
997 Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
999 /* Copy the incoming user parameter */
1001 ACPI_MEMCPY (&Params[1], Value, sizeof (ACPI_OBJECT));
1003 ParamObjects.Count = 2;
1004 ParamObjects.Pointer = Params;
1006 AcpiGbl_MethodExecuting = TRUE;
1007 Status = AcpiEvaluateObject (WriteHandle, NULL, &ParamObjects, NULL);
1008 AcpiGbl_MethodExecuting = FALSE;
1010 if (ACPI_FAILURE (Status))
1012 AcpiOsPrintf ("Could not write to object, %s",
1013 AcpiFormatException (Status));
1020 /*******************************************************************************
1022 * FUNCTION: AcpiDbEvaluateAllPredefinedNames
1024 * PARAMETERS: CountArg - Max number of methods to execute
1028 * DESCRIPTION: Namespace batch execution. Execute predefined names in the
1029 * namespace, up to the max count, if specified.
1031 ******************************************************************************/
1034 AcpiDbEvaluateAllPredefinedNames (
1037 ACPI_DB_EXECUTE_WALK Info;
1041 Info.MaxCount = ACPI_UINT32_MAX;
1045 Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
1048 /* Search all nodes in namespace */
1050 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1051 AcpiDbEvaluateOnePredefinedName, NULL, (void *) &Info, NULL);
1053 AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count);
1057 /*******************************************************************************
1059 * FUNCTION: AcpiDbEvaluateOnePredefinedName
1061 * PARAMETERS: Callback from WalkNamespace
1065 * DESCRIPTION: Batch execution module. Currently only executes predefined
1068 ******************************************************************************/
1071 AcpiDbEvaluateOnePredefinedName (
1072 ACPI_HANDLE ObjHandle,
1073 UINT32 NestingLevel,
1077 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1078 ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context;
1080 const ACPI_PREDEFINED_INFO *Predefined;
1081 ACPI_DEVICE_INFO *ObjInfo;
1082 ACPI_OBJECT_LIST ParamObjects;
1083 ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
1084 ACPI_OBJECT *ThisParam;
1085 ACPI_BUFFER ReturnObj;
1093 /* The name must be a predefined ACPI name */
1095 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
1101 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
1106 Pathname = AcpiNsGetExternalPathname (Node);
1112 /* Get the object info for number of method parameters */
1114 Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
1115 if (ACPI_FAILURE (Status))
1117 ACPI_FREE (Pathname);
1121 ParamObjects.Count = 0;
1122 ParamObjects.Pointer = NULL;
1124 if (ObjInfo->Type == ACPI_TYPE_METHOD)
1126 /* Setup default parameters (with proper types) */
1128 ArgTypeList = Predefined->Info.ArgumentList;
1129 ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
1132 * Setup the ACPI-required number of arguments, regardless of what
1133 * the actual method defines. If there is a difference, then the
1134 * method is wrong and a warning will be issued during execution.
1137 for (i = 0; i < ArgCount; i++)
1139 ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
1140 ThisParam->Type = ArgType;
1144 case ACPI_TYPE_INTEGER:
1146 ThisParam->Integer.Value = 1;
1149 case ACPI_TYPE_STRING:
1151 ThisParam->String.Pointer = "This is the default argument string";
1152 ThisParam->String.Length = ACPI_STRLEN (ThisParam->String.Pointer);
1155 case ACPI_TYPE_BUFFER:
1157 ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
1158 ThisParam->Buffer.Length = 48;
1161 case ACPI_TYPE_PACKAGE:
1163 ThisParam->Package.Elements = NULL;
1164 ThisParam->Package.Count = 0;
1169 AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
1177 ParamObjects.Count = ArgCount;
1178 ParamObjects.Pointer = Params;
1181 ACPI_FREE (ObjInfo);
1182 ReturnObj.Pointer = NULL;
1183 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
1185 /* Do the actual method execution */
1187 AcpiGbl_MethodExecuting = TRUE;
1189 Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
1191 AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
1192 AcpiGbl_MethodExecuting = FALSE;
1193 ACPI_FREE (Pathname);
1195 /* Ignore status from method execution */
1199 /* Update count, check if we have executed enough methods */
1202 if (Info->Count >= Info->MaxCount)
1204 Status = AE_CTRL_TERMINATE;
1210 #endif /* ACPI_DEBUGGER */