1 /*******************************************************************************
3 * Module Name: dbtest - Various debug-related tests
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2014, 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 ACPI_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 (ACPI_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 (ACPI_MEMCMP (Temp1->Buffer.Pointer, 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 = ACPI_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 (ACPI_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 = ACPI_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 (ACPI_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, &ParamObjects, &ReturnObj);
851 AcpiGbl_MethodExecuting = FALSE;
853 if (ACPI_FAILURE (Status))
855 AcpiOsPrintf ("Could not read from object, %s",
856 AcpiFormatException (Status));
860 RetValue = (ACPI_OBJECT *) ReturnObj.Pointer;
862 switch (RetValue->Type)
864 case ACPI_TYPE_INTEGER:
865 case ACPI_TYPE_BUFFER:
866 case ACPI_TYPE_STRING:
868 * Did we receive the type we wanted? Most important for the
869 * Integer/Buffer case (when a field is larger than an Integer,
870 * it should return a Buffer).
872 if (RetValue->Type != ExpectedType)
874 AcpiOsPrintf (" Type mismatch: Expected %s, Received %s",
875 AcpiUtGetTypeName (ExpectedType),
876 AcpiUtGetTypeName (RetValue->Type));
886 AcpiOsPrintf (" Unsupported return object type, %s",
887 AcpiUtGetTypeName (RetValue->Type));
888 AcpiOsFree (ReturnObj.Pointer);
897 /*******************************************************************************
899 * FUNCTION: AcpiDbWriteToObject
901 * PARAMETERS: Node - Parent NS node for the object
902 * Value - Value to be written
906 * DESCRIPTION: Performs a write to the specified object by invoking the
907 * special debugger control method that writes the object. Thus,
908 * the AML interpreter is doing all of the work, increasing the
909 * validity of the test.
911 ******************************************************************************/
914 AcpiDbWriteToObject (
915 ACPI_NAMESPACE_NODE *Node,
918 ACPI_OBJECT_LIST ParamObjects;
919 ACPI_OBJECT Params[2];
923 Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
924 Params[0].Reference.ActualType = Node->Type;
925 Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
927 /* Copy the incoming user parameter */
929 ACPI_MEMCPY (&Params[1], Value, sizeof (ACPI_OBJECT));
931 ParamObjects.Count = 2;
932 ParamObjects.Pointer = Params;
934 AcpiGbl_MethodExecuting = TRUE;
935 Status = AcpiEvaluateObject (WriteHandle, NULL, &ParamObjects, NULL);
936 AcpiGbl_MethodExecuting = FALSE;
938 if (ACPI_FAILURE (Status))
940 AcpiOsPrintf ("Could not write to object, %s",
941 AcpiFormatException (Status));
948 /*******************************************************************************
950 * FUNCTION: AcpiDbEvaluateAllPredefinedNames
952 * PARAMETERS: CountArg - Max number of methods to execute
956 * DESCRIPTION: Namespace batch execution. Execute predefined names in the
957 * namespace, up to the max count, if specified.
959 ******************************************************************************/
962 AcpiDbEvaluateAllPredefinedNames (
965 ACPI_DB_EXECUTE_WALK Info;
969 Info.MaxCount = ACPI_UINT32_MAX;
973 Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
976 /* Search all nodes in namespace */
978 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
979 AcpiDbEvaluateOnePredefinedName, NULL, (void *) &Info, NULL);
981 AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count);
985 /*******************************************************************************
987 * FUNCTION: AcpiDbEvaluateOnePredefinedName
989 * PARAMETERS: Callback from WalkNamespace
993 * DESCRIPTION: Batch execution module. Currently only executes predefined
996 ******************************************************************************/
999 AcpiDbEvaluateOnePredefinedName (
1000 ACPI_HANDLE ObjHandle,
1001 UINT32 NestingLevel,
1005 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1006 ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context;
1008 const ACPI_PREDEFINED_INFO *Predefined;
1009 ACPI_DEVICE_INFO *ObjInfo;
1010 ACPI_OBJECT_LIST ParamObjects;
1011 ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
1012 ACPI_OBJECT *ThisParam;
1013 ACPI_BUFFER ReturnObj;
1021 /* The name must be a predefined ACPI name */
1023 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
1029 if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
1034 Pathname = AcpiNsGetExternalPathname (Node);
1040 /* Get the object info for number of method parameters */
1042 Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
1043 if (ACPI_FAILURE (Status))
1048 ParamObjects.Count = 0;
1049 ParamObjects.Pointer = NULL;
1051 if (ObjInfo->Type == ACPI_TYPE_METHOD)
1053 /* Setup default parameters (with proper types) */
1055 ArgTypeList = Predefined->Info.ArgumentList;
1056 ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
1059 * Setup the ACPI-required number of arguments, regardless of what
1060 * the actual method defines. If there is a difference, then the
1061 * method is wrong and a warning will be issued during execution.
1064 for (i = 0; i < ArgCount; i++)
1066 ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
1067 ThisParam->Type = ArgType;
1071 case ACPI_TYPE_INTEGER:
1073 ThisParam->Integer.Value = 1;
1076 case ACPI_TYPE_STRING:
1078 ThisParam->String.Pointer = "This is the default argument string";
1079 ThisParam->String.Length = ACPI_STRLEN (ThisParam->String.Pointer);
1082 case ACPI_TYPE_BUFFER:
1084 ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
1085 ThisParam->Buffer.Length = 48;
1088 case ACPI_TYPE_PACKAGE:
1090 ThisParam->Package.Elements = NULL;
1091 ThisParam->Package.Count = 0;
1096 AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
1104 ParamObjects.Count = ArgCount;
1105 ParamObjects.Pointer = Params;
1108 ACPI_FREE (ObjInfo);
1109 ReturnObj.Pointer = NULL;
1110 ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
1112 /* Do the actual method execution */
1114 AcpiGbl_MethodExecuting = TRUE;
1116 Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
1118 AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
1119 AcpiGbl_MethodExecuting = FALSE;
1120 ACPI_FREE (Pathname);
1122 /* Ignore status from method execution */
1126 /* Update count, check if we have executed enough methods */
1129 if (Info->Count >= Info->MaxCount)
1131 Status = AE_CTRL_TERMINATE;
1137 #endif /* ACPI_DEBUGGER */