1 /*******************************************************************************
3 * Module Name: dbtest - Various debug-related tests
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2017, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acdebug.h>
47 #include <contrib/dev/acpica/include/acnamesp.h>
48 #include <contrib/dev/acpica/include/acpredef.h>
51 #define _COMPONENT ACPI_CA_DEBUGGER
52 ACPI_MODULE_NAME ("dbtest")
55 /* Local prototypes */
58 AcpiDbTestAllObjects (
63 ACPI_HANDLE ObjHandle,
69 AcpiDbTestIntegerType (
70 ACPI_NAMESPACE_NODE *Node,
74 AcpiDbTestBufferType (
75 ACPI_NAMESPACE_NODE *Node,
79 AcpiDbTestStringType (
80 ACPI_NAMESPACE_NODE *Node,
84 AcpiDbReadFromObject (
85 ACPI_NAMESPACE_NODE *Node,
86 ACPI_OBJECT_TYPE ExpectedType,
91 ACPI_NAMESPACE_NODE *Node,
95 AcpiDbEvaluateAllPredefinedNames (
99 AcpiDbEvaluateOnePredefinedName (
100 ACPI_HANDLE ObjHandle,
108 static ACPI_DB_ARGUMENT_INFO AcpiDbTestTypes [] =
112 {NULL} /* Must be null terminated */
115 #define CMD_TEST_OBJECTS 0
116 #define CMD_TEST_PREDEFINED 1
118 #define BUFFER_FILL_VALUE 0xFF
121 * Support for the special debugger read/write control methods.
122 * These methods are installed into the current namespace and are
123 * used to read and write the various namespace objects. The point
124 * is to force the AML interpreter do all of the work.
126 #define ACPI_DB_READ_METHOD "\\_T98"
127 #define ACPI_DB_WRITE_METHOD "\\_T99"
129 static ACPI_HANDLE ReadHandle = NULL;
130 static ACPI_HANDLE WriteHandle = NULL;
132 /* ASL Definitions of the debugger read/write control methods */
135 DefinitionBlock ("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
137 Method (_T98, 1, NotSerialized) /* Read */
139 Return (DeRefOf (Arg0))
142 DefinitionBlock ("ssdt2.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
144 Method (_T99, 2, NotSerialized) /* Write */
151 static unsigned char ReadMethodCode[] =
153 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */
154 0x02,0xC9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
155 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */
156 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
157 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */
158 0x39,0x38,0x01,0xA4,0x83,0x68 /* 00000028 "98...h" */
161 static unsigned char WriteMethodCode[] =
163 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */
164 0x02,0x15,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
165 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */
166 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
167 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */
168 0x39,0x39,0x02,0x70,0x69,0x68 /* 00000028 "99.pih" */
172 /*******************************************************************************
174 * FUNCTION: AcpiDbExecuteTest
176 * PARAMETERS: TypeArg - Subcommand
180 * DESCRIPTION: Execute various debug tests.
182 * Note: Code is prepared for future expansion of the TEST command.
184 ******************************************************************************/
193 AcpiUtStrupr (TypeArg);
194 Temp = AcpiDbMatchArgument (TypeArg, AcpiDbTestTypes);
195 if (Temp == ACPI_TYPE_NOT_FOUND)
197 AcpiOsPrintf ("Invalid or unsupported argument\n");
203 case CMD_TEST_OBJECTS:
205 AcpiDbTestAllObjects ();
208 case CMD_TEST_PREDEFINED:
210 AcpiDbEvaluateAllPredefinedNames (NULL);
219 /*******************************************************************************
221 * FUNCTION: AcpiDbTestAllObjects
227 * DESCRIPTION: This test implements the OBJECTS subcommand. It exercises the
228 * namespace by reading/writing/comparing all data objects such
229 * as integers, strings, buffers, fields, buffer fields, etc.
231 ******************************************************************************/
234 AcpiDbTestAllObjects (
240 /* Install the debugger read-object control method if necessary */
244 Status = AcpiInstallMethod (ReadMethodCode);
245 if (ACPI_FAILURE (Status))
247 AcpiOsPrintf ("%s, Could not install debugger read method\n",
248 AcpiFormatException (Status));
252 Status = AcpiGetHandle (NULL, ACPI_DB_READ_METHOD, &ReadHandle);
253 if (ACPI_FAILURE (Status))
255 AcpiOsPrintf ("Could not obtain handle for debug method %s\n",
256 ACPI_DB_READ_METHOD);
261 /* Install the debugger write-object control method if necessary */
265 Status = AcpiInstallMethod (WriteMethodCode);
266 if (ACPI_FAILURE (Status))
268 AcpiOsPrintf ("%s, Could not install debugger write method\n",
269 AcpiFormatException (Status));
273 Status = AcpiGetHandle (NULL, ACPI_DB_WRITE_METHOD, &WriteHandle);
274 if (ACPI_FAILURE (Status))
276 AcpiOsPrintf ("Could not obtain handle for debug method %s\n",
277 ACPI_DB_WRITE_METHOD);
282 /* Walk the entire namespace, testing each supported named data object */
284 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
285 ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL);
289 /*******************************************************************************
291 * FUNCTION: AcpiDbTestOneObject
293 * PARAMETERS: ACPI_WALK_CALLBACK
297 * DESCRIPTION: Test one namespace object. Supported types are Integer,
298 * String, Buffer, BufferField, and FieldUnit. All other object
299 * types are simply ignored.
301 * Note: Support for Packages is not implemented.
303 ******************************************************************************/
306 AcpiDbTestOneObject (
307 ACPI_HANDLE ObjHandle,
312 ACPI_NAMESPACE_NODE *Node;
313 ACPI_OPERAND_OBJECT *ObjDesc;
314 ACPI_OPERAND_OBJECT *RegionObj;
315 ACPI_OBJECT_TYPE LocalType;
316 UINT32 BitLength = 0;
317 UINT32 ByteLength = 0;
318 ACPI_STATUS Status = AE_OK;
321 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
322 ObjDesc = Node->Object;
325 * For the supported types, get the actual bit length or
326 * byte length. Map the type to one of Integer/String/Buffer.
330 case ACPI_TYPE_INTEGER:
332 /* Integer width is either 32 or 64 */
334 LocalType = ACPI_TYPE_INTEGER;
335 BitLength = AcpiGbl_IntegerBitWidth;
338 case ACPI_TYPE_STRING:
340 LocalType = ACPI_TYPE_STRING;
341 ByteLength = ObjDesc->String.Length;
344 case ACPI_TYPE_BUFFER:
346 LocalType = ACPI_TYPE_BUFFER;
347 ByteLength = ObjDesc->Buffer.Length;
348 BitLength = ByteLength * 8;
351 case ACPI_TYPE_FIELD_UNIT:
352 case ACPI_TYPE_BUFFER_FIELD:
353 case ACPI_TYPE_LOCAL_REGION_FIELD:
354 case ACPI_TYPE_LOCAL_INDEX_FIELD:
355 case ACPI_TYPE_LOCAL_BANK_FIELD:
357 LocalType = ACPI_TYPE_INTEGER;
361 * Returned object will be a Buffer if the field length
362 * is larger than the size of an Integer (32 or 64 bits
363 * depending on the DSDT version).
365 BitLength = ObjDesc->CommonField.BitLength;
366 ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
367 if (BitLength > AcpiGbl_IntegerBitWidth)
369 LocalType = ACPI_TYPE_BUFFER;
376 /* Ignore all other types */
381 /* Emit the common prefix: Type:Name */
383 AcpiOsPrintf ("%14s: %4.4s",
384 AcpiUtGetTypeName (Node->Type), Node->Name.Ascii);
387 AcpiOsPrintf (" Ignoring, no attached object\n");
392 * Check for unsupported region types. Note: AcpiExec simulates
393 * access to SystemMemory, SystemIO, PCI_Config, and EC.
397 case ACPI_TYPE_LOCAL_REGION_FIELD:
399 RegionObj = ObjDesc->Field.RegionObj;
400 switch (RegionObj->Region.SpaceId)
402 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
403 case ACPI_ADR_SPACE_SYSTEM_IO:
404 case ACPI_ADR_SPACE_PCI_CONFIG:
405 case ACPI_ADR_SPACE_EC:
411 AcpiOsPrintf (" %s space is not supported [%4.4s]\n",
412 AcpiUtGetRegionName (RegionObj->Region.SpaceId),
413 RegionObj->Region.Node->Name.Ascii);
422 /* At this point, we have resolved the object to one of the major types */
426 case ACPI_TYPE_INTEGER:
428 Status = AcpiDbTestIntegerType (Node, BitLength);
431 case ACPI_TYPE_STRING:
433 Status = AcpiDbTestStringType (Node, ByteLength);
436 case ACPI_TYPE_BUFFER:
438 Status = AcpiDbTestBufferType (Node, BitLength);
443 AcpiOsPrintf (" Ignoring, type not implemented (%2.2X)",
450 case ACPI_TYPE_LOCAL_REGION_FIELD:
452 RegionObj = ObjDesc->Field.RegionObj;
453 AcpiOsPrintf (" (%s)",
454 AcpiUtGetRegionName (RegionObj->Region.SpaceId));
466 /*******************************************************************************
468 * FUNCTION: AcpiDbTestIntegerType
470 * PARAMETERS: Node - Parent NS node for the object
471 * BitLength - Actual length of the object. Used for
472 * support of arbitrary length FieldUnit
473 * and BufferField objects.
477 * DESCRIPTION: Test read/write for an Integer-valued object. Performs a
478 * write/read/compare of an arbitrary new value, then performs
479 * a write/read/compare of the original value.
481 ******************************************************************************/
484 AcpiDbTestIntegerType (
485 ACPI_NAMESPACE_NODE *Node,
488 ACPI_OBJECT *Temp1 = NULL;
489 ACPI_OBJECT *Temp2 = NULL;
490 ACPI_OBJECT *Temp3 = NULL;
491 ACPI_OBJECT WriteValue;
498 AcpiOsPrintf (" Invalid length for an Integer: %u", BitLength);
502 /* Read the original value */
504 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp1);
505 if (ACPI_FAILURE (Status))
510 AcpiOsPrintf (" (%4.4X/%3.3X) %8.8X%8.8X",
511 BitLength, ACPI_ROUND_BITS_UP_TO_BYTES (BitLength),
512 ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
514 ValueToWrite = ACPI_UINT64_MAX >> (64 - BitLength);
515 if (Temp1->Integer.Value == ValueToWrite)
520 /* Write a new value */
522 WriteValue.Type = ACPI_TYPE_INTEGER;
523 WriteValue.Integer.Value = ValueToWrite;
524 Status = AcpiDbWriteToObject (Node, &WriteValue);
525 if (ACPI_FAILURE (Status))
530 /* Ensure that we can read back the new value */
532 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp2);
533 if (ACPI_FAILURE (Status))
538 if (Temp2->Integer.Value != ValueToWrite)
540 AcpiOsPrintf (" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
541 ACPI_FORMAT_UINT64 (Temp2->Integer.Value),
542 ACPI_FORMAT_UINT64 (ValueToWrite));
545 /* Write back the original value */
547 WriteValue.Integer.Value = Temp1->Integer.Value;
548 Status = AcpiDbWriteToObject (Node, &WriteValue);
549 if (ACPI_FAILURE (Status))
554 /* Ensure that we can read back the original value */
556 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp3);
557 if (ACPI_FAILURE (Status))
562 if (Temp3->Integer.Value != Temp1->Integer.Value)
564 AcpiOsPrintf (" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
565 ACPI_FORMAT_UINT64 (Temp3->Integer.Value),
566 ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
570 if (Temp1) {AcpiOsFree (Temp1);}
571 if (Temp2) {AcpiOsFree (Temp2);}
572 if (Temp3) {AcpiOsFree (Temp3);}
577 /*******************************************************************************
579 * FUNCTION: AcpiDbTestBufferType
581 * PARAMETERS: Node - Parent NS node for the object
582 * BitLength - Actual length of the object.
586 * DESCRIPTION: Test read/write for an Buffer-valued object. Performs a
587 * write/read/compare of an arbitrary new value, then performs
588 * a write/read/compare of the original value.
590 ******************************************************************************/
593 AcpiDbTestBufferType (
594 ACPI_NAMESPACE_NODE *Node,
597 ACPI_OBJECT *Temp1 = NULL;
598 ACPI_OBJECT *Temp2 = NULL;
599 ACPI_OBJECT *Temp3 = NULL;
601 ACPI_OBJECT WriteValue;
608 ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
611 AcpiOsPrintf (" Ignoring zero length buffer");
615 /* Allocate a local buffer */
617 Buffer = ACPI_ALLOCATE_ZEROED (ByteLength);
620 return (AE_NO_MEMORY);
623 /* Read the original value */
625 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp1);
626 if (ACPI_FAILURE (Status))
631 /* Emit a few bytes of the buffer */
633 AcpiOsPrintf (" (%4.4X/%3.3X)", BitLength, Temp1->Buffer.Length);
634 for (i = 0; ((i < 4) && (i < ByteLength)); i++)
636 AcpiOsPrintf (" %2.2X", Temp1->Buffer.Pointer[i]);
638 AcpiOsPrintf ("... ");
643 * Handle possible extra bits at the end of the buffer. Can
644 * happen for FieldUnits larger than an integer, but the bit
645 * count is not an integral number of bytes. Zero out the
648 memset (Buffer, BUFFER_FILL_VALUE, ByteLength);
649 ExtraBits = BitLength % 8;
652 Buffer [ByteLength - 1] = ACPI_MASK_BITS_ABOVE (ExtraBits);
655 WriteValue.Type = ACPI_TYPE_BUFFER;
656 WriteValue.Buffer.Length = ByteLength;
657 WriteValue.Buffer.Pointer = Buffer;
659 Status = AcpiDbWriteToObject (Node, &WriteValue);
660 if (ACPI_FAILURE (Status))
665 /* Ensure that we can read back the new value */
667 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp2);
668 if (ACPI_FAILURE (Status))
673 if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength))
675 AcpiOsPrintf (" MISMATCH 2: New buffer value");
678 /* Write back the original value */
680 WriteValue.Buffer.Length = ByteLength;
681 WriteValue.Buffer.Pointer = Temp1->Buffer.Pointer;
683 Status = AcpiDbWriteToObject (Node, &WriteValue);
684 if (ACPI_FAILURE (Status))
689 /* Ensure that we can read back the original value */
691 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp3);
692 if (ACPI_FAILURE (Status))
697 if (memcmp (Temp1->Buffer.Pointer,
698 Temp3->Buffer.Pointer, ByteLength))
700 AcpiOsPrintf (" MISMATCH 3: While restoring original buffer");
705 if (Temp1) {AcpiOsFree (Temp1);}
706 if (Temp2) {AcpiOsFree (Temp2);}
707 if (Temp3) {AcpiOsFree (Temp3);}
712 /*******************************************************************************
714 * FUNCTION: AcpiDbTestStringType
716 * PARAMETERS: Node - Parent NS node for the object
717 * ByteLength - Actual length of the object.
721 * DESCRIPTION: Test read/write for an String-valued object. Performs a
722 * write/read/compare of an arbitrary new value, then performs
723 * a write/read/compare of the original value.
725 ******************************************************************************/
728 AcpiDbTestStringType (
729 ACPI_NAMESPACE_NODE *Node,
732 ACPI_OBJECT *Temp1 = NULL;
733 ACPI_OBJECT *Temp2 = NULL;
734 ACPI_OBJECT *Temp3 = NULL;
735 char *ValueToWrite = "Test String from AML Debugger";
736 ACPI_OBJECT WriteValue;
740 /* Read the original value */
742 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp1);
743 if (ACPI_FAILURE (Status))
748 AcpiOsPrintf (" (%4.4X/%3.3X) \"%s\"", (Temp1->String.Length * 8),
749 Temp1->String.Length, Temp1->String.Pointer);
751 /* Write a new value */
753 WriteValue.Type = ACPI_TYPE_STRING;
754 WriteValue.String.Length = strlen (ValueToWrite);
755 WriteValue.String.Pointer = ValueToWrite;
757 Status = AcpiDbWriteToObject (Node, &WriteValue);
758 if (ACPI_FAILURE (Status))
763 /* Ensure that we can read back the new value */
765 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp2);
766 if (ACPI_FAILURE (Status))
771 if (strcmp (Temp2->String.Pointer, ValueToWrite))
773 AcpiOsPrintf (" MISMATCH 2: %s, expecting %s",
774 Temp2->String.Pointer, ValueToWrite);
777 /* Write back the original value */
779 WriteValue.String.Length = strlen (Temp1->String.Pointer);
780 WriteValue.String.Pointer = Temp1->String.Pointer;
782 Status = AcpiDbWriteToObject (Node, &WriteValue);
783 if (ACPI_FAILURE (Status))
788 /* Ensure that we can read back the original value */
790 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp3);
791 if (ACPI_FAILURE (Status))
796 if (strcmp (Temp1->String.Pointer, Temp3->String.Pointer))
798 AcpiOsPrintf (" MISMATCH 3: %s, expecting %s",
799 Temp3->String.Pointer, Temp1->String.Pointer);
803 if (Temp1) {AcpiOsFree (Temp1);}
804 if (Temp2) {AcpiOsFree (Temp2);}
805 if (Temp3) {AcpiOsFree (Temp3);}
810 /*******************************************************************************
812 * FUNCTION: AcpiDbReadFromObject
814 * PARAMETERS: Node - Parent NS node for the object
815 * ExpectedType - Object type expected from the read
816 * Value - Where the value read is returned
820 * DESCRIPTION: Performs a read from the specified object by invoking the
821 * special debugger control method that reads the object. Thus,
822 * the AML interpreter is doing all of the work, increasing the
823 * validity of the test.
825 ******************************************************************************/
828 AcpiDbReadFromObject (
829 ACPI_NAMESPACE_NODE *Node,
830 ACPI_OBJECT_TYPE ExpectedType,
833 ACPI_OBJECT *RetValue;
834 ACPI_OBJECT_LIST ParamObjects;
835 ACPI_OBJECT Params[2];
836 ACPI_BUFFER ReturnObj;
840 Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
841 Params[0].Reference.ActualType = Node->Type;
842 Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
844 ParamObjects.Count = 1;
845 ParamObjects.Pointer = Params;
847 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
849 AcpiGbl_MethodExecuting = TRUE;
850 Status = AcpiEvaluateObject (ReadHandle, NULL,
851 &ParamObjects, &ReturnObj);
852 AcpiGbl_MethodExecuting = FALSE;
854 if (ACPI_FAILURE (Status))
856 AcpiOsPrintf ("Could not read from object, %s",
857 AcpiFormatException (Status));
861 RetValue = (ACPI_OBJECT *) ReturnObj.Pointer;
863 switch (RetValue->Type)
865 case ACPI_TYPE_INTEGER:
866 case ACPI_TYPE_BUFFER:
867 case ACPI_TYPE_STRING:
869 * Did we receive the type we wanted? Most important for the
870 * Integer/Buffer case (when a field is larger than an Integer,
871 * it should return a Buffer).
873 if (RetValue->Type != ExpectedType)
875 AcpiOsPrintf (" Type mismatch: Expected %s, Received %s",
876 AcpiUtGetTypeName (ExpectedType),
877 AcpiUtGetTypeName (RetValue->Type));
887 AcpiOsPrintf (" Unsupported return object type, %s",
888 AcpiUtGetTypeName (RetValue->Type));
890 AcpiOsFree (ReturnObj.Pointer);
898 /*******************************************************************************
900 * FUNCTION: AcpiDbWriteToObject
902 * PARAMETERS: Node - Parent NS node for the object
903 * Value - Value to be written
907 * DESCRIPTION: Performs a write to the specified object by invoking the
908 * special debugger control method that writes the object. Thus,
909 * the AML interpreter is doing all of the work, increasing the
910 * validity of the test.
912 ******************************************************************************/
915 AcpiDbWriteToObject (
916 ACPI_NAMESPACE_NODE *Node,
919 ACPI_OBJECT_LIST ParamObjects;
920 ACPI_OBJECT Params[2];
924 Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
925 Params[0].Reference.ActualType = Node->Type;
926 Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
928 /* Copy the incoming user parameter */
930 memcpy (&Params[1], Value, sizeof (ACPI_OBJECT));
932 ParamObjects.Count = 2;
933 ParamObjects.Pointer = Params;
935 AcpiGbl_MethodExecuting = TRUE;
936 Status = AcpiEvaluateObject (WriteHandle, NULL, &ParamObjects, NULL);
937 AcpiGbl_MethodExecuting = FALSE;
939 if (ACPI_FAILURE (Status))
941 AcpiOsPrintf ("Could not write to object, %s",
942 AcpiFormatException (Status));
949 /*******************************************************************************
951 * FUNCTION: AcpiDbEvaluateAllPredefinedNames
953 * PARAMETERS: CountArg - Max number of methods to execute
957 * DESCRIPTION: Namespace batch execution. Execute predefined names in the
958 * namespace, up to the max count, if specified.
960 ******************************************************************************/
963 AcpiDbEvaluateAllPredefinedNames (
966 ACPI_DB_EXECUTE_WALK Info;
970 Info.MaxCount = ACPI_UINT32_MAX;
974 Info.MaxCount = strtoul (CountArg, NULL, 0);
977 /* Search all nodes in namespace */
979 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
980 ACPI_UINT32_MAX, AcpiDbEvaluateOnePredefinedName, NULL,
981 (void *) &Info, NULL);
984 "Evaluated %u predefined names in the namespace\n", Info.Count);
988 /*******************************************************************************
990 * FUNCTION: AcpiDbEvaluateOnePredefinedName
992 * PARAMETERS: Callback from WalkNamespace
996 * DESCRIPTION: Batch execution module. Currently only executes predefined
999 ******************************************************************************/
1002 AcpiDbEvaluateOnePredefinedName (
1003 ACPI_HANDLE ObjHandle,
1004 UINT32 NestingLevel,
1008 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1009 ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context;
1011 const ACPI_PREDEFINED_INFO *Predefined;
1012 ACPI_DEVICE_INFO *ObjInfo;
1013 ACPI_OBJECT_LIST ParamObjects;
1014 ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
1015 ACPI_OBJECT *ThisParam;
1016 ACPI_BUFFER ReturnObj;
1024 /* The name must be a predefined ACPI name */
1026 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
1032 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
1037 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
1043 /* Get the object info for number of method parameters */
1045 Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
1046 if (ACPI_FAILURE (Status))
1048 ACPI_FREE (Pathname);
1052 ParamObjects.Count = 0;
1053 ParamObjects.Pointer = NULL;
1055 if (ObjInfo->Type == ACPI_TYPE_METHOD)
1057 /* Setup default parameters (with proper types) */
1059 ArgTypeList = Predefined->Info.ArgumentList;
1060 ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
1063 * Setup the ACPI-required number of arguments, regardless of what
1064 * the actual method defines. If there is a difference, then the
1065 * method is wrong and a warning will be issued during execution.
1068 for (i = 0; i < ArgCount; i++)
1070 ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
1071 ThisParam->Type = ArgType;
1075 case ACPI_TYPE_INTEGER:
1077 ThisParam->Integer.Value = 1;
1080 case ACPI_TYPE_STRING:
1082 ThisParam->String.Pointer =
1083 "This is the default argument string";
1084 ThisParam->String.Length =
1085 strlen (ThisParam->String.Pointer);
1088 case ACPI_TYPE_BUFFER:
1090 ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
1091 ThisParam->Buffer.Length = 48;
1094 case ACPI_TYPE_PACKAGE:
1096 ThisParam->Package.Elements = NULL;
1097 ThisParam->Package.Count = 0;
1102 AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
1110 ParamObjects.Count = ArgCount;
1111 ParamObjects.Pointer = Params;
1114 ACPI_FREE (ObjInfo);
1115 ReturnObj.Pointer = NULL;
1116 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
1118 /* Do the actual method execution */
1120 AcpiGbl_MethodExecuting = TRUE;
1122 Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
1124 AcpiOsPrintf ("%-32s returned %s\n",
1125 Pathname, AcpiFormatException (Status));
1126 AcpiGbl_MethodExecuting = FALSE;
1127 ACPI_FREE (Pathname);
1129 /* Ignore status from method execution */
1133 /* Update count, check if we have executed enough methods */
1136 if (Info->Count >= Info->MaxCount)
1138 Status = AE_CTRL_TERMINATE;