ReactOS 0.4.15-dev-5669-g09dde2c
exresnte.c
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Module Name: exresnte - AML Interpreter object resolution
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2022, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
25 *
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.
29 *
30 * NO WARRANTY
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 MERCHANTABILITY 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.
42 */
43
44#include "acpi.h"
45#include "accommon.h"
46#include "acdispat.h"
47#include "acinterp.h"
48#include "acnamesp.h"
49
50
51#define _COMPONENT ACPI_EXECUTER
52 ACPI_MODULE_NAME ("exresnte")
53
54
55/*******************************************************************************
56 *
57 * FUNCTION: AcpiExResolveNodeToValue
58 *
59 * PARAMETERS: ObjectPtr - Pointer to a location that contains
60 * a pointer to a NS node, and will receive a
61 * pointer to the resolved object.
62 * WalkState - Current state. Valid only if executing AML
63 * code. NULL if simply resolving an object
64 *
65 * RETURN: Status
66 *
67 * DESCRIPTION: Resolve a Namespace node to a valued object
68 *
69 * Note: for some of the data types, the pointer attached to the Node
70 * can be either a pointer to an actual internal object or a pointer into the
71 * AML stream itself. These types are currently:
72 *
73 * ACPI_TYPE_INTEGER
74 * ACPI_TYPE_STRING
75 * ACPI_TYPE_BUFFER
76 * ACPI_TYPE_MUTEX
77 * ACPI_TYPE_PACKAGE
78 *
79 ******************************************************************************/
80
83 ACPI_NAMESPACE_NODE **ObjectPtr,
84 ACPI_WALK_STATE *WalkState)
85
86{
88 ACPI_OPERAND_OBJECT *SourceDesc;
89 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
91 ACPI_OBJECT_TYPE EntryType;
92
93
94 ACPI_FUNCTION_TRACE (ExResolveNodeToValue);
95
96
97 /*
98 * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the
99 * object that is attached to the Node.
100 */
101 Node = *ObjectPtr;
102 SourceDesc = AcpiNsGetAttachedObject (Node);
103 EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
104
105 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
106 Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
107
108 if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
109 (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
110 {
111 /* There is always exactly one level of indirection */
112
114 SourceDesc = AcpiNsGetAttachedObject (Node);
115 EntryType = AcpiNsGetType ((ACPI_HANDLE) Node);
116 *ObjectPtr = Node;
117 }
118
119 /*
120 * Several object types require no further processing:
121 * 1) Device/Thermal objects don't have a "real" subobject, return Node
122 * 2) Method locals and arguments have a pseudo-Node
123 * 3) 10/2007: Added method type to assist with Package construction.
124 */
125 if ((EntryType == ACPI_TYPE_DEVICE) ||
126 (EntryType == ACPI_TYPE_THERMAL) ||
127 (EntryType == ACPI_TYPE_METHOD) ||
129 {
131 }
132
133 if (!SourceDesc)
134 {
135 ACPI_ERROR ((AE_INFO, "No object attached to node [%4.4s] %p",
136 Node->Name.Ascii, Node));
138 }
139
140 /*
141 * Action is based on the type of the Node, which indicates the type
142 * of the attached object or pointer
143 */
144 switch (EntryType)
145 {
147
148 if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
149 {
150 ACPI_ERROR ((AE_INFO, "Object not a Package, type %s",
151 AcpiUtGetObjectTypeName (SourceDesc)));
153 }
154
155 Status = AcpiDsGetPackageArguments (SourceDesc);
156 if (ACPI_SUCCESS (Status))
157 {
158 /* Return an additional reference to the object */
159
160 ObjDesc = SourceDesc;
161 AcpiUtAddReference (ObjDesc);
162 }
163 break;
164
165 case ACPI_TYPE_BUFFER:
166
167 if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
168 {
169 ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s",
170 AcpiUtGetObjectTypeName (SourceDesc)));
172 }
173
174 Status = AcpiDsGetBufferArguments (SourceDesc);
175 if (ACPI_SUCCESS (Status))
176 {
177 /* Return an additional reference to the object */
178
179 ObjDesc = SourceDesc;
180 AcpiUtAddReference (ObjDesc);
181 }
182 break;
183
184 case ACPI_TYPE_STRING:
185
186 if (SourceDesc->Common.Type != ACPI_TYPE_STRING)
187 {
188 ACPI_ERROR ((AE_INFO, "Object not a String, type %s",
189 AcpiUtGetObjectTypeName (SourceDesc)));
191 }
192
193 /* Return an additional reference to the object */
194
195 ObjDesc = SourceDesc;
196 AcpiUtAddReference (ObjDesc);
197 break;
198
200
201 if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
202 {
203 ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s",
204 AcpiUtGetObjectTypeName (SourceDesc)));
206 }
207
208 /* Return an additional reference to the object */
209
210 ObjDesc = SourceDesc;
211 AcpiUtAddReference (ObjDesc);
212 break;
213
218
220 "FieldRead Node=%p SourceDesc=%p Type=%X\n",
221 Node, SourceDesc, EntryType));
222
223 Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc);
224 break;
225
226 /* For these objects, just return the object attached to the Node */
227
228 case ACPI_TYPE_MUTEX:
229 case ACPI_TYPE_POWER:
231 case ACPI_TYPE_EVENT:
232 case ACPI_TYPE_REGION:
233
234 /* Return an additional reference to the object */
235
236 ObjDesc = SourceDesc;
237 AcpiUtAddReference (ObjDesc);
238 break;
239
240 /* TYPE_ANY is untyped, and thus there is no object associated with it */
241
242 case ACPI_TYPE_ANY:
243
245 "Untyped entry %p, no attached object!", Node));
246
247 return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
248
250
251 switch (SourceDesc->Reference.Class)
252 {
253 case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */
256
257 /* Return an additional reference to the object */
258
259 ObjDesc = SourceDesc;
260 AcpiUtAddReference (ObjDesc);
261 break;
262
263 default:
264
265 /* No named references are allowed here */
266
268 "Unsupported Reference type 0x%X",
269 SourceDesc->Reference.Class));
270
272 }
273 break;
274
275 default:
276
277 /* Default case is for unknown types */
278
280 "Node %p - Unknown object type 0x%X",
281 Node, EntryType));
282
284
285 } /* switch (EntryType) */
286
287
288 /* Return the object descriptor */
289
290 *ObjectPtr = (void *) ObjDesc;
292}
#define AE_AML_UNINITIALIZED_NODE
Definition: acexcep.h:213
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define AE_OK
Definition: acexcep.h:97
#define ANOBJ_METHOD_ARG
Definition: aclocal.h:217
#define ANOBJ_METHOD_LOCAL
Definition: aclocal.h:218
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
ACPI_OBJECT_TYPE AcpiNsGetType(ACPI_NAMESPACE_NODE *Node)
Definition: nsutils.c:120
@ ACPI_REFCLASS_TABLE
Definition: acobject.h:463
@ ACPI_REFCLASS_INDEX
Definition: acobject.h:462
@ ACPI_REFCLASS_REFOF
Definition: acobject.h:461
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
#define ACPI_TYPE_BUFFER_FIELD
Definition: actypes.h:701
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_LOCAL_BANK_FIELD
Definition: actypes.h:717
#define ACPI_TYPE_EVENT
Definition: actypes.h:694
#define ACPI_TYPE_PROCESSOR
Definition: actypes.h:699
UINT32 ACPI_OBJECT_TYPE
Definition: actypes.h:685
#define ACPI_TYPE_MUTEX
Definition: actypes.h:696
#define ACPI_TYPE_LOCAL_ALIAS
Definition: actypes.h:720
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_TYPE_REGION
Definition: actypes.h:697
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
#define ACPI_TYPE_LOCAL_REGION_FIELD
Definition: actypes.h:716
#define ACPI_TYPE_POWER
Definition: actypes.h:698
#define ACPI_TYPE_ANY
Definition: actypes.h:687
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_TYPE_DEVICE
Definition: actypes.h:693
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691
#define ACPI_TYPE_LOCAL_METHOD_ALIAS
Definition: actypes.h:721
#define ACPI_TYPE_LOCAL_INDEX_FIELD
Definition: actypes.h:718
#define ACPI_TYPE_METHOD
Definition: actypes.h:695
#define ACPI_TYPE_THERMAL
Definition: actypes.h:700
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
const char * AcpiUtGetObjectTypeName(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: utdecode.c:264
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:752
#define NULL
Definition: types.h:112
union node Node
Definition: types.h:1255
ACPI_STATUS AcpiDsGetPackageArguments(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsargs.c:344
ACPI_STATUS AcpiDsGetBufferArguments(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsargs.c:294
ACPI_STATUS AcpiExReadDataFromField(ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **RetBufferDesc)
Definition: exfield.c:147
ACPI_STATUS AcpiExResolveNodeToValue(ACPI_NAMESPACE_NODE **ObjectPtr, ACPI_WALK_STATE *WalkState)
Definition: exresnte.c:82
Status
Definition: gdiplustypes.h:25
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:443
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:540
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
Definition: dlist.c:348