dbtest.c revision 1.1.1.4 1 1.1 christos /*******************************************************************************
2 1.1 christos *
3 1.1 christos * Module Name: dbtest - Various debug-related tests
4 1.1 christos *
5 1.1 christos ******************************************************************************/
6 1.1 christos
7 1.1 christos /*
8 1.1.1.4 christos * Copyright (C) 2000 - 2016, Intel Corp.
9 1.1 christos * All rights reserved.
10 1.1 christos *
11 1.1 christos * Redistribution and use in source and binary forms, with or without
12 1.1 christos * modification, are permitted provided that the following conditions
13 1.1 christos * are met:
14 1.1 christos * 1. Redistributions of source code must retain the above copyright
15 1.1 christos * notice, this list of conditions, and the following disclaimer,
16 1.1 christos * without modification.
17 1.1 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1 christos * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1 christos * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1 christos * including a substantially similar Disclaimer requirement for further
21 1.1 christos * binary redistribution.
22 1.1 christos * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1 christos * of any contributors may be used to endorse or promote products derived
24 1.1 christos * from this software without specific prior written permission.
25 1.1 christos *
26 1.1 christos * Alternatively, this software may be distributed under the terms of the
27 1.1 christos * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1 christos * Software Foundation.
29 1.1 christos *
30 1.1 christos * NO WARRANTY
31 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1 christos * POSSIBILITY OF SUCH DAMAGES.
42 1.1 christos */
43 1.1 christos
44 1.1 christos #include "acpi.h"
45 1.1 christos #include "accommon.h"
46 1.1 christos #include "acdebug.h"
47 1.1 christos #include "acnamesp.h"
48 1.1 christos #include "acpredef.h"
49 1.1 christos
50 1.1 christos
51 1.1 christos #define _COMPONENT ACPI_CA_DEBUGGER
52 1.1 christos ACPI_MODULE_NAME ("dbtest")
53 1.1 christos
54 1.1 christos
55 1.1 christos /* Local prototypes */
56 1.1 christos
57 1.1 christos static void
58 1.1 christos AcpiDbTestAllObjects (
59 1.1 christos void);
60 1.1 christos
61 1.1 christos static ACPI_STATUS
62 1.1 christos AcpiDbTestOneObject (
63 1.1 christos ACPI_HANDLE ObjHandle,
64 1.1 christos UINT32 NestingLevel,
65 1.1 christos void *Context,
66 1.1 christos void **ReturnValue);
67 1.1 christos
68 1.1 christos static ACPI_STATUS
69 1.1 christos AcpiDbTestIntegerType (
70 1.1 christos ACPI_NAMESPACE_NODE *Node,
71 1.1 christos UINT32 BitLength);
72 1.1 christos
73 1.1 christos static ACPI_STATUS
74 1.1 christos AcpiDbTestBufferType (
75 1.1 christos ACPI_NAMESPACE_NODE *Node,
76 1.1 christos UINT32 BitLength);
77 1.1 christos
78 1.1 christos static ACPI_STATUS
79 1.1 christos AcpiDbTestStringType (
80 1.1 christos ACPI_NAMESPACE_NODE *Node,
81 1.1 christos UINT32 ByteLength);
82 1.1 christos
83 1.1 christos static ACPI_STATUS
84 1.1 christos AcpiDbReadFromObject (
85 1.1 christos ACPI_NAMESPACE_NODE *Node,
86 1.1 christos ACPI_OBJECT_TYPE ExpectedType,
87 1.1 christos ACPI_OBJECT **Value);
88 1.1 christos
89 1.1 christos static ACPI_STATUS
90 1.1 christos AcpiDbWriteToObject (
91 1.1 christos ACPI_NAMESPACE_NODE *Node,
92 1.1 christos ACPI_OBJECT *Value);
93 1.1 christos
94 1.1 christos static void
95 1.1 christos AcpiDbEvaluateAllPredefinedNames (
96 1.1 christos char *CountArg);
97 1.1 christos
98 1.1 christos static ACPI_STATUS
99 1.1 christos AcpiDbEvaluateOnePredefinedName (
100 1.1 christos ACPI_HANDLE ObjHandle,
101 1.1 christos UINT32 NestingLevel,
102 1.1 christos void *Context,
103 1.1 christos void **ReturnValue);
104 1.1 christos
105 1.1 christos /*
106 1.1 christos * Test subcommands
107 1.1 christos */
108 1.1 christos static ACPI_DB_ARGUMENT_INFO AcpiDbTestTypes [] =
109 1.1 christos {
110 1.1 christos {"OBJECTS"},
111 1.1 christos {"PREDEFINED"},
112 1.1 christos {NULL} /* Must be null terminated */
113 1.1 christos };
114 1.1 christos
115 1.1 christos #define CMD_TEST_OBJECTS 0
116 1.1 christos #define CMD_TEST_PREDEFINED 1
117 1.1 christos
118 1.1 christos #define BUFFER_FILL_VALUE 0xFF
119 1.1 christos
120 1.1 christos /*
121 1.1 christos * Support for the special debugger read/write control methods.
122 1.1 christos * These methods are installed into the current namespace and are
123 1.1 christos * used to read and write the various namespace objects. The point
124 1.1 christos * is to force the AML interpreter do all of the work.
125 1.1 christos */
126 1.1.1.4 christos #define ACPI_DB_READ_METHOD "\\_T98"
127 1.1.1.4 christos #define ACPI_DB_WRITE_METHOD "\\_T99"
128 1.1 christos
129 1.1 christos static ACPI_HANDLE ReadHandle = NULL;
130 1.1 christos static ACPI_HANDLE WriteHandle = NULL;
131 1.1 christos
132 1.1 christos /* ASL Definitions of the debugger read/write control methods */
133 1.1 christos
134 1.1 christos #if 0
135 1.1 christos DefinitionBlock ("ssdt.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
136 1.1 christos {
137 1.1 christos Method (_T98, 1, NotSerialized) /* Read */
138 1.1 christos {
139 1.1 christos Return (DeRefOf (Arg0))
140 1.1 christos }
141 1.1 christos }
142 1.1 christos DefinitionBlock ("ssdt2.aml", "SSDT", 2, "Intel", "DEBUG", 0x00000001)
143 1.1 christos {
144 1.1 christos Method (_T99, 2, NotSerialized) /* Write */
145 1.1 christos {
146 1.1 christos Store (Arg1, Arg0)
147 1.1 christos }
148 1.1 christos }
149 1.1 christos #endif
150 1.1 christos
151 1.1 christos static unsigned char ReadMethodCode[] =
152 1.1 christos {
153 1.1 christos 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */
154 1.1 christos 0x02,0xC9,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
155 1.1 christos 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */
156 1.1 christos 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
157 1.1 christos 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */
158 1.1 christos 0x39,0x38,0x01,0xA4,0x83,0x68 /* 00000028 "98...h" */
159 1.1 christos };
160 1.1 christos
161 1.1 christos static unsigned char WriteMethodCode[] =
162 1.1 christos {
163 1.1 christos 0x53,0x53,0x44,0x54,0x2E,0x00,0x00,0x00, /* 00000000 "SSDT...." */
164 1.1 christos 0x02,0x15,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
165 1.1 christos 0x44,0x45,0x42,0x55,0x47,0x00,0x00,0x00, /* 00000010 "DEBUG..." */
166 1.1 christos 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
167 1.1 christos 0x18,0x12,0x13,0x20,0x14,0x09,0x5F,0x54, /* 00000020 "... .._T" */
168 1.1 christos 0x39,0x39,0x02,0x70,0x69,0x68 /* 00000028 "99.pih" */
169 1.1 christos };
170 1.1 christos
171 1.1 christos
172 1.1 christos /*******************************************************************************
173 1.1 christos *
174 1.1 christos * FUNCTION: AcpiDbExecuteTest
175 1.1 christos *
176 1.1 christos * PARAMETERS: TypeArg - Subcommand
177 1.1 christos *
178 1.1 christos * RETURN: None
179 1.1 christos *
180 1.1 christos * DESCRIPTION: Execute various debug tests.
181 1.1 christos *
182 1.1 christos * Note: Code is prepared for future expansion of the TEST command.
183 1.1 christos *
184 1.1 christos ******************************************************************************/
185 1.1 christos
186 1.1 christos void
187 1.1 christos AcpiDbExecuteTest (
188 1.1 christos char *TypeArg)
189 1.1 christos {
190 1.1 christos UINT32 Temp;
191 1.1 christos
192 1.1 christos
193 1.1 christos AcpiUtStrupr (TypeArg);
194 1.1 christos Temp = AcpiDbMatchArgument (TypeArg, AcpiDbTestTypes);
195 1.1 christos if (Temp == ACPI_TYPE_NOT_FOUND)
196 1.1 christos {
197 1.1 christos AcpiOsPrintf ("Invalid or unsupported argument\n");
198 1.1 christos return;
199 1.1 christos }
200 1.1 christos
201 1.1 christos switch (Temp)
202 1.1 christos {
203 1.1 christos case CMD_TEST_OBJECTS:
204 1.1 christos
205 1.1 christos AcpiDbTestAllObjects ();
206 1.1 christos break;
207 1.1 christos
208 1.1 christos case CMD_TEST_PREDEFINED:
209 1.1 christos
210 1.1 christos AcpiDbEvaluateAllPredefinedNames (NULL);
211 1.1 christos break;
212 1.1 christos
213 1.1 christos default:
214 1.1 christos break;
215 1.1 christos }
216 1.1 christos }
217 1.1 christos
218 1.1 christos
219 1.1 christos /*******************************************************************************
220 1.1 christos *
221 1.1 christos * FUNCTION: AcpiDbTestAllObjects
222 1.1 christos *
223 1.1 christos * PARAMETERS: None
224 1.1 christos *
225 1.1 christos * RETURN: None
226 1.1 christos *
227 1.1 christos * DESCRIPTION: This test implements the OBJECTS subcommand. It exercises the
228 1.1 christos * namespace by reading/writing/comparing all data objects such
229 1.1 christos * as integers, strings, buffers, fields, buffer fields, etc.
230 1.1 christos *
231 1.1 christos ******************************************************************************/
232 1.1 christos
233 1.1 christos static void
234 1.1 christos AcpiDbTestAllObjects (
235 1.1 christos void)
236 1.1 christos {
237 1.1 christos ACPI_STATUS Status;
238 1.1 christos
239 1.1 christos
240 1.1 christos /* Install the debugger read-object control method if necessary */
241 1.1 christos
242 1.1 christos if (!ReadHandle)
243 1.1 christos {
244 1.1 christos Status = AcpiInstallMethod (ReadMethodCode);
245 1.1 christos if (ACPI_FAILURE (Status))
246 1.1 christos {
247 1.1 christos AcpiOsPrintf ("%s, Could not install debugger read method\n",
248 1.1 christos AcpiFormatException (Status));
249 1.1 christos return;
250 1.1 christos }
251 1.1 christos
252 1.1 christos Status = AcpiGetHandle (NULL, ACPI_DB_READ_METHOD, &ReadHandle);
253 1.1 christos if (ACPI_FAILURE (Status))
254 1.1 christos {
255 1.1 christos AcpiOsPrintf ("Could not obtain handle for debug method %s\n",
256 1.1 christos ACPI_DB_READ_METHOD);
257 1.1 christos return;
258 1.1 christos }
259 1.1 christos }
260 1.1 christos
261 1.1 christos /* Install the debugger write-object control method if necessary */
262 1.1 christos
263 1.1 christos if (!WriteHandle)
264 1.1 christos {
265 1.1 christos Status = AcpiInstallMethod (WriteMethodCode);
266 1.1 christos if (ACPI_FAILURE (Status))
267 1.1 christos {
268 1.1 christos AcpiOsPrintf ("%s, Could not install debugger write method\n",
269 1.1 christos AcpiFormatException (Status));
270 1.1 christos return;
271 1.1 christos }
272 1.1 christos
273 1.1 christos Status = AcpiGetHandle (NULL, ACPI_DB_WRITE_METHOD, &WriteHandle);
274 1.1 christos if (ACPI_FAILURE (Status))
275 1.1 christos {
276 1.1 christos AcpiOsPrintf ("Could not obtain handle for debug method %s\n",
277 1.1 christos ACPI_DB_WRITE_METHOD);
278 1.1 christos return;
279 1.1 christos }
280 1.1 christos }
281 1.1 christos
282 1.1 christos /* Walk the entire namespace, testing each supported named data object */
283 1.1 christos
284 1.1 christos (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
285 1.1.1.4 christos ACPI_UINT32_MAX, AcpiDbTestOneObject, NULL, NULL, NULL);
286 1.1 christos }
287 1.1 christos
288 1.1 christos
289 1.1 christos /*******************************************************************************
290 1.1 christos *
291 1.1 christos * FUNCTION: AcpiDbTestOneObject
292 1.1 christos *
293 1.1 christos * PARAMETERS: ACPI_WALK_CALLBACK
294 1.1 christos *
295 1.1 christos * RETURN: Status
296 1.1 christos *
297 1.1 christos * DESCRIPTION: Test one namespace object. Supported types are Integer,
298 1.1 christos * String, Buffer, BufferField, and FieldUnit. All other object
299 1.1 christos * types are simply ignored.
300 1.1 christos *
301 1.1 christos * Note: Support for Packages is not implemented.
302 1.1 christos *
303 1.1 christos ******************************************************************************/
304 1.1 christos
305 1.1 christos static ACPI_STATUS
306 1.1 christos AcpiDbTestOneObject (
307 1.1 christos ACPI_HANDLE ObjHandle,
308 1.1 christos UINT32 NestingLevel,
309 1.1 christos void *Context,
310 1.1 christos void **ReturnValue)
311 1.1 christos {
312 1.1 christos ACPI_NAMESPACE_NODE *Node;
313 1.1 christos ACPI_OPERAND_OBJECT *ObjDesc;
314 1.1 christos ACPI_OPERAND_OBJECT *RegionObj;
315 1.1 christos ACPI_OBJECT_TYPE LocalType;
316 1.1 christos UINT32 BitLength = 0;
317 1.1 christos UINT32 ByteLength = 0;
318 1.1 christos ACPI_STATUS Status = AE_OK;
319 1.1 christos
320 1.1 christos
321 1.1 christos Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
322 1.1 christos ObjDesc = Node->Object;
323 1.1 christos
324 1.1 christos /*
325 1.1 christos * For the supported types, get the actual bit length or
326 1.1 christos * byte length. Map the type to one of Integer/String/Buffer.
327 1.1 christos */
328 1.1 christos switch (Node->Type)
329 1.1 christos {
330 1.1 christos case ACPI_TYPE_INTEGER:
331 1.1 christos
332 1.1 christos /* Integer width is either 32 or 64 */
333 1.1 christos
334 1.1 christos LocalType = ACPI_TYPE_INTEGER;
335 1.1 christos BitLength = AcpiGbl_IntegerBitWidth;
336 1.1 christos break;
337 1.1 christos
338 1.1 christos case ACPI_TYPE_STRING:
339 1.1 christos
340 1.1 christos LocalType = ACPI_TYPE_STRING;
341 1.1 christos ByteLength = ObjDesc->String.Length;
342 1.1 christos break;
343 1.1 christos
344 1.1 christos case ACPI_TYPE_BUFFER:
345 1.1 christos
346 1.1 christos LocalType = ACPI_TYPE_BUFFER;
347 1.1 christos ByteLength = ObjDesc->Buffer.Length;
348 1.1 christos BitLength = ByteLength * 8;
349 1.1 christos break;
350 1.1 christos
351 1.1 christos case ACPI_TYPE_FIELD_UNIT:
352 1.1 christos case ACPI_TYPE_BUFFER_FIELD:
353 1.1 christos case ACPI_TYPE_LOCAL_REGION_FIELD:
354 1.1 christos case ACPI_TYPE_LOCAL_INDEX_FIELD:
355 1.1 christos case ACPI_TYPE_LOCAL_BANK_FIELD:
356 1.1 christos
357 1.1 christos LocalType = ACPI_TYPE_INTEGER;
358 1.1 christos if (ObjDesc)
359 1.1 christos {
360 1.1 christos /*
361 1.1 christos * Returned object will be a Buffer if the field length
362 1.1 christos * is larger than the size of an Integer (32 or 64 bits
363 1.1 christos * depending on the DSDT version).
364 1.1 christos */
365 1.1 christos BitLength = ObjDesc->CommonField.BitLength;
366 1.1 christos ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
367 1.1 christos if (BitLength > AcpiGbl_IntegerBitWidth)
368 1.1 christos {
369 1.1 christos LocalType = ACPI_TYPE_BUFFER;
370 1.1 christos }
371 1.1 christos }
372 1.1 christos break;
373 1.1 christos
374 1.1 christos default:
375 1.1 christos
376 1.1 christos /* Ignore all other types */
377 1.1 christos
378 1.1 christos return (AE_OK);
379 1.1 christos }
380 1.1 christos
381 1.1 christos /* Emit the common prefix: Type:Name */
382 1.1 christos
383 1.1 christos AcpiOsPrintf ("%14s: %4.4s",
384 1.1 christos AcpiUtGetTypeName (Node->Type), Node->Name.Ascii);
385 1.1 christos if (!ObjDesc)
386 1.1 christos {
387 1.1 christos AcpiOsPrintf (" Ignoring, no attached object\n");
388 1.1 christos return (AE_OK);
389 1.1 christos }
390 1.1 christos
391 1.1 christos /*
392 1.1 christos * Check for unsupported region types. Note: AcpiExec simulates
393 1.1 christos * access to SystemMemory, SystemIO, PCI_Config, and EC.
394 1.1 christos */
395 1.1 christos switch (Node->Type)
396 1.1 christos {
397 1.1 christos case ACPI_TYPE_LOCAL_REGION_FIELD:
398 1.1 christos
399 1.1 christos RegionObj = ObjDesc->Field.RegionObj;
400 1.1 christos switch (RegionObj->Region.SpaceId)
401 1.1 christos {
402 1.1 christos case ACPI_ADR_SPACE_SYSTEM_MEMORY:
403 1.1 christos case ACPI_ADR_SPACE_SYSTEM_IO:
404 1.1 christos case ACPI_ADR_SPACE_PCI_CONFIG:
405 1.1 christos case ACPI_ADR_SPACE_EC:
406 1.1 christos
407 1.1 christos break;
408 1.1 christos
409 1.1 christos default:
410 1.1 christos
411 1.1 christos AcpiOsPrintf (" %s space is not supported [%4.4s]\n",
412 1.1 christos AcpiUtGetRegionName (RegionObj->Region.SpaceId),
413 1.1 christos RegionObj->Region.Node->Name.Ascii);
414 1.1 christos return (AE_OK);
415 1.1 christos }
416 1.1 christos break;
417 1.1 christos
418 1.1 christos default:
419 1.1 christos break;
420 1.1 christos }
421 1.1 christos
422 1.1 christos /* At this point, we have resolved the object to one of the major types */
423 1.1 christos
424 1.1 christos switch (LocalType)
425 1.1 christos {
426 1.1 christos case ACPI_TYPE_INTEGER:
427 1.1 christos
428 1.1 christos Status = AcpiDbTestIntegerType (Node, BitLength);
429 1.1 christos break;
430 1.1 christos
431 1.1 christos case ACPI_TYPE_STRING:
432 1.1 christos
433 1.1 christos Status = AcpiDbTestStringType (Node, ByteLength);
434 1.1 christos break;
435 1.1 christos
436 1.1 christos case ACPI_TYPE_BUFFER:
437 1.1 christos
438 1.1 christos Status = AcpiDbTestBufferType (Node, BitLength);
439 1.1 christos break;
440 1.1 christos
441 1.1 christos default:
442 1.1 christos
443 1.1 christos AcpiOsPrintf (" Ignoring, type not implemented (%2.2X)",
444 1.1 christos LocalType);
445 1.1 christos break;
446 1.1 christos }
447 1.1 christos
448 1.1 christos switch (Node->Type)
449 1.1 christos {
450 1.1 christos case ACPI_TYPE_LOCAL_REGION_FIELD:
451 1.1 christos
452 1.1 christos RegionObj = ObjDesc->Field.RegionObj;
453 1.1 christos AcpiOsPrintf (" (%s)",
454 1.1 christos AcpiUtGetRegionName (RegionObj->Region.SpaceId));
455 1.1 christos break;
456 1.1 christos
457 1.1 christos default:
458 1.1 christos break;
459 1.1 christos }
460 1.1 christos
461 1.1 christos AcpiOsPrintf ("\n");
462 1.1 christos return (Status);
463 1.1 christos }
464 1.1 christos
465 1.1 christos
466 1.1 christos /*******************************************************************************
467 1.1 christos *
468 1.1 christos * FUNCTION: AcpiDbTestIntegerType
469 1.1 christos *
470 1.1 christos * PARAMETERS: Node - Parent NS node for the object
471 1.1 christos * BitLength - Actual length of the object. Used for
472 1.1 christos * support of arbitrary length FieldUnit
473 1.1 christos * and BufferField objects.
474 1.1 christos *
475 1.1 christos * RETURN: Status
476 1.1 christos *
477 1.1 christos * DESCRIPTION: Test read/write for an Integer-valued object. Performs a
478 1.1 christos * write/read/compare of an arbitrary new value, then performs
479 1.1 christos * a write/read/compare of the original value.
480 1.1 christos *
481 1.1 christos ******************************************************************************/
482 1.1 christos
483 1.1 christos static ACPI_STATUS
484 1.1 christos AcpiDbTestIntegerType (
485 1.1 christos ACPI_NAMESPACE_NODE *Node,
486 1.1 christos UINT32 BitLength)
487 1.1 christos {
488 1.1 christos ACPI_OBJECT *Temp1 = NULL;
489 1.1 christos ACPI_OBJECT *Temp2 = NULL;
490 1.1 christos ACPI_OBJECT *Temp3 = NULL;
491 1.1 christos ACPI_OBJECT WriteValue;
492 1.1 christos UINT64 ValueToWrite;
493 1.1 christos ACPI_STATUS Status;
494 1.1 christos
495 1.1 christos
496 1.1 christos if (BitLength > 64)
497 1.1 christos {
498 1.1 christos AcpiOsPrintf (" Invalid length for an Integer: %u", BitLength);
499 1.1 christos return (AE_OK);
500 1.1 christos }
501 1.1 christos
502 1.1 christos /* Read the original value */
503 1.1 christos
504 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp1);
505 1.1 christos if (ACPI_FAILURE (Status))
506 1.1 christos {
507 1.1 christos return (Status);
508 1.1 christos }
509 1.1 christos
510 1.1 christos AcpiOsPrintf (" (%4.4X/%3.3X) %8.8X%8.8X",
511 1.1 christos BitLength, ACPI_ROUND_BITS_UP_TO_BYTES (BitLength),
512 1.1 christos ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
513 1.1 christos
514 1.1 christos ValueToWrite = ACPI_UINT64_MAX >> (64 - BitLength);
515 1.1 christos if (Temp1->Integer.Value == ValueToWrite)
516 1.1 christos {
517 1.1 christos ValueToWrite = 0;
518 1.1 christos }
519 1.1 christos
520 1.1 christos /* Write a new value */
521 1.1 christos
522 1.1 christos WriteValue.Type = ACPI_TYPE_INTEGER;
523 1.1 christos WriteValue.Integer.Value = ValueToWrite;
524 1.1 christos Status = AcpiDbWriteToObject (Node, &WriteValue);
525 1.1 christos if (ACPI_FAILURE (Status))
526 1.1 christos {
527 1.1 christos goto Exit;
528 1.1 christos }
529 1.1 christos
530 1.1 christos /* Ensure that we can read back the new value */
531 1.1 christos
532 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp2);
533 1.1 christos if (ACPI_FAILURE (Status))
534 1.1 christos {
535 1.1 christos goto Exit;
536 1.1 christos }
537 1.1 christos
538 1.1 christos if (Temp2->Integer.Value != ValueToWrite)
539 1.1 christos {
540 1.1 christos AcpiOsPrintf (" MISMATCH 2: %8.8X%8.8X, expecting %8.8X%8.8X",
541 1.1 christos ACPI_FORMAT_UINT64 (Temp2->Integer.Value),
542 1.1 christos ACPI_FORMAT_UINT64 (ValueToWrite));
543 1.1 christos }
544 1.1 christos
545 1.1 christos /* Write back the original value */
546 1.1 christos
547 1.1 christos WriteValue.Integer.Value = Temp1->Integer.Value;
548 1.1 christos Status = AcpiDbWriteToObject (Node, &WriteValue);
549 1.1 christos if (ACPI_FAILURE (Status))
550 1.1 christos {
551 1.1 christos goto Exit;
552 1.1 christos }
553 1.1 christos
554 1.1 christos /* Ensure that we can read back the original value */
555 1.1 christos
556 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_INTEGER, &Temp3);
557 1.1 christos if (ACPI_FAILURE (Status))
558 1.1 christos {
559 1.1 christos goto Exit;
560 1.1 christos }
561 1.1 christos
562 1.1 christos if (Temp3->Integer.Value != Temp1->Integer.Value)
563 1.1 christos {
564 1.1 christos AcpiOsPrintf (" MISMATCH 3: %8.8X%8.8X, expecting %8.8X%8.8X",
565 1.1 christos ACPI_FORMAT_UINT64 (Temp3->Integer.Value),
566 1.1 christos ACPI_FORMAT_UINT64 (Temp1->Integer.Value));
567 1.1 christos }
568 1.1 christos
569 1.1 christos Exit:
570 1.1 christos if (Temp1) {AcpiOsFree (Temp1);}
571 1.1 christos if (Temp2) {AcpiOsFree (Temp2);}
572 1.1 christos if (Temp3) {AcpiOsFree (Temp3);}
573 1.1 christos return (AE_OK);
574 1.1 christos }
575 1.1 christos
576 1.1 christos
577 1.1 christos /*******************************************************************************
578 1.1 christos *
579 1.1 christos * FUNCTION: AcpiDbTestBufferType
580 1.1 christos *
581 1.1 christos * PARAMETERS: Node - Parent NS node for the object
582 1.1 christos * BitLength - Actual length of the object.
583 1.1 christos *
584 1.1 christos * RETURN: Status
585 1.1 christos *
586 1.1 christos * DESCRIPTION: Test read/write for an Buffer-valued object. Performs a
587 1.1 christos * write/read/compare of an arbitrary new value, then performs
588 1.1 christos * a write/read/compare of the original value.
589 1.1 christos *
590 1.1 christos ******************************************************************************/
591 1.1 christos
592 1.1 christos static ACPI_STATUS
593 1.1 christos AcpiDbTestBufferType (
594 1.1 christos ACPI_NAMESPACE_NODE *Node,
595 1.1 christos UINT32 BitLength)
596 1.1 christos {
597 1.1 christos ACPI_OBJECT *Temp1 = NULL;
598 1.1 christos ACPI_OBJECT *Temp2 = NULL;
599 1.1 christos ACPI_OBJECT *Temp3 = NULL;
600 1.1 christos UINT8 *Buffer;
601 1.1 christos ACPI_OBJECT WriteValue;
602 1.1 christos ACPI_STATUS Status;
603 1.1 christos UINT32 ByteLength;
604 1.1 christos UINT32 i;
605 1.1 christos UINT8 ExtraBits;
606 1.1 christos
607 1.1 christos
608 1.1 christos ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
609 1.1 christos if (ByteLength == 0)
610 1.1 christos {
611 1.1 christos AcpiOsPrintf (" Ignoring zero length buffer");
612 1.1 christos return (AE_OK);
613 1.1 christos }
614 1.1 christos
615 1.1 christos /* Allocate a local buffer */
616 1.1 christos
617 1.1 christos Buffer = ACPI_ALLOCATE_ZEROED (ByteLength);
618 1.1 christos if (!Buffer)
619 1.1 christos {
620 1.1 christos return (AE_NO_MEMORY);
621 1.1 christos }
622 1.1 christos
623 1.1 christos /* Read the original value */
624 1.1 christos
625 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp1);
626 1.1 christos if (ACPI_FAILURE (Status))
627 1.1 christos {
628 1.1 christos goto Exit;
629 1.1 christos }
630 1.1 christos
631 1.1 christos /* Emit a few bytes of the buffer */
632 1.1 christos
633 1.1 christos AcpiOsPrintf (" (%4.4X/%3.3X)", BitLength, Temp1->Buffer.Length);
634 1.1 christos for (i = 0; ((i < 4) && (i < ByteLength)); i++)
635 1.1 christos {
636 1.1 christos AcpiOsPrintf (" %2.2X", Temp1->Buffer.Pointer[i]);
637 1.1 christos }
638 1.1 christos AcpiOsPrintf ("... ");
639 1.1 christos
640 1.1 christos /*
641 1.1 christos * Write a new value.
642 1.1 christos *
643 1.1 christos * Handle possible extra bits at the end of the buffer. Can
644 1.1 christos * happen for FieldUnits larger than an integer, but the bit
645 1.1 christos * count is not an integral number of bytes. Zero out the
646 1.1 christos * unused bits.
647 1.1 christos */
648 1.1.1.3 christos memset (Buffer, BUFFER_FILL_VALUE, ByteLength);
649 1.1 christos ExtraBits = BitLength % 8;
650 1.1 christos if (ExtraBits)
651 1.1 christos {
652 1.1 christos Buffer [ByteLength - 1] = ACPI_MASK_BITS_ABOVE (ExtraBits);
653 1.1 christos }
654 1.1 christos
655 1.1 christos WriteValue.Type = ACPI_TYPE_BUFFER;
656 1.1 christos WriteValue.Buffer.Length = ByteLength;
657 1.1 christos WriteValue.Buffer.Pointer = Buffer;
658 1.1 christos
659 1.1 christos Status = AcpiDbWriteToObject (Node, &WriteValue);
660 1.1 christos if (ACPI_FAILURE (Status))
661 1.1 christos {
662 1.1 christos goto Exit;
663 1.1 christos }
664 1.1 christos
665 1.1 christos /* Ensure that we can read back the new value */
666 1.1 christos
667 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp2);
668 1.1 christos if (ACPI_FAILURE (Status))
669 1.1 christos {
670 1.1 christos goto Exit;
671 1.1 christos }
672 1.1 christos
673 1.1.1.3 christos if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength))
674 1.1 christos {
675 1.1 christos AcpiOsPrintf (" MISMATCH 2: New buffer value");
676 1.1 christos }
677 1.1 christos
678 1.1 christos /* Write back the original value */
679 1.1 christos
680 1.1 christos WriteValue.Buffer.Length = ByteLength;
681 1.1 christos WriteValue.Buffer.Pointer = Temp1->Buffer.Pointer;
682 1.1 christos
683 1.1 christos Status = AcpiDbWriteToObject (Node, &WriteValue);
684 1.1 christos if (ACPI_FAILURE (Status))
685 1.1 christos {
686 1.1 christos goto Exit;
687 1.1 christos }
688 1.1 christos
689 1.1 christos /* Ensure that we can read back the original value */
690 1.1 christos
691 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp3);
692 1.1 christos if (ACPI_FAILURE (Status))
693 1.1 christos {
694 1.1 christos goto Exit;
695 1.1 christos }
696 1.1 christos
697 1.1.1.4 christos if (memcmp (Temp1->Buffer.Pointer,
698 1.1.1.4 christos Temp3->Buffer.Pointer, ByteLength))
699 1.1 christos {
700 1.1 christos AcpiOsPrintf (" MISMATCH 3: While restoring original buffer");
701 1.1 christos }
702 1.1 christos
703 1.1 christos Exit:
704 1.1 christos ACPI_FREE (Buffer);
705 1.1 christos if (Temp1) {AcpiOsFree (Temp1);}
706 1.1 christos if (Temp2) {AcpiOsFree (Temp2);}
707 1.1 christos if (Temp3) {AcpiOsFree (Temp3);}
708 1.1 christos return (Status);
709 1.1 christos }
710 1.1 christos
711 1.1 christos
712 1.1 christos /*******************************************************************************
713 1.1 christos *
714 1.1 christos * FUNCTION: AcpiDbTestStringType
715 1.1 christos *
716 1.1 christos * PARAMETERS: Node - Parent NS node for the object
717 1.1 christos * ByteLength - Actual length of the object.
718 1.1 christos *
719 1.1 christos * RETURN: Status
720 1.1 christos *
721 1.1 christos * DESCRIPTION: Test read/write for an String-valued object. Performs a
722 1.1 christos * write/read/compare of an arbitrary new value, then performs
723 1.1 christos * a write/read/compare of the original value.
724 1.1 christos *
725 1.1 christos ******************************************************************************/
726 1.1 christos
727 1.1 christos static ACPI_STATUS
728 1.1 christos AcpiDbTestStringType (
729 1.1 christos ACPI_NAMESPACE_NODE *Node,
730 1.1 christos UINT32 ByteLength)
731 1.1 christos {
732 1.1 christos ACPI_OBJECT *Temp1 = NULL;
733 1.1 christos ACPI_OBJECT *Temp2 = NULL;
734 1.1 christos ACPI_OBJECT *Temp3 = NULL;
735 1.1 christos char *ValueToWrite = "Test String from AML Debugger";
736 1.1 christos ACPI_OBJECT WriteValue;
737 1.1 christos ACPI_STATUS Status;
738 1.1 christos
739 1.1 christos
740 1.1 christos /* Read the original value */
741 1.1 christos
742 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp1);
743 1.1 christos if (ACPI_FAILURE (Status))
744 1.1 christos {
745 1.1 christos return (Status);
746 1.1 christos }
747 1.1 christos
748 1.1 christos AcpiOsPrintf (" (%4.4X/%3.3X) \"%s\"", (Temp1->String.Length * 8),
749 1.1 christos Temp1->String.Length, Temp1->String.Pointer);
750 1.1 christos
751 1.1 christos /* Write a new value */
752 1.1 christos
753 1.1 christos WriteValue.Type = ACPI_TYPE_STRING;
754 1.1.1.3 christos WriteValue.String.Length = strlen (ValueToWrite);
755 1.1 christos WriteValue.String.Pointer = ValueToWrite;
756 1.1 christos
757 1.1 christos Status = AcpiDbWriteToObject (Node, &WriteValue);
758 1.1 christos if (ACPI_FAILURE (Status))
759 1.1 christos {
760 1.1 christos goto Exit;
761 1.1 christos }
762 1.1 christos
763 1.1 christos /* Ensure that we can read back the new value */
764 1.1 christos
765 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp2);
766 1.1 christos if (ACPI_FAILURE (Status))
767 1.1 christos {
768 1.1 christos goto Exit;
769 1.1 christos }
770 1.1 christos
771 1.1.1.3 christos if (strcmp (Temp2->String.Pointer, ValueToWrite))
772 1.1 christos {
773 1.1 christos AcpiOsPrintf (" MISMATCH 2: %s, expecting %s",
774 1.1 christos Temp2->String.Pointer, ValueToWrite);
775 1.1 christos }
776 1.1 christos
777 1.1 christos /* Write back the original value */
778 1.1 christos
779 1.1.1.3 christos WriteValue.String.Length = strlen (Temp1->String.Pointer);
780 1.1 christos WriteValue.String.Pointer = Temp1->String.Pointer;
781 1.1 christos
782 1.1 christos Status = AcpiDbWriteToObject (Node, &WriteValue);
783 1.1 christos if (ACPI_FAILURE (Status))
784 1.1 christos {
785 1.1 christos goto Exit;
786 1.1 christos }
787 1.1 christos
788 1.1 christos /* Ensure that we can read back the original value */
789 1.1 christos
790 1.1 christos Status = AcpiDbReadFromObject (Node, ACPI_TYPE_STRING, &Temp3);
791 1.1 christos if (ACPI_FAILURE (Status))
792 1.1 christos {
793 1.1 christos goto Exit;
794 1.1 christos }
795 1.1 christos
796 1.1.1.3 christos if (strcmp (Temp1->String.Pointer, Temp3->String.Pointer))
797 1.1 christos {
798 1.1 christos AcpiOsPrintf (" MISMATCH 3: %s, expecting %s",
799 1.1 christos Temp3->String.Pointer, Temp1->String.Pointer);
800 1.1 christos }
801 1.1 christos
802 1.1 christos Exit:
803 1.1 christos if (Temp1) {AcpiOsFree (Temp1);}
804 1.1 christos if (Temp2) {AcpiOsFree (Temp2);}
805 1.1 christos if (Temp3) {AcpiOsFree (Temp3);}
806 1.1 christos return (Status);
807 1.1 christos }
808 1.1 christos
809 1.1 christos
810 1.1 christos /*******************************************************************************
811 1.1 christos *
812 1.1 christos * FUNCTION: AcpiDbReadFromObject
813 1.1 christos *
814 1.1 christos * PARAMETERS: Node - Parent NS node for the object
815 1.1 christos * ExpectedType - Object type expected from the read
816 1.1 christos * Value - Where the value read is returned
817 1.1 christos *
818 1.1 christos * RETURN: Status
819 1.1 christos *
820 1.1 christos * DESCRIPTION: Performs a read from the specified object by invoking the
821 1.1 christos * special debugger control method that reads the object. Thus,
822 1.1 christos * the AML interpreter is doing all of the work, increasing the
823 1.1 christos * validity of the test.
824 1.1 christos *
825 1.1 christos ******************************************************************************/
826 1.1 christos
827 1.1 christos static ACPI_STATUS
828 1.1 christos AcpiDbReadFromObject (
829 1.1 christos ACPI_NAMESPACE_NODE *Node,
830 1.1 christos ACPI_OBJECT_TYPE ExpectedType,
831 1.1 christos ACPI_OBJECT **Value)
832 1.1 christos {
833 1.1 christos ACPI_OBJECT *RetValue;
834 1.1 christos ACPI_OBJECT_LIST ParamObjects;
835 1.1 christos ACPI_OBJECT Params[2];
836 1.1 christos ACPI_BUFFER ReturnObj;
837 1.1 christos ACPI_STATUS Status;
838 1.1 christos
839 1.1 christos
840 1.1 christos Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
841 1.1 christos Params[0].Reference.ActualType = Node->Type;
842 1.1 christos Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
843 1.1 christos
844 1.1 christos ParamObjects.Count = 1;
845 1.1 christos ParamObjects.Pointer = Params;
846 1.1 christos
847 1.1 christos ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
848 1.1 christos
849 1.1 christos AcpiGbl_MethodExecuting = TRUE;
850 1.1.1.4 christos Status = AcpiEvaluateObject (ReadHandle, NULL,
851 1.1.1.4 christos &ParamObjects, &ReturnObj);
852 1.1 christos AcpiGbl_MethodExecuting = FALSE;
853 1.1 christos
854 1.1 christos if (ACPI_FAILURE (Status))
855 1.1 christos {
856 1.1 christos AcpiOsPrintf ("Could not read from object, %s",
857 1.1 christos AcpiFormatException (Status));
858 1.1 christos return (Status);
859 1.1 christos }
860 1.1 christos
861 1.1 christos RetValue = (ACPI_OBJECT *) ReturnObj.Pointer;
862 1.1 christos
863 1.1 christos switch (RetValue->Type)
864 1.1 christos {
865 1.1 christos case ACPI_TYPE_INTEGER:
866 1.1 christos case ACPI_TYPE_BUFFER:
867 1.1 christos case ACPI_TYPE_STRING:
868 1.1 christos /*
869 1.1 christos * Did we receive the type we wanted? Most important for the
870 1.1 christos * Integer/Buffer case (when a field is larger than an Integer,
871 1.1 christos * it should return a Buffer).
872 1.1 christos */
873 1.1 christos if (RetValue->Type != ExpectedType)
874 1.1 christos {
875 1.1 christos AcpiOsPrintf (" Type mismatch: Expected %s, Received %s",
876 1.1 christos AcpiUtGetTypeName (ExpectedType),
877 1.1 christos AcpiUtGetTypeName (RetValue->Type));
878 1.1 christos
879 1.1 christos return (AE_TYPE);
880 1.1 christos }
881 1.1 christos
882 1.1 christos *Value = RetValue;
883 1.1 christos break;
884 1.1 christos
885 1.1 christos default:
886 1.1 christos
887 1.1 christos AcpiOsPrintf (" Unsupported return object type, %s",
888 1.1 christos AcpiUtGetTypeName (RetValue->Type));
889 1.1 christos
890 1.1.1.4 christos AcpiOsFree (ReturnObj.Pointer);
891 1.1 christos return (AE_TYPE);
892 1.1 christos }
893 1.1 christos
894 1.1 christos return (Status);
895 1.1 christos }
896 1.1 christos
897 1.1 christos
898 1.1 christos /*******************************************************************************
899 1.1 christos *
900 1.1 christos * FUNCTION: AcpiDbWriteToObject
901 1.1 christos *
902 1.1 christos * PARAMETERS: Node - Parent NS node for the object
903 1.1 christos * Value - Value to be written
904 1.1 christos *
905 1.1 christos * RETURN: Status
906 1.1 christos *
907 1.1 christos * DESCRIPTION: Performs a write to the specified object by invoking the
908 1.1 christos * special debugger control method that writes the object. Thus,
909 1.1 christos * the AML interpreter is doing all of the work, increasing the
910 1.1 christos * validity of the test.
911 1.1 christos *
912 1.1 christos ******************************************************************************/
913 1.1 christos
914 1.1 christos static ACPI_STATUS
915 1.1 christos AcpiDbWriteToObject (
916 1.1 christos ACPI_NAMESPACE_NODE *Node,
917 1.1 christos ACPI_OBJECT *Value)
918 1.1 christos {
919 1.1 christos ACPI_OBJECT_LIST ParamObjects;
920 1.1 christos ACPI_OBJECT Params[2];
921 1.1 christos ACPI_STATUS Status;
922 1.1 christos
923 1.1 christos
924 1.1 christos Params[0].Type = ACPI_TYPE_LOCAL_REFERENCE;
925 1.1 christos Params[0].Reference.ActualType = Node->Type;
926 1.1 christos Params[0].Reference.Handle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
927 1.1 christos
928 1.1 christos /* Copy the incoming user parameter */
929 1.1 christos
930 1.1.1.3 christos memcpy (&Params[1], Value, sizeof (ACPI_OBJECT));
931 1.1 christos
932 1.1 christos ParamObjects.Count = 2;
933 1.1 christos ParamObjects.Pointer = Params;
934 1.1 christos
935 1.1 christos AcpiGbl_MethodExecuting = TRUE;
936 1.1 christos Status = AcpiEvaluateObject (WriteHandle, NULL, &ParamObjects, NULL);
937 1.1 christos AcpiGbl_MethodExecuting = FALSE;
938 1.1 christos
939 1.1 christos if (ACPI_FAILURE (Status))
940 1.1 christos {
941 1.1 christos AcpiOsPrintf ("Could not write to object, %s",
942 1.1 christos AcpiFormatException (Status));
943 1.1 christos }
944 1.1 christos
945 1.1 christos return (Status);
946 1.1 christos }
947 1.1 christos
948 1.1 christos
949 1.1 christos /*******************************************************************************
950 1.1 christos *
951 1.1 christos * FUNCTION: AcpiDbEvaluateAllPredefinedNames
952 1.1 christos *
953 1.1 christos * PARAMETERS: CountArg - Max number of methods to execute
954 1.1 christos *
955 1.1 christos * RETURN: None
956 1.1 christos *
957 1.1 christos * DESCRIPTION: Namespace batch execution. Execute predefined names in the
958 1.1 christos * namespace, up to the max count, if specified.
959 1.1 christos *
960 1.1 christos ******************************************************************************/
961 1.1 christos
962 1.1 christos static void
963 1.1 christos AcpiDbEvaluateAllPredefinedNames (
964 1.1 christos char *CountArg)
965 1.1 christos {
966 1.1 christos ACPI_DB_EXECUTE_WALK Info;
967 1.1 christos
968 1.1 christos
969 1.1 christos Info.Count = 0;
970 1.1 christos Info.MaxCount = ACPI_UINT32_MAX;
971 1.1 christos
972 1.1 christos if (CountArg)
973 1.1 christos {
974 1.1.1.3 christos Info.MaxCount = strtoul (CountArg, NULL, 0);
975 1.1 christos }
976 1.1 christos
977 1.1 christos /* Search all nodes in namespace */
978 1.1 christos
979 1.1.1.4 christos (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
980 1.1.1.4 christos ACPI_UINT32_MAX, AcpiDbEvaluateOnePredefinedName, NULL,
981 1.1.1.4 christos (void *) &Info, NULL);
982 1.1 christos
983 1.1.1.4 christos AcpiOsPrintf (
984 1.1.1.4 christos "Evaluated %u predefined names in the namespace\n", Info.Count);
985 1.1 christos }
986 1.1 christos
987 1.1 christos
988 1.1 christos /*******************************************************************************
989 1.1 christos *
990 1.1 christos * FUNCTION: AcpiDbEvaluateOnePredefinedName
991 1.1 christos *
992 1.1 christos * PARAMETERS: Callback from WalkNamespace
993 1.1 christos *
994 1.1 christos * RETURN: Status
995 1.1 christos *
996 1.1 christos * DESCRIPTION: Batch execution module. Currently only executes predefined
997 1.1 christos * ACPI names.
998 1.1 christos *
999 1.1 christos ******************************************************************************/
1000 1.1 christos
1001 1.1 christos static ACPI_STATUS
1002 1.1 christos AcpiDbEvaluateOnePredefinedName (
1003 1.1 christos ACPI_HANDLE ObjHandle,
1004 1.1 christos UINT32 NestingLevel,
1005 1.1 christos void *Context,
1006 1.1 christos void **ReturnValue)
1007 1.1 christos {
1008 1.1 christos ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1009 1.1 christos ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context;
1010 1.1 christos char *Pathname;
1011 1.1 christos const ACPI_PREDEFINED_INFO *Predefined;
1012 1.1 christos ACPI_DEVICE_INFO *ObjInfo;
1013 1.1 christos ACPI_OBJECT_LIST ParamObjects;
1014 1.1 christos ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
1015 1.1 christos ACPI_OBJECT *ThisParam;
1016 1.1 christos ACPI_BUFFER ReturnObj;
1017 1.1 christos ACPI_STATUS Status;
1018 1.1 christos UINT16 ArgTypeList;
1019 1.1 christos UINT8 ArgCount;
1020 1.1 christos UINT8 ArgType;
1021 1.1 christos UINT32 i;
1022 1.1 christos
1023 1.1 christos
1024 1.1 christos /* The name must be a predefined ACPI name */
1025 1.1 christos
1026 1.1 christos Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
1027 1.1 christos if (!Predefined)
1028 1.1 christos {
1029 1.1 christos return (AE_OK);
1030 1.1 christos }
1031 1.1 christos
1032 1.1 christos if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
1033 1.1 christos {
1034 1.1 christos return (AE_OK);
1035 1.1 christos }
1036 1.1 christos
1037 1.1.1.4 christos Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
1038 1.1 christos if (!Pathname)
1039 1.1 christos {
1040 1.1 christos return (AE_OK);
1041 1.1 christos }
1042 1.1 christos
1043 1.1 christos /* Get the object info for number of method parameters */
1044 1.1 christos
1045 1.1 christos Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
1046 1.1 christos if (ACPI_FAILURE (Status))
1047 1.1 christos {
1048 1.1 christos ACPI_FREE (Pathname);
1049 1.1 christos return (Status);
1050 1.1 christos }
1051 1.1 christos
1052 1.1 christos ParamObjects.Count = 0;
1053 1.1 christos ParamObjects.Pointer = NULL;
1054 1.1 christos
1055 1.1 christos if (ObjInfo->Type == ACPI_TYPE_METHOD)
1056 1.1 christos {
1057 1.1 christos /* Setup default parameters (with proper types) */
1058 1.1 christos
1059 1.1 christos ArgTypeList = Predefined->Info.ArgumentList;
1060 1.1 christos ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
1061 1.1 christos
1062 1.1 christos /*
1063 1.1 christos * Setup the ACPI-required number of arguments, regardless of what
1064 1.1 christos * the actual method defines. If there is a difference, then the
1065 1.1 christos * method is wrong and a warning will be issued during execution.
1066 1.1 christos */
1067 1.1 christos ThisParam = Params;
1068 1.1 christos for (i = 0; i < ArgCount; i++)
1069 1.1 christos {
1070 1.1 christos ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
1071 1.1 christos ThisParam->Type = ArgType;
1072 1.1 christos
1073 1.1 christos switch (ArgType)
1074 1.1 christos {
1075 1.1 christos case ACPI_TYPE_INTEGER:
1076 1.1 christos
1077 1.1 christos ThisParam->Integer.Value = 1;
1078 1.1 christos break;
1079 1.1 christos
1080 1.1 christos case ACPI_TYPE_STRING:
1081 1.1 christos
1082 1.1.1.4 christos ThisParam->String.Pointer =
1083 1.1.1.4 christos "This is the default argument string";
1084 1.1.1.4 christos ThisParam->String.Length =
1085 1.1.1.4 christos strlen (ThisParam->String.Pointer);
1086 1.1 christos break;
1087 1.1 christos
1088 1.1 christos case ACPI_TYPE_BUFFER:
1089 1.1 christos
1090 1.1 christos ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
1091 1.1 christos ThisParam->Buffer.Length = 48;
1092 1.1 christos break;
1093 1.1 christos
1094 1.1 christos case ACPI_TYPE_PACKAGE:
1095 1.1 christos
1096 1.1 christos ThisParam->Package.Elements = NULL;
1097 1.1 christos ThisParam->Package.Count = 0;
1098 1.1 christos break;
1099 1.1 christos
1100 1.1 christos default:
1101 1.1 christos
1102 1.1 christos AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
1103 1.1 christos Pathname, ArgType);
1104 1.1 christos break;
1105 1.1 christos }
1106 1.1 christos
1107 1.1 christos ThisParam++;
1108 1.1 christos }
1109 1.1 christos
1110 1.1 christos ParamObjects.Count = ArgCount;
1111 1.1 christos ParamObjects.Pointer = Params;
1112 1.1 christos }
1113 1.1 christos
1114 1.1 christos ACPI_FREE (ObjInfo);
1115 1.1 christos ReturnObj.Pointer = NULL;
1116 1.1 christos ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
1117 1.1 christos
1118 1.1 christos /* Do the actual method execution */
1119 1.1 christos
1120 1.1 christos AcpiGbl_MethodExecuting = TRUE;
1121 1.1 christos
1122 1.1 christos Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
1123 1.1 christos
1124 1.1.1.4 christos AcpiOsPrintf ("%-32s returned %s\n",
1125 1.1.1.4 christos Pathname, AcpiFormatException (Status));
1126 1.1 christos AcpiGbl_MethodExecuting = FALSE;
1127 1.1 christos ACPI_FREE (Pathname);
1128 1.1 christos
1129 1.1 christos /* Ignore status from method execution */
1130 1.1 christos
1131 1.1 christos Status = AE_OK;
1132 1.1 christos
1133 1.1 christos /* Update count, check if we have executed enough methods */
1134 1.1 christos
1135 1.1 christos Info->Count++;
1136 1.1 christos if (Info->Count >= Info->MaxCount)
1137 1.1 christos {
1138 1.1 christos Status = AE_CTRL_TERMINATE;
1139 1.1 christos }
1140 1.1 christos
1141 1.1 christos return (Status);
1142 1.1 christos }
1143