1 /*******************************************************************************
3 * Module Name: dbtest - Various debug-related tests
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2015, 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.
52 #define _COMPONENT ACPI_CA_DEBUGGER
53 ACPI_MODULE_NAME ("dbtest")
56 /* Local prototypes */
59 AcpiDbTestAllObjects (
64 ACPI_HANDLE ObjHandle,
70 AcpiDbTestIntegerType (
71 ACPI_NAMESPACE_NODE *Node,
75 AcpiDbTestBufferType (
76 ACPI_NAMESPACE_NODE *Node,
80 AcpiDbTestStringType (
81 ACPI_NAMESPACE_NODE *Node,
85 AcpiDbReadFromObject (
86 ACPI_NAMESPACE_NODE *Node,
87 ACPI_OBJECT_TYPE ExpectedType,
92 ACPI_NAMESPACE_NODE *Node,
96 AcpiDbEvaluateAllPredefinedNames (
100 AcpiDbEvaluateOnePredefinedName (
101 ACPI_HANDLE ObjHandle,
109 static ACPI_DB_ARGUMENT_INFO AcpiDbTestTypes [] =
113 {NULL} /* Must be null terminated */
116 #define CMD_TEST_OBJECTS 0
117 #define CMD_TEST_PREDEFINED 1
119 #define BUFFER_FILL_VALUE 0xFF
122 * Support for the special debugger read/write control methods.
123 * These methods are installed into the current namespace and are
124 * used to read and write the various namespace objects. The point
125 * is to force the AML interpreter do all of the work.
127 #define ACPI_DB_READ_METHOD "\\_T98"
128 #define ACPI_DB_WRITE_METHOD "\\_T99"
130 static ACPI_HANDLE ReadHandle = NULL;
131 static ACPI_HANDLE WriteHandle = NULL;
133 /* ASL Definitions of the debugger read/write control methods */
136 DefinitionBlock ("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
138 Method (_T98, 1, NotSerialized) /* Read */
140 Return (DeRefOf (Arg0))
143 DefinitionBlock ("ssdt2.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
145 Method (_T99, 2, NotSerialized) /* Write */
152 static unsigned char ReadMethodCode[] =
154 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */
155 0x02,0xC9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
156 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */
157 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
158 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */
159 0x39,0x38,0x01,0xA4,0x83,0x68 /* 00000028 "98...h" */
162 static unsigned char WriteMethodCode[] =
164 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */
165 0x02,0x15,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
166 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */
167 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
168 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */
169 0x39,0x39,0x02,0x70,0x69,0x68 /* 00000028 "99.pih" */
173 /*******************************************************************************
175 * FUNCTION: AcpiDbExecuteTest
177 * PARAMETERS: TypeArg - Subcommand
181 * DESCRIPTION: Execute various debug tests.
183 * Note: Code is prepared for future expansion of the TEST command.
185 ******************************************************************************/
194 AcpiUtStrupr (TypeArg);
195 Temp = AcpiDbMatchArgument (TypeArg, AcpiDbTestTypes);
196 if (Temp == ACPI_TYPE_NOT_FOUND)
198 AcpiOsPrintf ("Invalid or unsupported argument\n");
204 case CMD_TEST_OBJECTS:
206 AcpiDbTestAllObjects ();
209 case CMD_TEST_PREDEFINED:
211 AcpiDbEvaluateAllPredefinedNames (NULL);
220 /*******************************************************************************
222 * FUNCTION: AcpiDbTestAllObjects
228 * DESCRIPTION: This test implements the OBJECTS subcommand. It exercises the
229 * namespace by reading/writing/comparing all data objects such
230 * as integers, strings, buffers, fields, buffer fields, etc.
232 ******************************************************************************/
235 AcpiDbTestAllObjects (
241 /* Install the debugger read-object control method if necessary */
245 Status = AcpiInstallMethod (ReadMethodCode);
246 if (ACPI_FAILURE (Status))
248 AcpiOsPrintf ("%s, Could not install debugger read method\n",
249 AcpiFormatException (Status));
253 Status = AcpiGetHandle (NULL, ACPI_DB_READ_METHOD, &ReadHandle);
254 if (ACPI_FAILURE (Status))
256 AcpiOsPrintf ("Could not obtain handle for debug method %s\n",
257 ACPI_DB_READ_METHOD);
262 /* Install the debugger write-object control method if necessary */
266 Status = AcpiInstallMethod (WriteMethodCode);
267 if (ACPI_FAILURE (Status))
269 AcpiOsPrintf ("%s, Could not install debugger write method\n",
270 AcpiFormatException (Status));
274 Status = AcpiGetHandle (NULL, ACPI_DB_WRITE_METHOD, &WriteHandle);
275 if (ACPI_FAILURE (Status))
277 AcpiOsPrintf ("Could not obtain handle for debug method %s\n",
278 ACPI_DB_WRITE_METHOD);
283 /* Walk the entire namespace, testing each supported named data object */
285 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
286 ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL);
290 /*******************************************************************************
292 * FUNCTION: AcpiDbTestOneObject
294 * PARAMETERS: ACPI_WALK_CALLBACK
298 * DESCRIPTION: Test one namespace object. Supported types are Integer,
299 * String, Buffer, BufferField, and FieldUnit. All other object
300 * types are simply ignored.
302 * Note: Support for Packages is not implemented.
304 ******************************************************************************/
307 AcpiDbTestOneObject (
308 ACPI_HANDLE ObjHandle,
313 ACPI_NAMESPACE_NODE *Node;
314 ACPI_OPERAND_OBJECT *ObjDesc;
315 ACPI_OPERAND_OBJECT *RegionObj;
316 ACPI_OBJECT_TYPE LocalType;
317 UINT32 BitLength = 0;
318 UINT32 ByteLength = 0;
319 ACPI_STATUS Status = AE_OK;
322 Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
323 ObjDesc = Node->Object;
326 * For the supported types, get the actual bit length or
327 * byte length. Map the type to one of Integer/String/Buffer.
331 case ACPI_TYPE_INTEGER:
333 /* Integer width is either 32 or 64 */
335 LocalType = ACPI_TYPE_INTEGER;
336 BitLength = AcpiGbl_IntegerBitWidth;
339 case ACPI_TYPE_STRING:
341 LocalType = ACPI_TYPE_STRING;
342 ByteLength = ObjDesc->String.Length;
345 case ACPI_TYPE_BUFFER:
347 LocalType = ACPI_TYPE_BUFFER;
348 ByteLength = ObjDesc->Buffer.Length;
349 BitLength = ByteLength * 8;
352 case ACPI_TYPE_FIELD_UNIT:
353 case ACPI_TYPE_BUFFER_FIELD:
354 case ACPI_TYPE_LOCAL_REGION_FIELD:
355 case ACPI_TYPE_LOCAL_INDEX_FIELD:
356 case ACPI_TYPE_LOCAL_BANK_FIELD:
358 LocalType = ACPI_TYPE_INTEGER;
362 * Returned object will be a Buffer if the field length
363 * is larger than the size of an Integer (32 or 64 bits
364 * depending on the DSDT version).
366 BitLength = ObjDesc->CommonField.BitLength;
367 ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
368 if (BitLength > AcpiGbl_IntegerBitWidth)
370 LocalType = ACPI_TYPE_BUFFER;
377 /* Ignore all other types */
382 /* Emit the common prefix: Type:Name */
384 AcpiOsPrintf ("%14s: %4.4s",
385 AcpiUtGetTypeName (Node->Type), Node->Name.Ascii);
388 AcpiOsPrintf (" Ignoring, no attached object\n");
393 * Check for unsupported region types. Note: AcpiExec simulates
394 * access to SystemMemory, SystemIO, PCI_Config, and EC.
398 case ACPI_TYPE_LOCAL_REGION_FIELD:
400 RegionObj = ObjDesc->Field.RegionObj;
401 switch (RegionObj->Region.SpaceId)
403 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
404 case ACPI_ADR_SPACE_SYSTEM_IO:
405 case ACPI_ADR_SPACE_PCI_CONFIG:
406 case ACPI_ADR_SPACE_EC:
412 AcpiOsPrintf (" %s space is not supported [%4.4s]\n",
413 AcpiUtGetRegionName (RegionObj->Region.SpaceId),
414 RegionObj->Region.Node->Name.Ascii);
423 /* At this point, we have resolved the object to one of the major types */
427 case ACPI_TYPE_INTEGER:
429 Status = AcpiDbTestIntegerType (Node, BitLength);
432 case ACPI_TYPE_STRING:
434 Status = AcpiDbTestStringType (Node, ByteLength);
437 case ACPI_TYPE_BUFFER:
439 Status = AcpiDbTestBufferType (Node, BitLength);
444 AcpiOsPrintf (" Ignoring, type not implemented (%2.2X)",
451 case ACPI_TYPE_LOCAL_REGION_FIELD:
453 RegionObj = ObjDesc->Field.RegionObj;
454 AcpiOsPrintf (" (%s)",
455 AcpiUtGetRegionName (RegionObj->Region.SpaceId));
467 /*******************************************************************************
469 * FUNCTION: AcpiDbTestIntegerType
471 * PARAMETERS: Node - Parent NS node for the object
472 * BitLength - Actual length of the object. Used for
473 * support of arbitrary length FieldUnit
474 * and BufferField objects.
478 * DESCRIPTION: Test read/write for an Integer-valued object. Performs a
479 * write/read/compare of an arbitrary new value, then performs
480 * a write/read/compare of the original value.
482 ******************************************************************************/
485 AcpiDbTestIntegerType (
486 ACPI_NAMESPACE_NODE *Node,
489 ACPI_OBJECT *Temp1 = NULL;
490 ACPI_OBJECT *Temp2 = NULL;
491 ACPI_OBJECT *Temp3 = NULL;
492 ACPI_OBJECT WriteValue;
499 AcpiOsPrintf (" Invalid length for an Integer: %u", BitLength);
503 /* Read the original value */
505 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp1);
506 if (ACPI_FAILURE (Status))
511 AcpiOsPrintf (" (%4.4X/%3.3X) %8.8X%8.8X",
512 BitLength, ACPI_ROUND_BITS_UP_TO_BYTES (BitLength),
513 ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
515 ValueToWrite = ACPI_UINT64_MAX >> (64 - BitLength);
516 if (Temp1->Integer.Value == ValueToWrite)
521 /* Write a new value */
523 WriteValue.Type = ACPI_TYPE_INTEGER;
524 WriteValue.Integer.Value = ValueToWrite;
525 Status = AcpiDbWriteToObject (Node, &WriteValue);
526 if (ACPI_FAILURE (Status))
531 /* Ensure that we can read back the new value */
533 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp2);
534 if (ACPI_FAILURE (Status))
539 if (Temp2->Integer.Value != ValueToWrite)
541 AcpiOsPrintf (" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
542 ACPI_FORMAT_UINT64 (Temp2->Integer.Value),
543 ACPI_FORMAT_UINT64 (ValueToWrite));
546 /* Write back the original value */
548 WriteValue.Integer.Value = Temp1->Integer.Value;
549 Status = AcpiDbWriteToObject (Node, &WriteValue);
550 if (ACPI_FAILURE (Status))
555 /* Ensure that we can read back the original value */
557 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp3);
558 if (ACPI_FAILURE (Status))
563 if (Temp3->Integer.Value != Temp1->Integer.Value)
565 AcpiOsPrintf (" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
566 ACPI_FORMAT_UINT64 (Temp3->Integer.Value),
567 ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
571 if (Temp1) {AcpiOsFree (Temp1);}
572 if (Temp2) {AcpiOsFree (Temp2);}
573 if (Temp3) {AcpiOsFree (Temp3);}
578 /*******************************************************************************
580 * FUNCTION: AcpiDbTestBufferType
582 * PARAMETERS: Node - Parent NS node for the object
583 * BitLength - Actual length of the object.
587 * DESCRIPTION: Test read/write for an Buffer-valued object. Performs a
588 * write/read/compare of an arbitrary new value, then performs
589 * a write/read/compare of the original value.
591 ******************************************************************************/
594 AcpiDbTestBufferType (
595 ACPI_NAMESPACE_NODE *Node,
598 ACPI_OBJECT *Temp1 = NULL;
599 ACPI_OBJECT *Temp2 = NULL;
600 ACPI_OBJECT *Temp3 = NULL;
602 ACPI_OBJECT WriteValue;
609 ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
612 AcpiOsPrintf (" Ignoring zero length buffer");
616 /* Allocate a local buffer */
618 Buffer = ACPI_ALLOCATE_ZEROED (ByteLength);
621 return (AE_NO_MEMORY);
624 /* Read the original value */
626 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp1);
627 if (ACPI_FAILURE (Status))
632 /* Emit a few bytes of the buffer */
634 AcpiOsPrintf (" (%4.4X/%3.3X)", BitLength, Temp1->Buffer.Length);
635 for (i = 0; ((i < 4) && (i < ByteLength)); i++)
637 AcpiOsPrintf (" %2.2X", Temp1->Buffer.Pointer[i]);
639 AcpiOsPrintf ("... ");
644 * Handle possible extra bits at the end of the buffer. Can
645 * happen for FieldUnits larger than an integer, but the bit
646 * count is not an integral number of bytes. Zero out the
649 memset (Buffer, BUFFER_FILL_VALUE, ByteLength);
650 ExtraBits = BitLength % 8;
653 Buffer [ByteLength - 1] = ACPI_MASK_BITS_ABOVE (ExtraBits);
656 WriteValue.Type = ACPI_TYPE_BUFFER;
657 WriteValue.Buffer.Length = ByteLength;
658 WriteValue.Buffer.Pointer = Buffer;
660 Status = AcpiDbWriteToObject (Node, &WriteValue);
661 if (ACPI_FAILURE (Status))
666 /* Ensure that we can read back the new value */
668 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp2);
669 if (ACPI_FAILURE (Status))
674 if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength))
676 AcpiOsPrintf (" MISMATCH 2: New buffer value");
679 /* Write back the original value */
681 WriteValue.Buffer.Length = ByteLength;
682 WriteValue.Buffer.Pointer = Temp1->Buffer.Pointer;
684 Status = AcpiDbWriteToObject (Node, &WriteValue);
685 if (ACPI_FAILURE (Status))
690 /* Ensure that we can read back the original value */
692 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp3);
693 if (ACPI_FAILURE (Status))
698 if (memcmp (Temp1->Buffer.Pointer,
699 Temp3->Buffer.Pointer, ByteLength))
701 AcpiOsPrintf (" MISMATCH 3: While restoring original buffer");
706 if (Temp1) {AcpiOsFree (Temp1);}
707 if (Temp2) {AcpiOsFree (Temp2);}
708 if (Temp3) {AcpiOsFree (Temp3);}
713 /*******************************************************************************
715 * FUNCTION: AcpiDbTestStringType
717 * PARAMETERS: Node - Parent NS node for the object
718 * ByteLength - Actual length of the object.
722 * DESCRIPTION: Test read/write for an String-valued object. Performs a
723 * write/read/compare of an arbitrary new value, then performs
724 * a write/read/compare of the original value.
726 ******************************************************************************/
729 AcpiDbTestStringType (
730 ACPI_NAMESPACE_NODE *Node,
733 ACPI_OBJECT *Temp1 = NULL;
734 ACPI_OBJECT *Temp2 = NULL;
735 ACPI_OBJECT *Temp3 = NULL;
736 char *ValueToWrite = "Test String from AML Debugger";
737 ACPI_OBJECT WriteValue;
741 /* Read the original value */
743 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp1);
744 if (ACPI_FAILURE (Status))
749 AcpiOsPrintf (" (%4.4X/%3.3X) \"%s\"", (Temp1->String.Length * 8),
750 Temp1->String.Length, Temp1->String.Pointer);
752 /* Write a new value */
754 WriteValue.Type = ACPI_TYPE_STRING;
755 WriteValue.String.Length = strlen (ValueToWrite);
756 WriteValue.String.Pointer = ValueToWrite;
758 Status = AcpiDbWriteToObject (Node, &WriteValue);
759 if (ACPI_FAILURE (Status))
764 /* Ensure that we can read back the new value */
766 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp2);
767 if (ACPI_FAILURE (Status))
772 if (strcmp (Temp2->String.Pointer, ValueToWrite))
774 AcpiOsPrintf (" MISMATCH 2: %s, expecting %s",
775 Temp2->String.Pointer, ValueToWrite);
778 /* Write back the original value */
780 WriteValue.String.Length = strlen (Temp1->String.Pointer);
781 WriteValue.String.Pointer = Temp1->String.Pointer;
783 Status = AcpiDbWriteToObject (Node, &WriteValue);
784 if (ACPI_FAILURE (Status))
789 /* Ensure that we can read back the original value */
791 Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp3);
792 if (ACPI_FAILURE (Status))
797 if (strcmp (Temp1->String.Pointer, Temp3->String.Pointer))
799 AcpiOsPrintf (" MISMATCH 3: %s, expecting %s",
800 Temp3->String.Pointer, Temp1->String.Pointer);
804 if (Temp1) {AcpiOsFree (Temp1);}
805 if (Temp2) {AcpiOsFree (Temp2);}
806 if (Temp3) {AcpiOsFree (Temp3);}
811 /*******************************************************************************
813 * FUNCTION: AcpiDbReadFromObject
815 * PARAMETERS: Node - Parent NS node for the object
816 * ExpectedType - Object type expected from the read
817 * Value - Where the value read is returned
821 * DESCRIPTION: Performs a read from the specified object by invoking the
822 * special debugger control method that reads the object. Thus,
823 * the AML interpreter is doing all of the work, increasing the
824 * validity of the test.
826 ******************************************************************************/
829 AcpiDbReadFromObject (
830 ACPI_NAMESPACE_NODE *Node,
831 ACPI_OBJECT_TYPE ExpectedType,
834 ACPI_OBJECT *RetValue;
835 ACPI_OBJECT_LIST ParamObjects;
836 ACPI_OBJECT Params[2];
837 ACPI_BUFFER ReturnObj;
841 Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
842 Params[0].Reference.ActualType = Node->Type;
843 Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
845 ParamObjects.Count = 1;
846 ParamObjects.Pointer = Params;
848 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
850 AcpiGbl_MethodExecuting = TRUE;
851 Status = AcpiEvaluateObject (ReadHandle, NULL,
852 &ParamObjects, &ReturnObj);
853 AcpiGbl_MethodExecuting = FALSE;
855 if (ACPI_FAILURE (Status))
857 AcpiOsPrintf ("Could not read from object, %s",
858 AcpiFormatException (Status));
862 RetValue = (ACPI_OBJECT *) ReturnObj.Pointer;
864 switch (RetValue->Type)
866 case ACPI_TYPE_INTEGER:
867 case ACPI_TYPE_BUFFER:
868 case ACPI_TYPE_STRING:
870 * Did we receive the type we wanted? Most important for the
871 * Integer/Buffer case (when a field is larger than an Integer,
872 * it should return a Buffer).
874 if (RetValue->Type != ExpectedType)
876 AcpiOsPrintf (" Type mismatch: Expected %s, Received %s",
877 AcpiUtGetTypeName (ExpectedType),
878 AcpiUtGetTypeName (RetValue->Type));
888 AcpiOsPrintf (" Unsupported return object type, %s",
889 AcpiUtGetTypeName (RetValue->Type));
891 AcpiOsFree (ReturnObj.Pointer);
899 /*******************************************************************************
901 * FUNCTION: AcpiDbWriteToObject
903 * PARAMETERS: Node - Parent NS node for the object
904 * Value - Value to be written
908 * DESCRIPTION: Performs a write to the specified object by invoking the
909 * special debugger control method that writes the object. Thus,
910 * the AML interpreter is doing all of the work, increasing the
911 * validity of the test.
913 ******************************************************************************/
916 AcpiDbWriteToObject (
917 ACPI_NAMESPACE_NODE *Node,
920 ACPI_OBJECT_LIST ParamObjects;
921 ACPI_OBJECT Params[2];
925 Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
926 Params[0].Reference.ActualType = Node->Type;
927 Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
929 /* Copy the incoming user parameter */
931 memcpy (&Params[1], Value, sizeof (ACPI_OBJECT));
933 ParamObjects.Count = 2;
934 ParamObjects.Pointer = Params;
936 AcpiGbl_MethodExecuting = TRUE;
937 Status = AcpiEvaluateObject (WriteHandle, NULL, &ParamObjects, NULL);
938 AcpiGbl_MethodExecuting = FALSE;
940 if (ACPI_FAILURE (Status))
942 AcpiOsPrintf ("Could not write to object, %s",
943 AcpiFormatException (Status));
950 /*******************************************************************************
952 * FUNCTION: AcpiDbEvaluateAllPredefinedNames
954 * PARAMETERS: CountArg - Max number of methods to execute
958 * DESCRIPTION: Namespace batch execution. Execute predefined names in the
959 * namespace, up to the max count, if specified.
961 ******************************************************************************/
964 AcpiDbEvaluateAllPredefinedNames (
967 ACPI_DB_EXECUTE_WALK Info;
971 Info.MaxCount = ACPI_UINT32_MAX;
975 Info.MaxCount = strtoul (CountArg, NULL, 0);
978 /* Search all nodes in namespace */
980 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
981 ACPI_UINT32_MAX, AcpiDbEvaluateOnePredefinedName, NULL,
982 (void *) &Info, NULL);
985 "Evaluated %u predefined names in the namespace\n", Info.Count);
989 /*******************************************************************************
991 * FUNCTION: AcpiDbEvaluateOnePredefinedName
993 * PARAMETERS: Callback from WalkNamespace
997 * DESCRIPTION: Batch execution module. Currently only executes predefined
1000 ******************************************************************************/
1003 AcpiDbEvaluateOnePredefinedName (
1004 ACPI_HANDLE ObjHandle,
1005 UINT32 NestingLevel,
1009 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1010 ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context;
1012 const ACPI_PREDEFINED_INFO *Predefined;
1013 ACPI_DEVICE_INFO *ObjInfo;
1014 ACPI_OBJECT_LIST ParamObjects;
1015 ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
1016 ACPI_OBJECT *ThisParam;
1017 ACPI_BUFFER ReturnObj;
1025 /* The name must be a predefined ACPI name */
1027 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
1033 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
1038 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
1044 /* Get the object info for number of method parameters */
1046 Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
1047 if (ACPI_FAILURE (Status))
1049 ACPI_FREE (Pathname);
1053 ParamObjects.Count = 0;
1054 ParamObjects.Pointer = NULL;
1056 if (ObjInfo->Type == ACPI_TYPE_METHOD)
1058 /* Setup default parameters (with proper types) */
1060 ArgTypeList = Predefined->Info.ArgumentList;
1061 ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
1064 * Setup the ACPI-required number of arguments, regardless of what
1065 * the actual method defines. If there is a difference, then the
1066 * method is wrong and a warning will be issued during execution.
1069 for (i = 0; i < ArgCount; i++)
1071 ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
1072 ThisParam->Type = ArgType;
1076 case ACPI_TYPE_INTEGER:
1078 ThisParam->Integer.Value = 1;
1081 case ACPI_TYPE_STRING:
1083 ThisParam->String.Pointer =
1084 "This is the default argument string";
1085 ThisParam->String.Length =
1086 strlen (ThisParam->String.Pointer);
1089 case ACPI_TYPE_BUFFER:
1091 ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
1092 ThisParam->Buffer.Length = 48;
1095 case ACPI_TYPE_PACKAGE:
1097 ThisParam->Package.Elements = NULL;
1098 ThisParam->Package.Count = 0;
1103 AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
1111 ParamObjects.Count = ArgCount;
1112 ParamObjects.Pointer = Params;
1115 ACPI_FREE (ObjInfo);
1116 ReturnObj.Pointer = NULL;
1117 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
1119 /* Do the actual method execution */
1121 AcpiGbl_MethodExecuting = TRUE;
1123 Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
1125 AcpiOsPrintf ("%-32s returned %s\n",
1126 Pathname, AcpiFormatException (Status));
1127 AcpiGbl_MethodExecuting = FALSE;
1128 ACPI_FREE (Pathname);
1130 /* Ignore status from method execution */
1134 /* Update count, check if we have executed enough methods */
1137 if (Info->Count >= Info->MaxCount)
1139 Status = AE_CTRL_TERMINATE;
1145 #endif /* ACPI_DEBUGGER */