dbmethod.c revision 1.1.1.1.2.2 1 1.1.1.1.2.2 bouyer /*******************************************************************************
2 1.1.1.1.2.2 bouyer *
3 1.1.1.1.2.2 bouyer * Module Name: dbmethod - Debug commands for control methods
4 1.1.1.1.2.2 bouyer *
5 1.1.1.1.2.2 bouyer ******************************************************************************/
6 1.1.1.1.2.2 bouyer
7 1.1.1.1.2.2 bouyer /*
8 1.1.1.1.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.1.2.2 bouyer * All rights reserved.
10 1.1.1.1.2.2 bouyer *
11 1.1.1.1.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.1.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.1.2.2 bouyer * are met:
14 1.1.1.1.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.1.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.1.2.2 bouyer * without modification.
17 1.1.1.1.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.1.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.1.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.1.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.1.2.2 bouyer * binary redistribution.
22 1.1.1.1.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.1.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.1.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.1.2.2 bouyer *
26 1.1.1.1.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.1.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.1.2.2 bouyer * Software Foundation.
29 1.1.1.1.2.2 bouyer *
30 1.1.1.1.2.2 bouyer * NO WARRANTY
31 1.1.1.1.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.1.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.1.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.1.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.1.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.1.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.1.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.1.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.1.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.1.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.1.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.1.2.2 bouyer */
43 1.1.1.1.2.2 bouyer
44 1.1.1.1.2.2 bouyer
45 1.1.1.1.2.2 bouyer #include "acpi.h"
46 1.1.1.1.2.2 bouyer #include "accommon.h"
47 1.1.1.1.2.2 bouyer #include "acdispat.h"
48 1.1.1.1.2.2 bouyer #include "acnamesp.h"
49 1.1.1.1.2.2 bouyer #include "acdebug.h"
50 1.1.1.1.2.2 bouyer #include "acdisasm.h"
51 1.1.1.1.2.2 bouyer #include "acparser.h"
52 1.1.1.1.2.2 bouyer
53 1.1.1.1.2.2 bouyer
54 1.1.1.1.2.2 bouyer #ifdef ACPI_DEBUGGER
55 1.1.1.1.2.2 bouyer
56 1.1.1.1.2.2 bouyer #define _COMPONENT ACPI_CA_DEBUGGER
57 1.1.1.1.2.2 bouyer ACPI_MODULE_NAME ("dbmethod")
58 1.1.1.1.2.2 bouyer
59 1.1.1.1.2.2 bouyer
60 1.1.1.1.2.2 bouyer /* Local prototypes */
61 1.1.1.1.2.2 bouyer
62 1.1.1.1.2.2 bouyer static ACPI_STATUS
63 1.1.1.1.2.2 bouyer AcpiDbWalkForExecute (
64 1.1.1.1.2.2 bouyer ACPI_HANDLE ObjHandle,
65 1.1.1.1.2.2 bouyer UINT32 NestingLevel,
66 1.1.1.1.2.2 bouyer void *Context,
67 1.1.1.1.2.2 bouyer void **ReturnValue);
68 1.1.1.1.2.2 bouyer
69 1.1.1.1.2.2 bouyer
70 1.1.1.1.2.2 bouyer /*******************************************************************************
71 1.1.1.1.2.2 bouyer *
72 1.1.1.1.2.2 bouyer * FUNCTION: AcpiDbSetMethodBreakpoint
73 1.1.1.1.2.2 bouyer *
74 1.1.1.1.2.2 bouyer * PARAMETERS: Location - AML offset of breakpoint
75 1.1.1.1.2.2 bouyer * WalkState - Current walk info
76 1.1.1.1.2.2 bouyer * Op - Current Op (from parse walk)
77 1.1.1.1.2.2 bouyer *
78 1.1.1.1.2.2 bouyer * RETURN: None
79 1.1.1.1.2.2 bouyer *
80 1.1.1.1.2.2 bouyer * DESCRIPTION: Set a breakpoint in a control method at the specified
81 1.1.1.1.2.2 bouyer * AML offset
82 1.1.1.1.2.2 bouyer *
83 1.1.1.1.2.2 bouyer ******************************************************************************/
84 1.1.1.1.2.2 bouyer
85 1.1.1.1.2.2 bouyer void
86 1.1.1.1.2.2 bouyer AcpiDbSetMethodBreakpoint (
87 1.1.1.1.2.2 bouyer char *Location,
88 1.1.1.1.2.2 bouyer ACPI_WALK_STATE *WalkState,
89 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op)
90 1.1.1.1.2.2 bouyer {
91 1.1.1.1.2.2 bouyer UINT32 Address;
92 1.1.1.1.2.2 bouyer
93 1.1.1.1.2.2 bouyer
94 1.1.1.1.2.2 bouyer if (!Op)
95 1.1.1.1.2.2 bouyer {
96 1.1.1.1.2.2 bouyer AcpiOsPrintf ("There is no method currently executing\n");
97 1.1.1.1.2.2 bouyer return;
98 1.1.1.1.2.2 bouyer }
99 1.1.1.1.2.2 bouyer
100 1.1.1.1.2.2 bouyer /* Get and verify the breakpoint address */
101 1.1.1.1.2.2 bouyer
102 1.1.1.1.2.2 bouyer Address = ACPI_STRTOUL (Location, NULL, 16);
103 1.1.1.1.2.2 bouyer if (Address <= Op->Common.AmlOffset)
104 1.1.1.1.2.2 bouyer {
105 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
106 1.1.1.1.2.2 bouyer Address, Op->Common.AmlOffset);
107 1.1.1.1.2.2 bouyer }
108 1.1.1.1.2.2 bouyer
109 1.1.1.1.2.2 bouyer /* Save breakpoint in current walk */
110 1.1.1.1.2.2 bouyer
111 1.1.1.1.2.2 bouyer WalkState->UserBreakpoint = Address;
112 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
113 1.1.1.1.2.2 bouyer }
114 1.1.1.1.2.2 bouyer
115 1.1.1.1.2.2 bouyer
116 1.1.1.1.2.2 bouyer /*******************************************************************************
117 1.1.1.1.2.2 bouyer *
118 1.1.1.1.2.2 bouyer * FUNCTION: AcpiDbSetMethodCallBreakpoint
119 1.1.1.1.2.2 bouyer *
120 1.1.1.1.2.2 bouyer * PARAMETERS: Op - Current Op (from parse walk)
121 1.1.1.1.2.2 bouyer *
122 1.1.1.1.2.2 bouyer * RETURN: None
123 1.1.1.1.2.2 bouyer *
124 1.1.1.1.2.2 bouyer * DESCRIPTION: Set a breakpoint in a control method at the specified
125 1.1.1.1.2.2 bouyer * AML offset
126 1.1.1.1.2.2 bouyer *
127 1.1.1.1.2.2 bouyer ******************************************************************************/
128 1.1.1.1.2.2 bouyer
129 1.1.1.1.2.2 bouyer void
130 1.1.1.1.2.2 bouyer AcpiDbSetMethodCallBreakpoint (
131 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op)
132 1.1.1.1.2.2 bouyer {
133 1.1.1.1.2.2 bouyer
134 1.1.1.1.2.2 bouyer
135 1.1.1.1.2.2 bouyer if (!Op)
136 1.1.1.1.2.2 bouyer {
137 1.1.1.1.2.2 bouyer AcpiOsPrintf ("There is no method currently executing\n");
138 1.1.1.1.2.2 bouyer return;
139 1.1.1.1.2.2 bouyer }
140 1.1.1.1.2.2 bouyer
141 1.1.1.1.2.2 bouyer AcpiGbl_StepToNextCall = TRUE;
142 1.1.1.1.2.2 bouyer }
143 1.1.1.1.2.2 bouyer
144 1.1.1.1.2.2 bouyer
145 1.1.1.1.2.2 bouyer /*******************************************************************************
146 1.1.1.1.2.2 bouyer *
147 1.1.1.1.2.2 bouyer * FUNCTION: AcpiDbSetMethodData
148 1.1.1.1.2.2 bouyer *
149 1.1.1.1.2.2 bouyer * PARAMETERS: TypeArg - L for local, A for argument
150 1.1.1.1.2.2 bouyer * IndexArg - which one
151 1.1.1.1.2.2 bouyer * ValueArg - Value to set.
152 1.1.1.1.2.2 bouyer *
153 1.1.1.1.2.2 bouyer * RETURN: None
154 1.1.1.1.2.2 bouyer *
155 1.1.1.1.2.2 bouyer * DESCRIPTION: Set a local or argument for the running control method.
156 1.1.1.1.2.2 bouyer * NOTE: only object supported is Number.
157 1.1.1.1.2.2 bouyer *
158 1.1.1.1.2.2 bouyer ******************************************************************************/
159 1.1.1.1.2.2 bouyer
160 1.1.1.1.2.2 bouyer void
161 1.1.1.1.2.2 bouyer AcpiDbSetMethodData (
162 1.1.1.1.2.2 bouyer char *TypeArg,
163 1.1.1.1.2.2 bouyer char *IndexArg,
164 1.1.1.1.2.2 bouyer char *ValueArg)
165 1.1.1.1.2.2 bouyer {
166 1.1.1.1.2.2 bouyer char Type;
167 1.1.1.1.2.2 bouyer UINT32 Index;
168 1.1.1.1.2.2 bouyer UINT32 Value;
169 1.1.1.1.2.2 bouyer ACPI_WALK_STATE *WalkState;
170 1.1.1.1.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
171 1.1.1.1.2.2 bouyer ACPI_STATUS Status;
172 1.1.1.1.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
173 1.1.1.1.2.2 bouyer
174 1.1.1.1.2.2 bouyer
175 1.1.1.1.2.2 bouyer /* Validate TypeArg */
176 1.1.1.1.2.2 bouyer
177 1.1.1.1.2.2 bouyer AcpiUtStrupr (TypeArg);
178 1.1.1.1.2.2 bouyer Type = TypeArg[0];
179 1.1.1.1.2.2 bouyer if ((Type != 'L') &&
180 1.1.1.1.2.2 bouyer (Type != 'A') &&
181 1.1.1.1.2.2 bouyer (Type != 'N'))
182 1.1.1.1.2.2 bouyer {
183 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
184 1.1.1.1.2.2 bouyer return;
185 1.1.1.1.2.2 bouyer }
186 1.1.1.1.2.2 bouyer
187 1.1.1.1.2.2 bouyer Value = ACPI_STRTOUL (ValueArg, NULL, 16);
188 1.1.1.1.2.2 bouyer
189 1.1.1.1.2.2 bouyer if (Type == 'N')
190 1.1.1.1.2.2 bouyer {
191 1.1.1.1.2.2 bouyer Node = AcpiDbConvertToNode (IndexArg);
192 1.1.1.1.2.2 bouyer if (Node->Type != ACPI_TYPE_INTEGER)
193 1.1.1.1.2.2 bouyer {
194 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Can only set Integer nodes\n");
195 1.1.1.1.2.2 bouyer return;
196 1.1.1.1.2.2 bouyer }
197 1.1.1.1.2.2 bouyer ObjDesc = Node->Object;
198 1.1.1.1.2.2 bouyer ObjDesc->Integer.Value = Value;
199 1.1.1.1.2.2 bouyer return;
200 1.1.1.1.2.2 bouyer }
201 1.1.1.1.2.2 bouyer
202 1.1.1.1.2.2 bouyer /* Get the index and value */
203 1.1.1.1.2.2 bouyer
204 1.1.1.1.2.2 bouyer Index = ACPI_STRTOUL (IndexArg, NULL, 16);
205 1.1.1.1.2.2 bouyer
206 1.1.1.1.2.2 bouyer WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
207 1.1.1.1.2.2 bouyer if (!WalkState)
208 1.1.1.1.2.2 bouyer {
209 1.1.1.1.2.2 bouyer AcpiOsPrintf ("There is no method currently executing\n");
210 1.1.1.1.2.2 bouyer return;
211 1.1.1.1.2.2 bouyer }
212 1.1.1.1.2.2 bouyer
213 1.1.1.1.2.2 bouyer /* Create and initialize the new object */
214 1.1.1.1.2.2 bouyer
215 1.1.1.1.2.2 bouyer ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value);
216 1.1.1.1.2.2 bouyer if (!ObjDesc)
217 1.1.1.1.2.2 bouyer {
218 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Could not create an internal object\n");
219 1.1.1.1.2.2 bouyer return;
220 1.1.1.1.2.2 bouyer }
221 1.1.1.1.2.2 bouyer
222 1.1.1.1.2.2 bouyer /* Store the new object into the target */
223 1.1.1.1.2.2 bouyer
224 1.1.1.1.2.2 bouyer switch (Type)
225 1.1.1.1.2.2 bouyer {
226 1.1.1.1.2.2 bouyer case 'A':
227 1.1.1.1.2.2 bouyer
228 1.1.1.1.2.2 bouyer /* Set a method argument */
229 1.1.1.1.2.2 bouyer
230 1.1.1.1.2.2 bouyer if (Index > ACPI_METHOD_MAX_ARG)
231 1.1.1.1.2.2 bouyer {
232 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index);
233 1.1.1.1.2.2 bouyer goto Cleanup;
234 1.1.1.1.2.2 bouyer }
235 1.1.1.1.2.2 bouyer
236 1.1.1.1.2.2 bouyer Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc,
237 1.1.1.1.2.2 bouyer WalkState);
238 1.1.1.1.2.2 bouyer if (ACPI_FAILURE (Status))
239 1.1.1.1.2.2 bouyer {
240 1.1.1.1.2.2 bouyer goto Cleanup;
241 1.1.1.1.2.2 bouyer }
242 1.1.1.1.2.2 bouyer
243 1.1.1.1.2.2 bouyer ObjDesc = WalkState->Arguments[Index].Object;
244 1.1.1.1.2.2 bouyer
245 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Arg%u: ", Index);
246 1.1.1.1.2.2 bouyer AcpiDmDisplayInternalObject (ObjDesc, WalkState);
247 1.1.1.1.2.2 bouyer break;
248 1.1.1.1.2.2 bouyer
249 1.1.1.1.2.2 bouyer case 'L':
250 1.1.1.1.2.2 bouyer
251 1.1.1.1.2.2 bouyer /* Set a method local */
252 1.1.1.1.2.2 bouyer
253 1.1.1.1.2.2 bouyer if (Index > ACPI_METHOD_MAX_LOCAL)
254 1.1.1.1.2.2 bouyer {
255 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index);
256 1.1.1.1.2.2 bouyer goto Cleanup;
257 1.1.1.1.2.2 bouyer }
258 1.1.1.1.2.2 bouyer
259 1.1.1.1.2.2 bouyer Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc,
260 1.1.1.1.2.2 bouyer WalkState);
261 1.1.1.1.2.2 bouyer if (ACPI_FAILURE (Status))
262 1.1.1.1.2.2 bouyer {
263 1.1.1.1.2.2 bouyer goto Cleanup;
264 1.1.1.1.2.2 bouyer }
265 1.1.1.1.2.2 bouyer
266 1.1.1.1.2.2 bouyer ObjDesc = WalkState->LocalVariables[Index].Object;
267 1.1.1.1.2.2 bouyer
268 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Local%u: ", Index);
269 1.1.1.1.2.2 bouyer AcpiDmDisplayInternalObject (ObjDesc, WalkState);
270 1.1.1.1.2.2 bouyer break;
271 1.1.1.1.2.2 bouyer
272 1.1.1.1.2.2 bouyer default:
273 1.1.1.1.2.2 bouyer break;
274 1.1.1.1.2.2 bouyer }
275 1.1.1.1.2.2 bouyer
276 1.1.1.1.2.2 bouyer Cleanup:
277 1.1.1.1.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
278 1.1.1.1.2.2 bouyer }
279 1.1.1.1.2.2 bouyer
280 1.1.1.1.2.2 bouyer
281 1.1.1.1.2.2 bouyer /*******************************************************************************
282 1.1.1.1.2.2 bouyer *
283 1.1.1.1.2.2 bouyer * FUNCTION: AcpiDbDisassembleAml
284 1.1.1.1.2.2 bouyer *
285 1.1.1.1.2.2 bouyer * PARAMETERS: Statements - Number of statements to disassemble
286 1.1.1.1.2.2 bouyer * Op - Current Op (from parse walk)
287 1.1.1.1.2.2 bouyer *
288 1.1.1.1.2.2 bouyer * RETURN: None
289 1.1.1.1.2.2 bouyer *
290 1.1.1.1.2.2 bouyer * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
291 1.1.1.1.2.2 bouyer * of statements specified.
292 1.1.1.1.2.2 bouyer *
293 1.1.1.1.2.2 bouyer ******************************************************************************/
294 1.1.1.1.2.2 bouyer
295 1.1.1.1.2.2 bouyer void
296 1.1.1.1.2.2 bouyer AcpiDbDisassembleAml (
297 1.1.1.1.2.2 bouyer char *Statements,
298 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op)
299 1.1.1.1.2.2 bouyer {
300 1.1.1.1.2.2 bouyer UINT32 NumStatements = 8;
301 1.1.1.1.2.2 bouyer
302 1.1.1.1.2.2 bouyer
303 1.1.1.1.2.2 bouyer if (!Op)
304 1.1.1.1.2.2 bouyer {
305 1.1.1.1.2.2 bouyer AcpiOsPrintf ("There is no method currently executing\n");
306 1.1.1.1.2.2 bouyer return;
307 1.1.1.1.2.2 bouyer }
308 1.1.1.1.2.2 bouyer
309 1.1.1.1.2.2 bouyer if (Statements)
310 1.1.1.1.2.2 bouyer {
311 1.1.1.1.2.2 bouyer NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
312 1.1.1.1.2.2 bouyer }
313 1.1.1.1.2.2 bouyer
314 1.1.1.1.2.2 bouyer AcpiDmDisassemble (NULL, Op, NumStatements);
315 1.1.1.1.2.2 bouyer }
316 1.1.1.1.2.2 bouyer
317 1.1.1.1.2.2 bouyer
318 1.1.1.1.2.2 bouyer /*******************************************************************************
319 1.1.1.1.2.2 bouyer *
320 1.1.1.1.2.2 bouyer * FUNCTION: AcpiDbDisassembleMethod
321 1.1.1.1.2.2 bouyer *
322 1.1.1.1.2.2 bouyer * PARAMETERS: Name - Name of control method
323 1.1.1.1.2.2 bouyer *
324 1.1.1.1.2.2 bouyer * RETURN: None
325 1.1.1.1.2.2 bouyer *
326 1.1.1.1.2.2 bouyer * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
327 1.1.1.1.2.2 bouyer * of statements specified.
328 1.1.1.1.2.2 bouyer *
329 1.1.1.1.2.2 bouyer ******************************************************************************/
330 1.1.1.1.2.2 bouyer
331 1.1.1.1.2.2 bouyer ACPI_STATUS
332 1.1.1.1.2.2 bouyer AcpiDbDisassembleMethod (
333 1.1.1.1.2.2 bouyer char *Name)
334 1.1.1.1.2.2 bouyer {
335 1.1.1.1.2.2 bouyer ACPI_STATUS Status;
336 1.1.1.1.2.2 bouyer ACPI_PARSE_OBJECT *Op;
337 1.1.1.1.2.2 bouyer ACPI_WALK_STATE *WalkState;
338 1.1.1.1.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
339 1.1.1.1.2.2 bouyer ACPI_NAMESPACE_NODE *Method;
340 1.1.1.1.2.2 bouyer
341 1.1.1.1.2.2 bouyer
342 1.1.1.1.2.2 bouyer Method = AcpiDbConvertToNode (Name);
343 1.1.1.1.2.2 bouyer if (!Method)
344 1.1.1.1.2.2 bouyer {
345 1.1.1.1.2.2 bouyer return (AE_BAD_PARAMETER);
346 1.1.1.1.2.2 bouyer }
347 1.1.1.1.2.2 bouyer
348 1.1.1.1.2.2 bouyer ObjDesc = Method->Object;
349 1.1.1.1.2.2 bouyer
350 1.1.1.1.2.2 bouyer Op = AcpiPsCreateScopeOp ();
351 1.1.1.1.2.2 bouyer if (!Op)
352 1.1.1.1.2.2 bouyer {
353 1.1.1.1.2.2 bouyer return (AE_NO_MEMORY);
354 1.1.1.1.2.2 bouyer }
355 1.1.1.1.2.2 bouyer
356 1.1.1.1.2.2 bouyer /* Create and initialize a new walk state */
357 1.1.1.1.2.2 bouyer
358 1.1.1.1.2.2 bouyer WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
359 1.1.1.1.2.2 bouyer if (!WalkState)
360 1.1.1.1.2.2 bouyer {
361 1.1.1.1.2.2 bouyer return (AE_NO_MEMORY);
362 1.1.1.1.2.2 bouyer }
363 1.1.1.1.2.2 bouyer
364 1.1.1.1.2.2 bouyer Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
365 1.1.1.1.2.2 bouyer ObjDesc->Method.AmlStart,
366 1.1.1.1.2.2 bouyer ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
367 1.1.1.1.2.2 bouyer if (ACPI_FAILURE (Status))
368 1.1.1.1.2.2 bouyer {
369 1.1.1.1.2.2 bouyer return (Status);
370 1.1.1.1.2.2 bouyer }
371 1.1.1.1.2.2 bouyer
372 1.1.1.1.2.2 bouyer /* Parse the AML */
373 1.1.1.1.2.2 bouyer
374 1.1.1.1.2.2 bouyer WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
375 1.1.1.1.2.2 bouyer WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
376 1.1.1.1.2.2 bouyer Status = AcpiPsParseAml (WalkState);
377 1.1.1.1.2.2 bouyer
378 1.1.1.1.2.2 bouyer AcpiDmDisassemble (NULL, Op, 0);
379 1.1.1.1.2.2 bouyer AcpiPsDeleteParseTree (Op);
380 1.1.1.1.2.2 bouyer return (AE_OK);
381 1.1.1.1.2.2 bouyer }
382 1.1.1.1.2.2 bouyer
383 1.1.1.1.2.2 bouyer
384 1.1.1.1.2.2 bouyer /*******************************************************************************
385 1.1.1.1.2.2 bouyer *
386 1.1.1.1.2.2 bouyer * FUNCTION: AcpiDbWalkForExecute
387 1.1.1.1.2.2 bouyer *
388 1.1.1.1.2.2 bouyer * PARAMETERS: Callback from WalkNamespace
389 1.1.1.1.2.2 bouyer *
390 1.1.1.1.2.2 bouyer * RETURN: Status
391 1.1.1.1.2.2 bouyer *
392 1.1.1.1.2.2 bouyer * DESCRIPTION: Batch execution module. Currently only executes predefined
393 1.1.1.1.2.2 bouyer * ACPI names.
394 1.1.1.1.2.2 bouyer *
395 1.1.1.1.2.2 bouyer ******************************************************************************/
396 1.1.1.1.2.2 bouyer
397 1.1.1.1.2.2 bouyer static ACPI_STATUS
398 1.1.1.1.2.2 bouyer AcpiDbWalkForExecute (
399 1.1.1.1.2.2 bouyer ACPI_HANDLE ObjHandle,
400 1.1.1.1.2.2 bouyer UINT32 NestingLevel,
401 1.1.1.1.2.2 bouyer void *Context,
402 1.1.1.1.2.2 bouyer void **ReturnValue)
403 1.1.1.1.2.2 bouyer {
404 1.1.1.1.2.2 bouyer ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
405 1.1.1.1.2.2 bouyer ACPI_EXECUTE_WALK *Info = (ACPI_EXECUTE_WALK *) Context;
406 1.1.1.1.2.2 bouyer ACPI_BUFFER ReturnObj;
407 1.1.1.1.2.2 bouyer ACPI_STATUS Status;
408 1.1.1.1.2.2 bouyer char *Pathname;
409 1.1.1.1.2.2 bouyer UINT32 i;
410 1.1.1.1.2.2 bouyer ACPI_DEVICE_INFO *ObjInfo;
411 1.1.1.1.2.2 bouyer ACPI_OBJECT_LIST ParamObjects;
412 1.1.1.1.2.2 bouyer ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS];
413 1.1.1.1.2.2 bouyer const ACPI_PREDEFINED_INFO *Predefined;
414 1.1.1.1.2.2 bouyer
415 1.1.1.1.2.2 bouyer
416 1.1.1.1.2.2 bouyer Predefined = AcpiNsCheckForPredefinedName (Node);
417 1.1.1.1.2.2 bouyer if (!Predefined)
418 1.1.1.1.2.2 bouyer {
419 1.1.1.1.2.2 bouyer return (AE_OK);
420 1.1.1.1.2.2 bouyer }
421 1.1.1.1.2.2 bouyer
422 1.1.1.1.2.2 bouyer if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
423 1.1.1.1.2.2 bouyer {
424 1.1.1.1.2.2 bouyer return (AE_OK);
425 1.1.1.1.2.2 bouyer }
426 1.1.1.1.2.2 bouyer
427 1.1.1.1.2.2 bouyer Pathname = AcpiNsGetExternalPathname (Node);
428 1.1.1.1.2.2 bouyer if (!Pathname)
429 1.1.1.1.2.2 bouyer {
430 1.1.1.1.2.2 bouyer return (AE_OK);
431 1.1.1.1.2.2 bouyer }
432 1.1.1.1.2.2 bouyer
433 1.1.1.1.2.2 bouyer /* Get the object info for number of method parameters */
434 1.1.1.1.2.2 bouyer
435 1.1.1.1.2.2 bouyer Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
436 1.1.1.1.2.2 bouyer if (ACPI_FAILURE (Status))
437 1.1.1.1.2.2 bouyer {
438 1.1.1.1.2.2 bouyer return (Status);
439 1.1.1.1.2.2 bouyer }
440 1.1.1.1.2.2 bouyer
441 1.1.1.1.2.2 bouyer ParamObjects.Pointer = NULL;
442 1.1.1.1.2.2 bouyer ParamObjects.Count = 0;
443 1.1.1.1.2.2 bouyer
444 1.1.1.1.2.2 bouyer if (ObjInfo->Type == ACPI_TYPE_METHOD)
445 1.1.1.1.2.2 bouyer {
446 1.1.1.1.2.2 bouyer /* Setup default parameters */
447 1.1.1.1.2.2 bouyer
448 1.1.1.1.2.2 bouyer for (i = 0; i < ObjInfo->ParamCount; i++)
449 1.1.1.1.2.2 bouyer {
450 1.1.1.1.2.2 bouyer Params[i].Type = ACPI_TYPE_INTEGER;
451 1.1.1.1.2.2 bouyer Params[i].Integer.Value = 1;
452 1.1.1.1.2.2 bouyer }
453 1.1.1.1.2.2 bouyer
454 1.1.1.1.2.2 bouyer ParamObjects.Pointer = Params;
455 1.1.1.1.2.2 bouyer ParamObjects.Count = ObjInfo->ParamCount;
456 1.1.1.1.2.2 bouyer }
457 1.1.1.1.2.2 bouyer
458 1.1.1.1.2.2 bouyer ACPI_FREE (ObjInfo);
459 1.1.1.1.2.2 bouyer ReturnObj.Pointer = NULL;
460 1.1.1.1.2.2 bouyer ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
461 1.1.1.1.2.2 bouyer
462 1.1.1.1.2.2 bouyer /* Do the actual method execution */
463 1.1.1.1.2.2 bouyer
464 1.1.1.1.2.2 bouyer AcpiGbl_MethodExecuting = TRUE;
465 1.1.1.1.2.2 bouyer
466 1.1.1.1.2.2 bouyer Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
467 1.1.1.1.2.2 bouyer
468 1.1.1.1.2.2 bouyer AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
469 1.1.1.1.2.2 bouyer AcpiGbl_MethodExecuting = FALSE;
470 1.1.1.1.2.2 bouyer ACPI_FREE (Pathname);
471 1.1.1.1.2.2 bouyer
472 1.1.1.1.2.2 bouyer /* Ignore status from method execution */
473 1.1.1.1.2.2 bouyer
474 1.1.1.1.2.2 bouyer Status = AE_OK;
475 1.1.1.1.2.2 bouyer
476 1.1.1.1.2.2 bouyer /* Update count, check if we have executed enough methods */
477 1.1.1.1.2.2 bouyer
478 1.1.1.1.2.2 bouyer Info->Count++;
479 1.1.1.1.2.2 bouyer if (Info->Count >= Info->MaxCount)
480 1.1.1.1.2.2 bouyer {
481 1.1.1.1.2.2 bouyer Status = AE_CTRL_TERMINATE;
482 1.1.1.1.2.2 bouyer }
483 1.1.1.1.2.2 bouyer
484 1.1.1.1.2.2 bouyer return (Status);
485 1.1.1.1.2.2 bouyer }
486 1.1.1.1.2.2 bouyer
487 1.1.1.1.2.2 bouyer
488 1.1.1.1.2.2 bouyer /*******************************************************************************
489 1.1.1.1.2.2 bouyer *
490 1.1.1.1.2.2 bouyer * FUNCTION: AcpiDbBatchExecute
491 1.1.1.1.2.2 bouyer *
492 1.1.1.1.2.2 bouyer * PARAMETERS: CountArg - Max number of methods to execute
493 1.1.1.1.2.2 bouyer *
494 1.1.1.1.2.2 bouyer * RETURN: None
495 1.1.1.1.2.2 bouyer *
496 1.1.1.1.2.2 bouyer * DESCRIPTION: Namespace batch execution. Execute predefined names in the
497 1.1.1.1.2.2 bouyer * namespace, up to the max count, if specified.
498 1.1.1.1.2.2 bouyer *
499 1.1.1.1.2.2 bouyer ******************************************************************************/
500 1.1.1.1.2.2 bouyer
501 1.1.1.1.2.2 bouyer void
502 1.1.1.1.2.2 bouyer AcpiDbBatchExecute (
503 1.1.1.1.2.2 bouyer char *CountArg)
504 1.1.1.1.2.2 bouyer {
505 1.1.1.1.2.2 bouyer ACPI_EXECUTE_WALK Info;
506 1.1.1.1.2.2 bouyer
507 1.1.1.1.2.2 bouyer
508 1.1.1.1.2.2 bouyer Info.Count = 0;
509 1.1.1.1.2.2 bouyer Info.MaxCount = ACPI_UINT32_MAX;
510 1.1.1.1.2.2 bouyer
511 1.1.1.1.2.2 bouyer if (CountArg)
512 1.1.1.1.2.2 bouyer {
513 1.1.1.1.2.2 bouyer Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
514 1.1.1.1.2.2 bouyer }
515 1.1.1.1.2.2 bouyer
516 1.1.1.1.2.2 bouyer
517 1.1.1.1.2.2 bouyer /* Search all nodes in namespace */
518 1.1.1.1.2.2 bouyer
519 1.1.1.1.2.2 bouyer (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
520 1.1.1.1.2.2 bouyer AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
521 1.1.1.1.2.2 bouyer
522 1.1.1.1.2.2 bouyer AcpiOsPrintf ("Executed %u predefined names in the namespace\n", Info.Count);
523 1.1.1.1.2.2 bouyer }
524 1.1.1.1.2.2 bouyer
525 1.1.1.1.2.2 bouyer #endif /* ACPI_DEBUGGER */
526