ReactOS 0.4.15-dev-7924-g5949c20
excreate.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
#include "amlcode.h"
#include "acnamesp.h"
Include dependency graph for excreate.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_EXECUTER
 

Functions

ACPI_STATUS AcpiExCreateAlias (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateEvent (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateMutex (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateRegion (UINT8 *AmlStart, UINT32 AmlLength, UINT8 SpaceId, ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateProcessor (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreatePowerResource (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiExCreateMethod (UINT8 *AmlStart, UINT32 AmlLength, ACPI_WALK_STATE *WalkState)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_EXECUTER

Definition at line 51 of file excreate.c.

Function Documentation

◆ AcpiExCreateAlias()

ACPI_STATUS AcpiExCreateAlias ( ACPI_WALK_STATE WalkState)

Definition at line 68 of file excreate.c.

70{
71 ACPI_NAMESPACE_NODE *TargetNode;
72 ACPI_NAMESPACE_NODE *AliasNode;
74
75
76 ACPI_FUNCTION_TRACE (ExCreateAlias);
77
78
79 /* Get the source/alias operands (both namespace nodes) */
80
81 AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
82 TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
83
84 if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
85 (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
86 {
87 /*
88 * Dereference an existing alias so that we don't create a chain
89 * of aliases. With this code, we guarantee that an alias is
90 * always exactly one level of indirection away from the
91 * actual aliased name.
92 */
93 TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
94 }
95
96 /* Ensure that the target node is valid */
97
98 if (!TargetNode)
99 {
101 }
102
103 /* Construct the alias object (a namespace node) */
104
105 switch (TargetNode->Type)
106 {
107 case ACPI_TYPE_METHOD:
108 /*
109 * Control method aliases need to be differentiated with
110 * a special type
111 */
113 break;
114
115 default:
116 /*
117 * All other object types.
118 *
119 * The new alias has the type ALIAS and points to the original
120 * NS node, not the object itself.
121 */
122 AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
123 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
124 break;
125 }
126
127 /* Since both operands are Nodes, we don't need to delete them */
128
129 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
131}
#define AE_NULL_OBJECT
Definition: acexcep.h:117
#define AE_OK
Definition: acexcep.h:97
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_TYPE_LOCAL_ALIAS
Definition: actypes.h:720
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define ACPI_TYPE_LOCAL_METHOD_ALIAS
Definition: actypes.h:721
#define ACPI_TYPE_METHOD
Definition: actypes.h:695
Status
Definition: gdiplustypes.h:25
union acpi_operand_object * Object
Definition: aclocal.h:187
union acpi_operand_object * Operands[ACPI_OBJ_NUM_OPERANDS+1]
Definition: acstruct.h:105

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreateEvent()

ACPI_STATUS AcpiExCreateEvent ( ACPI_WALK_STATE WalkState)

Definition at line 147 of file excreate.c.

149{
151 ACPI_OPERAND_OBJECT *ObjDesc;
152
153
154 ACPI_FUNCTION_TRACE (ExCreateEvent);
155
156
158 if (!ObjDesc)
159 {
161 goto Cleanup;
162 }
163
164 /*
165 * Create the actual OS semaphore, with zero initial units -- meaning
166 * that the event is created in an unsignalled state
167 */
169 &ObjDesc->Event.OsSemaphore);
170 if (ACPI_FAILURE (Status))
171 {
172 goto Cleanup;
173 }
174
175 /* Attach object to the Node */
176
178 (ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
179 ObjDesc, ACPI_TYPE_EVENT);
180
181Cleanup:
182 /*
183 * Remove local reference to the object (on error, will cause deletion
184 * of both object and semaphore if present.)
185 */
186 AcpiUtRemoveReference (ObjDesc);
188}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_STATUS AcpiNsAttachObject(ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type)
Definition: nsobject.c:76
ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_SEMAPHORE *OutHandle)
Definition: osl.c:352
#define ACPI_NO_UNIT_LIMIT
Definition: acpiosxf.h:67
#define ACPI_TYPE_EVENT
Definition: actypes.h:694
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
static const WCHAR Cleanup[]
Definition: register.c:80
ACPI_OBJECT_COMMON_HEADER ACPI_SEMAPHORE OsSemaphore
Definition: acobject.h:178
ACPI_OBJECT_EVENT Event
Definition: acobject.h:524

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreateMethod()

ACPI_STATUS AcpiExCreateMethod ( UINT8 AmlStart,
UINT32  AmlLength,
ACPI_WALK_STATE WalkState 
)

Definition at line 484 of file excreate.c.

488{
489 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
490 ACPI_OPERAND_OBJECT *ObjDesc;
492 UINT8 MethodFlags;
493
494
495 ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
496
497
498 /* Create a new method object */
499
501 if (!ObjDesc)
502 {
504 goto Exit;
505 }
506
507 /* Save the method's AML pointer and length */
508
509 ObjDesc->Method.AmlStart = AmlStart;
510 ObjDesc->Method.AmlLength = AmlLength;
511 ObjDesc->Method.Node = Operand[0];
512
513 /*
514 * Disassemble the method flags. Split off the ArgCount, Serialized
515 * flag, and SyncLevel for efficiency.
516 */
517 MethodFlags = (UINT8) Operand[1]->Integer.Value;
518 ObjDesc->Method.ParamCount = (UINT8)
519 (MethodFlags & AML_METHOD_ARG_COUNT);
520
521 /*
522 * Get the SyncLevel. If method is serialized, a mutex will be
523 * created for this method when it is parsed.
524 */
525 if (MethodFlags & AML_METHOD_SERIALIZED)
526 {
528
529 /*
530 * ACPI 1.0: SyncLevel = 0
531 * ACPI 2.0: SyncLevel = SyncLevel in method declaration
532 */
533 ObjDesc->Method.SyncLevel = (UINT8)
534 ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
535 }
536
537 /* Attach the new object to the method Node */
538
540 ObjDesc, ACPI_TYPE_METHOD);
541
542 /* Remove local reference to the object */
543
544 AcpiUtRemoveReference (ObjDesc);
545
546Exit:
547 /* Remove a reference to the operand */
548
549 AcpiUtRemoveReference (Operand[1]);
551}
unsigned char UINT8
#define ACPI_METHOD_SERIALIZED
Definition: acobject.h:238
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define AML_METHOD_ARG_COUNT
Definition: amlcode.h:505
#define AML_METHOD_SERIALIZED
Definition: amlcode.h:506
#define AML_METHOD_SYNC_LEVEL
Definition: amlcode.h:507
static void Exit(void)
Definition: sock.c:1330
UINT8 * AmlStart
Definition: acobject.h:221
ACPI_OBJECT_COMMON_HEADER UINT8 InfoFlags
Definition: acobject.h:216
union acpi_operand_object * Node
Definition: acobject.h:220
ACPI_OBJECT_METHOD Method
Definition: acobject.h:525

Referenced by AcpiDsLoad1EndOp(), and AcpiDsLoad2EndOp().

◆ AcpiExCreateMutex()

ACPI_STATUS AcpiExCreateMutex ( ACPI_WALK_STATE WalkState)

Definition at line 206 of file excreate.c.

208{
210 ACPI_OPERAND_OBJECT *ObjDesc;
211
212
214
215
216 /* Create the new mutex object */
217
219 if (!ObjDesc)
220 {
222 goto Cleanup;
223 }
224
225 /* Create the actual OS Mutex */
226
228 if (ACPI_FAILURE (Status))
229 {
230 goto Cleanup;
231 }
232
233 /* Init object and attach to NS node */
234
235 ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
236 ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
237
239 ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
240
241
242Cleanup:
243 /*
244 * Remove local reference to the object (on error, will cause deletion
245 * of both object and semaphore if present.)
246 */
247 AcpiUtRemoveReference (ObjDesc);
249}
#define ACPI_WALK_OPERANDS
Definition: acinterp.h:48
#define ACPI_TYPE_MUTEX
Definition: actypes.h:696
#define AcpiOsCreateMutex(OutHandle)
Definition: actypes.h:274
ACPI_OBJECT_COMMON_HEADER UINT8 SyncLevel
Definition: acobject.h:186
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:193
ACPI_MUTEX OsMutex
Definition: acobject.h:188
ACPI_OBJECT_MUTEX Mutex
Definition: acobject.h:526
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreatePowerResource()

ACPI_STATUS AcpiExCreatePowerResource ( ACPI_WALK_STATE WalkState)

Definition at line 433 of file excreate.c.

435{
436 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
438 ACPI_OPERAND_OBJECT *ObjDesc;
439
440
441 ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
442
443
444 /* Create the power resource object */
445
447 if (!ObjDesc)
448 {
450 }
451
452 /* Initialize the power object from the operands */
453
454 ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
455 ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
456
457 /* Install the power resource object in the parent Node */
458
460 ObjDesc, ACPI_TYPE_POWER);
461
462 /* Remove local reference to the object */
463
464 AcpiUtRemoveReference (ObjDesc);
466}
unsigned short UINT16
#define ACPI_TYPE_POWER
Definition: actypes.h:698
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO UINT32 SystemLevel
Definition: acobject.h:280
ACPI_OBJECT_POWER_RESOURCE PowerResource
Definition: acobject.h:530

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreateProcessor()

ACPI_STATUS AcpiExCreateProcessor ( ACPI_WALK_STATE WalkState)

Definition at line 381 of file excreate.c.

383{
384 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
385 ACPI_OPERAND_OBJECT *ObjDesc;
387
388
389 ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
390
391
392 /* Create the processor object */
393
395 if (!ObjDesc)
396 {
398 }
399
400 /* Initialize the processor object from the operands */
401
402 ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
403 ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
404 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
405
406 /* Install the processor object in the parent Node */
407
409 ObjDesc, ACPI_TYPE_PROCESSOR);
410
411 /* Remove local reference to the object */
412
413 AcpiUtRemoveReference (ObjDesc);
415}
#define ACPI_TYPE_PROCESSOR
Definition: actypes.h:699
ACPI_COMMON_NOTIFY_INFO ACPI_IO_ADDRESS Address
Definition: acobject.h:295
ACPI_OBJECT_COMMON_HEADER UINT8 ProcId
Definition: acobject.h:292
ACPI_OBJECT_PROCESSOR Processor
Definition: acobject.h:531

Referenced by AcpiDsLoad2EndOp().

◆ AcpiExCreateRegion()

ACPI_STATUS AcpiExCreateRegion ( UINT8 AmlStart,
UINT32  AmlLength,
UINT8  SpaceId,
ACPI_WALK_STATE WalkState 
)

Definition at line 268 of file excreate.c.

273{
275 ACPI_OPERAND_OBJECT *ObjDesc;
277 ACPI_OPERAND_OBJECT *RegionObj2;
278
279
280 ACPI_FUNCTION_TRACE (ExCreateRegion);
281
282
283 /* Get the Namespace Node */
284
285 Node = WalkState->Op->Common.Node;
286
287 /*
288 * If the region object is already attached to this node,
289 * just return
290 */
292 {
294 }
295
296 /*
297 * Space ID must be one of the predefined IDs, or in the user-defined
298 * range
299 */
301 {
302 /*
303 * Print an error message, but continue. We don't want to abort
304 * a table load for this exception. Instead, if the region is
305 * actually used at runtime, abort the executing method.
306 */
308 "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
309 }
310
311 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
313
314 /* Create the region descriptor */
315
317 if (!ObjDesc)
318 {
320 goto Cleanup;
321 }
322
323 /*
324 * Remember location in AML stream of address & length
325 * operands since they need to be evaluated at run time.
326 */
327 RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc);
328 RegionObj2->Extra.AmlStart = AmlStart;
329 RegionObj2->Extra.AmlLength = AmlLength;
330 RegionObj2->Extra.Method_REG = NULL;
331 if (WalkState->ScopeInfo)
332 {
333 RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
334 }
335 else
336 {
337 RegionObj2->Extra.ScopeNode = Node;
338 }
339
340 /* Init the region from the operands */
341
342 ObjDesc->Region.SpaceId = SpaceId;
343 ObjDesc->Region.Address = 0;
344 ObjDesc->Region.Length = 0;
345 ObjDesc->Region.Pointer = NULL;
346 ObjDesc->Region.Node = Node;
347 ObjDesc->Region.Handler = NULL;
348 ObjDesc->Common.Flags &=
351
352 /* Install the new region object in the parent Node */
353
355
356
357Cleanup:
358
359 /* Remove local reference to the object */
360
361 AcpiUtRemoveReference (ObjDesc);
363}
ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: nsobject.c:346
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
#define AOPOBJ_REG_CONNECTED
Definition: acobject.h:98
#define AOPOBJ_OBJECT_INITIALIZED
Definition: acobject.h:97
#define AOPOBJ_SETUP_COMPLETE
Definition: acobject.h:99
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define ACPI_DB_LOAD
Definition: acoutput.h:164
#define AE_INFO
Definition: acoutput.h:230
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE SpaceId
Definition: acpixf.h:832
#define ACPI_TYPE_REGION
Definition: actypes.h:697
const char * AcpiUtGetRegionName(UINT8 SpaceId)
Definition: utdecode.c:125
#define NULL
Definition: types.h:112
union node Node
Definition: types.h:1255
BOOLEAN AcpiIsValidSpaceId(UINT8 SpaceId)
Definition: exutils.c:494
ACPI_OBJECT_COMMON_HEADER ACPI_NAMESPACE_NODE * Method_REG
Definition: acobject.h:481
UINT32 AmlLength
Definition: acobject.h:485
ACPI_NAMESPACE_NODE * ScopeNode
Definition: acobject.h:482
UINT8 * AmlStart
Definition: acobject.h:484
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:203
ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId
Definition: acobject.h:202
ACPI_PHYSICAL_ADDRESS Address
Definition: acobject.h:206
union acpi_operand_object * Handler
Definition: acobject.h:204
ACPI_STATE_COMMON ACPI_NAMESPACE_NODE * Node
Definition: aclocal.h:740
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118
ACPI_GENERIC_STATE * ScopeInfo
Definition: acstruct.h:124
ACPI_SCOPE_STATE Scope
Definition: aclocal.h:825
ACPI_OBJECT_REGION Region
Definition: acobject.h:527
ACPI_OBJECT_EXTRA Extra
Definition: acobject.h:541
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
Definition: dlist.c:348

Referenced by AcpiDsLoad1EndOp(), and AcpiDsLoad2EndOp().