ReactOS  0.4.14-dev-552-g2fad488
nsxfobj.c
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
4  * ACPI Object oriented interfaces
5  *
6  ******************************************************************************/
7 
8 /*
9  * Copyright (C) 2000 - 2019, Intel Corp.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  * notice, this list of conditions, and the following disclaimer,
17  * without modification.
18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19  * substantially similar to the "NO WARRANTY" disclaimer below
20  * ("Disclaimer") and any redistribution must be conditioned upon
21  * including a substantially similar Disclaimer requirement for further
22  * binary redistribution.
23  * 3. Neither the names of the above-listed copyright holders nor the names
24  * of any contributors may be used to endorse or promote products derived
25  * from this software without specific prior written permission.
26  *
27  * Alternatively, this software may be distributed under the terms of the
28  * GNU General Public License ("GPL") version 2 as published by the Free
29  * Software Foundation.
30  *
31  * NO WARRANTY
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42  * POSSIBILITY OF SUCH DAMAGES.
43  */
44 
45 #define EXPORT_ACPI_INTERFACES
46 
47 #include "acpi.h"
48 #include "accommon.h"
49 #include "acnamesp.h"
50 
51 
52 #define _COMPONENT ACPI_NAMESPACE
53  ACPI_MODULE_NAME ("nsxfobj")
54 
55 /*******************************************************************************
56  *
57  * FUNCTION: AcpiGetType
58  *
59  * PARAMETERS: Handle - Handle of object whose type is desired
60  * RetType - Where the type will be placed
61  *
62  * RETURN: Status
63  *
64  * DESCRIPTION: This routine returns the type associatd with a particular handle
65  *
66  ******************************************************************************/
67 
71  ACPI_OBJECT_TYPE *RetType)
72 {
75 
76 
77  /* Parameter Validation */
78 
79  if (!RetType)
80  {
81  return (AE_BAD_PARAMETER);
82  }
83 
84  /* Special case for the predefined Root Node (return type ANY) */
85 
86  if (Handle == ACPI_ROOT_OBJECT)
87  {
88  *RetType = ACPI_TYPE_ANY;
89  return (AE_OK);
90  }
91 
93  if (ACPI_FAILURE (Status))
94  {
95  return (Status);
96  }
97 
98  /* Convert and validate the handle */
99 
101  if (!Node)
102  {
104  return (AE_BAD_PARAMETER);
105  }
106 
107  *RetType = Node->Type;
108 
110  return (Status);
111 }
112 
114 
115 
116 /*******************************************************************************
117  *
118  * FUNCTION: AcpiGetParent
119  *
120  * PARAMETERS: Handle - Handle of object whose parent is desired
121  * RetHandle - Where the parent handle will be placed
122  *
123  * RETURN: Status
124  *
125  * DESCRIPTION: Returns a handle to the parent of the object represented by
126  * Handle.
127  *
128  ******************************************************************************/
129 
133  ACPI_HANDLE *RetHandle)
134 {
136  ACPI_NAMESPACE_NODE *ParentNode;
138 
139 
140  if (!RetHandle)
141  {
142  return (AE_BAD_PARAMETER);
143  }
144 
145  /* Special case for the predefined Root Node (no parent) */
146 
147  if (Handle == ACPI_ROOT_OBJECT)
148  {
149  return (AE_NULL_ENTRY);
150  }
151 
153  if (ACPI_FAILURE (Status))
154  {
155  return (Status);
156  }
157 
158  /* Convert and validate the handle */
159 
161  if (!Node)
162  {
164  goto UnlockAndExit;
165  }
166 
167  /* Get the parent entry */
168 
169  ParentNode = Node->Parent;
170  *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode);
171 
172  /* Return exception if parent is null */
173 
174  if (!ParentNode)
175  {
177  }
178 
179 
180 UnlockAndExit:
181 
183  return (Status);
184 }
185 
187 
188 
189 /*******************************************************************************
190  *
191  * FUNCTION: AcpiGetNextObject
192  *
193  * PARAMETERS: Type - Type of object to be searched for
194  * Parent - Parent object whose children we are getting
195  * LastChild - Previous child that was found.
196  * The NEXT child will be returned
197  * RetHandle - Where handle to the next object is placed
198  *
199  * RETURN: Status
200  *
201  * DESCRIPTION: Return the next peer object within the namespace. If Handle is
202  * valid, Scope is ignored. Otherwise, the first object within
203  * Scope is returned.
204  *
205  ******************************************************************************/
206 
212  ACPI_HANDLE *RetHandle)
213 {
216  ACPI_NAMESPACE_NODE *ParentNode = NULL;
217  ACPI_NAMESPACE_NODE *ChildNode = NULL;
218 
219 
220  /* Parameter validation */
221 
223  {
224  return (AE_BAD_PARAMETER);
225  }
226 
228  if (ACPI_FAILURE (Status))
229  {
230  return (Status);
231  }
232 
233  /* If null handle, use the parent */
234 
235  if (!Child)
236  {
237  /* Start search at the beginning of the specified scope */
238 
239  ParentNode = AcpiNsValidateHandle (Parent);
240  if (!ParentNode)
241  {
243  goto UnlockAndExit;
244  }
245  }
246  else
247  {
248  /* Non-null handle, ignore the parent */
249  /* Convert and validate the handle */
250 
251  ChildNode = AcpiNsValidateHandle (Child);
252  if (!ChildNode)
253  {
255  goto UnlockAndExit;
256  }
257  }
258 
259  /* Internal function does the real work */
260 
261  Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode);
262  if (!Node)
263  {
265  goto UnlockAndExit;
266  }
267 
268  if (RetHandle)
269  {
270  *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node);
271  }
272 
273 
274 UnlockAndExit:
275 
277  return (Status);
278 }
279 
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
Type
Definition: Type.h:6
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
ACPI_STATUS AcpiGetParent(ACPI_HANDLE Handle, ACPI_HANDLE *RetHandle)
Definition: nsxfobj.c:131
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_NAMESPACE_NODE * AcpiNsGetNextNodeTyped(ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE *Parent, ACPI_NAMESPACE_NODE *Child)
Definition: nswalk.c:112
#define ACPI_TYPE_EXTERNAL_MAX
Definition: actypes.h:696
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
union node Node
Definition: types.h:1255
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_EXPORT_SYMBOL(Symbol)
Definition: actypes.h:343
smooth NULL
Definition: ftsmooth.c:416
UINT32 ACPI_OBJECT_TYPE
Definition: actypes.h:676
#define ACPI_ROOT_OBJECT
Definition: actypes.h:500
_In_ HANDLE Handle
Definition: extypes.h:390
ACPI_STATUS AcpiGetNextObject(ACPI_OBJECT_TYPE Type, ACPI_HANDLE Parent, ACPI_HANDLE Child, ACPI_HANDLE *RetHandle)
Definition: nsxfobj.c:208
#define AE_NOT_FOUND
Definition: acexcep.h:113
#define ACPI_TYPE_ANY
Definition: actypes.h:678
Status
Definition: gdiplustypes.h:24
#define AE_NULL_ENTRY
Definition: acexcep.h:118
ACPI_STATUS AcpiGetType(ACPI_HANDLE Handle, ACPI_OBJECT_TYPE *RetType)
Definition: nsxfobj.c:69
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:728
ACPI_NAMESPACE_NODE * AcpiNsValidateHandle(ACPI_HANDLE Handle)
Definition: nsutils.c:655
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define AE_OK
Definition: acexcep.h:97
Definition: dlist.c:348