ReactOS 0.4.15-dev-7942-gd23573b
dsinit.c
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Module Name: dsinit - Object initialization namespace walk
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 "acnamesp.h"
48#include "actables.h"
49#include "acinterp.h"
50
51#define _COMPONENT ACPI_DISPATCHER
52 ACPI_MODULE_NAME ("dsinit")
53
54
55/* Local prototypes */
56
57static ACPI_STATUS
59 ACPI_HANDLE ObjHandle,
61 void *Context,
62 void **ReturnValue);
63
64
65/*******************************************************************************
66 *
67 * FUNCTION: AcpiDsInitOneObject
68 *
69 * PARAMETERS: ObjHandle - Node for the object
70 * Level - Current nesting level
71 * Context - Points to a init info struct
72 * ReturnValue - Not used
73 *
74 * RETURN: Status
75 *
76 * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
77 * within the namespace.
78 *
79 * Currently, the only objects that require initialization are:
80 * 1) Methods
81 * 2) Operation Regions
82 *
83 ******************************************************************************/
84
85static ACPI_STATUS
87 ACPI_HANDLE ObjHandle,
89 void *Context,
90 void **ReturnValue)
91{
95 ACPI_OPERAND_OBJECT *ObjDesc;
96
97
99
100
101 /*
102 * We are only interested in NS nodes owned by the table that
103 * was just loaded
104 */
105 if (Node->OwnerId != Info->OwnerId)
106 {
107 return (AE_OK);
108 }
109
110 Info->ObjectCount++;
111
112 /* And even then, we are only interested in a few object types */
113
114 switch (AcpiNsGetType (ObjHandle))
115 {
116 case ACPI_TYPE_REGION:
117
118 Status = AcpiDsInitializeRegion (ObjHandle);
119 if (ACPI_FAILURE (Status))
120 {
122 "During Region initialization %p [%4.4s]",
123 ObjHandle, AcpiUtGetNodeName (ObjHandle)));
124 }
125
126 Info->OpRegionCount++;
127 break;
128
129 case ACPI_TYPE_METHOD:
130 /*
131 * Auto-serialization support. We will examine each method that is
132 * NotSerialized to determine if it creates any Named objects. If
133 * it does, it will be marked serialized to prevent problems if
134 * the method is entered by two or more threads and an attempt is
135 * made to create the same named object twice -- which results in
136 * an AE_ALREADY_EXISTS exception and method abort.
137 */
138 Info->MethodCount++;
139 ObjDesc = AcpiNsGetAttachedObject (Node);
140 if (!ObjDesc)
141 {
142 break;
143 }
144
145 /* Ignore if already serialized */
146
148 {
149 Info->SerialMethodCount++;
150 break;
151 }
152
153 if (AcpiGbl_AutoSerializeMethods)
154 {
155 /* Parse/scan method and serialize it if necessary */
156
159 {
160 /* Method was just converted to Serialized */
161
162 Info->SerialMethodCount++;
163 Info->SerializedMethodCount++;
164 break;
165 }
166 }
167
168 Info->NonSerialMethodCount++;
169 break;
170
171 case ACPI_TYPE_DEVICE:
172
173 Info->DeviceCount++;
174 break;
175
176 default:
177
178 break;
179 }
180
181 /*
182 * We ignore errors from above, and always return OK, since
183 * we don't want to abort the walk on a single error.
184 */
185 return (AE_OK);
186}
187
188
189/*******************************************************************************
190 *
191 * FUNCTION: AcpiDsInitializeObjects
192 *
193 * PARAMETERS: TableDesc - Descriptor for parent ACPI table
194 * StartNode - Root of subtree to be initialized.
195 *
196 * RETURN: Status
197 *
198 * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any
199 * necessary initialization on the objects found therein
200 *
201 ******************************************************************************/
202
205 UINT32 TableIndex,
206 ACPI_NAMESPACE_NODE *StartNode)
207{
212
213
214 ACPI_FUNCTION_TRACE (DsInitializeObjects);
215
216
217 Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
218 if (ACPI_FAILURE (Status))
219 {
221 }
222
224 "**** Starting initialization of namespace objects ****\n"));
225
226 /* Set all init info to zero */
227
228 memset (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
229
230 Info.OwnerId = OwnerId;
231 Info.TableIndex = TableIndex;
232
233 /* Walk entire namespace from the supplied root */
234
235 /*
236 * We don't use AcpiWalkNamespace since we do not want to acquire
237 * the namespace reader lock.
238 */
241 if (ACPI_FAILURE (Status))
242 {
243 ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
244 }
245
246 Status = AcpiGetTableByIndex (TableIndex, &Table);
247 if (ACPI_FAILURE (Status))
248 {
250 }
251
252 /* DSDT is always the first AML table */
253
254 if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_DSDT))
255 {
257 "\nACPI table initialization:\n"));
258 }
259
260 /* Summary of objects initialized */
261
263 "Table [%4.4s: %-8.8s] (id %.2X) - %4u Objects with %3u Devices, "
264 "%3u Regions, %4u Methods (%u/%u/%u Serial/Non/Cvt)\n",
265 Table->Signature, Table->OemTableId, OwnerId, Info.ObjectCount,
266 Info.DeviceCount,Info.OpRegionCount, Info.MethodCount,
267 Info.SerialMethodCount, Info.NonSerialMethodCount,
268 Info.SerializedMethodCount));
269
270 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "%u Methods, %u Regions\n",
271 Info.MethodCount, Info.OpRegionCount));
272
274}
unsigned int UINT32
UINT32 void void ** ReturnValue
Definition: acevents.h:216
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_OK
Definition: acexcep.h:97
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
ACPI_OBJECT_TYPE AcpiNsGetType(ACPI_NAMESPACE_NODE *Node)
Definition: nsutils.c:120
#define ACPI_NS_WALK_NO_UNLOCK
Definition: acnamesp.h:76
ACPI_STATUS AcpiNsWalkNamespace(ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, UINT32 Flags, ACPI_WALK_CALLBACK DescendingCallback, ACPI_WALK_CALLBACK AscendingCallback, void *Context, void **ReturnValue)
Definition: nswalk.c:190
#define ACPI_METHOD_SERIALIZED
Definition: acobject.h:238
#define ACPI_DB_DISPATCH
Definition: acoutput.h:163
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define ACPI_DB_INIT
Definition: acoutput.h:151
ACPI_STATUS AcpiTbGetOwnerId(UINT32 TableIndex, ACPI_OWNER_ID *OwnerId)
Definition: tbdata.c:993
#define ACPI_SIG_DSDT
Definition: actbl.h:67
#define ACPI_COMPARE_NAMESEG(a, b)
Definition: actypes.h:564
#define ACPI_TYPE_REGION
Definition: actypes.h:697
#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_UINT32_MAX
Definition: actypes.h:66
UINT16 ACPI_OWNER_ID
Definition: actypes.h:486
#define ACPI_TYPE_METHOD
Definition: actypes.h:695
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:306
#define NULL
Definition: types.h:112
static ACPI_STATUS AcpiDsInitOneObject(ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue)
Definition: dsinit.c:86
ACPI_STATUS AcpiDsInitializeObjects(UINT32 TableIndex, ACPI_NAMESPACE_NODE *StartNode)
Definition: dsinit.c:204
ACPI_STATUS AcpiDsAutoSerializeMethod(ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *ObjDesc)
Definition: dsmethod.c:94
ACPI_STATUS AcpiDsInitializeRegion(ACPI_HANDLE ObjHandle)
Definition: dsopcode.c:82
_Must_inspect_result_ _In_opt_ PVOID OwnerId
Definition: fsrtlfuncs.h:907
Status
Definition: gdiplustypes.h:25
ASMGENDATA Table[]
Definition: genincdata.c:61
#define memset(x, y, z)
Definition: compat.h:39
ACPI_OBJECT_COMMON_HEADER UINT8 InfoFlags
Definition: acobject.h:216
ACPI_STATUS AcpiGetTableByIndex(UINT32 TableIndex, ACPI_TABLE_HEADER **OutTable)
Definition: tbxface.c:491
ACPI_OBJECT_METHOD Method
Definition: acobject.h:525
Definition: dlist.c:348
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56