ReactOS 0.4.15-dev-7953-g1f49173
nswalk.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
Include dependency graph for nswalk.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_NAMESPACE
 

Functions

ACPI_NAMESPACE_NODEAcpiNsGetNextNode (ACPI_NAMESPACE_NODE *ParentNode, ACPI_NAMESPACE_NODE *ChildNode)
 
ACPI_NAMESPACE_NODEAcpiNsGetNextNodeTyped (ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE *ParentNode, ACPI_NAMESPACE_NODE *ChildNode)
 
ACPI_STATUS AcpiNsWalkNamespace (ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartNode, UINT32 MaxDepth, UINT32 Flags, ACPI_WALK_CALLBACK DescendingCallback, ACPI_WALK_CALLBACK AscendingCallback, void *Context, void **ReturnValue)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_NAMESPACE

Definition at line 49 of file nswalk.c.

Function Documentation

◆ AcpiNsGetNextNode()

ACPI_NAMESPACE_NODE * AcpiNsGetNextNode ( ACPI_NAMESPACE_NODE ParentNode,
ACPI_NAMESPACE_NODE ChildNode 
)

Definition at line 72 of file nswalk.c.

75{
77
78
79 if (!ChildNode)
80 {
81 /* It's really the parent's _scope_ that we want */
82
83 return (ParentNode->Child);
84 }
85
86 /* Otherwise just return the next peer */
87
88 return (ChildNode->Peer);
89}
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
struct acpi_namespace_node * Child
Definition: aclocal.h:193
struct acpi_namespace_node * Peer
Definition: aclocal.h:194

Referenced by AcpiEvExecuteOrphanRegMethod(), AcpiNsDeleteNamespaceByOwner(), AcpiNsDeleteNamespaceSubtree(), AcpiNsGetNextNodeTyped(), and AcpiNsWalkNamespace().

◆ AcpiNsGetNextNodeTyped()

ACPI_NAMESPACE_NODE * AcpiNsGetNextNodeTyped ( ACPI_OBJECT_TYPE  Type,
ACPI_NAMESPACE_NODE ParentNode,
ACPI_NAMESPACE_NODE ChildNode 
)

Definition at line 112 of file nswalk.c.

116{
117 ACPI_NAMESPACE_NODE *NextNode = NULL;
118
119
121
122
123 NextNode = AcpiNsGetNextNode (ParentNode, ChildNode);
124
125 /* If any type is OK, we are done */
126
127 if (Type == ACPI_TYPE_ANY)
128 {
129 /* NextNode is NULL if we are at the end-of-list */
130
131 return (NextNode);
132 }
133
134 /* Must search for the node -- but within this scope only */
135
136 while (NextNode)
137 {
138 /* If type matches, we are done */
139
140 if (NextNode->Type == Type)
141 {
142 return (NextNode);
143 }
144
145 /* Otherwise, move on to the next peer node */
146
147 NextNode = NextNode->Peer;
148 }
149
150 /* Not found */
151
152 return (NULL);
153}
Type
Definition: Type.h:7
#define ACPI_TYPE_ANY
Definition: actypes.h:687
#define NULL
Definition: types.h:112
ACPI_NAMESPACE_NODE * AcpiNsGetNextNode(ACPI_NAMESPACE_NODE *ParentNode, ACPI_NAMESPACE_NODE *ChildNode)
Definition: nswalk.c:72

Referenced by AcpiGetNextObject().

◆ AcpiNsWalkNamespace()

ACPI_STATUS AcpiNsWalkNamespace ( ACPI_OBJECT_TYPE  Type,
ACPI_HANDLE  StartNode,
UINT32  MaxDepth,
UINT32  Flags,
ACPI_WALK_CALLBACK  DescendingCallback,
ACPI_WALK_CALLBACK  AscendingCallback,
void Context,
void **  ReturnValue 
)

Definition at line 190 of file nswalk.c.

199{
201 ACPI_STATUS MutexStatus;
202 ACPI_NAMESPACE_NODE *ChildNode;
203 ACPI_NAMESPACE_NODE *ParentNode;
204 ACPI_OBJECT_TYPE ChildType;
206 BOOLEAN NodePreviouslyVisited = FALSE;
207
208
209 ACPI_FUNCTION_TRACE (NsWalkNamespace);
210
211
212 /* Special case for the namespace Root Node */
213
214 if (StartNode == ACPI_ROOT_OBJECT)
215 {
216 StartNode = AcpiGbl_RootNode;
217 if (!StartNode)
218 {
220 }
221 }
222
223 /* Null child means "get first node" */
224
225 ParentNode = StartNode;
226 ChildNode = AcpiNsGetNextNode (ParentNode, NULL);
227 ChildType = ACPI_TYPE_ANY;
228 Level = 1;
229
230 /*
231 * Traverse the tree of nodes until we bubble back up to where we
232 * started. When Level is zero, the loop is done because we have
233 * bubbled up to (and passed) the original parent handle (StartEntry)
234 */
235 while (Level > 0 && ChildNode)
236 {
237 Status = AE_OK;
238
239 /* Found next child, get the type if we are not searching for ANY */
240
241 if (Type != ACPI_TYPE_ANY)
242 {
243 ChildType = ChildNode->Type;
244 }
245
246 /*
247 * Ignore all temporary namespace nodes (created during control
248 * method execution) unless told otherwise. These temporary nodes
249 * can cause a race condition because they can be deleted during
250 * the execution of the user function (if the namespace is
251 * unlocked before invocation of the user function.) Only the
252 * debugger namespace dump will examine the temporary nodes.
253 */
254 if ((ChildNode->Flags & ANOBJ_TEMPORARY) &&
256 {
258 }
259
260 /* Type must match requested type */
261
262 else if (ChildType == Type)
263 {
264 /*
265 * Found a matching node, invoke the user callback function.
266 * Unlock the namespace if flag is set.
267 */
269 {
271 if (ACPI_FAILURE (MutexStatus))
272 {
273 return_ACPI_STATUS (MutexStatus);
274 }
275 }
276
277 /*
278 * Invoke the user function, either descending, ascending,
279 * or both.
280 */
281 if (!NodePreviouslyVisited)
282 {
284 {
285 Status = DescendingCallback (ChildNode, Level,
287 }
288 }
289 else
290 {
292 {
293 Status = AscendingCallback (ChildNode, Level,
295 }
296 }
297
299 {
301 if (ACPI_FAILURE (MutexStatus))
302 {
303 return_ACPI_STATUS (MutexStatus);
304 }
305 }
306
307 switch (Status)
308 {
309 case AE_OK:
310 case AE_CTRL_DEPTH:
311
312 /* Just keep going */
313 break;
314
316
317 /* Exit now, with OK status */
318
320
321 default:
322
323 /* All others are valid exceptions */
324
326 }
327 }
328
329 /*
330 * Depth first search: Attempt to go down another level in the
331 * namespace if we are allowed to. Don't go any further if we have
332 * reached the caller specified maximum depth or if the user
333 * function has specified that the maximum depth has been reached.
334 */
335 if (!NodePreviouslyVisited &&
336 (Level < MaxDepth) &&
338 {
339 if (ChildNode->Child)
340 {
341 /* There is at least one child of this node, visit it */
342
343 Level++;
344 ParentNode = ChildNode;
345 ChildNode = AcpiNsGetNextNode (ParentNode, NULL);
346 continue;
347 }
348 }
349
350 /* No more children, re-visit this node */
351
352 if (!NodePreviouslyVisited)
353 {
354 NodePreviouslyVisited = TRUE;
355 continue;
356 }
357
358 /* No more children, visit peers */
359
360 ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode);
361 if (ChildNode)
362 {
363 NodePreviouslyVisited = FALSE;
364 }
365
366 /* No peers, re-visit parent */
367
368 else
369 {
370 /*
371 * No more children of this node (AcpiNsGetNextNode failed), go
372 * back upwards in the namespace tree to the node's parent.
373 */
374 Level--;
375 ChildNode = ParentNode;
376 ParentNode = ParentNode->Parent;
377
378 NodePreviouslyVisited = TRUE;
379 }
380 }
381
382 /* Complete walk, not terminated by user function */
383
385}
unsigned char BOOLEAN
unsigned int UINT32
UINT32 void void ** ReturnValue
Definition: acevents.h:216
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
#define AE_CTRL_DEPTH
Definition: acexcep.h:229
#define AE_NO_NAMESPACE
Definition: acexcep.h:111
#define AE_OK
Definition: acexcep.h:97
#define ANOBJ_TEMPORARY
Definition: aclocal.h:216
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
#define ACPI_NS_WALK_TEMP_NODES
Definition: acnamesp.h:78
#define ACPI_NS_WALK_UNLOCK
Definition: acnamesp.h:77
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK DescendingCallback
Definition: acpixf.h:641
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK AscendingCallback
Definition: acpixf.h:642
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 MaxDepth
Definition: acpixf.h:640
UINT32 ACPI_OBJECT_TYPE
Definition: actypes.h:685
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_ROOT_OBJECT
Definition: actypes.h:500
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:25
struct acpi_namespace_node * Parent
Definition: aclocal.h:192
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by AcpiDsInitializeObjects(), AcpiEvCreateGpeBlock(), AcpiEvExecuteRegMethods(), AcpiEvInstallSpaceHandler(), AcpiEvUpdateGpes(), AcpiGetDevices(), AcpiNsInitializeDevices(), and AcpiWalkNamespace().