Deleted Added
full compact
excreate.c (127175) excreate.c (128212)
1/******************************************************************************
2 *
3 * Module Name: excreate - Named object creation
1/******************************************************************************
2 *
3 * Module Name: excreate - Named object creation
4 * $Revision: 102 $
4 * $Revision: 103 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * PARTICULAR PURPOSE.
91 *
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * LIMITED REMEDY.
100 *
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
115 *
116 *****************************************************************************/
117
118#define __EXCREATE_C__
119
120#include "acpi.h"
121#include "acinterp.h"
122#include "amlcode.h"
123#include "acnamesp.h"
124#include "acevents.h"
125#include "actables.h"
126
127
128#define _COMPONENT ACPI_EXECUTER
129 ACPI_MODULE_NAME ("excreate")
130
131
132#ifndef ACPI_NO_METHOD_EXECUTION
133/*****************************************************************************
134 *
135 * FUNCTION: AcpiExCreateAlias
136 *
137 * PARAMETERS: WalkState - Current state, contains operands
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Create a new named alias
142 *
143 ****************************************************************************/
144
145ACPI_STATUS
146AcpiExCreateAlias (
147 ACPI_WALK_STATE *WalkState)
148{
149 ACPI_NAMESPACE_NODE *TargetNode;
150 ACPI_NAMESPACE_NODE *AliasNode;
151 ACPI_STATUS Status = AE_OK;
152
153
154 ACPI_FUNCTION_TRACE ("ExCreateAlias");
155
156
157 /* Get the source/alias operands (both namespace nodes) */
158
159 AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
160 TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
161
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * PARTICULAR PURPOSE.
91 *
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * LIMITED REMEDY.
100 *
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
115 *
116 *****************************************************************************/
117
118#define __EXCREATE_C__
119
120#include "acpi.h"
121#include "acinterp.h"
122#include "amlcode.h"
123#include "acnamesp.h"
124#include "acevents.h"
125#include "actables.h"
126
127
128#define _COMPONENT ACPI_EXECUTER
129 ACPI_MODULE_NAME ("excreate")
130
131
132#ifndef ACPI_NO_METHOD_EXECUTION
133/*****************************************************************************
134 *
135 * FUNCTION: AcpiExCreateAlias
136 *
137 * PARAMETERS: WalkState - Current state, contains operands
138 *
139 * RETURN: Status
140 *
141 * DESCRIPTION: Create a new named alias
142 *
143 ****************************************************************************/
144
145ACPI_STATUS
146AcpiExCreateAlias (
147 ACPI_WALK_STATE *WalkState)
148{
149 ACPI_NAMESPACE_NODE *TargetNode;
150 ACPI_NAMESPACE_NODE *AliasNode;
151 ACPI_STATUS Status = AE_OK;
152
153
154 ACPI_FUNCTION_TRACE ("ExCreateAlias");
155
156
157 /* Get the source/alias operands (both namespace nodes) */
158
159 AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
160 TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
161
162 if (TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS)
162 if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
163 (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
163 {
164 /*
165 * Dereference an existing alias so that we don't create a chain
166 * of aliases. With this code, we guarantee that an alias is
167 * always exactly one level of indirection away from the
168 * actual aliased name.
169 */
164 {
165 /*
166 * Dereference an existing alias so that we don't create a chain
167 * of aliases. With this code, we guarantee that an alias is
168 * always exactly one level of indirection away from the
169 * actual aliased name.
170 */
170 TargetNode = (ACPI_NAMESPACE_NODE *) TargetNode->Object;
171 TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
171 }
172
173 /*
174 * For objects that can never change (i.e., the NS node will
175 * permanently point to the same object), we can simply attach
176 * the object to the new NS node. For other objects (such as
177 * Integers, buffers, etc.), we have to point the Alias node
178 * to the original Node.
179 */
180 switch (TargetNode->Type)
181 {
182 case ACPI_TYPE_INTEGER:
183 case ACPI_TYPE_STRING:
184 case ACPI_TYPE_BUFFER:
185 case ACPI_TYPE_PACKAGE:
186 case ACPI_TYPE_BUFFER_FIELD:
187
188 /*
189 * The new alias has the type ALIAS and points to the original
190 * NS node, not the object itself. This is because for these
191 * types, the object can change dynamically via a Store.
192 */
193 AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
194 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
195 break;
196
172 }
173
174 /*
175 * For objects that can never change (i.e., the NS node will
176 * permanently point to the same object), we can simply attach
177 * the object to the new NS node. For other objects (such as
178 * Integers, buffers, etc.), we have to point the Alias node
179 * to the original Node.
180 */
181 switch (TargetNode->Type)
182 {
183 case ACPI_TYPE_INTEGER:
184 case ACPI_TYPE_STRING:
185 case ACPI_TYPE_BUFFER:
186 case ACPI_TYPE_PACKAGE:
187 case ACPI_TYPE_BUFFER_FIELD:
188
189 /*
190 * The new alias has the type ALIAS and points to the original
191 * NS node, not the object itself. This is because for these
192 * types, the object can change dynamically via a Store.
193 */
194 AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
195 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
196 break;
197
198 case ACPI_TYPE_METHOD:
199
200 /*
201 * The new alias has the type ALIAS and points to the original
202 * NS node, not the object itself. This is because for these
203 * types, the object can change dynamically via a Store.
204 */
205 AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
206 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
207 break;
208
197 default:
198
199 /* Attach the original source object to the new Alias Node */
200
201 /*
202 * The new alias assumes the type of the target, and it points
203 * to the same object. The reference count of the object has an
204 * additional reference to prevent deletion out from under either the
205 * target node or the alias Node
206 */
207 Status = AcpiNsAttachObject (AliasNode,
208 AcpiNsGetAttachedObject (TargetNode),
209 TargetNode->Type);
210 break;
211 }
212
213 /* Since both operands are Nodes, we don't need to delete them */
214
215 return_ACPI_STATUS (Status);
216}
217
218
219/*****************************************************************************
220 *
221 * FUNCTION: AcpiExCreateEvent
222 *
223 * PARAMETERS: WalkState - Current state
224 *
225 * RETURN: Status
226 *
227 * DESCRIPTION: Create a new event object
228 *
229 ****************************************************************************/
230
231ACPI_STATUS
232AcpiExCreateEvent (
233 ACPI_WALK_STATE *WalkState)
234{
235 ACPI_STATUS Status;
236 ACPI_OPERAND_OBJECT *ObjDesc;
237
238
239 ACPI_FUNCTION_TRACE ("ExCreateEvent");
240
241
242 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
243 if (!ObjDesc)
244 {
245 Status = AE_NO_MEMORY;
246 goto Cleanup;
247 }
248
249 /*
250 * Create the actual OS semaphore, with zero initial units -- meaning
251 * that the event is created in an unsignalled state
252 */
253 Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
254 &ObjDesc->Event.Semaphore);
255 if (ACPI_FAILURE (Status))
256 {
257 goto Cleanup;
258 }
259
260 /* Attach object to the Node */
261
262 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
263 ObjDesc, ACPI_TYPE_EVENT);
264
265Cleanup:
266 /*
267 * Remove local reference to the object (on error, will cause deletion
268 * of both object and semaphore if present.)
269 */
270 AcpiUtRemoveReference (ObjDesc);
271 return_ACPI_STATUS (Status);
272}
273
274
275/*****************************************************************************
276 *
277 * FUNCTION: AcpiExCreateMutex
278 *
279 * PARAMETERS: WalkState - Current state
280 *
281 * RETURN: Status
282 *
283 * DESCRIPTION: Create a new mutex object
284 *
285 * Mutex (Name[0], SyncLevel[1])
286 *
287 ****************************************************************************/
288
289ACPI_STATUS
290AcpiExCreateMutex (
291 ACPI_WALK_STATE *WalkState)
292{
293 ACPI_STATUS Status = AE_OK;
294 ACPI_OPERAND_OBJECT *ObjDesc;
295
296
297 ACPI_FUNCTION_TRACE_PTR ("ExCreateMutex", ACPI_WALK_OPERANDS);
298
299
300 /* Create the new mutex object */
301
302 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
303 if (!ObjDesc)
304 {
305 Status = AE_NO_MEMORY;
306 goto Cleanup;
307 }
308
309 /*
310 * Create the actual OS semaphore.
311 * One unit max to make it a mutex, with one initial unit to allow
312 * the mutex to be acquired.
313 */
314 Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore);
315 if (ACPI_FAILURE (Status))
316 {
317 goto Cleanup;
318 }
319
320 /* Init object and attach to NS node */
321
322 ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
323 ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
324
325 Status = AcpiNsAttachObject (ObjDesc->Mutex.Node,
326 ObjDesc, ACPI_TYPE_MUTEX);
327
328
329Cleanup:
330 /*
331 * Remove local reference to the object (on error, will cause deletion
332 * of both object and semaphore if present.)
333 */
334 AcpiUtRemoveReference (ObjDesc);
335 return_ACPI_STATUS (Status);
336}
337
338
339/*****************************************************************************
340 *
341 * FUNCTION: AcpiExCreateRegion
342 *
343 * PARAMETERS: AmlStart - Pointer to the region declaration AML
344 * AmlLength - Max length of the declaration AML
345 * Operands - List of operands for the opcode
346 * WalkState - Current state
347 *
348 * RETURN: Status
349 *
350 * DESCRIPTION: Create a new operation region object
351 *
352 ****************************************************************************/
353
354ACPI_STATUS
355AcpiExCreateRegion (
356 UINT8 *AmlStart,
357 UINT32 AmlLength,
358 UINT8 RegionSpace,
359 ACPI_WALK_STATE *WalkState)
360{
361 ACPI_STATUS Status;
362 ACPI_OPERAND_OBJECT *ObjDesc;
363 ACPI_NAMESPACE_NODE *Node;
364 ACPI_OPERAND_OBJECT *RegionObj2;
365
366
367 ACPI_FUNCTION_TRACE ("ExCreateRegion");
368
369
370 /* Get the Namespace Node */
371
372 Node = WalkState->Op->Common.Node;
373
374 /*
375 * If the region object is already attached to this node,
376 * just return
377 */
378 if (AcpiNsGetAttachedObject (Node))
379 {
380 return_ACPI_STATUS (AE_OK);
381 }
382
383 /*
384 * Space ID must be one of the predefined IDs, or in the user-defined
385 * range
386 */
387 if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) &&
388 (RegionSpace < ACPI_USER_REGION_BEGIN))
389 {
390 ACPI_REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace));
391 return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
392 }
393
394 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
395 AcpiUtGetRegionName (RegionSpace), RegionSpace));
396
397 /* Create the region descriptor */
398
399 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
400 if (!ObjDesc)
401 {
402 Status = AE_NO_MEMORY;
403 goto Cleanup;
404 }
405
406 /*
407 * Remember location in AML stream of address & length
408 * operands since they need to be evaluated at run time.
409 */
410 RegionObj2 = ObjDesc->Common.NextObject;
411 RegionObj2->Extra.AmlStart = AmlStart;
412 RegionObj2->Extra.AmlLength = AmlLength;
413
414 /* Init the region from the operands */
415
416 ObjDesc->Region.SpaceId = RegionSpace;
417 ObjDesc->Region.Address = 0;
418 ObjDesc->Region.Length = 0;
419 ObjDesc->Region.Node = Node;
420
421 /* Install the new region object in the parent Node */
422
423 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
424
425
426Cleanup:
427
428 /* Remove local reference to the object */
429
430 AcpiUtRemoveReference (ObjDesc);
431 return_ACPI_STATUS (Status);
432}
433
434
435/*****************************************************************************
436 *
437 * FUNCTION: AcpiExCreateTableRegion
438 *
439 * PARAMETERS: WalkState - Current state
440 *
441 * RETURN: Status
442 *
443 * DESCRIPTION: Create a new DataTableRegion object
444 *
445 ****************************************************************************/
446
447ACPI_STATUS
448AcpiExCreateTableRegion (
449 ACPI_WALK_STATE *WalkState)
450{
451 ACPI_STATUS Status;
452 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
453 ACPI_OPERAND_OBJECT *ObjDesc;
454 ACPI_NAMESPACE_NODE *Node;
455 ACPI_TABLE_HEADER *Table;
456 ACPI_OPERAND_OBJECT *RegionObj2;
457
458
459 ACPI_FUNCTION_TRACE ("ExCreateTableRegion");
460
461
462 /* Get the Node from the object stack */
463
464 Node = WalkState->Op->Common.Node;
465
466 /*
467 * If the region object is already attached to this node,
468 * just return
469 */
470 if (AcpiNsGetAttachedObject (Node))
471 {
472 return_ACPI_STATUS (AE_OK);
473 }
474
475 /* Find the ACPI table */
476
477 Status = AcpiTbFindTable (Operand[1]->String.Pointer,
478 Operand[2]->String.Pointer,
479 Operand[3]->String.Pointer, &Table);
480 if (ACPI_FAILURE (Status))
481 {
482 return_ACPI_STATUS (Status);
483 }
484
485 /* Create the region descriptor */
486
487 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
488 if (!ObjDesc)
489 {
490 return_ACPI_STATUS (AE_NO_MEMORY);
491 }
492
493 RegionObj2 = ObjDesc->Common.NextObject;
494 RegionObj2->Extra.RegionContext = NULL;
495
496 /* Init the region from the operands */
497
498 ObjDesc->Region.SpaceId = REGION_DATA_TABLE;
499 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table);
500 ObjDesc->Region.Length = Table->Length;
501 ObjDesc->Region.Node = Node;
502 ObjDesc->Region.Flags = AOPOBJ_DATA_VALID;
503
504 /* Install the new region object in the parent Node */
505
506 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
507 if (ACPI_FAILURE (Status))
508 {
509 goto Cleanup;
510 }
511
512 Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
513 if (ACPI_FAILURE (Status))
514 {
515 if (Status == AE_NOT_EXIST)
516 {
517 Status = AE_OK;
518 }
519 else
520 {
521 goto Cleanup;
522 }
523 }
524
525 ObjDesc->Region.Flags |= AOPOBJ_SETUP_COMPLETE;
526
527
528Cleanup:
529
530 /* Remove local reference to the object */
531
532 AcpiUtRemoveReference (ObjDesc);
533 return_ACPI_STATUS (Status);
534}
535
536
537/*****************************************************************************
538 *
539 * FUNCTION: AcpiExCreateProcessor
540 *
541 * PARAMETERS: WalkState - Current state
542 *
543 * RETURN: Status
544 *
545 * DESCRIPTION: Create a new processor object and populate the fields
546 *
547 * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
548 *
549 ****************************************************************************/
550
551ACPI_STATUS
552AcpiExCreateProcessor (
553 ACPI_WALK_STATE *WalkState)
554{
555 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
556 ACPI_OPERAND_OBJECT *ObjDesc;
557 ACPI_STATUS Status;
558
559
560 ACPI_FUNCTION_TRACE_PTR ("ExCreateProcessor", WalkState);
561
562
563 /* Create the processor object */
564
565 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
566 if (!ObjDesc)
567 {
568 return_ACPI_STATUS (AE_NO_MEMORY);
569 }
570
571 /*
572 * Initialize the processor object from the operands
573 */
574 ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
575 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
576 ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
577
578 /* Install the processor object in the parent Node */
579
580 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
581 ObjDesc, ACPI_TYPE_PROCESSOR);
582
583 /* Remove local reference to the object */
584
585 AcpiUtRemoveReference (ObjDesc);
586 return_ACPI_STATUS (Status);
587}
588
589
590/*****************************************************************************
591 *
592 * FUNCTION: AcpiExCreatePowerResource
593 *
594 * PARAMETERS: WalkState - Current state
595 *
596 * RETURN: Status
597 *
598 * DESCRIPTION: Create a new PowerResource object and populate the fields
599 *
600 * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
601 *
602 ****************************************************************************/
603
604ACPI_STATUS
605AcpiExCreatePowerResource (
606 ACPI_WALK_STATE *WalkState)
607{
608 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
609 ACPI_STATUS Status;
610 ACPI_OPERAND_OBJECT *ObjDesc;
611
612
613 ACPI_FUNCTION_TRACE_PTR ("ExCreatePowerResource", WalkState);
614
615
616 /* Create the power resource object */
617
618 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
619 if (!ObjDesc)
620 {
621 return_ACPI_STATUS (AE_NO_MEMORY);
622 }
623
624 /* Initialize the power object from the operands */
625
626 ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
627 ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
628
629 /* Install the power resource object in the parent Node */
630
631 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
632 ObjDesc, ACPI_TYPE_POWER);
633
634 /* Remove local reference to the object */
635
636 AcpiUtRemoveReference (ObjDesc);
637 return_ACPI_STATUS (Status);
638}
639
640#endif
641
642/*****************************************************************************
643 *
644 * FUNCTION: AcpiExCreateMethod
645 *
646 * PARAMETERS: AmlStart - First byte of the method's AML
647 * AmlLength - AML byte count for this method
648 * WalkState - Current state
649 *
650 * RETURN: Status
651 *
652 * DESCRIPTION: Create a new method object
653 *
654 ****************************************************************************/
655
656ACPI_STATUS
657AcpiExCreateMethod (
658 UINT8 *AmlStart,
659 UINT32 AmlLength,
660 ACPI_WALK_STATE *WalkState)
661{
662 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
663 ACPI_OPERAND_OBJECT *ObjDesc;
664 ACPI_STATUS Status;
665 UINT8 MethodFlags;
666
667
668 ACPI_FUNCTION_TRACE_PTR ("ExCreateMethod", WalkState);
669
670
671 /* Create a new method object */
672
673 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
674 if (!ObjDesc)
675 {
676 return_ACPI_STATUS (AE_NO_MEMORY);
677 }
678
679 /* Save the method's AML pointer and length */
680
681 ObjDesc->Method.AmlStart = AmlStart;
682 ObjDesc->Method.AmlLength = AmlLength;
683
684 /*
685 * Disassemble the method flags. Split off the Arg Count
686 * for efficiency
687 */
688 MethodFlags = (UINT8) Operand[1]->Integer.Value;
689
690 ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT);
691 ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
692
693 /*
694 * Get the concurrency count. If required, a semaphore will be
695 * created for this method when it is parsed.
696 */
697 if (AcpiGbl_AllMethodsSerialized)
698 {
699 ObjDesc->Method.Concurrency = 1;
700 ObjDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED;
701 }
702 else if (MethodFlags & AML_METHOD_SERIALIZED)
703 {
704 /*
705 * ACPI 1.0: Concurrency = 1
706 * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1)
707 */
708 ObjDesc->Method.Concurrency = (UINT8)
709 (((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);
710 }
711 else
712 {
713 ObjDesc->Method.Concurrency = ACPI_INFINITE_CONCURRENCY;
714 }
715
716 /* Attach the new object to the method Node */
717
718 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
719 ObjDesc, ACPI_TYPE_METHOD);
720
721 /* Remove local reference to the object */
722
723 AcpiUtRemoveReference (ObjDesc);
724
725 /* Remove a reference to the operand */
726
727 AcpiUtRemoveReference (Operand[1]);
728 return_ACPI_STATUS (Status);
729}
730
731
209 default:
210
211 /* Attach the original source object to the new Alias Node */
212
213 /*
214 * The new alias assumes the type of the target, and it points
215 * to the same object. The reference count of the object has an
216 * additional reference to prevent deletion out from under either the
217 * target node or the alias Node
218 */
219 Status = AcpiNsAttachObject (AliasNode,
220 AcpiNsGetAttachedObject (TargetNode),
221 TargetNode->Type);
222 break;
223 }
224
225 /* Since both operands are Nodes, we don't need to delete them */
226
227 return_ACPI_STATUS (Status);
228}
229
230
231/*****************************************************************************
232 *
233 * FUNCTION: AcpiExCreateEvent
234 *
235 * PARAMETERS: WalkState - Current state
236 *
237 * RETURN: Status
238 *
239 * DESCRIPTION: Create a new event object
240 *
241 ****************************************************************************/
242
243ACPI_STATUS
244AcpiExCreateEvent (
245 ACPI_WALK_STATE *WalkState)
246{
247 ACPI_STATUS Status;
248 ACPI_OPERAND_OBJECT *ObjDesc;
249
250
251 ACPI_FUNCTION_TRACE ("ExCreateEvent");
252
253
254 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
255 if (!ObjDesc)
256 {
257 Status = AE_NO_MEMORY;
258 goto Cleanup;
259 }
260
261 /*
262 * Create the actual OS semaphore, with zero initial units -- meaning
263 * that the event is created in an unsignalled state
264 */
265 Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
266 &ObjDesc->Event.Semaphore);
267 if (ACPI_FAILURE (Status))
268 {
269 goto Cleanup;
270 }
271
272 /* Attach object to the Node */
273
274 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
275 ObjDesc, ACPI_TYPE_EVENT);
276
277Cleanup:
278 /*
279 * Remove local reference to the object (on error, will cause deletion
280 * of both object and semaphore if present.)
281 */
282 AcpiUtRemoveReference (ObjDesc);
283 return_ACPI_STATUS (Status);
284}
285
286
287/*****************************************************************************
288 *
289 * FUNCTION: AcpiExCreateMutex
290 *
291 * PARAMETERS: WalkState - Current state
292 *
293 * RETURN: Status
294 *
295 * DESCRIPTION: Create a new mutex object
296 *
297 * Mutex (Name[0], SyncLevel[1])
298 *
299 ****************************************************************************/
300
301ACPI_STATUS
302AcpiExCreateMutex (
303 ACPI_WALK_STATE *WalkState)
304{
305 ACPI_STATUS Status = AE_OK;
306 ACPI_OPERAND_OBJECT *ObjDesc;
307
308
309 ACPI_FUNCTION_TRACE_PTR ("ExCreateMutex", ACPI_WALK_OPERANDS);
310
311
312 /* Create the new mutex object */
313
314 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
315 if (!ObjDesc)
316 {
317 Status = AE_NO_MEMORY;
318 goto Cleanup;
319 }
320
321 /*
322 * Create the actual OS semaphore.
323 * One unit max to make it a mutex, with one initial unit to allow
324 * the mutex to be acquired.
325 */
326 Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore);
327 if (ACPI_FAILURE (Status))
328 {
329 goto Cleanup;
330 }
331
332 /* Init object and attach to NS node */
333
334 ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
335 ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
336
337 Status = AcpiNsAttachObject (ObjDesc->Mutex.Node,
338 ObjDesc, ACPI_TYPE_MUTEX);
339
340
341Cleanup:
342 /*
343 * Remove local reference to the object (on error, will cause deletion
344 * of both object and semaphore if present.)
345 */
346 AcpiUtRemoveReference (ObjDesc);
347 return_ACPI_STATUS (Status);
348}
349
350
351/*****************************************************************************
352 *
353 * FUNCTION: AcpiExCreateRegion
354 *
355 * PARAMETERS: AmlStart - Pointer to the region declaration AML
356 * AmlLength - Max length of the declaration AML
357 * Operands - List of operands for the opcode
358 * WalkState - Current state
359 *
360 * RETURN: Status
361 *
362 * DESCRIPTION: Create a new operation region object
363 *
364 ****************************************************************************/
365
366ACPI_STATUS
367AcpiExCreateRegion (
368 UINT8 *AmlStart,
369 UINT32 AmlLength,
370 UINT8 RegionSpace,
371 ACPI_WALK_STATE *WalkState)
372{
373 ACPI_STATUS Status;
374 ACPI_OPERAND_OBJECT *ObjDesc;
375 ACPI_NAMESPACE_NODE *Node;
376 ACPI_OPERAND_OBJECT *RegionObj2;
377
378
379 ACPI_FUNCTION_TRACE ("ExCreateRegion");
380
381
382 /* Get the Namespace Node */
383
384 Node = WalkState->Op->Common.Node;
385
386 /*
387 * If the region object is already attached to this node,
388 * just return
389 */
390 if (AcpiNsGetAttachedObject (Node))
391 {
392 return_ACPI_STATUS (AE_OK);
393 }
394
395 /*
396 * Space ID must be one of the predefined IDs, or in the user-defined
397 * range
398 */
399 if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) &&
400 (RegionSpace < ACPI_USER_REGION_BEGIN))
401 {
402 ACPI_REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace));
403 return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
404 }
405
406 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
407 AcpiUtGetRegionName (RegionSpace), RegionSpace));
408
409 /* Create the region descriptor */
410
411 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
412 if (!ObjDesc)
413 {
414 Status = AE_NO_MEMORY;
415 goto Cleanup;
416 }
417
418 /*
419 * Remember location in AML stream of address & length
420 * operands since they need to be evaluated at run time.
421 */
422 RegionObj2 = ObjDesc->Common.NextObject;
423 RegionObj2->Extra.AmlStart = AmlStart;
424 RegionObj2->Extra.AmlLength = AmlLength;
425
426 /* Init the region from the operands */
427
428 ObjDesc->Region.SpaceId = RegionSpace;
429 ObjDesc->Region.Address = 0;
430 ObjDesc->Region.Length = 0;
431 ObjDesc->Region.Node = Node;
432
433 /* Install the new region object in the parent Node */
434
435 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
436
437
438Cleanup:
439
440 /* Remove local reference to the object */
441
442 AcpiUtRemoveReference (ObjDesc);
443 return_ACPI_STATUS (Status);
444}
445
446
447/*****************************************************************************
448 *
449 * FUNCTION: AcpiExCreateTableRegion
450 *
451 * PARAMETERS: WalkState - Current state
452 *
453 * RETURN: Status
454 *
455 * DESCRIPTION: Create a new DataTableRegion object
456 *
457 ****************************************************************************/
458
459ACPI_STATUS
460AcpiExCreateTableRegion (
461 ACPI_WALK_STATE *WalkState)
462{
463 ACPI_STATUS Status;
464 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
465 ACPI_OPERAND_OBJECT *ObjDesc;
466 ACPI_NAMESPACE_NODE *Node;
467 ACPI_TABLE_HEADER *Table;
468 ACPI_OPERAND_OBJECT *RegionObj2;
469
470
471 ACPI_FUNCTION_TRACE ("ExCreateTableRegion");
472
473
474 /* Get the Node from the object stack */
475
476 Node = WalkState->Op->Common.Node;
477
478 /*
479 * If the region object is already attached to this node,
480 * just return
481 */
482 if (AcpiNsGetAttachedObject (Node))
483 {
484 return_ACPI_STATUS (AE_OK);
485 }
486
487 /* Find the ACPI table */
488
489 Status = AcpiTbFindTable (Operand[1]->String.Pointer,
490 Operand[2]->String.Pointer,
491 Operand[3]->String.Pointer, &Table);
492 if (ACPI_FAILURE (Status))
493 {
494 return_ACPI_STATUS (Status);
495 }
496
497 /* Create the region descriptor */
498
499 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
500 if (!ObjDesc)
501 {
502 return_ACPI_STATUS (AE_NO_MEMORY);
503 }
504
505 RegionObj2 = ObjDesc->Common.NextObject;
506 RegionObj2->Extra.RegionContext = NULL;
507
508 /* Init the region from the operands */
509
510 ObjDesc->Region.SpaceId = REGION_DATA_TABLE;
511 ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table);
512 ObjDesc->Region.Length = Table->Length;
513 ObjDesc->Region.Node = Node;
514 ObjDesc->Region.Flags = AOPOBJ_DATA_VALID;
515
516 /* Install the new region object in the parent Node */
517
518 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
519 if (ACPI_FAILURE (Status))
520 {
521 goto Cleanup;
522 }
523
524 Status = AcpiEvInitializeRegion (ObjDesc, FALSE);
525 if (ACPI_FAILURE (Status))
526 {
527 if (Status == AE_NOT_EXIST)
528 {
529 Status = AE_OK;
530 }
531 else
532 {
533 goto Cleanup;
534 }
535 }
536
537 ObjDesc->Region.Flags |= AOPOBJ_SETUP_COMPLETE;
538
539
540Cleanup:
541
542 /* Remove local reference to the object */
543
544 AcpiUtRemoveReference (ObjDesc);
545 return_ACPI_STATUS (Status);
546}
547
548
549/*****************************************************************************
550 *
551 * FUNCTION: AcpiExCreateProcessor
552 *
553 * PARAMETERS: WalkState - Current state
554 *
555 * RETURN: Status
556 *
557 * DESCRIPTION: Create a new processor object and populate the fields
558 *
559 * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
560 *
561 ****************************************************************************/
562
563ACPI_STATUS
564AcpiExCreateProcessor (
565 ACPI_WALK_STATE *WalkState)
566{
567 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
568 ACPI_OPERAND_OBJECT *ObjDesc;
569 ACPI_STATUS Status;
570
571
572 ACPI_FUNCTION_TRACE_PTR ("ExCreateProcessor", WalkState);
573
574
575 /* Create the processor object */
576
577 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
578 if (!ObjDesc)
579 {
580 return_ACPI_STATUS (AE_NO_MEMORY);
581 }
582
583 /*
584 * Initialize the processor object from the operands
585 */
586 ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
587 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
588 ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
589
590 /* Install the processor object in the parent Node */
591
592 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
593 ObjDesc, ACPI_TYPE_PROCESSOR);
594
595 /* Remove local reference to the object */
596
597 AcpiUtRemoveReference (ObjDesc);
598 return_ACPI_STATUS (Status);
599}
600
601
602/*****************************************************************************
603 *
604 * FUNCTION: AcpiExCreatePowerResource
605 *
606 * PARAMETERS: WalkState - Current state
607 *
608 * RETURN: Status
609 *
610 * DESCRIPTION: Create a new PowerResource object and populate the fields
611 *
612 * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
613 *
614 ****************************************************************************/
615
616ACPI_STATUS
617AcpiExCreatePowerResource (
618 ACPI_WALK_STATE *WalkState)
619{
620 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
621 ACPI_STATUS Status;
622 ACPI_OPERAND_OBJECT *ObjDesc;
623
624
625 ACPI_FUNCTION_TRACE_PTR ("ExCreatePowerResource", WalkState);
626
627
628 /* Create the power resource object */
629
630 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
631 if (!ObjDesc)
632 {
633 return_ACPI_STATUS (AE_NO_MEMORY);
634 }
635
636 /* Initialize the power object from the operands */
637
638 ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
639 ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
640
641 /* Install the power resource object in the parent Node */
642
643 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
644 ObjDesc, ACPI_TYPE_POWER);
645
646 /* Remove local reference to the object */
647
648 AcpiUtRemoveReference (ObjDesc);
649 return_ACPI_STATUS (Status);
650}
651
652#endif
653
654/*****************************************************************************
655 *
656 * FUNCTION: AcpiExCreateMethod
657 *
658 * PARAMETERS: AmlStart - First byte of the method's AML
659 * AmlLength - AML byte count for this method
660 * WalkState - Current state
661 *
662 * RETURN: Status
663 *
664 * DESCRIPTION: Create a new method object
665 *
666 ****************************************************************************/
667
668ACPI_STATUS
669AcpiExCreateMethod (
670 UINT8 *AmlStart,
671 UINT32 AmlLength,
672 ACPI_WALK_STATE *WalkState)
673{
674 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
675 ACPI_OPERAND_OBJECT *ObjDesc;
676 ACPI_STATUS Status;
677 UINT8 MethodFlags;
678
679
680 ACPI_FUNCTION_TRACE_PTR ("ExCreateMethod", WalkState);
681
682
683 /* Create a new method object */
684
685 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
686 if (!ObjDesc)
687 {
688 return_ACPI_STATUS (AE_NO_MEMORY);
689 }
690
691 /* Save the method's AML pointer and length */
692
693 ObjDesc->Method.AmlStart = AmlStart;
694 ObjDesc->Method.AmlLength = AmlLength;
695
696 /*
697 * Disassemble the method flags. Split off the Arg Count
698 * for efficiency
699 */
700 MethodFlags = (UINT8) Operand[1]->Integer.Value;
701
702 ObjDesc->Method.MethodFlags = (UINT8) (MethodFlags & ~AML_METHOD_ARG_COUNT);
703 ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
704
705 /*
706 * Get the concurrency count. If required, a semaphore will be
707 * created for this method when it is parsed.
708 */
709 if (AcpiGbl_AllMethodsSerialized)
710 {
711 ObjDesc->Method.Concurrency = 1;
712 ObjDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED;
713 }
714 else if (MethodFlags & AML_METHOD_SERIALIZED)
715 {
716 /*
717 * ACPI 1.0: Concurrency = 1
718 * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1)
719 */
720 ObjDesc->Method.Concurrency = (UINT8)
721 (((MethodFlags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);
722 }
723 else
724 {
725 ObjDesc->Method.Concurrency = ACPI_INFINITE_CONCURRENCY;
726 }
727
728 /* Attach the new object to the method Node */
729
730 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
731 ObjDesc, ACPI_TYPE_METHOD);
732
733 /* Remove local reference to the object */
734
735 AcpiUtRemoveReference (ObjDesc);
736
737 /* Remove a reference to the operand */
738
739 AcpiUtRemoveReference (Operand[1]);
740 return_ACPI_STATUS (Status);
741}
742
743