1 /******************************************************************************
3 * Module Name: dsinit - Object initialization namespace walk
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2019, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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 MERCHANTIBILITY 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.
51 #define _COMPONENT ACPI_DISPATCHER
52 ACPI_MODULE_NAME ("dsinit")
55 /* Local prototypes */
59 ACPI_HANDLE ObjHandle
,
65 /*******************************************************************************
67 * FUNCTION: AcpiDsInitOneObject
69 * PARAMETERS: ObjHandle - Node for the object
70 * Level - Current nesting level
71 * Context - Points to a init info struct
72 * ReturnValue - Not used
76 * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
77 * within the namespace.
79 * Currently, the only objects that require initialization are:
81 * 2) Operation Regions
83 ******************************************************************************/
87 ACPI_HANDLE ObjHandle
,
92 ACPI_INIT_WALK_INFO
*Info
= (ACPI_INIT_WALK_INFO
*) Context
;
93 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
95 ACPI_OPERAND_OBJECT
*ObjDesc
;
98 ACPI_FUNCTION_ENTRY ();
102 * We are only interested in NS nodes owned by the table that
105 if (Node
->OwnerId
!= Info
->OwnerId
)
112 /* And even then, we are only interested in a few object types */
114 switch (AcpiNsGetType (ObjHandle
))
116 case ACPI_TYPE_REGION
:
118 Status
= AcpiDsInitializeRegion (ObjHandle
);
119 if (ACPI_FAILURE (Status
))
121 ACPI_EXCEPTION ((AE_INFO
, Status
,
122 "During Region initialization %p [%4.4s]",
123 ObjHandle
, AcpiUtGetNodeName (ObjHandle
)));
126 Info
->OpRegionCount
++;
129 case ACPI_TYPE_METHOD
:
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.
139 ObjDesc
= AcpiNsGetAttachedObject (Node
);
145 /* Ignore if already serialized */
147 if (ObjDesc
->Method
.InfoFlags
& ACPI_METHOD_SERIALIZED
)
149 Info
->SerialMethodCount
++;
153 if (AcpiGbl_AutoSerializeMethods
)
155 /* Parse/scan method and serialize it if necessary */
157 AcpiDsAutoSerializeMethod (Node
, ObjDesc
);
158 if (ObjDesc
->Method
.InfoFlags
& ACPI_METHOD_SERIALIZED
)
160 /* Method was just converted to Serialized */
162 Info
->SerialMethodCount
++;
163 Info
->SerializedMethodCount
++;
168 Info
->NonSerialMethodCount
++;
171 case ACPI_TYPE_DEVICE
:
182 * We ignore errors from above, and always return OK, since
183 * we don't want to abort the walk on a single error.
189 /*******************************************************************************
191 * FUNCTION: AcpiDsInitializeObjects
193 * PARAMETERS: TableDesc - Descriptor for parent ACPI table
194 * StartNode - Root of subtree to be initialized.
198 * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any
199 * necessary initialization on the objects found therein
201 ******************************************************************************/
204 AcpiDsInitializeObjects (
206 ACPI_NAMESPACE_NODE
*StartNode
)
209 ACPI_INIT_WALK_INFO Info
;
210 ACPI_TABLE_HEADER
*Table
;
211 ACPI_OWNER_ID OwnerId
;
214 ACPI_FUNCTION_TRACE (DsInitializeObjects
);
217 Status
= AcpiTbGetOwnerId (TableIndex
, &OwnerId
);
218 if (ACPI_FAILURE (Status
))
220 return_ACPI_STATUS (Status
);
223 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
,
224 "**** Starting initialization of namespace objects ****\n"));
226 /* Set all init info to zero */
228 memset (&Info
, 0, sizeof (ACPI_INIT_WALK_INFO
));
230 Info
.OwnerId
= OwnerId
;
231 Info
.TableIndex
= TableIndex
;
233 /* Walk entire namespace from the supplied root */
236 * We don't use AcpiWalkNamespace since we do not want to acquire
237 * the namespace reader lock.
239 Status
= AcpiNsWalkNamespace (ACPI_TYPE_ANY
, StartNode
, ACPI_UINT32_MAX
,
240 ACPI_NS_WALK_NO_UNLOCK
, AcpiDsInitOneObject
, NULL
, &Info
, NULL
);
241 if (ACPI_FAILURE (Status
))
243 ACPI_EXCEPTION ((AE_INFO
, Status
, "During WalkNamespace"));
246 Status
= AcpiGetTableByIndex (TableIndex
, &Table
);
247 if (ACPI_FAILURE (Status
))
249 return_ACPI_STATUS (Status
);
252 /* DSDT is always the first AML table */
254 if (ACPI_COMPARE_NAME (Table
->Signature
, ACPI_SIG_DSDT
))
256 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT
,
257 "\nInitializing Namespace objects:\n"));
260 /* Summary of objects initialized */
262 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT
,
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
));
270 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH
, "%u Methods, %u Regions\n",
271 Info
.MethodCount
, Info
.OpRegionCount
));
273 return_ACPI_STATUS (AE_OK
);