ReactOS 0.4.15-dev-7953-g1f49173
dsobject.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
#include "acdispat.h"
#include "acnamesp.h"
#include "acinterp.h"
Include dependency graph for dsobject.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_DISPATCHER
 

Functions

ACPI_STATUS AcpiDsBuildInternalObject (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT **ObjDescPtr)
 
ACPI_STATUS AcpiDsBuildInternalBufferObj (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT32 BufferLength, ACPI_OPERAND_OBJECT **ObjDescPtr)
 
ACPI_STATUS AcpiDsCreateNode (ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiDsInitObjectFromOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT16 Opcode, ACPI_OPERAND_OBJECT **RetObjDesc)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_DISPATCHER

Definition at line 52 of file dsobject.c.

Function Documentation

◆ AcpiDsBuildInternalBufferObj()

ACPI_STATUS AcpiDsBuildInternalBufferObj ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
UINT32  BufferLength,
ACPI_OPERAND_OBJECT **  ObjDescPtr 
)

Definition at line 188 of file dsobject.c.

193{
195 ACPI_OPERAND_OBJECT *ObjDesc;
196 ACPI_PARSE_OBJECT *ByteList;
197 UINT32 ByteListLength = 0;
198
199
200 ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj);
201
202
203 /*
204 * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
205 * The buffer object already exists (from the NS node), otherwise it must
206 * be created.
207 */
208 ObjDesc = *ObjDescPtr;
209 if (!ObjDesc)
210 {
211 /* Create a new buffer object */
212
214 *ObjDescPtr = ObjDesc;
215 if (!ObjDesc)
216 {
218 }
219 }
220
221 /*
222 * Second arg is the buffer data (optional) ByteList can be either
223 * individual bytes or a string initializer. In either case, a
224 * ByteList appears in the AML.
225 */
226 Arg = Op->Common.Value.Arg; /* skip first arg */
227
228 ByteList = Arg->Named.Next;
229 if (ByteList)
230 {
231 if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP)
232 {
234 "Expecting bytelist, found AML opcode 0x%X in op %p",
235 ByteList->Common.AmlOpcode, ByteList));
236
237 AcpiUtRemoveReference (ObjDesc);
238 return (AE_TYPE);
239 }
240
241 ByteListLength = (UINT32) ByteList->Common.Value.Integer;
242 }
243
244 /*
245 * The buffer length (number of bytes) will be the larger of:
246 * 1) The specified buffer length and
247 * 2) The length of the initializer byte list
248 */
249 ObjDesc->Buffer.Length = BufferLength;
250 if (ByteListLength > BufferLength)
251 {
252 ObjDesc->Buffer.Length = ByteListLength;
253 }
254
255 /* Allocate the buffer */
256
257 if (ObjDesc->Buffer.Length == 0)
258 {
259 ObjDesc->Buffer.Pointer = NULL;
261 "Buffer defined with zero length in AML, creating\n"));
262 }
263 else
264 {
265 ObjDesc->Buffer.Pointer =
266 ACPI_ALLOCATE_ZEROED (ObjDesc->Buffer.Length);
267 if (!ObjDesc->Buffer.Pointer)
268 {
269 AcpiUtDeleteObjectDesc (ObjDesc);
271 }
272
273 /* Initialize buffer from the ByteList (if present) */
274
275 if (ByteList)
276 {
277 memcpy (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
278 ByteListLength);
279 }
280 }
281
282 ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
283 Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
285}
unsigned int UINT32
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_TYPE
Definition: acexcep.h:116
#define AE_OK
Definition: acexcep.h:97
#define AOPOBJ_DATA_VALID
Definition: acobject.h:96
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
void AcpiUtDeleteObjectDesc(ACPI_OPERAND_OBJECT *Object)
Definition: utobject.c:473
#define AML_INT_BYTELIST_OP
Definition: amlcode.h:209
#define NULL
Definition: types.h:112
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:522
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by AcpiDsEvalDataObjectOperands().

◆ AcpiDsBuildInternalObject()

ACPI_STATUS AcpiDsBuildInternalObject ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
ACPI_OPERAND_OBJECT **  ObjDescPtr 
)

Definition at line 72 of file dsobject.c.

76{
77 ACPI_OPERAND_OBJECT *ObjDesc;
79
80
81 ACPI_FUNCTION_TRACE (DsBuildInternalObject);
82
83
84 *ObjDescPtr = NULL;
85 if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
86 {
87 /*
88 * This is a named object reference. If this name was
89 * previously looked up in the namespace, it was stored in
90 * this op. Otherwise, go ahead and look it up now
91 */
92 if (!Op->Common.Node)
93 {
94 /* Check if we are resolving a named reference within a package */
95
96 if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
97 (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
98 {
99 /*
100 * We won't resolve package elements here, we will do this
101 * after all ACPI tables are loaded into the namespace. This
102 * behavior supports both forward references to named objects
103 * and external references to objects in other tables.
104 */
105 goto CreateNewObject;
106 }
107 else
108 {
109 Status = AcpiNsLookup (WalkState->ScopeInfo,
110 Op->Common.Value.String,
114 ACPI_NAMESPACE_NODE, &(Op->Common.Node)));
115 if (ACPI_FAILURE (Status))
116 {
118 Op->Common.Value.String, Status);
120 }
121 }
122 }
123 }
124
125CreateNewObject:
126
127 /* Create and init a new internal ACPI object */
128
130 (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType);
131 if (!ObjDesc)
132 {
134 }
135
137 WalkState, Op, Op->Common.AmlOpcode, &ObjDesc);
138 if (ACPI_FAILURE (Status))
139 {
140 AcpiUtRemoveReference (ObjDesc);
142 }
143
144 /*
145 * Handling for unresolved package reference elements.
146 * These are elements that are namepaths.
147 */
148 if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
149 (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
150 {
151 ObjDesc->Reference.Resolved = TRUE;
152
153 if ((Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
154 !ObjDesc->Reference.Node)
155 {
156 /*
157 * Name was unresolved above.
158 * Get the prefix node for later lookup
159 */
160 ObjDesc->Reference.Node = WalkState->ScopeInfo->Scope.Node;
161 ObjDesc->Reference.Aml = Op->Common.Aml;
162 ObjDesc->Reference.Resolved = FALSE;
163 }
164 }
165
166 *ObjDescPtr = ObjDesc;
168}
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
@ ACPI_IMODE_EXECUTE
Definition: aclocal.h:169
#define ACPI_ERROR_NAMESPACE(s, p, e)
Definition: acmacros.h:462
ACPI_STATUS AcpiNsLookup(ACPI_GENERIC_STATE *ScopeInfo, char *Name, ACPI_OBJECT_TYPE Type, ACPI_INTERPRETER_MODE InterpreterMode, UINT32 Flags, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **RetNode)
Definition: nsaccess.c:328
#define ACPI_NS_DONT_OPEN_SCOPE
Definition: acnamesp.h:64
#define ACPI_NS_SEARCH_PARENT
Definition: acnamesp.h:63
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
#define ACPI_CAST_INDIRECT_PTR(t, p)
Definition: actypes.h:545
#define ACPI_TYPE_ANY
Definition: actypes.h:687
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AML_VARIABLE_PACKAGE_OP
Definition: amlcode.h:63
#define AML_PACKAGE_OP
Definition: amlcode.h:62
#define AML_INT_NAMEPATH_OP
Definition: amlcode.h:205
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ACPI_STATUS AcpiDsInitObjectFromOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT16 Opcode, ACPI_OPERAND_OBJECT **RetObjDesc)
Definition: dsobject.c:373
Status
Definition: gdiplustypes.h:25
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:447
ACPI_STATE_COMMON ACPI_NAMESPACE_NODE * Node
Definition: aclocal.h:740
ACPI_GENERIC_STATE * ScopeInfo
Definition: acstruct.h:124
ACPI_SCOPE_STATE Scope
Definition: aclocal.h:825
ACPI_OBJECT_REFERENCE Reference
Definition: acobject.h:540

Referenced by AcpiDsBuildInternalPackageObj(), and AcpiDsCreateNode().

◆ AcpiDsCreateNode()

ACPI_STATUS AcpiDsCreateNode ( ACPI_WALK_STATE WalkState,
ACPI_NAMESPACE_NODE Node,
ACPI_PARSE_OBJECT Op 
)

Definition at line 302 of file dsobject.c.

306{
308 ACPI_OPERAND_OBJECT *ObjDesc;
309
310
311 ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op);
312
313
314 /*
315 * Because of the execution pass through the non-control-method
316 * parts of the table, we can arrive here twice. Only init
317 * the named object node the first time through
318 */
320 {
322 }
323
324 if (!Op->Common.Value.Arg)
325 {
326 /* No arguments, there is nothing to do */
327
329 }
330
331 /* Build an internal object for the argument(s) */
332
334 WalkState, Op->Common.Value.Arg, &ObjDesc);
335 if (ACPI_FAILURE (Status))
336 {
338 }
339
340 /* Re-type the object according to its argument */
341
342 Node->Type = ObjDesc->Common.Type;
343
344 /* Attach obj to node */
345
346 Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
347
348 /* Remove local reference to the object */
349
350 AcpiUtRemoveReference (ObjDesc);
352}
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
ACPI_STATUS AcpiNsAttachObject(ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type)
Definition: nsobject.c:76
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_STATUS AcpiDsBuildInternalObject(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT **ObjDescPtr)
Definition: dsobject.c:72
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
Definition: dlist.c:348

Referenced by AcpiDsExecEndOp(), and AcpiDsLoad2EndOp().

◆ AcpiDsInitObjectFromOp()

ACPI_STATUS AcpiDsInitObjectFromOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
UINT16  Opcode,
ACPI_OPERAND_OBJECT **  RetObjDesc 
)

Definition at line 373 of file dsobject.c.

378{
379 const ACPI_OPCODE_INFO *OpInfo;
380 ACPI_OPERAND_OBJECT *ObjDesc;
382
383
384 ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
385
386
387 ObjDesc = *RetObjDesc;
388 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
389 if (OpInfo->Class == AML_CLASS_UNKNOWN)
390 {
391 /* Unknown opcode */
392
394 }
395
396 /* Perform per-object initialization */
397
398 switch (ObjDesc->Common.Type)
399 {
400 case ACPI_TYPE_BUFFER:
401 /*
402 * Defer evaluation of Buffer TermArg operand
403 */
404 ObjDesc->Buffer.Node = ACPI_CAST_PTR (
405 ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
406 ObjDesc->Buffer.AmlStart = Op->Named.Data;
407 ObjDesc->Buffer.AmlLength = Op->Named.Length;
408 break;
409
411 /*
412 * Defer evaluation of Package TermArg operand and all
413 * package elements. (01/2017): We defer the element
414 * resolution to allow forward references from the package
415 * in order to provide compatibility with other ACPI
416 * implementations.
417 */
418 ObjDesc->Package.Node = ACPI_CAST_PTR (
419 ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
420
421 if (!Op->Named.Data)
422 {
424 }
425
426 ObjDesc->Package.AmlStart = Op->Named.Data;
427 ObjDesc->Package.AmlLength = Op->Named.Length;
428 break;
429
431
432 switch (OpInfo->Type)
433 {
435 /*
436 * Resolve AML Constants here - AND ONLY HERE!
437 * All constants are integers.
438 * We mark the integer with a flag that indicates that it started
439 * life as a constant -- so that stores to constants will perform
440 * as expected (noop). ZeroOp is used as a placeholder for optional
441 * target operands.
442 */
443 ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
444
445 switch (Opcode)
446 {
447 case AML_ZERO_OP:
448
449 ObjDesc->Integer.Value = 0;
450 break;
451
452 case AML_ONE_OP:
453
454 ObjDesc->Integer.Value = 1;
455 break;
456
457 case AML_ONES_OP:
458
459 ObjDesc->Integer.Value = ACPI_UINT64_MAX;
460
461 /* Truncate value if we are executing from a 32-bit ACPI table */
462
464 break;
465
466 case AML_REVISION_OP:
467
468 ObjDesc->Integer.Value = ACPI_CA_VERSION;
469 break;
470
471 default:
472
474 "Unknown constant opcode 0x%X", Opcode));
476 break;
477 }
478 break;
479
480 case AML_TYPE_LITERAL:
481
482 ObjDesc->Integer.Value = Op->Common.Value.Integer;
483
484 if (AcpiExTruncateFor32bitTable (ObjDesc))
485 {
486 /* Warn if we found a 64-bit constant in a 32-bit table */
487
489 "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
490 ACPI_FORMAT_UINT64 (Op->Common.Value.Integer),
491 (UINT32) ObjDesc->Integer.Value));
492 }
493 break;
494
495 default:
496
497 ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
498 OpInfo->Type));
500 break;
501 }
502 break;
503
504 case ACPI_TYPE_STRING:
505
506 ObjDesc->String.Pointer = Op->Common.Value.String;
507 ObjDesc->String.Length = (UINT32) strlen (Op->Common.Value.String);
508
509 /*
510 * The string is contained in the ACPI table, don't ever try
511 * to delete it
512 */
513 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
514 break;
515
516 case ACPI_TYPE_METHOD:
517 break;
518
520
521 switch (OpInfo->Type)
522 {
524
525 /* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */
526
529
531 ObjDesc->Reference.Value, WalkState,
533 &ObjDesc->Reference.Object));
534 break;
535
537
538 /* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */
539
542
544 ObjDesc->Reference.Value, WalkState,
546 &ObjDesc->Reference.Object));
547 break;
548
549 default: /* Object name or Debug object */
550
551 switch (Op->Common.AmlOpcode)
552 {
554
555 /* Node was saved in Op */
556
557 ObjDesc->Reference.Node = Op->Common.Node;
559 if (Op->Common.Node)
560 {
561 ObjDesc->Reference.Object = Op->Common.Node->Object;
562 }
563 break;
564
565 case AML_DEBUG_OP:
566
568 break;
569
570 default:
571
573 "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
575 }
576 break;
577 }
578 break;
579
580 default:
581
582 ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
583 ObjDesc->Common.Type));
584
586 break;
587 }
588
590}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define ACPI_FORMAT_UINT64(i)
Definition: acmacros.h:71
@ ACPI_REFCLASS_NAME
Definition: acobject.h:464
@ ACPI_REFCLASS_ARG
Definition: acobject.h:460
@ ACPI_REFCLASS_LOCAL
Definition: acobject.h:459
@ ACPI_REFCLASS_DEBUG
Definition: acobject.h:465
#define AOPOBJ_STATIC_POINTER
Definition: acobject.h:95
#define AOPOBJ_AML_CONSTANT
Definition: acobject.h:94
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define ACPI_CA_VERSION
Definition: acpixf.h:49
#define ACPI_TYPE_LOCAL_REFERENCE
Definition: actypes.h:719
#define ACPI_UINT64_MAX
Definition: actypes.h:67
#define ACPI_TYPE_STRING
Definition: actypes.h:689
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691
#define ACPI_TYPE_METHOD
Definition: actypes.h:695
#define AML_FIRST_ARG_OP
Definition: amlcode.h:80
#define AML_ONES_OP
Definition: amlcode.h:142
#define AML_FIRST_LOCAL_OP
Definition: amlcode.h:71
#define AML_TYPE_METHOD_ARGUMENT
Definition: amlcode.h:369
#define AML_DEBUG_OP
Definition: amlcode.h:177
#define AML_TYPE_LITERAL
Definition: amlcode.h:367
#define AML_ZERO_OP
Definition: amlcode.h:51
#define AML_ONE_OP
Definition: amlcode.h:52
#define AML_TYPE_LOCAL_VARIABLE
Definition: amlcode.h:370
#define AML_TYPE_CONSTANT
Definition: amlcode.h:368
#define AML_CLASS_UNKNOWN
Definition: amlcode.h:410
#define AML_REVISION_OP
Definition: amlcode.h:176
ACPI_STATUS AcpiDsMethodDataGetNode(UINT8 Type, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node)
Definition: dsmthdat.c:275
BOOLEAN AcpiExTruncateFor32bitTable(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exutils.c:177
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:331
UINT8 * AmlStart
Definition: acobject.h:151
ACPI_OBJECT_COMMON_HEADER UINT32 AmlLength
Definition: acobject.h:150
ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:152
ACPI_OBJECT_COMMON_HEADER ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:160
ACPI_OBJECT_COMMON_HEADER UINT8 Class
Definition: acobject.h:443
union acpi_operand_object * Operands[ACPI_OBJ_NUM_OPERANDS+1]
Definition: acstruct.h:105
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:523
ACPI_OBJECT_STRING String
Definition: acobject.h:521

Referenced by AcpiDsBuildInternalObject(), and AcpiDsCreateOperand().