Deleted Added
full compact
dsobject.c (99146) dsobject.c (99679)
1/******************************************************************************
2 *
3 * Module Name: dsobject - Dispatcher object management routines
1/******************************************************************************
2 *
3 * Module Name: dsobject - Dispatcher object management routines
4 * $Revision: 91 $
4 * $Revision: 103 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.

--- 102 unchanged lines hidden (view full) ---

115 *****************************************************************************/
116
117#define __DSOBJECT_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "amlcode.h"
122#include "acdispat.h"
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.

--- 102 unchanged lines hidden (view full) ---

115 *****************************************************************************/
116
117#define __DSOBJECT_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "amlcode.h"
122#include "acdispat.h"
123#include "acinterp.h"
124#include "acnamesp.h"
123#include "acnamesp.h"
124#include "acinterp.h"
125
126#define _COMPONENT ACPI_DISPATCHER
127 ACPI_MODULE_NAME ("dsobject")
128
129
130/*******************************************************************************
131 *
132 * FUNCTION: AcpiDsInitOneObject

--- 19 unchanged lines hidden (view full) ---

152 ACPI_HANDLE ObjHandle,
153 UINT32 Level,
154 void *Context,
155 void **ReturnValue)
156{
157 ACPI_OBJECT_TYPE Type;
158 ACPI_STATUS Status;
159 ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
125
126#define _COMPONENT ACPI_DISPATCHER
127 ACPI_MODULE_NAME ("dsobject")
128
129
130/*******************************************************************************
131 *
132 * FUNCTION: AcpiDsInitOneObject

--- 19 unchanged lines hidden (view full) ---

152 ACPI_HANDLE ObjHandle,
153 UINT32 Level,
154 void *Context,
155 void **ReturnValue)
156{
157 ACPI_OBJECT_TYPE Type;
158 ACPI_STATUS Status;
159 ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context;
160 UINT8 TableRevision;
161
162
163 ACPI_FUNCTION_NAME ("DsInitOneObject");
164
165
160
161
162 ACPI_FUNCTION_NAME ("DsInitOneObject");
163
164
166 Info->ObjectCount++;
167 TableRevision = Info->TableDesc->Pointer->Revision;
168
169 /*
170 * We are only interested in objects owned by the table that
171 * was just loaded
172 */
173 if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId !=
174 Info->TableDesc->TableId)
175 {
176 return (AE_OK);
177 }
178
165 /*
166 * We are only interested in objects owned by the table that
167 * was just loaded
168 */
169 if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId !=
170 Info->TableDesc->TableId)
171 {
172 return (AE_OK);
173 }
174
175 Info->ObjectCount++;
176
179 /* And even then, we are only interested in a few object types */
180
181 Type = AcpiNsGetType (ObjHandle);
182
183 switch (Type)
184 {
185 case ACPI_TYPE_REGION:
186
177 /* And even then, we are only interested in a few object types */
178
179 Type = AcpiNsGetType (ObjHandle);
180
181 switch (Type)
182 {
183 case ACPI_TYPE_REGION:
184
187 AcpiDsInitializeRegion (ObjHandle);
185 Status = AcpiDsInitializeRegion (ObjHandle);
186 if (ACPI_FAILURE (Status))
187 {
188 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n",
189 ObjHandle, ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii,
190 AcpiFormatException (Status)));
191 }
188
189 Info->OpRegionCount++;
190 break;
191
192
193 case ACPI_TYPE_METHOD:
194
195 Info->MethodCount++;
196
197 if (!(AcpiDbgLevel & ACPI_LV_INIT))
198 {
199 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
200 }
201
202 /*
203 * Set the execution data width (32 or 64) based upon the
204 * revision number of the parent ACPI table.
192
193 Info->OpRegionCount++;
194 break;
195
196
197 case ACPI_TYPE_METHOD:
198
199 Info->MethodCount++;
200
201 if (!(AcpiDbgLevel & ACPI_LV_INIT))
202 {
203 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "."));
204 }
205
206 /*
207 * Set the execution data width (32 or 64) based upon the
208 * revision number of the parent ACPI table.
209 * TBD: This is really for possible future support of integer width
210 * on a per-table basis. Currently, we just use a global for the width.
205 */
211 */
206 if (TableRevision == 1)
212 if (Info->TableDesc->Pointer->Revision == 1)
207 {
213 {
208 ((ACPI_NAMESPACE_NODE *)ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32;
214 ((ACPI_NAMESPACE_NODE *) ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32;
209 }
210
211 /*
212 * Always parse methods to detect errors, we may delete
213 * the parse tree below
214 */
215 Status = AcpiDsParseMethod (ObjHandle);
216 if (ACPI_FAILURE (Status))
217 {
218 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n",
215 }
216
217 /*
218 * Always parse methods to detect errors, we may delete
219 * the parse tree below
220 */
221 Status = AcpiDsParseMethod (ObjHandle);
222 if (ACPI_FAILURE (Status))
223 {
224 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n",
219 ObjHandle, (char *) &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name,
225 ObjHandle, ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii,
220 AcpiFormatException (Status)));
221
222 /* This parse failed, but we will continue parsing more methods */
223
224 break;
225 }
226
227 /*
228 * Delete the parse tree. We simple re-parse the method
229 * for every execution since there isn't much overhead
230 */
231 AcpiNsDeleteNamespaceSubtree (ObjHandle);
232 AcpiNsDeleteNamespaceByOwner (((ACPI_NAMESPACE_NODE *) ObjHandle)->Object->Method.OwningId);
233 break;
234
226 AcpiFormatException (Status)));
227
228 /* This parse failed, but we will continue parsing more methods */
229
230 break;
231 }
232
233 /*
234 * Delete the parse tree. We simple re-parse the method
235 * for every execution since there isn't much overhead
236 */
237 AcpiNsDeleteNamespaceSubtree (ObjHandle);
238 AcpiNsDeleteNamespaceByOwner (((ACPI_NAMESPACE_NODE *) ObjHandle)->Object->Method.OwningId);
239 break;
240
241
242 case ACPI_TYPE_DEVICE:
243
244 Info->DeviceCount++;
245 break;
246
247
235 default:
236 break;
237 }
238
239 /*
240 * We ignore errors from above, and always return OK, since
241 * we don't want to abort the walk on a single error.
242 */

--- 26 unchanged lines hidden (view full) ---

269
270 ACPI_FUNCTION_TRACE ("DsInitializeObjects");
271
272
273 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
274 "**** Starting initialization of namespace objects ****\n"));
275 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Parsing Methods:"));
276
248 default:
249 break;
250 }
251
252 /*
253 * We ignore errors from above, and always return OK, since
254 * we don't want to abort the walk on a single error.
255 */

--- 26 unchanged lines hidden (view full) ---

282
283 ACPI_FUNCTION_TRACE ("DsInitializeObjects");
284
285
286 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
287 "**** Starting initialization of namespace objects ****\n"));
288 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Parsing Methods:"));
289
277
278 Info.MethodCount = 0;
279 Info.OpRegionCount = 0;
280 Info.ObjectCount = 0;
290 Info.MethodCount = 0;
291 Info.OpRegionCount = 0;
292 Info.ObjectCount = 0;
293 Info.DeviceCount = 0;
281 Info.TableDesc = TableDesc;
282
283 /* Walk entire namespace from the supplied root */
284
285 Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX,
286 AcpiDsInitOneObject, &Info, NULL);
287 if (ACPI_FAILURE (Status))
288 {
294 Info.TableDesc = TableDesc;
295
296 /* Walk entire namespace from the supplied root */
297
298 Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX,
299 AcpiDsInitOneObject, &Info, NULL);
300 if (ACPI_FAILURE (Status))
301 {
289 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WalkNamespace failed! %x\n", Status));
302 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WalkNamespace failed, %s\n",
303 AcpiFormatException (Status)));
290 }
291
292 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
304 }
305
306 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK,
293 "\n%d Control Methods found and parsed (%d nodes total)\n",
294 Info.MethodCount, Info.ObjectCount));
307 "\nTable [%4.4s] - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
308 TableDesc->Pointer->Signature, Info.ObjectCount,
309 Info.DeviceCount, Info.MethodCount, Info.OpRegionCount));
310
295 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
311 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
296 "%d Control Methods found\n", Info.MethodCount));
297 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
298 "%d Op Regions found\n", Info.OpRegionCount));
312 "%hd Methods, %hd Regions\n", Info.MethodCount, Info.OpRegionCount));
299
300 return_ACPI_STATUS (AE_OK);
301}
302
303
304/*****************************************************************************
305 *
306 * FUNCTION: AcpiDsInitObjectFromOp

--- 15 unchanged lines hidden (view full) ---

322AcpiDsInitObjectFromOp (
323 ACPI_WALK_STATE *WalkState,
324 ACPI_PARSE_OBJECT *Op,
325 UINT16 Opcode,
326 ACPI_OPERAND_OBJECT **RetObjDesc)
327{
328 const ACPI_OPCODE_INFO *OpInfo;
329 ACPI_OPERAND_OBJECT *ObjDesc;
313
314 return_ACPI_STATUS (AE_OK);
315}
316
317
318/*****************************************************************************
319 *
320 * FUNCTION: AcpiDsInitObjectFromOp

--- 15 unchanged lines hidden (view full) ---

336AcpiDsInitObjectFromOp (
337 ACPI_WALK_STATE *WalkState,
338 ACPI_PARSE_OBJECT *Op,
339 UINT16 Opcode,
340 ACPI_OPERAND_OBJECT **RetObjDesc)
341{
342 const ACPI_OPCODE_INFO *OpInfo;
343 ACPI_OPERAND_OBJECT *ObjDesc;
344 ACPI_STATUS Status = AE_OK;
330
331
345
346
332 ACPI_FUNCTION_NAME ("DsInitObjectFromOp");
347 ACPI_FUNCTION_TRACE ("DsInitObjectFromOp");
333
334
335 ObjDesc = *RetObjDesc;
336 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
337 if (OpInfo->Class == AML_CLASS_UNKNOWN)
338 {
339 /* Unknown opcode */
340
348
349
350 ObjDesc = *RetObjDesc;
351 OpInfo = AcpiPsGetOpcodeInfo (Opcode);
352 if (OpInfo->Class == AML_CLASS_UNKNOWN)
353 {
354 /* Unknown opcode */
355
341 return (AE_TYPE);
356 return_ACPI_STATUS (AE_TYPE);
342 }
343
344 /* Perform per-object initialization */
345
357 }
358
359 /* Perform per-object initialization */
360
346 switch (ObjDesc->Common.Type)
361 switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
347 {
348 case ACPI_TYPE_BUFFER:
349
350 /*
351 * Defer evaluation of Buffer TermArg operand
352 */
353 ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
362 {
363 case ACPI_TYPE_BUFFER:
364
365 /*
366 * Defer evaluation of Buffer TermArg operand
367 */
368 ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
354 ObjDesc->Buffer.AmlStart = ((ACPI_PARSE2_OBJECT *) Op)->Data;
355 ObjDesc->Buffer.AmlLength = ((ACPI_PARSE2_OBJECT *) Op)->Length;
369 ObjDesc->Buffer.AmlStart = Op->Named.Data;
370 ObjDesc->Buffer.AmlLength = Op->Named.Length;
356 break;
357
358
359 case ACPI_TYPE_PACKAGE:
360
361 /*
362 * Defer evaluation of Package TermArg operand
363 */
364 ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
371 break;
372
373
374 case ACPI_TYPE_PACKAGE:
375
376 /*
377 * Defer evaluation of Package TermArg operand
378 */
379 ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
365 ObjDesc->Package.AmlStart = ((ACPI_PARSE2_OBJECT *) Op)->Data;
366 ObjDesc->Package.AmlLength = ((ACPI_PARSE2_OBJECT *) Op)->Length;
380 ObjDesc->Package.AmlStart = Op->Named.Data;
381 ObjDesc->Package.AmlLength = Op->Named.Length;
367 break;
368
369
370 case ACPI_TYPE_INTEGER:
371
382 break;
383
384
385 case ACPI_TYPE_INTEGER:
386
372 ObjDesc->Integer.Value = Op->Value.Integer;
387 switch (OpInfo->Type)
388 {
389 case AML_TYPE_CONSTANT:
390 /*
391 * Resolve AML Constants here - AND ONLY HERE!
392 * All constants are integers.
393 * We mark the integer with a flag that indicates that it started life
394 * as a constant -- so that stores to constants will perform as expected (noop).
395 * (ZeroOp is used as a placeholder for optional target operands.)
396 */
397 ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
398
399 switch (Opcode)
400 {
401 case AML_ZERO_OP:
402
403 ObjDesc->Integer.Value = 0;
404 break;
405
406 case AML_ONE_OP:
407
408 ObjDesc->Integer.Value = 1;
409 break;
410
411 case AML_ONES_OP:
412
413 ObjDesc->Integer.Value = ACPI_INTEGER_MAX;
414
415 /* Truncate value if we are executing from a 32-bit ACPI table */
416
417 AcpiExTruncateFor32bitTable (ObjDesc);
418 break;
419
420 case AML_REVISION_OP:
421
422 ObjDesc->Integer.Value = ACPI_CA_SUPPORT_LEVEL;
423 break;
424
425 default:
426
427 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown constant opcode %X\n", Opcode));
428 Status = AE_AML_OPERAND_TYPE;
429 break;
430 }
431 break;
432
433
434 case AML_TYPE_LITERAL:
435
436 ObjDesc->Integer.Value = Op->Common.Value.Integer;
437 break;
438
439
440 default:
441 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", OpInfo->Type));
442 Status = AE_AML_OPERAND_TYPE;
443 break;
444 }
373 break;
374
375
376 case ACPI_TYPE_STRING:
377
445 break;
446
447
448 case ACPI_TYPE_STRING:
449
378 ObjDesc->String.Pointer = Op->Value.String;
379 ObjDesc->String.Length = ACPI_STRLEN (Op->Value.String);
450 ObjDesc->String.Pointer = Op->Common.Value.String;
451 ObjDesc->String.Length = ACPI_STRLEN (Op->Common.Value.String);
380
381 /*
382 * The string is contained in the ACPI table, don't ever try
383 * to delete it
384 */
385 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
386 break;
387

--- 19 unchanged lines hidden (view full) ---

407
408 /* Split the opcode into a base opcode + offset */
409
410 ObjDesc->Reference.Opcode = AML_ARG_OP;
411 ObjDesc->Reference.Offset = Opcode - AML_ARG_OP;
412 break;
413
414
452
453 /*
454 * The string is contained in the ACPI table, don't ever try
455 * to delete it
456 */
457 ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
458 break;
459

--- 19 unchanged lines hidden (view full) ---

479
480 /* Split the opcode into a base opcode + offset */
481
482 ObjDesc->Reference.Opcode = AML_ARG_OP;
483 ObjDesc->Reference.Offset = Opcode - AML_ARG_OP;
484 break;
485
486
415 default: /* Constants, Literals, etc.. */
487 default: /* Other literals, etc.. */
416
488
417 if (Op->Opcode == AML_INT_NAMEPATH_OP)
489 if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
418 {
419 /* Node was saved in Op */
420
490 {
491 /* Node was saved in Op */
492
421 ObjDesc->Reference.Node = Op->Node;
493 ObjDesc->Reference.Node = Op->Common.Node;
422 }
423
424 ObjDesc->Reference.Opcode = Opcode;
425 break;
426 }
427 break;
428
429
430 default:
431
494 }
495
496 ObjDesc->Reference.Opcode = Opcode;
497 break;
498 }
499 break;
500
501
502 default:
503
432 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %x\n",
433 ObjDesc->Common.Type));
504 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n",
505 ACPI_GET_OBJECT_TYPE (ObjDesc)));
434
506
507 Status = AE_AML_OPERAND_TYPE;
435 break;
436 }
437
508 break;
509 }
510
438 return (AE_OK);
511 return_ACPI_STATUS (Status);
439}
440
441
442/*****************************************************************************
443 *
444 * FUNCTION: AcpiDsBuildInternalObject
445 *
446 * PARAMETERS: WalkState - Current walk state

--- 16 unchanged lines hidden (view full) ---

463 ACPI_OPERAND_OBJECT *ObjDesc;
464 ACPI_STATUS Status;
465 char *Name;
466
467
468 ACPI_FUNCTION_TRACE ("DsBuildInternalObject");
469
470
512}
513
514
515/*****************************************************************************
516 *
517 * FUNCTION: AcpiDsBuildInternalObject
518 *
519 * PARAMETERS: WalkState - Current walk state

--- 16 unchanged lines hidden (view full) ---

536 ACPI_OPERAND_OBJECT *ObjDesc;
537 ACPI_STATUS Status;
538 char *Name;
539
540
541 ACPI_FUNCTION_TRACE ("DsBuildInternalObject");
542
543
471 if (Op->Opcode == AML_INT_NAMEPATH_OP)
544 if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
472 {
473 /*
545 {
546 /*
474 * This is an object reference. If this name was
547 * This is an named object reference. If this name was
475 * previously looked up in the namespace, it was stored in this op.
476 * Otherwise, go ahead and look it up now
477 */
548 * previously looked up in the namespace, it was stored in this op.
549 * Otherwise, go ahead and look it up now
550 */
478 if (!Op->Node)
551 if (!Op->Common.Node)
479 {
552 {
480 Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Value.String,
553 Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String,
481 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
482 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
554 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
555 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
483 (ACPI_NAMESPACE_NODE **) &(Op->Node));
556 (ACPI_NAMESPACE_NODE **) &(Op->Common.Node));
484
485 if (ACPI_FAILURE (Status))
486 {
487 if (Status == AE_NOT_FOUND)
488 {
489 Name = NULL;
557
558 if (ACPI_FAILURE (Status))
559 {
560 if (Status == AE_NOT_FOUND)
561 {
562 Name = NULL;
490 AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Value.String, NULL, &Name);
491
492 if (Name)
563 Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, Op->Common.Value.String, NULL, &Name);
564 if (ACPI_SUCCESS (Status))
493 {
494 ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n",
565 {
566 ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n",
495 Name, Op->AmlOffset));
567 Name, Op->Common.AmlOffset));
496 ACPI_MEM_FREE (Name);
497 }
498 else
499 {
500 ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n",
568 ACPI_MEM_FREE (Name);
569 }
570 else
571 {
572 ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n",
501 Op->Value.String, Op->AmlOffset));
573 Op->Common.Value.String, Op->Common.AmlOffset));
502 }
503
504 *ObjDescPtr = NULL;
505 }
506 else
507 {
508 return_ACPI_STATUS (Status);
509 }
510 }
511 }
512 }
513
514 /* Create and init the internal ACPI object */
515
574 }
575
576 *ObjDescPtr = NULL;
577 }
578 else
579 {
580 return_ACPI_STATUS (Status);
581 }
582 }
583 }
584 }
585
586 /* Create and init the internal ACPI object */
587
516 ObjDesc = AcpiUtCreateInternalObject ((AcpiPsGetOpcodeInfo (Op->Opcode))->ObjectType);
588 ObjDesc = AcpiUtCreateInternalObject ((AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType);
517 if (!ObjDesc)
518 {
519 return_ACPI_STATUS (AE_NO_MEMORY);
520 }
521
589 if (!ObjDesc)
590 {
591 return_ACPI_STATUS (AE_NO_MEMORY);
592 }
593
522 Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Opcode, &ObjDesc);
594 Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, &ObjDesc);
523 if (ACPI_FAILURE (Status))
524 {
525 AcpiUtRemoveReference (ObjDesc);
526 return_ACPI_STATUS (Status);
527 }
528
529 *ObjDescPtr = ObjDesc;
530 return_ACPI_STATUS (AE_OK);
531}
532
533
534/*****************************************************************************
535 *
536 * FUNCTION: AcpiDsBuildInternalBufferObj
537 *
595 if (ACPI_FAILURE (Status))
596 {
597 AcpiUtRemoveReference (ObjDesc);
598 return_ACPI_STATUS (Status);
599 }
600
601 *ObjDescPtr = ObjDesc;
602 return_ACPI_STATUS (AE_OK);
603}
604
605
606/*****************************************************************************
607 *
608 * FUNCTION: AcpiDsBuildInternalBufferObj
609 *
538 * PARAMETERS: Op - Parser object to be translated
610 * PARAMETERS: WalkState - Current walk state
611 * Op - Parser object to be translated
612 * BufferLength - Length of the buffer
539 * ObjDescPtr - Where the ACPI internal object is returned
540 *
541 * RETURN: Status
542 *
543 * DESCRIPTION: Translate a parser Op package object to the equivalent
544 * namespace object
545 *
546 ****************************************************************************/
547
548ACPI_STATUS
549AcpiDsBuildInternalBufferObj (
550 ACPI_WALK_STATE *WalkState,
551 ACPI_PARSE_OBJECT *Op,
552 UINT32 BufferLength,
553 ACPI_OPERAND_OBJECT **ObjDescPtr)
554{
555 ACPI_PARSE_OBJECT *Arg;
556 ACPI_OPERAND_OBJECT *ObjDesc;
613 * ObjDescPtr - Where the ACPI internal object is returned
614 *
615 * RETURN: Status
616 *
617 * DESCRIPTION: Translate a parser Op package object to the equivalent
618 * namespace object
619 *
620 ****************************************************************************/
621
622ACPI_STATUS
623AcpiDsBuildInternalBufferObj (
624 ACPI_WALK_STATE *WalkState,
625 ACPI_PARSE_OBJECT *Op,
626 UINT32 BufferLength,
627 ACPI_OPERAND_OBJECT **ObjDescPtr)
628{
629 ACPI_PARSE_OBJECT *Arg;
630 ACPI_OPERAND_OBJECT *ObjDesc;
557 ACPI_PARSE2_OBJECT *ByteList;
631 ACPI_PARSE_OBJECT *ByteList;
558 UINT32 ByteListLength = 0;
559
560
561 ACPI_FUNCTION_TRACE ("DsBuildInternalBufferObj");
562
563
564 ObjDesc = *ObjDescPtr;
565 if (ObjDesc)

--- 15 unchanged lines hidden (view full) ---

581 }
582 }
583
584 /*
585 * Second arg is the buffer data (optional) ByteList can be either
586 * individual bytes or a string initializer. In either case, a
587 * ByteList appears in the AML.
588 */
632 UINT32 ByteListLength = 0;
633
634
635 ACPI_FUNCTION_TRACE ("DsBuildInternalBufferObj");
636
637
638 ObjDesc = *ObjDescPtr;
639 if (ObjDesc)

--- 15 unchanged lines hidden (view full) ---

655 }
656 }
657
658 /*
659 * Second arg is the buffer data (optional) ByteList can be either
660 * individual bytes or a string initializer. In either case, a
661 * ByteList appears in the AML.
662 */
589 Arg = Op->Value.Arg; /* skip first arg */
663 Arg = Op->Common.Value.Arg; /* skip first arg */
590
664
591 ByteList = (ACPI_PARSE2_OBJECT *) Arg->Next;
665 ByteList = Arg->Named.Next;
592 if (ByteList)
593 {
666 if (ByteList)
667 {
594 if (ByteList->Opcode != AML_INT_BYTELIST_OP)
668 if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP)
595 {
596 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
597 "Expecting bytelist, got AML opcode %X in op %p\n",
669 {
670 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
671 "Expecting bytelist, got AML opcode %X in op %p\n",
598 ByteList->Opcode, ByteList));
672 ByteList->Common.AmlOpcode, ByteList));
599
600 AcpiUtRemoveReference (ObjDesc);
601 return (AE_TYPE);
602 }
603
673
674 AcpiUtRemoveReference (ObjDesc);
675 return (AE_TYPE);
676 }
677
604 ByteListLength = ByteList->Value.Integer32;
678 ByteListLength = ByteList->Common.Value.Integer32;
605 }
606
607 /*
608 * The buffer length (number of bytes) will be the larger of:
609 * 1) The specified buffer length and
610 * 2) The length of the initializer byte list
611 */
612 ObjDesc->Buffer.Length = BufferLength;

--- 18 unchanged lines hidden (view full) ---

631 AcpiUtDeleteObjectDesc (ObjDesc);
632 return_ACPI_STATUS (AE_NO_MEMORY);
633 }
634
635 /* Initialize buffer from the ByteList (if present) */
636
637 if (ByteList)
638 {
679 }
680
681 /*
682 * The buffer length (number of bytes) will be the larger of:
683 * 1) The specified buffer length and
684 * 2) The length of the initializer byte list
685 */
686 ObjDesc->Buffer.Length = BufferLength;

--- 18 unchanged lines hidden (view full) ---

705 AcpiUtDeleteObjectDesc (ObjDesc);
706 return_ACPI_STATUS (AE_NO_MEMORY);
707 }
708
709 /* Initialize buffer from the ByteList (if present) */
710
711 if (ByteList)
712 {
639 ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Data,
713 ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
640 ByteListLength);
641 }
642
643 ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
714 ByteListLength);
715 }
716
717 ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
644 Op->Node = (ACPI_NAMESPACE_NODE *) ObjDesc;
718 Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc;
645 return_ACPI_STATUS (AE_OK);
646}
647
648
649/*****************************************************************************
650 *
651 * FUNCTION: AcpiDsBuildInternalPackageObj
652 *
719 return_ACPI_STATUS (AE_OK);
720}
721
722
723/*****************************************************************************
724 *
725 * FUNCTION: AcpiDsBuildInternalPackageObj
726 *
653 * PARAMETERS: Op - Parser object to be translated
727 * PARAMETERS: WalkState - Current walk state
728 * Op - Parser object to be translated
729 * PackageLength - Number of elements in the package
654 * ObjDescPtr - Where the ACPI internal object is returned
655 *
656 * RETURN: Status
657 *
658 * DESCRIPTION: Translate a parser Op package object to the equivalent
659 * namespace object
660 *
661 ****************************************************************************/

--- 13 unchanged lines hidden (view full) ---

675 UINT32 i;
676
677
678 ACPI_FUNCTION_TRACE ("DsBuildInternalPackageObj");
679
680
681 /* Find the parent of a possibly nested package */
682
730 * ObjDescPtr - Where the ACPI internal object is returned
731 *
732 * RETURN: Status
733 *
734 * DESCRIPTION: Translate a parser Op package object to the equivalent
735 * namespace object
736 *
737 ****************************************************************************/

--- 13 unchanged lines hidden (view full) ---

751 UINT32 i;
752
753
754 ACPI_FUNCTION_TRACE ("DsBuildInternalPackageObj");
755
756
757 /* Find the parent of a possibly nested package */
758
683
684 Parent = Op->Parent;
685 while ((Parent->Opcode == AML_PACKAGE_OP) ||
686 (Parent->Opcode == AML_VAR_PACKAGE_OP))
759 Parent = Op->Common.Parent;
760 while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
761 (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
687 {
762 {
688 Parent = Parent->Parent;
763 Parent = Parent->Common.Parent;
689 }
690
691 ObjDesc = *ObjDescPtr;
692 if (ObjDesc)
693 {
694 /*
695 * We are evaluating a Named package object "Name (xxxx, Package)".
696 * Get the existing package object from the NS node
697 */
698 }
699 else
700 {
701 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
702 *ObjDescPtr = ObjDesc;
703 if (!ObjDesc)
704 {
705 return_ACPI_STATUS (AE_NO_MEMORY);
706 }
707
764 }
765
766 ObjDesc = *ObjDescPtr;
767 if (ObjDesc)
768 {
769 /*
770 * We are evaluating a Named package object "Name (xxxx, Package)".
771 * Get the existing package object from the NS node
772 */
773 }
774 else
775 {
776 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
777 *ObjDescPtr = ObjDesc;
778 if (!ObjDesc)
779 {
780 return_ACPI_STATUS (AE_NO_MEMORY);
781 }
782
708 ObjDesc->Package.Node = Parent->Node;
783 ObjDesc->Package.Node = Parent->Common.Node;
709 }
710
711 ObjDesc->Package.Count = PackageLength;
712
713 /* Count the number of items in the package list */
714
715 PackageListLength = 0;
784 }
785
786 ObjDesc->Package.Count = PackageLength;
787
788 /* Count the number of items in the package list */
789
790 PackageListLength = 0;
716 Arg = Op->Value.Arg;
717 Arg = Arg->Next;
791 Arg = Op->Common.Value.Arg;
792 Arg = Arg->Common.Next;
718 while (Arg)
719 {
720 PackageListLength++;
793 while (Arg)
794 {
795 PackageListLength++;
721 Arg = Arg->Next;
796 Arg = Arg->Common.Next;
722 }
723
724 /*
725 * The package length (number of elements) will be the greater
726 * of the specified length and the length of the initializer list
727 */
728 if (PackageListLength > PackageLength)
729 {
730 ObjDesc->Package.Count = PackageListLength;
731 }
732
733 /*
734 * Allocate the pointer array (array of pointers to the
735 * individual objects). Add an extra pointer slot so
736 * that the list is always null terminated.
737 */
738 ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE (
797 }
798
799 /*
800 * The package length (number of elements) will be the greater
801 * of the specified length and the length of the initializer list
802 */
803 if (PackageListLength > PackageLength)
804 {
805 ObjDesc->Package.Count = PackageListLength;
806 }
807
808 /*
809 * Allocate the pointer array (array of pointers to the
810 * individual objects). Add an extra pointer slot so
811 * that the list is always null terminated.
812 */
813 ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE (
739 (ObjDesc->Package.Count + 1) * sizeof (void *));
814 ((ACPI_SIZE) ObjDesc->Package.Count + 1) * sizeof (void *));
740
741 if (!ObjDesc->Package.Elements)
742 {
743 AcpiUtDeleteObjectDesc (ObjDesc);
744 return_ACPI_STATUS (AE_NO_MEMORY);
745 }
746
747 /*
748 * Now init the elements of the package
749 */
750 i = 0;
815
816 if (!ObjDesc->Package.Elements)
817 {
818 AcpiUtDeleteObjectDesc (ObjDesc);
819 return_ACPI_STATUS (AE_NO_MEMORY);
820 }
821
822 /*
823 * Now init the elements of the package
824 */
825 i = 0;
751 Arg = Op->Value.Arg;
752 Arg = Arg->Next;
826 Arg = Op->Common.Value.Arg;
827 Arg = Arg->Common.Next;
753 while (Arg)
754 {
828 while (Arg)
829 {
755 if (Arg->Opcode == AML_INT_RETURN_VALUE_OP)
830 if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
756 {
757 /* Object (package or buffer) is already built */
758
831 {
832 /* Object (package or buffer) is already built */
833
759 ObjDesc->Package.Elements[i] = (ACPI_OPERAND_OBJECT *) Arg->Node;
834 ObjDesc->Package.Elements[i] = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node);
760 }
761 else
762 {
763 Status = AcpiDsBuildInternalObject (WalkState, Arg,
764 &ObjDesc->Package.Elements[i]);
765 }
766
767 i++;
835 }
836 else
837 {
838 Status = AcpiDsBuildInternalObject (WalkState, Arg,
839 &ObjDesc->Package.Elements[i]);
840 }
841
842 i++;
768 Arg = Arg->Next;
843 Arg = Arg->Common.Next;
769 }
770
771 ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
844 }
845
846 ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
772 Op->Node = (ACPI_NAMESPACE_NODE *) ObjDesc;
847 Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc;
773 return_ACPI_STATUS (Status);
774}
775
776
777/*****************************************************************************
778 *
779 * FUNCTION: AcpiDsCreateNode
780 *
848 return_ACPI_STATUS (Status);
849}
850
851
852/*****************************************************************************
853 *
854 * FUNCTION: AcpiDsCreateNode
855 *
781 * PARAMETERS: Op - Parser object to be translated
782 * ObjDescPtr - Where the ACPI internal object is returned
856 * PARAMETERS: WalkState - Current walk state
857 * Node - NS Node to be initialized
858 * Op - Parser object to be translated
783 *
784 * RETURN: Status
785 *
859 *
860 * RETURN: Status
861 *
786 * DESCRIPTION:
862 * DESCRIPTION: Create the object to be associated with a namespace node
787 *
788 ****************************************************************************/
789
790ACPI_STATUS
791AcpiDsCreateNode (
792 ACPI_WALK_STATE *WalkState,
793 ACPI_NAMESPACE_NODE *Node,
794 ACPI_PARSE_OBJECT *Op)

--- 10 unchanged lines hidden (view full) ---

805 * parts of the table, we can arrive here twice. Only init
806 * the named object node the first time through
807 */
808 if (AcpiNsGetAttachedObject (Node))
809 {
810 return_ACPI_STATUS (AE_OK);
811 }
812
863 *
864 ****************************************************************************/
865
866ACPI_STATUS
867AcpiDsCreateNode (
868 ACPI_WALK_STATE *WalkState,
869 ACPI_NAMESPACE_NODE *Node,
870 ACPI_PARSE_OBJECT *Op)

--- 10 unchanged lines hidden (view full) ---

881 * parts of the table, we can arrive here twice. Only init
882 * the named object node the first time through
883 */
884 if (AcpiNsGetAttachedObject (Node))
885 {
886 return_ACPI_STATUS (AE_OK);
887 }
888
813 if (!Op->Value.Arg)
889 if (!Op->Common.Value.Arg)
814 {
815 /* No arguments, there is nothing to do */
816
817 return_ACPI_STATUS (AE_OK);
818 }
819
820 /* Build an internal object for the argument(s) */
821
890 {
891 /* No arguments, there is nothing to do */
892
893 return_ACPI_STATUS (AE_OK);
894 }
895
896 /* Build an internal object for the argument(s) */
897
822 Status = AcpiDsBuildInternalObject (WalkState, Op->Value.Arg, &ObjDesc);
898 Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, &ObjDesc);
823 if (ACPI_FAILURE (Status))
824 {
825 return_ACPI_STATUS (Status);
826 }
827
828 /* Re-type the object according to it's argument */
829
899 if (ACPI_FAILURE (Status))
900 {
901 return_ACPI_STATUS (Status);
902 }
903
904 /* Re-type the object according to it's argument */
905
830 Node->Type = ObjDesc->Common.Type;
906 Node->Type = ACPI_GET_OBJECT_TYPE (ObjDesc);
831
832 /* Attach obj to node */
833
834 Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
835
836 /* Remove local reference to the object */
837
838 AcpiUtRemoveReference (ObjDesc);
839 return_ACPI_STATUS (Status);
840}
841
842
907
908 /* Attach obj to node */
909
910 Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
911
912 /* Remove local reference to the object */
913
914 AcpiUtRemoveReference (ObjDesc);
915 return_ACPI_STATUS (Status);
916}
917
918