1433d6423SLionel Sambuc /******************************************************************************
2433d6423SLionel Sambuc *
3433d6423SLionel Sambuc * Module Name: excreate - Named object creation
4433d6423SLionel Sambuc *
5433d6423SLionel Sambuc *****************************************************************************/
6433d6423SLionel Sambuc
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc * All rights reserved.
10433d6423SLionel Sambuc *
11*29492bb7SDavid van Moolenbroek * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek * are met:
14*29492bb7SDavid van Moolenbroek * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek * notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek * without modification.
17*29492bb7SDavid van Moolenbroek * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek * substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek * ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek * including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek * binary redistribution.
22*29492bb7SDavid van Moolenbroek * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek * of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek * from this software without specific prior written permission.
25433d6423SLionel Sambuc *
26*29492bb7SDavid van Moolenbroek * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek * Software Foundation.
29433d6423SLionel Sambuc *
30*29492bb7SDavid van Moolenbroek * NO WARRANTY
31*29492bb7SDavid van Moolenbroek * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek */
43433d6423SLionel Sambuc
44433d6423SLionel Sambuc #include "acpi.h"
45433d6423SLionel Sambuc #include "accommon.h"
46433d6423SLionel Sambuc #include "acinterp.h"
47433d6423SLionel Sambuc #include "amlcode.h"
48433d6423SLionel Sambuc #include "acnamesp.h"
49433d6423SLionel Sambuc
50433d6423SLionel Sambuc
51433d6423SLionel Sambuc #define _COMPONENT ACPI_EXECUTER
52433d6423SLionel Sambuc ACPI_MODULE_NAME ("excreate")
53433d6423SLionel Sambuc
54433d6423SLionel Sambuc
55433d6423SLionel Sambuc #ifndef ACPI_NO_METHOD_EXECUTION
56433d6423SLionel Sambuc /*******************************************************************************
57433d6423SLionel Sambuc *
58433d6423SLionel Sambuc * FUNCTION: AcpiExCreateAlias
59433d6423SLionel Sambuc *
60433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state, contains operands
61433d6423SLionel Sambuc *
62433d6423SLionel Sambuc * RETURN: Status
63433d6423SLionel Sambuc *
64433d6423SLionel Sambuc * DESCRIPTION: Create a new named alias
65433d6423SLionel Sambuc *
66433d6423SLionel Sambuc ******************************************************************************/
67433d6423SLionel Sambuc
68433d6423SLionel Sambuc ACPI_STATUS
AcpiExCreateAlias(ACPI_WALK_STATE * WalkState)69433d6423SLionel Sambuc AcpiExCreateAlias (
70433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState)
71433d6423SLionel Sambuc {
72433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *TargetNode;
73433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *AliasNode;
74433d6423SLionel Sambuc ACPI_STATUS Status = AE_OK;
75433d6423SLionel Sambuc
76433d6423SLionel Sambuc
77433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (ExCreateAlias);
78433d6423SLionel Sambuc
79433d6423SLionel Sambuc
80433d6423SLionel Sambuc /* Get the source/alias operands (both namespace nodes) */
81433d6423SLionel Sambuc
82433d6423SLionel Sambuc AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
83433d6423SLionel Sambuc TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
84433d6423SLionel Sambuc
85433d6423SLionel Sambuc if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
86433d6423SLionel Sambuc (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
87433d6423SLionel Sambuc {
88433d6423SLionel Sambuc /*
89433d6423SLionel Sambuc * Dereference an existing alias so that we don't create a chain
90433d6423SLionel Sambuc * of aliases. With this code, we guarantee that an alias is
91433d6423SLionel Sambuc * always exactly one level of indirection away from the
92433d6423SLionel Sambuc * actual aliased name.
93433d6423SLionel Sambuc */
94433d6423SLionel Sambuc TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
95433d6423SLionel Sambuc }
96433d6423SLionel Sambuc
97433d6423SLionel Sambuc /*
98433d6423SLionel Sambuc * For objects that can never change (i.e., the NS node will
99433d6423SLionel Sambuc * permanently point to the same object), we can simply attach
100433d6423SLionel Sambuc * the object to the new NS node. For other objects (such as
101433d6423SLionel Sambuc * Integers, buffers, etc.), we have to point the Alias node
102433d6423SLionel Sambuc * to the original Node.
103433d6423SLionel Sambuc */
104433d6423SLionel Sambuc switch (TargetNode->Type)
105433d6423SLionel Sambuc {
106433d6423SLionel Sambuc
107433d6423SLionel Sambuc /* For these types, the sub-object can change dynamically via a Store */
108433d6423SLionel Sambuc
109433d6423SLionel Sambuc case ACPI_TYPE_INTEGER:
110433d6423SLionel Sambuc case ACPI_TYPE_STRING:
111433d6423SLionel Sambuc case ACPI_TYPE_BUFFER:
112433d6423SLionel Sambuc case ACPI_TYPE_PACKAGE:
113433d6423SLionel Sambuc case ACPI_TYPE_BUFFER_FIELD:
114433d6423SLionel Sambuc /*
115433d6423SLionel Sambuc * These types open a new scope, so we need the NS node in order to access
116433d6423SLionel Sambuc * any children.
117433d6423SLionel Sambuc */
118433d6423SLionel Sambuc case ACPI_TYPE_DEVICE:
119433d6423SLionel Sambuc case ACPI_TYPE_POWER:
120433d6423SLionel Sambuc case ACPI_TYPE_PROCESSOR:
121433d6423SLionel Sambuc case ACPI_TYPE_THERMAL:
122433d6423SLionel Sambuc case ACPI_TYPE_LOCAL_SCOPE:
123433d6423SLionel Sambuc /*
124433d6423SLionel Sambuc * The new alias has the type ALIAS and points to the original
125433d6423SLionel Sambuc * NS node, not the object itself.
126433d6423SLionel Sambuc */
127433d6423SLionel Sambuc AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
128433d6423SLionel Sambuc AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
129433d6423SLionel Sambuc break;
130433d6423SLionel Sambuc
131433d6423SLionel Sambuc case ACPI_TYPE_METHOD:
132433d6423SLionel Sambuc /*
133433d6423SLionel Sambuc * Control method aliases need to be differentiated
134433d6423SLionel Sambuc */
135433d6423SLionel Sambuc AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
136433d6423SLionel Sambuc AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
137433d6423SLionel Sambuc break;
138433d6423SLionel Sambuc
139433d6423SLionel Sambuc default:
140433d6423SLionel Sambuc
141433d6423SLionel Sambuc /* Attach the original source object to the new Alias Node */
142433d6423SLionel Sambuc
143433d6423SLionel Sambuc /*
144433d6423SLionel Sambuc * The new alias assumes the type of the target, and it points
145433d6423SLionel Sambuc * to the same object. The reference count of the object has an
146433d6423SLionel Sambuc * additional reference to prevent deletion out from under either the
147433d6423SLionel Sambuc * target node or the alias Node
148433d6423SLionel Sambuc */
149433d6423SLionel Sambuc Status = AcpiNsAttachObject (AliasNode,
150433d6423SLionel Sambuc AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
151433d6423SLionel Sambuc break;
152433d6423SLionel Sambuc }
153433d6423SLionel Sambuc
154433d6423SLionel Sambuc /* Since both operands are Nodes, we don't need to delete them */
155433d6423SLionel Sambuc
156433d6423SLionel Sambuc return_ACPI_STATUS (Status);
157433d6423SLionel Sambuc }
158433d6423SLionel Sambuc
159433d6423SLionel Sambuc
160433d6423SLionel Sambuc /*******************************************************************************
161433d6423SLionel Sambuc *
162433d6423SLionel Sambuc * FUNCTION: AcpiExCreateEvent
163433d6423SLionel Sambuc *
164433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state
165433d6423SLionel Sambuc *
166433d6423SLionel Sambuc * RETURN: Status
167433d6423SLionel Sambuc *
168433d6423SLionel Sambuc * DESCRIPTION: Create a new event object
169433d6423SLionel Sambuc *
170433d6423SLionel Sambuc ******************************************************************************/
171433d6423SLionel Sambuc
172433d6423SLionel Sambuc ACPI_STATUS
AcpiExCreateEvent(ACPI_WALK_STATE * WalkState)173433d6423SLionel Sambuc AcpiExCreateEvent (
174433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState)
175433d6423SLionel Sambuc {
176433d6423SLionel Sambuc ACPI_STATUS Status;
177433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
178433d6423SLionel Sambuc
179433d6423SLionel Sambuc
180433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (ExCreateEvent);
181433d6423SLionel Sambuc
182433d6423SLionel Sambuc
183433d6423SLionel Sambuc ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
184433d6423SLionel Sambuc if (!ObjDesc)
185433d6423SLionel Sambuc {
186433d6423SLionel Sambuc Status = AE_NO_MEMORY;
187433d6423SLionel Sambuc goto Cleanup;
188433d6423SLionel Sambuc }
189433d6423SLionel Sambuc
190433d6423SLionel Sambuc /*
191433d6423SLionel Sambuc * Create the actual OS semaphore, with zero initial units -- meaning
192433d6423SLionel Sambuc * that the event is created in an unsignalled state
193433d6423SLionel Sambuc */
194433d6423SLionel Sambuc Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
195433d6423SLionel Sambuc &ObjDesc->Event.OsSemaphore);
196433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
197433d6423SLionel Sambuc {
198433d6423SLionel Sambuc goto Cleanup;
199433d6423SLionel Sambuc }
200433d6423SLionel Sambuc
201433d6423SLionel Sambuc /* Attach object to the Node */
202433d6423SLionel Sambuc
203433d6423SLionel Sambuc Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
204433d6423SLionel Sambuc ObjDesc, ACPI_TYPE_EVENT);
205433d6423SLionel Sambuc
206433d6423SLionel Sambuc Cleanup:
207433d6423SLionel Sambuc /*
208433d6423SLionel Sambuc * Remove local reference to the object (on error, will cause deletion
209433d6423SLionel Sambuc * of both object and semaphore if present.)
210433d6423SLionel Sambuc */
211433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
212433d6423SLionel Sambuc return_ACPI_STATUS (Status);
213433d6423SLionel Sambuc }
214433d6423SLionel Sambuc
215433d6423SLionel Sambuc
216433d6423SLionel Sambuc /*******************************************************************************
217433d6423SLionel Sambuc *
218433d6423SLionel Sambuc * FUNCTION: AcpiExCreateMutex
219433d6423SLionel Sambuc *
220433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state
221433d6423SLionel Sambuc *
222433d6423SLionel Sambuc * RETURN: Status
223433d6423SLionel Sambuc *
224433d6423SLionel Sambuc * DESCRIPTION: Create a new mutex object
225433d6423SLionel Sambuc *
226433d6423SLionel Sambuc * Mutex (Name[0], SyncLevel[1])
227433d6423SLionel Sambuc *
228433d6423SLionel Sambuc ******************************************************************************/
229433d6423SLionel Sambuc
230433d6423SLionel Sambuc ACPI_STATUS
AcpiExCreateMutex(ACPI_WALK_STATE * WalkState)231433d6423SLionel Sambuc AcpiExCreateMutex (
232433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState)
233433d6423SLionel Sambuc {
234433d6423SLionel Sambuc ACPI_STATUS Status = AE_OK;
235433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
236433d6423SLionel Sambuc
237433d6423SLionel Sambuc
238433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
239433d6423SLionel Sambuc
240433d6423SLionel Sambuc
241433d6423SLionel Sambuc /* Create the new mutex object */
242433d6423SLionel Sambuc
243433d6423SLionel Sambuc ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
244433d6423SLionel Sambuc if (!ObjDesc)
245433d6423SLionel Sambuc {
246433d6423SLionel Sambuc Status = AE_NO_MEMORY;
247433d6423SLionel Sambuc goto Cleanup;
248433d6423SLionel Sambuc }
249433d6423SLionel Sambuc
250433d6423SLionel Sambuc /* Create the actual OS Mutex */
251433d6423SLionel Sambuc
252433d6423SLionel Sambuc Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
253433d6423SLionel Sambuc if (ACPI_FAILURE (Status))
254433d6423SLionel Sambuc {
255433d6423SLionel Sambuc goto Cleanup;
256433d6423SLionel Sambuc }
257433d6423SLionel Sambuc
258433d6423SLionel Sambuc /* Init object and attach to NS node */
259433d6423SLionel Sambuc
260433d6423SLionel Sambuc ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
261433d6423SLionel Sambuc ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
262433d6423SLionel Sambuc
263433d6423SLionel Sambuc Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
264433d6423SLionel Sambuc
265433d6423SLionel Sambuc
266433d6423SLionel Sambuc Cleanup:
267433d6423SLionel Sambuc /*
268433d6423SLionel Sambuc * Remove local reference to the object (on error, will cause deletion
269433d6423SLionel Sambuc * of both object and semaphore if present.)
270433d6423SLionel Sambuc */
271433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
272433d6423SLionel Sambuc return_ACPI_STATUS (Status);
273433d6423SLionel Sambuc }
274433d6423SLionel Sambuc
275433d6423SLionel Sambuc
276433d6423SLionel Sambuc /*******************************************************************************
277433d6423SLionel Sambuc *
278433d6423SLionel Sambuc * FUNCTION: AcpiExCreateRegion
279433d6423SLionel Sambuc *
280433d6423SLionel Sambuc * PARAMETERS: AmlStart - Pointer to the region declaration AML
281433d6423SLionel Sambuc * AmlLength - Max length of the declaration AML
282*29492bb7SDavid van Moolenbroek * SpaceId - Address space ID for the region
283433d6423SLionel Sambuc * WalkState - Current state
284433d6423SLionel Sambuc *
285433d6423SLionel Sambuc * RETURN: Status
286433d6423SLionel Sambuc *
287433d6423SLionel Sambuc * DESCRIPTION: Create a new operation region object
288433d6423SLionel Sambuc *
289433d6423SLionel Sambuc ******************************************************************************/
290433d6423SLionel Sambuc
291433d6423SLionel Sambuc ACPI_STATUS
AcpiExCreateRegion(UINT8 * AmlStart,UINT32 AmlLength,UINT8 SpaceId,ACPI_WALK_STATE * WalkState)292433d6423SLionel Sambuc AcpiExCreateRegion (
293433d6423SLionel Sambuc UINT8 *AmlStart,
294433d6423SLionel Sambuc UINT32 AmlLength,
295*29492bb7SDavid van Moolenbroek UINT8 SpaceId,
296433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState)
297433d6423SLionel Sambuc {
298433d6423SLionel Sambuc ACPI_STATUS Status;
299433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
300433d6423SLionel Sambuc ACPI_NAMESPACE_NODE *Node;
301433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *RegionObj2;
302433d6423SLionel Sambuc
303433d6423SLionel Sambuc
304433d6423SLionel Sambuc ACPI_FUNCTION_TRACE (ExCreateRegion);
305433d6423SLionel Sambuc
306433d6423SLionel Sambuc
307433d6423SLionel Sambuc /* Get the Namespace Node */
308433d6423SLionel Sambuc
309433d6423SLionel Sambuc Node = WalkState->Op->Common.Node;
310433d6423SLionel Sambuc
311433d6423SLionel Sambuc /*
312433d6423SLionel Sambuc * If the region object is already attached to this node,
313433d6423SLionel Sambuc * just return
314433d6423SLionel Sambuc */
315433d6423SLionel Sambuc if (AcpiNsGetAttachedObject (Node))
316433d6423SLionel Sambuc {
317433d6423SLionel Sambuc return_ACPI_STATUS (AE_OK);
318433d6423SLionel Sambuc }
319433d6423SLionel Sambuc
320433d6423SLionel Sambuc /*
321433d6423SLionel Sambuc * Space ID must be one of the predefined IDs, or in the user-defined
322433d6423SLionel Sambuc * range
323433d6423SLionel Sambuc */
324*29492bb7SDavid van Moolenbroek if (!AcpiIsValidSpaceId (SpaceId))
325433d6423SLionel Sambuc {
326*29492bb7SDavid van Moolenbroek /*
327*29492bb7SDavid van Moolenbroek * Print an error message, but continue. We don't want to abort
328*29492bb7SDavid van Moolenbroek * a table load for this exception. Instead, if the region is
329*29492bb7SDavid van Moolenbroek * actually used at runtime, abort the executing method.
330*29492bb7SDavid van Moolenbroek */
331*29492bb7SDavid van Moolenbroek ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
332433d6423SLionel Sambuc }
333433d6423SLionel Sambuc
334433d6423SLionel Sambuc ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
335*29492bb7SDavid van Moolenbroek AcpiUtGetRegionName (SpaceId), SpaceId));
336433d6423SLionel Sambuc
337433d6423SLionel Sambuc /* Create the region descriptor */
338433d6423SLionel Sambuc
339433d6423SLionel Sambuc ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
340433d6423SLionel Sambuc if (!ObjDesc)
341433d6423SLionel Sambuc {
342433d6423SLionel Sambuc Status = AE_NO_MEMORY;
343433d6423SLionel Sambuc goto Cleanup;
344433d6423SLionel Sambuc }
345433d6423SLionel Sambuc
346433d6423SLionel Sambuc /*
347433d6423SLionel Sambuc * Remember location in AML stream of address & length
348433d6423SLionel Sambuc * operands since they need to be evaluated at run time.
349433d6423SLionel Sambuc */
350433d6423SLionel Sambuc RegionObj2 = ObjDesc->Common.NextObject;
351433d6423SLionel Sambuc RegionObj2->Extra.AmlStart = AmlStart;
352433d6423SLionel Sambuc RegionObj2->Extra.AmlLength = AmlLength;
353*29492bb7SDavid van Moolenbroek if (WalkState->ScopeInfo)
354*29492bb7SDavid van Moolenbroek {
355*29492bb7SDavid van Moolenbroek RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
356*29492bb7SDavid van Moolenbroek }
357*29492bb7SDavid van Moolenbroek else
358*29492bb7SDavid van Moolenbroek {
359*29492bb7SDavid van Moolenbroek RegionObj2->Extra.ScopeNode = Node;
360*29492bb7SDavid van Moolenbroek }
361433d6423SLionel Sambuc
362433d6423SLionel Sambuc /* Init the region from the operands */
363433d6423SLionel Sambuc
364*29492bb7SDavid van Moolenbroek ObjDesc->Region.SpaceId = SpaceId;
365433d6423SLionel Sambuc ObjDesc->Region.Address = 0;
366433d6423SLionel Sambuc ObjDesc->Region.Length = 0;
367433d6423SLionel Sambuc ObjDesc->Region.Node = Node;
368433d6423SLionel Sambuc
369433d6423SLionel Sambuc /* Install the new region object in the parent Node */
370433d6423SLionel Sambuc
371433d6423SLionel Sambuc Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
372433d6423SLionel Sambuc
373433d6423SLionel Sambuc
374433d6423SLionel Sambuc Cleanup:
375433d6423SLionel Sambuc
376433d6423SLionel Sambuc /* Remove local reference to the object */
377433d6423SLionel Sambuc
378433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
379433d6423SLionel Sambuc return_ACPI_STATUS (Status);
380433d6423SLionel Sambuc }
381433d6423SLionel Sambuc
382433d6423SLionel Sambuc
383433d6423SLionel Sambuc /*******************************************************************************
384433d6423SLionel Sambuc *
385433d6423SLionel Sambuc * FUNCTION: AcpiExCreateProcessor
386433d6423SLionel Sambuc *
387433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state
388433d6423SLionel Sambuc *
389433d6423SLionel Sambuc * RETURN: Status
390433d6423SLionel Sambuc *
391433d6423SLionel Sambuc * DESCRIPTION: Create a new processor object and populate the fields
392433d6423SLionel Sambuc *
393433d6423SLionel Sambuc * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
394433d6423SLionel Sambuc *
395433d6423SLionel Sambuc ******************************************************************************/
396433d6423SLionel Sambuc
397433d6423SLionel Sambuc ACPI_STATUS
AcpiExCreateProcessor(ACPI_WALK_STATE * WalkState)398433d6423SLionel Sambuc AcpiExCreateProcessor (
399433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState)
400433d6423SLionel Sambuc {
401433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
402433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
403433d6423SLionel Sambuc ACPI_STATUS Status;
404433d6423SLionel Sambuc
405433d6423SLionel Sambuc
406433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
407433d6423SLionel Sambuc
408433d6423SLionel Sambuc
409433d6423SLionel Sambuc /* Create the processor object */
410433d6423SLionel Sambuc
411433d6423SLionel Sambuc ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
412433d6423SLionel Sambuc if (!ObjDesc)
413433d6423SLionel Sambuc {
414433d6423SLionel Sambuc return_ACPI_STATUS (AE_NO_MEMORY);
415433d6423SLionel Sambuc }
416433d6423SLionel Sambuc
417433d6423SLionel Sambuc /* Initialize the processor object from the operands */
418433d6423SLionel Sambuc
419433d6423SLionel Sambuc ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
420433d6423SLionel Sambuc ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
421433d6423SLionel Sambuc ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
422433d6423SLionel Sambuc
423433d6423SLionel Sambuc /* Install the processor object in the parent Node */
424433d6423SLionel Sambuc
425433d6423SLionel Sambuc Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
426433d6423SLionel Sambuc ObjDesc, ACPI_TYPE_PROCESSOR);
427433d6423SLionel Sambuc
428433d6423SLionel Sambuc /* Remove local reference to the object */
429433d6423SLionel Sambuc
430433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
431433d6423SLionel Sambuc return_ACPI_STATUS (Status);
432433d6423SLionel Sambuc }
433433d6423SLionel Sambuc
434433d6423SLionel Sambuc
435433d6423SLionel Sambuc /*******************************************************************************
436433d6423SLionel Sambuc *
437433d6423SLionel Sambuc * FUNCTION: AcpiExCreatePowerResource
438433d6423SLionel Sambuc *
439433d6423SLionel Sambuc * PARAMETERS: WalkState - Current state
440433d6423SLionel Sambuc *
441433d6423SLionel Sambuc * RETURN: Status
442433d6423SLionel Sambuc *
443433d6423SLionel Sambuc * DESCRIPTION: Create a new PowerResource object and populate the fields
444433d6423SLionel Sambuc *
445433d6423SLionel Sambuc * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
446433d6423SLionel Sambuc *
447433d6423SLionel Sambuc ******************************************************************************/
448433d6423SLionel Sambuc
449433d6423SLionel Sambuc ACPI_STATUS
AcpiExCreatePowerResource(ACPI_WALK_STATE * WalkState)450433d6423SLionel Sambuc AcpiExCreatePowerResource (
451433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState)
452433d6423SLionel Sambuc {
453433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
454433d6423SLionel Sambuc ACPI_STATUS Status;
455433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
456433d6423SLionel Sambuc
457433d6423SLionel Sambuc
458433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
459433d6423SLionel Sambuc
460433d6423SLionel Sambuc
461433d6423SLionel Sambuc /* Create the power resource object */
462433d6423SLionel Sambuc
463433d6423SLionel Sambuc ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
464433d6423SLionel Sambuc if (!ObjDesc)
465433d6423SLionel Sambuc {
466433d6423SLionel Sambuc return_ACPI_STATUS (AE_NO_MEMORY);
467433d6423SLionel Sambuc }
468433d6423SLionel Sambuc
469433d6423SLionel Sambuc /* Initialize the power object from the operands */
470433d6423SLionel Sambuc
471433d6423SLionel Sambuc ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
472433d6423SLionel Sambuc ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
473433d6423SLionel Sambuc
474433d6423SLionel Sambuc /* Install the power resource object in the parent Node */
475433d6423SLionel Sambuc
476433d6423SLionel Sambuc Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
477433d6423SLionel Sambuc ObjDesc, ACPI_TYPE_POWER);
478433d6423SLionel Sambuc
479433d6423SLionel Sambuc /* Remove local reference to the object */
480433d6423SLionel Sambuc
481433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
482433d6423SLionel Sambuc return_ACPI_STATUS (Status);
483433d6423SLionel Sambuc }
484433d6423SLionel Sambuc #endif
485433d6423SLionel Sambuc
486433d6423SLionel Sambuc
487433d6423SLionel Sambuc /*******************************************************************************
488433d6423SLionel Sambuc *
489433d6423SLionel Sambuc * FUNCTION: AcpiExCreateMethod
490433d6423SLionel Sambuc *
491433d6423SLionel Sambuc * PARAMETERS: AmlStart - First byte of the method's AML
492433d6423SLionel Sambuc * AmlLength - AML byte count for this method
493433d6423SLionel Sambuc * WalkState - Current state
494433d6423SLionel Sambuc *
495433d6423SLionel Sambuc * RETURN: Status
496433d6423SLionel Sambuc *
497433d6423SLionel Sambuc * DESCRIPTION: Create a new method object
498433d6423SLionel Sambuc *
499433d6423SLionel Sambuc ******************************************************************************/
500433d6423SLionel Sambuc
501433d6423SLionel Sambuc ACPI_STATUS
AcpiExCreateMethod(UINT8 * AmlStart,UINT32 AmlLength,ACPI_WALK_STATE * WalkState)502433d6423SLionel Sambuc AcpiExCreateMethod (
503433d6423SLionel Sambuc UINT8 *AmlStart,
504433d6423SLionel Sambuc UINT32 AmlLength,
505433d6423SLionel Sambuc ACPI_WALK_STATE *WalkState)
506433d6423SLionel Sambuc {
507433d6423SLionel Sambuc ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
508433d6423SLionel Sambuc ACPI_OPERAND_OBJECT *ObjDesc;
509433d6423SLionel Sambuc ACPI_STATUS Status;
510433d6423SLionel Sambuc UINT8 MethodFlags;
511433d6423SLionel Sambuc
512433d6423SLionel Sambuc
513433d6423SLionel Sambuc ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
514433d6423SLionel Sambuc
515433d6423SLionel Sambuc
516433d6423SLionel Sambuc /* Create a new method object */
517433d6423SLionel Sambuc
518433d6423SLionel Sambuc ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
519433d6423SLionel Sambuc if (!ObjDesc)
520433d6423SLionel Sambuc {
521433d6423SLionel Sambuc Status = AE_NO_MEMORY;
522433d6423SLionel Sambuc goto Exit;
523433d6423SLionel Sambuc }
524433d6423SLionel Sambuc
525433d6423SLionel Sambuc /* Save the method's AML pointer and length */
526433d6423SLionel Sambuc
527433d6423SLionel Sambuc ObjDesc->Method.AmlStart = AmlStart;
528433d6423SLionel Sambuc ObjDesc->Method.AmlLength = AmlLength;
529433d6423SLionel Sambuc
530433d6423SLionel Sambuc /*
531*29492bb7SDavid van Moolenbroek * Disassemble the method flags. Split off the ArgCount, Serialized
532*29492bb7SDavid van Moolenbroek * flag, and SyncLevel for efficiency.
533433d6423SLionel Sambuc */
534433d6423SLionel Sambuc MethodFlags = (UINT8) Operand[1]->Integer.Value;
535433d6423SLionel Sambuc ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
536433d6423SLionel Sambuc
537433d6423SLionel Sambuc /*
538433d6423SLionel Sambuc * Get the SyncLevel. If method is serialized, a mutex will be
539433d6423SLionel Sambuc * created for this method when it is parsed.
540433d6423SLionel Sambuc */
541433d6423SLionel Sambuc if (MethodFlags & AML_METHOD_SERIALIZED)
542433d6423SLionel Sambuc {
543*29492bb7SDavid van Moolenbroek ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
544*29492bb7SDavid van Moolenbroek
545433d6423SLionel Sambuc /*
546433d6423SLionel Sambuc * ACPI 1.0: SyncLevel = 0
547433d6423SLionel Sambuc * ACPI 2.0: SyncLevel = SyncLevel in method declaration
548433d6423SLionel Sambuc */
549433d6423SLionel Sambuc ObjDesc->Method.SyncLevel = (UINT8)
550433d6423SLionel Sambuc ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
551433d6423SLionel Sambuc }
552433d6423SLionel Sambuc
553433d6423SLionel Sambuc /* Attach the new object to the method Node */
554433d6423SLionel Sambuc
555433d6423SLionel Sambuc Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
556433d6423SLionel Sambuc ObjDesc, ACPI_TYPE_METHOD);
557433d6423SLionel Sambuc
558433d6423SLionel Sambuc /* Remove local reference to the object */
559433d6423SLionel Sambuc
560433d6423SLionel Sambuc AcpiUtRemoveReference (ObjDesc);
561433d6423SLionel Sambuc
562433d6423SLionel Sambuc Exit:
563433d6423SLionel Sambuc /* Remove a reference to the operand */
564433d6423SLionel Sambuc
565433d6423SLionel Sambuc AcpiUtRemoveReference (Operand[1]);
566433d6423SLionel Sambuc return_ACPI_STATUS (Status);
567433d6423SLionel Sambuc }
568