excreate.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer /******************************************************************************
2 1.1.1.2.2.2 bouyer *
3 1.1.1.2.2.2 bouyer * Module Name: excreate - Named object creation
4 1.1.1.2.2.2 bouyer *
5 1.1.1.2.2.2 bouyer *****************************************************************************/
6 1.1.1.2.2.2 bouyer
7 1.1.1.2.2.2 bouyer /*
8 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.2.2 bouyer * All rights reserved.
10 1.1.1.2.2.2 bouyer *
11 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
13 1.1.1.2.2.2 bouyer * are met:
14 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.2.2 bouyer * without modification.
17 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.2.2 bouyer * binary redistribution.
22 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
25 1.1.1.2.2.2 bouyer *
26 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.2.2 bouyer * Software Foundation.
29 1.1.1.2.2.2 bouyer *
30 1.1.1.2.2.2 bouyer * NO WARRANTY
31 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.2.2 bouyer */
43 1.1.1.2.2.2 bouyer
44 1.1.1.2.2.2 bouyer #define __EXCREATE_C__
45 1.1.1.2.2.2 bouyer
46 1.1.1.2.2.2 bouyer #include "acpi.h"
47 1.1.1.2.2.2 bouyer #include "accommon.h"
48 1.1.1.2.2.2 bouyer #include "acinterp.h"
49 1.1.1.2.2.2 bouyer #include "amlcode.h"
50 1.1.1.2.2.2 bouyer #include "acnamesp.h"
51 1.1.1.2.2.2 bouyer
52 1.1.1.2.2.2 bouyer
53 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_EXECUTER
54 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("excreate")
55 1.1.1.2.2.2 bouyer
56 1.1.1.2.2.2 bouyer
57 1.1.1.2.2.2 bouyer #ifndef ACPI_NO_METHOD_EXECUTION
58 1.1.1.2.2.2 bouyer /*******************************************************************************
59 1.1.1.2.2.2 bouyer *
60 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExCreateAlias
61 1.1.1.2.2.2 bouyer *
62 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current state, contains operands
63 1.1.1.2.2.2 bouyer *
64 1.1.1.2.2.2 bouyer * RETURN: Status
65 1.1.1.2.2.2 bouyer *
66 1.1.1.2.2.2 bouyer * DESCRIPTION: Create a new named alias
67 1.1.1.2.2.2 bouyer *
68 1.1.1.2.2.2 bouyer ******************************************************************************/
69 1.1.1.2.2.2 bouyer
70 1.1.1.2.2.2 bouyer ACPI_STATUS
71 1.1.1.2.2.2 bouyer AcpiExCreateAlias (
72 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState)
73 1.1.1.2.2.2 bouyer {
74 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *TargetNode;
75 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *AliasNode;
76 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
77 1.1.1.2.2.2 bouyer
78 1.1.1.2.2.2 bouyer
79 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExCreateAlias);
80 1.1.1.2.2.2 bouyer
81 1.1.1.2.2.2 bouyer
82 1.1.1.2.2.2 bouyer /* Get the source/alias operands (both namespace nodes) */
83 1.1.1.2.2.2 bouyer
84 1.1.1.2.2.2 bouyer AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
85 1.1.1.2.2.2 bouyer TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
86 1.1.1.2.2.2 bouyer
87 1.1.1.2.2.2 bouyer if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
88 1.1.1.2.2.2 bouyer (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
89 1.1.1.2.2.2 bouyer {
90 1.1.1.2.2.2 bouyer /*
91 1.1.1.2.2.2 bouyer * Dereference an existing alias so that we don't create a chain
92 1.1.1.2.2.2 bouyer * of aliases. With this code, we guarantee that an alias is
93 1.1.1.2.2.2 bouyer * always exactly one level of indirection away from the
94 1.1.1.2.2.2 bouyer * actual aliased name.
95 1.1.1.2.2.2 bouyer */
96 1.1.1.2.2.2 bouyer TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
97 1.1.1.2.2.2 bouyer }
98 1.1.1.2.2.2 bouyer
99 1.1.1.2.2.2 bouyer /*
100 1.1.1.2.2.2 bouyer * For objects that can never change (i.e., the NS node will
101 1.1.1.2.2.2 bouyer * permanently point to the same object), we can simply attach
102 1.1.1.2.2.2 bouyer * the object to the new NS node. For other objects (such as
103 1.1.1.2.2.2 bouyer * Integers, buffers, etc.), we have to point the Alias node
104 1.1.1.2.2.2 bouyer * to the original Node.
105 1.1.1.2.2.2 bouyer */
106 1.1.1.2.2.2 bouyer switch (TargetNode->Type)
107 1.1.1.2.2.2 bouyer {
108 1.1.1.2.2.2 bouyer
109 1.1.1.2.2.2 bouyer /* For these types, the sub-object can change dynamically via a Store */
110 1.1.1.2.2.2 bouyer
111 1.1.1.2.2.2 bouyer case ACPI_TYPE_INTEGER:
112 1.1.1.2.2.2 bouyer case ACPI_TYPE_STRING:
113 1.1.1.2.2.2 bouyer case ACPI_TYPE_BUFFER:
114 1.1.1.2.2.2 bouyer case ACPI_TYPE_PACKAGE:
115 1.1.1.2.2.2 bouyer case ACPI_TYPE_BUFFER_FIELD:
116 1.1.1.2.2.2 bouyer
117 1.1.1.2.2.2 bouyer /*
118 1.1.1.2.2.2 bouyer * These types open a new scope, so we need the NS node in order to access
119 1.1.1.2.2.2 bouyer * any children.
120 1.1.1.2.2.2 bouyer */
121 1.1.1.2.2.2 bouyer case ACPI_TYPE_DEVICE:
122 1.1.1.2.2.2 bouyer case ACPI_TYPE_POWER:
123 1.1.1.2.2.2 bouyer case ACPI_TYPE_PROCESSOR:
124 1.1.1.2.2.2 bouyer case ACPI_TYPE_THERMAL:
125 1.1.1.2.2.2 bouyer case ACPI_TYPE_LOCAL_SCOPE:
126 1.1.1.2.2.2 bouyer
127 1.1.1.2.2.2 bouyer /*
128 1.1.1.2.2.2 bouyer * The new alias has the type ALIAS and points to the original
129 1.1.1.2.2.2 bouyer * NS node, not the object itself.
130 1.1.1.2.2.2 bouyer */
131 1.1.1.2.2.2 bouyer AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
132 1.1.1.2.2.2 bouyer AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
133 1.1.1.2.2.2 bouyer break;
134 1.1.1.2.2.2 bouyer
135 1.1.1.2.2.2 bouyer case ACPI_TYPE_METHOD:
136 1.1.1.2.2.2 bouyer
137 1.1.1.2.2.2 bouyer /*
138 1.1.1.2.2.2 bouyer * Control method aliases need to be differentiated
139 1.1.1.2.2.2 bouyer */
140 1.1.1.2.2.2 bouyer AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
141 1.1.1.2.2.2 bouyer AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
142 1.1.1.2.2.2 bouyer break;
143 1.1.1.2.2.2 bouyer
144 1.1.1.2.2.2 bouyer default:
145 1.1.1.2.2.2 bouyer
146 1.1.1.2.2.2 bouyer /* Attach the original source object to the new Alias Node */
147 1.1.1.2.2.2 bouyer
148 1.1.1.2.2.2 bouyer /*
149 1.1.1.2.2.2 bouyer * The new alias assumes the type of the target, and it points
150 1.1.1.2.2.2 bouyer * to the same object. The reference count of the object has an
151 1.1.1.2.2.2 bouyer * additional reference to prevent deletion out from under either the
152 1.1.1.2.2.2 bouyer * target node or the alias Node
153 1.1.1.2.2.2 bouyer */
154 1.1.1.2.2.2 bouyer Status = AcpiNsAttachObject (AliasNode,
155 1.1.1.2.2.2 bouyer AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
156 1.1.1.2.2.2 bouyer break;
157 1.1.1.2.2.2 bouyer }
158 1.1.1.2.2.2 bouyer
159 1.1.1.2.2.2 bouyer /* Since both operands are Nodes, we don't need to delete them */
160 1.1.1.2.2.2 bouyer
161 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
162 1.1.1.2.2.2 bouyer }
163 1.1.1.2.2.2 bouyer
164 1.1.1.2.2.2 bouyer
165 1.1.1.2.2.2 bouyer /*******************************************************************************
166 1.1.1.2.2.2 bouyer *
167 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExCreateEvent
168 1.1.1.2.2.2 bouyer *
169 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current state
170 1.1.1.2.2.2 bouyer *
171 1.1.1.2.2.2 bouyer * RETURN: Status
172 1.1.1.2.2.2 bouyer *
173 1.1.1.2.2.2 bouyer * DESCRIPTION: Create a new event object
174 1.1.1.2.2.2 bouyer *
175 1.1.1.2.2.2 bouyer ******************************************************************************/
176 1.1.1.2.2.2 bouyer
177 1.1.1.2.2.2 bouyer ACPI_STATUS
178 1.1.1.2.2.2 bouyer AcpiExCreateEvent (
179 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState)
180 1.1.1.2.2.2 bouyer {
181 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
182 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
183 1.1.1.2.2.2 bouyer
184 1.1.1.2.2.2 bouyer
185 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExCreateEvent);
186 1.1.1.2.2.2 bouyer
187 1.1.1.2.2.2 bouyer
188 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
189 1.1.1.2.2.2 bouyer if (!ObjDesc)
190 1.1.1.2.2.2 bouyer {
191 1.1.1.2.2.2 bouyer Status = AE_NO_MEMORY;
192 1.1.1.2.2.2 bouyer goto Cleanup;
193 1.1.1.2.2.2 bouyer }
194 1.1.1.2.2.2 bouyer
195 1.1.1.2.2.2 bouyer /*
196 1.1.1.2.2.2 bouyer * Create the actual OS semaphore, with zero initial units -- meaning
197 1.1.1.2.2.2 bouyer * that the event is created in an unsignalled state
198 1.1.1.2.2.2 bouyer */
199 1.1.1.2.2.2 bouyer Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
200 1.1.1.2.2.2 bouyer &ObjDesc->Event.OsSemaphore);
201 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
202 1.1.1.2.2.2 bouyer {
203 1.1.1.2.2.2 bouyer goto Cleanup;
204 1.1.1.2.2.2 bouyer }
205 1.1.1.2.2.2 bouyer
206 1.1.1.2.2.2 bouyer /* Attach object to the Node */
207 1.1.1.2.2.2 bouyer
208 1.1.1.2.2.2 bouyer Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
209 1.1.1.2.2.2 bouyer ObjDesc, ACPI_TYPE_EVENT);
210 1.1.1.2.2.2 bouyer
211 1.1.1.2.2.2 bouyer Cleanup:
212 1.1.1.2.2.2 bouyer /*
213 1.1.1.2.2.2 bouyer * Remove local reference to the object (on error, will cause deletion
214 1.1.1.2.2.2 bouyer * of both object and semaphore if present.)
215 1.1.1.2.2.2 bouyer */
216 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
217 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
218 1.1.1.2.2.2 bouyer }
219 1.1.1.2.2.2 bouyer
220 1.1.1.2.2.2 bouyer
221 1.1.1.2.2.2 bouyer /*******************************************************************************
222 1.1.1.2.2.2 bouyer *
223 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExCreateMutex
224 1.1.1.2.2.2 bouyer *
225 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current state
226 1.1.1.2.2.2 bouyer *
227 1.1.1.2.2.2 bouyer * RETURN: Status
228 1.1.1.2.2.2 bouyer *
229 1.1.1.2.2.2 bouyer * DESCRIPTION: Create a new mutex object
230 1.1.1.2.2.2 bouyer *
231 1.1.1.2.2.2 bouyer * Mutex (Name[0], SyncLevel[1])
232 1.1.1.2.2.2 bouyer *
233 1.1.1.2.2.2 bouyer ******************************************************************************/
234 1.1.1.2.2.2 bouyer
235 1.1.1.2.2.2 bouyer ACPI_STATUS
236 1.1.1.2.2.2 bouyer AcpiExCreateMutex (
237 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState)
238 1.1.1.2.2.2 bouyer {
239 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
240 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
241 1.1.1.2.2.2 bouyer
242 1.1.1.2.2.2 bouyer
243 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
244 1.1.1.2.2.2 bouyer
245 1.1.1.2.2.2 bouyer
246 1.1.1.2.2.2 bouyer /* Create the new mutex object */
247 1.1.1.2.2.2 bouyer
248 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
249 1.1.1.2.2.2 bouyer if (!ObjDesc)
250 1.1.1.2.2.2 bouyer {
251 1.1.1.2.2.2 bouyer Status = AE_NO_MEMORY;
252 1.1.1.2.2.2 bouyer goto Cleanup;
253 1.1.1.2.2.2 bouyer }
254 1.1.1.2.2.2 bouyer
255 1.1.1.2.2.2 bouyer /* Create the actual OS Mutex */
256 1.1.1.2.2.2 bouyer
257 1.1.1.2.2.2 bouyer Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
258 1.1.1.2.2.2 bouyer if (ACPI_FAILURE (Status))
259 1.1.1.2.2.2 bouyer {
260 1.1.1.2.2.2 bouyer goto Cleanup;
261 1.1.1.2.2.2 bouyer }
262 1.1.1.2.2.2 bouyer
263 1.1.1.2.2.2 bouyer /* Init object and attach to NS node */
264 1.1.1.2.2.2 bouyer
265 1.1.1.2.2.2 bouyer ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
266 1.1.1.2.2.2 bouyer ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
267 1.1.1.2.2.2 bouyer
268 1.1.1.2.2.2 bouyer Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
269 1.1.1.2.2.2 bouyer
270 1.1.1.2.2.2 bouyer
271 1.1.1.2.2.2 bouyer Cleanup:
272 1.1.1.2.2.2 bouyer /*
273 1.1.1.2.2.2 bouyer * Remove local reference to the object (on error, will cause deletion
274 1.1.1.2.2.2 bouyer * of both object and semaphore if present.)
275 1.1.1.2.2.2 bouyer */
276 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
277 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
278 1.1.1.2.2.2 bouyer }
279 1.1.1.2.2.2 bouyer
280 1.1.1.2.2.2 bouyer
281 1.1.1.2.2.2 bouyer /*******************************************************************************
282 1.1.1.2.2.2 bouyer *
283 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExCreateRegion
284 1.1.1.2.2.2 bouyer *
285 1.1.1.2.2.2 bouyer * PARAMETERS: AmlStart - Pointer to the region declaration AML
286 1.1.1.2.2.2 bouyer * AmlLength - Max length of the declaration AML
287 1.1.1.2.2.2 bouyer * RegionSpace - SpaceID for the region
288 1.1.1.2.2.2 bouyer * WalkState - Current state
289 1.1.1.2.2.2 bouyer *
290 1.1.1.2.2.2 bouyer * RETURN: Status
291 1.1.1.2.2.2 bouyer *
292 1.1.1.2.2.2 bouyer * DESCRIPTION: Create a new operation region object
293 1.1.1.2.2.2 bouyer *
294 1.1.1.2.2.2 bouyer ******************************************************************************/
295 1.1.1.2.2.2 bouyer
296 1.1.1.2.2.2 bouyer ACPI_STATUS
297 1.1.1.2.2.2 bouyer AcpiExCreateRegion (
298 1.1.1.2.2.2 bouyer UINT8 *AmlStart,
299 1.1.1.2.2.2 bouyer UINT32 AmlLength,
300 1.1.1.2.2.2 bouyer UINT8 RegionSpace,
301 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState)
302 1.1.1.2.2.2 bouyer {
303 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
304 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
305 1.1.1.2.2.2 bouyer ACPI_NAMESPACE_NODE *Node;
306 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *RegionObj2;
307 1.1.1.2.2.2 bouyer
308 1.1.1.2.2.2 bouyer
309 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExCreateRegion);
310 1.1.1.2.2.2 bouyer
311 1.1.1.2.2.2 bouyer
312 1.1.1.2.2.2 bouyer /* Get the Namespace Node */
313 1.1.1.2.2.2 bouyer
314 1.1.1.2.2.2 bouyer Node = WalkState->Op->Common.Node;
315 1.1.1.2.2.2 bouyer
316 1.1.1.2.2.2 bouyer /*
317 1.1.1.2.2.2 bouyer * If the region object is already attached to this node,
318 1.1.1.2.2.2 bouyer * just return
319 1.1.1.2.2.2 bouyer */
320 1.1.1.2.2.2 bouyer if (AcpiNsGetAttachedObject (Node))
321 1.1.1.2.2.2 bouyer {
322 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
323 1.1.1.2.2.2 bouyer }
324 1.1.1.2.2.2 bouyer
325 1.1.1.2.2.2 bouyer /*
326 1.1.1.2.2.2 bouyer * Space ID must be one of the predefined IDs, or in the user-defined
327 1.1.1.2.2.2 bouyer * range
328 1.1.1.2.2.2 bouyer */
329 1.1.1.2.2.2 bouyer if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) &&
330 1.1.1.2.2.2 bouyer (RegionSpace < ACPI_USER_REGION_BEGIN))
331 1.1.1.2.2.2 bouyer {
332 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type 0x%X", RegionSpace));
333 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
334 1.1.1.2.2.2 bouyer }
335 1.1.1.2.2.2 bouyer
336 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
337 1.1.1.2.2.2 bouyer AcpiUtGetRegionName (RegionSpace), RegionSpace));
338 1.1.1.2.2.2 bouyer
339 1.1.1.2.2.2 bouyer /* Create the region descriptor */
340 1.1.1.2.2.2 bouyer
341 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
342 1.1.1.2.2.2 bouyer if (!ObjDesc)
343 1.1.1.2.2.2 bouyer {
344 1.1.1.2.2.2 bouyer Status = AE_NO_MEMORY;
345 1.1.1.2.2.2 bouyer goto Cleanup;
346 1.1.1.2.2.2 bouyer }
347 1.1.1.2.2.2 bouyer
348 1.1.1.2.2.2 bouyer /*
349 1.1.1.2.2.2 bouyer * Remember location in AML stream of address & length
350 1.1.1.2.2.2 bouyer * operands since they need to be evaluated at run time.
351 1.1.1.2.2.2 bouyer */
352 1.1.1.2.2.2 bouyer RegionObj2 = ObjDesc->Common.NextObject;
353 1.1.1.2.2.2 bouyer RegionObj2->Extra.AmlStart = AmlStart;
354 1.1.1.2.2.2 bouyer RegionObj2->Extra.AmlLength = AmlLength;
355 1.1.1.2.2.2 bouyer
356 1.1.1.2.2.2 bouyer /* Init the region from the operands */
357 1.1.1.2.2.2 bouyer
358 1.1.1.2.2.2 bouyer ObjDesc->Region.SpaceId = RegionSpace;
359 1.1.1.2.2.2 bouyer ObjDesc->Region.Address = 0;
360 1.1.1.2.2.2 bouyer ObjDesc->Region.Length = 0;
361 1.1.1.2.2.2 bouyer ObjDesc->Region.Node = Node;
362 1.1.1.2.2.2 bouyer
363 1.1.1.2.2.2 bouyer /* Install the new region object in the parent Node */
364 1.1.1.2.2.2 bouyer
365 1.1.1.2.2.2 bouyer Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
366 1.1.1.2.2.2 bouyer
367 1.1.1.2.2.2 bouyer
368 1.1.1.2.2.2 bouyer Cleanup:
369 1.1.1.2.2.2 bouyer
370 1.1.1.2.2.2 bouyer /* Remove local reference to the object */
371 1.1.1.2.2.2 bouyer
372 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
373 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
374 1.1.1.2.2.2 bouyer }
375 1.1.1.2.2.2 bouyer
376 1.1.1.2.2.2 bouyer
377 1.1.1.2.2.2 bouyer /*******************************************************************************
378 1.1.1.2.2.2 bouyer *
379 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExCreateProcessor
380 1.1.1.2.2.2 bouyer *
381 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current state
382 1.1.1.2.2.2 bouyer *
383 1.1.1.2.2.2 bouyer * RETURN: Status
384 1.1.1.2.2.2 bouyer *
385 1.1.1.2.2.2 bouyer * DESCRIPTION: Create a new processor object and populate the fields
386 1.1.1.2.2.2 bouyer *
387 1.1.1.2.2.2 bouyer * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
388 1.1.1.2.2.2 bouyer *
389 1.1.1.2.2.2 bouyer ******************************************************************************/
390 1.1.1.2.2.2 bouyer
391 1.1.1.2.2.2 bouyer ACPI_STATUS
392 1.1.1.2.2.2 bouyer AcpiExCreateProcessor (
393 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState)
394 1.1.1.2.2.2 bouyer {
395 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
396 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
397 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
398 1.1.1.2.2.2 bouyer
399 1.1.1.2.2.2 bouyer
400 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
401 1.1.1.2.2.2 bouyer
402 1.1.1.2.2.2 bouyer
403 1.1.1.2.2.2 bouyer /* Create the processor object */
404 1.1.1.2.2.2 bouyer
405 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
406 1.1.1.2.2.2 bouyer if (!ObjDesc)
407 1.1.1.2.2.2 bouyer {
408 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
409 1.1.1.2.2.2 bouyer }
410 1.1.1.2.2.2 bouyer
411 1.1.1.2.2.2 bouyer /* Initialize the processor object from the operands */
412 1.1.1.2.2.2 bouyer
413 1.1.1.2.2.2 bouyer ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
414 1.1.1.2.2.2 bouyer ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
415 1.1.1.2.2.2 bouyer ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
416 1.1.1.2.2.2 bouyer
417 1.1.1.2.2.2 bouyer /* Install the processor object in the parent Node */
418 1.1.1.2.2.2 bouyer
419 1.1.1.2.2.2 bouyer Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
420 1.1.1.2.2.2 bouyer ObjDesc, ACPI_TYPE_PROCESSOR);
421 1.1.1.2.2.2 bouyer
422 1.1.1.2.2.2 bouyer /* Remove local reference to the object */
423 1.1.1.2.2.2 bouyer
424 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
425 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
426 1.1.1.2.2.2 bouyer }
427 1.1.1.2.2.2 bouyer
428 1.1.1.2.2.2 bouyer
429 1.1.1.2.2.2 bouyer /*******************************************************************************
430 1.1.1.2.2.2 bouyer *
431 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExCreatePowerResource
432 1.1.1.2.2.2 bouyer *
433 1.1.1.2.2.2 bouyer * PARAMETERS: WalkState - Current state
434 1.1.1.2.2.2 bouyer *
435 1.1.1.2.2.2 bouyer * RETURN: Status
436 1.1.1.2.2.2 bouyer *
437 1.1.1.2.2.2 bouyer * DESCRIPTION: Create a new PowerResource object and populate the fields
438 1.1.1.2.2.2 bouyer *
439 1.1.1.2.2.2 bouyer * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
440 1.1.1.2.2.2 bouyer *
441 1.1.1.2.2.2 bouyer ******************************************************************************/
442 1.1.1.2.2.2 bouyer
443 1.1.1.2.2.2 bouyer ACPI_STATUS
444 1.1.1.2.2.2 bouyer AcpiExCreatePowerResource (
445 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState)
446 1.1.1.2.2.2 bouyer {
447 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
448 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
449 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
450 1.1.1.2.2.2 bouyer
451 1.1.1.2.2.2 bouyer
452 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
453 1.1.1.2.2.2 bouyer
454 1.1.1.2.2.2 bouyer
455 1.1.1.2.2.2 bouyer /* Create the power resource object */
456 1.1.1.2.2.2 bouyer
457 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
458 1.1.1.2.2.2 bouyer if (!ObjDesc)
459 1.1.1.2.2.2 bouyer {
460 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
461 1.1.1.2.2.2 bouyer }
462 1.1.1.2.2.2 bouyer
463 1.1.1.2.2.2 bouyer /* Initialize the power object from the operands */
464 1.1.1.2.2.2 bouyer
465 1.1.1.2.2.2 bouyer ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
466 1.1.1.2.2.2 bouyer ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
467 1.1.1.2.2.2 bouyer
468 1.1.1.2.2.2 bouyer /* Install the power resource object in the parent Node */
469 1.1.1.2.2.2 bouyer
470 1.1.1.2.2.2 bouyer Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
471 1.1.1.2.2.2 bouyer ObjDesc, ACPI_TYPE_POWER);
472 1.1.1.2.2.2 bouyer
473 1.1.1.2.2.2 bouyer /* Remove local reference to the object */
474 1.1.1.2.2.2 bouyer
475 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
476 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
477 1.1.1.2.2.2 bouyer }
478 1.1.1.2.2.2 bouyer #endif
479 1.1.1.2.2.2 bouyer
480 1.1.1.2.2.2 bouyer
481 1.1.1.2.2.2 bouyer /*******************************************************************************
482 1.1.1.2.2.2 bouyer *
483 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExCreateMethod
484 1.1.1.2.2.2 bouyer *
485 1.1.1.2.2.2 bouyer * PARAMETERS: AmlStart - First byte of the method's AML
486 1.1.1.2.2.2 bouyer * AmlLength - AML byte count for this method
487 1.1.1.2.2.2 bouyer * WalkState - Current state
488 1.1.1.2.2.2 bouyer *
489 1.1.1.2.2.2 bouyer * RETURN: Status
490 1.1.1.2.2.2 bouyer *
491 1.1.1.2.2.2 bouyer * DESCRIPTION: Create a new method object
492 1.1.1.2.2.2 bouyer *
493 1.1.1.2.2.2 bouyer ******************************************************************************/
494 1.1.1.2.2.2 bouyer
495 1.1.1.2.2.2 bouyer ACPI_STATUS
496 1.1.1.2.2.2 bouyer AcpiExCreateMethod (
497 1.1.1.2.2.2 bouyer UINT8 *AmlStart,
498 1.1.1.2.2.2 bouyer UINT32 AmlLength,
499 1.1.1.2.2.2 bouyer ACPI_WALK_STATE *WalkState)
500 1.1.1.2.2.2 bouyer {
501 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
502 1.1.1.2.2.2 bouyer ACPI_OPERAND_OBJECT *ObjDesc;
503 1.1.1.2.2.2 bouyer ACPI_STATUS Status;
504 1.1.1.2.2.2 bouyer UINT8 MethodFlags;
505 1.1.1.2.2.2 bouyer
506 1.1.1.2.2.2 bouyer
507 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
508 1.1.1.2.2.2 bouyer
509 1.1.1.2.2.2 bouyer
510 1.1.1.2.2.2 bouyer /* Create a new method object */
511 1.1.1.2.2.2 bouyer
512 1.1.1.2.2.2 bouyer ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
513 1.1.1.2.2.2 bouyer if (!ObjDesc)
514 1.1.1.2.2.2 bouyer {
515 1.1.1.2.2.2 bouyer Status = AE_NO_MEMORY;
516 1.1.1.2.2.2 bouyer goto Exit;
517 1.1.1.2.2.2 bouyer }
518 1.1.1.2.2.2 bouyer
519 1.1.1.2.2.2 bouyer /* Save the method's AML pointer and length */
520 1.1.1.2.2.2 bouyer
521 1.1.1.2.2.2 bouyer ObjDesc->Method.AmlStart = AmlStart;
522 1.1.1.2.2.2 bouyer ObjDesc->Method.AmlLength = AmlLength;
523 1.1.1.2.2.2 bouyer
524 1.1.1.2.2.2 bouyer /*
525 1.1.1.2.2.2 bouyer * Disassemble the method flags. Split off the ArgCount, Serialized
526 1.1.1.2.2.2 bouyer * flag, and SyncLevel for efficiency.
527 1.1.1.2.2.2 bouyer */
528 1.1.1.2.2.2 bouyer MethodFlags = (UINT8) Operand[1]->Integer.Value;
529 1.1.1.2.2.2 bouyer ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
530 1.1.1.2.2.2 bouyer
531 1.1.1.2.2.2 bouyer /*
532 1.1.1.2.2.2 bouyer * Get the SyncLevel. If method is serialized, a mutex will be
533 1.1.1.2.2.2 bouyer * created for this method when it is parsed.
534 1.1.1.2.2.2 bouyer */
535 1.1.1.2.2.2 bouyer if (MethodFlags & AML_METHOD_SERIALIZED)
536 1.1.1.2.2.2 bouyer {
537 1.1.1.2.2.2 bouyer ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
538 1.1.1.2.2.2 bouyer
539 1.1.1.2.2.2 bouyer /*
540 1.1.1.2.2.2 bouyer * ACPI 1.0: SyncLevel = 0
541 1.1.1.2.2.2 bouyer * ACPI 2.0: SyncLevel = SyncLevel in method declaration
542 1.1.1.2.2.2 bouyer */
543 1.1.1.2.2.2 bouyer ObjDesc->Method.SyncLevel = (UINT8)
544 1.1.1.2.2.2 bouyer ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
545 1.1.1.2.2.2 bouyer }
546 1.1.1.2.2.2 bouyer
547 1.1.1.2.2.2 bouyer /* Attach the new object to the method Node */
548 1.1.1.2.2.2 bouyer
549 1.1.1.2.2.2 bouyer Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
550 1.1.1.2.2.2 bouyer ObjDesc, ACPI_TYPE_METHOD);
551 1.1.1.2.2.2 bouyer
552 1.1.1.2.2.2 bouyer /* Remove local reference to the object */
553 1.1.1.2.2.2 bouyer
554 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (ObjDesc);
555 1.1.1.2.2.2 bouyer
556 1.1.1.2.2.2 bouyer Exit:
557 1.1.1.2.2.2 bouyer /* Remove a reference to the operand */
558 1.1.1.2.2.2 bouyer
559 1.1.1.2.2.2 bouyer AcpiUtRemoveReference (Operand[1]);
560 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
561 1.1.1.2.2.2 bouyer }
562 1.1.1.2.2.2 bouyer
563 1.1.1.2.2.2 bouyer
564