ReactOS 0.4.16-dev-321-g63bb46a
psobject.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
#include "acconvert.h"
#include "acnamesp.h"
Include dependency graph for psobject.c:

Go to the source code of this file.

Macros

#define _COMPONENT   ACPI_PARSER
 

Functions

static ACPI_STATUS AcpiPsGetAmlOpcode (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiPsBuildNamedOp (ACPI_WALK_STATE *WalkState, UINT8 *AmlOpStart, ACPI_PARSE_OBJECT *UnnamedOp, ACPI_PARSE_OBJECT **Op)
 
ACPI_STATUS AcpiPsCreateOp (ACPI_WALK_STATE *WalkState, UINT8 *AmlOpStart, ACPI_PARSE_OBJECT **NewOp)
 
ACPI_STATUS AcpiPsCompleteOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **Op, ACPI_STATUS Status)
 
ACPI_STATUS AcpiPsCompleteFinalOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS Status)
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_PARSER

Definition at line 51 of file psobject.c.

Function Documentation

◆ AcpiPsBuildNamedOp()

ACPI_STATUS AcpiPsBuildNamedOp ( ACPI_WALK_STATE WalkState,
UINT8 AmlOpStart,
ACPI_PARSE_OBJECT UnnamedOp,
ACPI_PARSE_OBJECT **  Op 
)

Definition at line 193 of file psobject.c.

198{
200 ACPI_PARSE_OBJECT *Arg = NULL;
201
202
203 ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState);
204
205
206 UnnamedOp->Common.Value.Arg = NULL;
207 UnnamedOp->Common.ArgListLength = 0;
208 UnnamedOp->Common.AmlOpcode = WalkState->Opcode;
209
210 /*
211 * Get and append arguments until we find the node that contains
212 * the name (the type ARGP_NAME).
213 */
214 while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
215 (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
216 {
217 ASL_CV_CAPTURE_COMMENTS (WalkState);
218 Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState),
219 GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
220 if (ACPI_FAILURE (Status))
221 {
223 }
224
225 AcpiPsAppendArg (UnnamedOp, Arg);
226 INCREMENT_ARG_LIST (WalkState->ArgTypes);
227 }
228
229 /* are there any inline comments associated with the NameSeg?? If so, save this. */
230
231 ASL_CV_CAPTURE_COMMENTS (WalkState);
232
233#ifdef ACPI_ASL_COMPILER
234 if (AcpiGbl_CurrentInlineComment != NULL)
235 {
236 UnnamedOp->Common.NameComment = AcpiGbl_CurrentInlineComment;
237 AcpiGbl_CurrentInlineComment = NULL;
238 }
239#endif
240
241 /*
242 * Make sure that we found a NAME and didn't run out of arguments
243 */
244 if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes))
245 {
247 }
248
249 /* We know that this arg is a name, move to next arg */
250
251 INCREMENT_ARG_LIST (WalkState->ArgTypes);
252
253 /*
254 * Find the object. This will either insert the object into
255 * the namespace or simply look it up
256 */
257 WalkState->Op = NULL;
258
259 Status = WalkState->DescendingCallback (WalkState, Op);
260 if (ACPI_FAILURE (Status))
261 {
263 {
264 ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog"));
265 }
267 }
268
269 if (!*Op)
270 {
272 }
273
274 Status = AcpiPsNextParseState (WalkState, *Op, Status);
275 if (ACPI_FAILURE (Status))
276 {
277 if (Status == AE_CTRL_PENDING)
278 {
280 }
282 }
283
284 AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg);
285
286#ifdef ACPI_ASL_COMPILER
287
288 /* save any comments that might be associated with UnnamedOp. */
289
290 (*Op)->Common.InlineComment = UnnamedOp->Common.InlineComment;
291 (*Op)->Common.EndNodeComment = UnnamedOp->Common.EndNodeComment;
292 (*Op)->Common.CloseBraceComment = UnnamedOp->Common.CloseBraceComment;
293 (*Op)->Common.NameComment = UnnamedOp->Common.NameComment;
294 (*Op)->Common.CommentList = UnnamedOp->Common.CommentList;
295 (*Op)->Common.EndBlkComment = UnnamedOp->Common.EndBlkComment;
296 (*Op)->Common.CvFilename = UnnamedOp->Common.CvFilename;
297 (*Op)->Common.CvParentFilename = UnnamedOp->Common.CvParentFilename;
298 (*Op)->Named.Aml = UnnamedOp->Common.Aml;
299
300 UnnamedOp->Common.InlineComment = NULL;
301 UnnamedOp->Common.EndNodeComment = NULL;
302 UnnamedOp->Common.CloseBraceComment = NULL;
303 UnnamedOp->Common.NameComment = NULL;
304 UnnamedOp->Common.CommentList = NULL;
305 UnnamedOp->Common.EndBlkComment = NULL;
306#endif
307
308 if ((*Op)->Common.AmlOpcode == AML_REGION_OP ||
309 (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP)
310 {
311 /*
312 * Defer final parsing of an OperationRegion body, because we don't
313 * have enough info in the first pass to parse it correctly (i.e.,
314 * there may be method calls within the TermArg elements of the body.)
315 *
316 * However, we must continue parsing because the opregion is not a
317 * standalone package -- we don't know where the end is at this point.
318 *
319 * (Length is unknown until parse of the body complete)
320 */
321 (*Op)->Named.Data = AmlOpStart;
322 (*Op)->Named.Length = 0;
323 }
324
326}
#define AE_AML_NO_OPERAND
Definition: acexcep.h:181
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_CTRL_PENDING
Definition: acexcep.h:225
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
#define AE_CTRL_PARSE_PENDING
Definition: acexcep.h:235
#define AE_CTRL_PARSE_CONTINUE
Definition: acexcep.h:234
#define AE_OK
Definition: acexcep.h:97
#define ASL_CV_CAPTURE_COMMENTS(a)
Definition: acmacros.h:526
#define GET_CURRENT_ARG_TYPE(List)
Definition: acmacros.h:450
#define INCREMENT_ARG_LIST(List)
Definition: acmacros.h:451
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define AE_INFO
Definition: acoutput.h:230
ACPI_STATUS AcpiPsGetNextArg(ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT **ReturnArg)
Definition: psargs.c:785
ACPI_STATUS AcpiPsNextParseState(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS CallbackStatus)
Definition: psparse.c:337
void AcpiPsAppendArg(ACPI_PARSE_OBJECT *op, ACPI_PARSE_OBJECT *arg)
Definition: pstree.c:138
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AML_REGION_OP
Definition: amlcode.h:180
#define ARGP_NAME
Definition: amlcode.h:231
#define AML_DATA_REGION_OP
Definition: amlcode.h:188
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
UINT32 ArgTypes
Definition: acstruct.h:92
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118
ACPI_PARSE_DOWNWARDS DescendingCallback
Definition: acstruct.h:128
UINT16 Opcode
Definition: acstruct.h:78
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078

Referenced by AcpiPsCreateOp().

◆ AcpiPsCompleteFinalOp()

ACPI_STATUS AcpiPsCompleteFinalOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
ACPI_STATUS  Status 
)

Definition at line 705 of file psobject.c.

709{
710 ACPI_STATUS Status2;
711
712
713 ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState);
714
715
716 /*
717 * Complete the last Op (if not completed), and clear the scope stack.
718 * It is easily possible to end an AML "package" with an unbounded number
719 * of open scopes (such as when several ASL blocks are closed with
720 * sequential closing braces). We want to terminate each one cleanly.
721 */
722 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op));
723 do
724 {
725 if (Op)
726 {
727 if (WalkState->AscendingCallback != NULL)
728 {
729 WalkState->Op = Op;
730 WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
731 WalkState->Opcode = Op->Common.AmlOpcode;
732
733 Status = WalkState->AscendingCallback (WalkState);
734 Status = AcpiPsNextParseState (WalkState, Op, Status);
735 if (Status == AE_CTRL_PENDING)
736 {
737 Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK);
738 if (ACPI_FAILURE (Status))
739 {
741 }
742 }
743
745 {
746 Status = AE_OK;
747
748 /* Clean up */
749 do
750 {
751 if (Op)
752 {
753 Status2 = AcpiPsCompleteThisOp (WalkState, Op);
754 if (ACPI_FAILURE (Status2))
755 {
756 return_ACPI_STATUS (Status2);
757 }
758 }
759
760 AcpiPsPopScope (&(WalkState->ParserState), &Op,
761 &WalkState->ArgTypes, &WalkState->ArgCount);
762
763 } while (Op);
764
766 }
767
768 else if (ACPI_FAILURE (Status))
769 {
770 /* First error is most important */
771
772 (void) AcpiPsCompleteThisOp (WalkState, Op);
774 }
775 }
776
777 Status2 = AcpiPsCompleteThisOp (WalkState, Op);
778 if (ACPI_FAILURE (Status2))
779 {
780 return_ACPI_STATUS (Status2);
781 }
782 }
783
784 AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes,
785 &WalkState->ArgCount);
786
787 } while (Op);
788
790}
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DB_PARSE
Definition: acoutput.h:162
ACPI_STATUS AcpiPsCompleteThisOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: psparse.c:144
void AcpiPsPopScope(ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT **Op, UINT32 *ArgList, UINT32 *ArgCount)
Definition: psscope.c:219
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
ACPI_STATUS AcpiPsCompleteOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **Op, ACPI_STATUS Status)
Definition: psobject.c:495
UINT32 ArgCount
Definition: acstruct.h:99
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119
ACPI_PARSE_UPWARDS AscendingCallback
Definition: acstruct.h:129

Referenced by AcpiPsParseLoop().

◆ AcpiPsCompleteOp()

ACPI_STATUS AcpiPsCompleteOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT **  Op,
ACPI_STATUS  Status 
)

Definition at line 495 of file psobject.c.

499{
500 ACPI_STATUS Status2;
501
502
503 ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState);
504
505
506 /*
507 * Finished one argument of the containing scope
508 */
509 WalkState->ParserState.Scope->ParseScope.ArgCount--;
510
511 /* Close this Op (will result in parse subtree deletion) */
512
513 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
514 if (ACPI_FAILURE (Status2))
515 {
516 return_ACPI_STATUS (Status2);
517 }
518
519 *Op = NULL;
520
521 switch (Status)
522 {
523 case AE_OK:
524
525 break;
526
527 case AE_CTRL_TRANSFER:
528
529 /* We are about to transfer to a called method */
530
531 WalkState->PrevOp = NULL;
532 WalkState->PrevArgTypes = WalkState->ArgTypes;
534
535 case AE_CTRL_END:
536
537 AcpiPsPopScope (&(WalkState->ParserState), Op,
538 &WalkState->ArgTypes, &WalkState->ArgCount);
539
540 if (*Op)
541 {
542 WalkState->Op = *Op;
543 WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
544 WalkState->Opcode = (*Op)->Common.AmlOpcode;
545
546 Status = WalkState->AscendingCallback (WalkState);
547 (void) AcpiPsNextParseState (WalkState, *Op, Status);
548
549 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
550 if (ACPI_FAILURE (Status2))
551 {
552 return_ACPI_STATUS (Status2);
553 }
554 }
555
556 break;
557
558 case AE_CTRL_BREAK:
559 case AE_CTRL_CONTINUE:
560
561 /* Pop off scopes until we find the While */
562
563 while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP))
564 {
565 AcpiPsPopScope (&(WalkState->ParserState), Op,
566 &WalkState->ArgTypes, &WalkState->ArgCount);
567 }
568
569 /* Close this iteration of the While loop */
570
571 WalkState->Op = *Op;
572 WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
573 WalkState->Opcode = (*Op)->Common.AmlOpcode;
574
575 Status = WalkState->AscendingCallback (WalkState);
576 (void) AcpiPsNextParseState (WalkState, *Op, Status);
577
578 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
579 if (ACPI_FAILURE (Status2))
580 {
581 return_ACPI_STATUS (Status2);
582 }
583
584 break;
585
587
588 /* Clean up */
589 do
590 {
591 if (*Op)
592 {
593 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
594 if (ACPI_FAILURE (Status2))
595 {
596 return_ACPI_STATUS (Status2);
597 }
598
600 AcpiUtPopGenericState (&WalkState->ControlState));
601 }
602
603 AcpiPsPopScope (&(WalkState->ParserState), Op,
604 &WalkState->ArgTypes, &WalkState->ArgCount);
605
606 } while (*Op);
607
609
610 default: /* All other non-AE_OK status */
611
612 do
613 {
614 if (*Op)
615 {
616 /*
617 * These Opcodes need to be removed from the namespace because they
618 * get created even if these opcodes cannot be created due to
619 * errors.
620 */
621 if (((*Op)->Common.AmlOpcode == AML_REGION_OP) ||
622 ((*Op)->Common.AmlOpcode == AML_DATA_REGION_OP))
623 {
624 AcpiNsDeleteChildren ((*Op)->Common.Node);
625 AcpiNsRemoveNode ((*Op)->Common.Node);
626 (*Op)->Common.Node = NULL;
628 }
629
630 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
631 if (ACPI_FAILURE (Status2))
632 {
633 return_ACPI_STATUS (Status2);
634 }
635 }
636
637 AcpiPsPopScope (&(WalkState->ParserState), Op,
638 &WalkState->ArgTypes, &WalkState->ArgCount);
639
640 } while (*Op);
641
642
643#if 0
644 /*
645 * TBD: Cleanup parse ops on error
646 */
647 if (*Op == NULL)
648 {
649 AcpiPsPopScope (ParserState, Op,
650 &WalkState->ArgTypes, &WalkState->ArgCount);
651 }
652#endif
653 WalkState->PrevOp = NULL;
654 WalkState->PrevArgTypes = WalkState->ArgTypes;
655
656 if (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)
657 {
658 /*
659 * There was something that went wrong while executing code at the
660 * module-level. We need to skip parsing whatever caused the
661 * error and keep going. One runtime error during the table load
662 * should not cause the entire table to not be loaded. This is
663 * because there could be correct AML beyond the parts that caused
664 * the runtime error.
665 */
666 ACPI_INFO (("Ignoring error and continuing table load"));
668 }
670 }
671
672 /* This scope complete? */
673
674 if (AcpiPsHasCompletedScope (&(WalkState->ParserState)))
675 {
676 AcpiPsPopScope (&(WalkState->ParserState), Op,
677 &WalkState->ArgTypes, &WalkState->ArgCount);
678 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op));
679 }
680 else
681 {
682 *Op = NULL;
683 }
684
686}
#define AE_CTRL_CONTINUE
Definition: acexcep.h:233
#define AE_CTRL_TRANSFER
Definition: acexcep.h:231
#define AE_CTRL_END
Definition: acexcep.h:230
#define AE_CTRL_BREAK
Definition: acexcep.h:232
void AcpiNsDeleteChildren(ACPI_NAMESPACE_NODE *Parent)
Definition: nsalloc.c:341
void AcpiNsRemoveNode(ACPI_NAMESPACE_NODE *Node)
Definition: nsalloc.c:188
#define ACPI_INFO(plist)
Definition: acoutput.h:237
void AcpiPsDeleteParseTree(ACPI_PARSE_OBJECT *root)
Definition: pswalk.c:67
#define ACPI_PARSE_MODULE_LEVEL
Definition: acparser.h:67
BOOLEAN AcpiPsHasCompletedScope(ACPI_PARSE_STATE *ParserState)
Definition: psscope.c:88
ACPI_GENERIC_STATE * AcpiUtPopGenericState(ACPI_GENERIC_STATE **ListHead)
Definition: utstate.c:93
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
#define AML_WHILE_OP
Definition: amlcode.h:136
union acpi_generic_state * Scope
Definition: aclocal.h:1108
ACPI_STATE_COMMON UINT32 ArgCount
Definition: aclocal.h:748
UINT32 PrevArgTypes
Definition: acstruct.h:98
UINT32 ParseFlags
Definition: acstruct.h:95
ACPI_PARSE_OBJECT * PrevOp
Definition: acstruct.h:125
ACPI_GENERIC_STATE * ControlState
Definition: acstruct.h:110
ACPI_PSCOPE_STATE ParseScope
Definition: aclocal.h:826

Referenced by AcpiPsCompleteFinalOp(), and AcpiPsParseLoop().

◆ AcpiPsCreateOp()

ACPI_STATUS AcpiPsCreateOp ( ACPI_WALK_STATE WalkState,
UINT8 AmlOpStart,
ACPI_PARSE_OBJECT **  NewOp 
)

Definition at line 344 of file psobject.c.

348{
351 ACPI_PARSE_OBJECT *NamedOp = NULL;
352 ACPI_PARSE_OBJECT *ParentScope;
353 UINT8 ArgumentCount;
354 const ACPI_OPCODE_INFO *OpInfo;
355
356
357 ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState);
358
359
360 Status = AcpiPsGetAmlOpcode (WalkState);
362 {
364 }
365 if (ACPI_FAILURE (Status))
366 {
368 }
369
370 /* Create Op structure and append to parent's argument list */
371
372 WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
373 Op = AcpiPsAllocOp (WalkState->Opcode, AmlOpStart);
374 if (!Op)
375 {
377 }
378
379 if (WalkState->OpInfo->Flags & AML_NAMED)
380 {
381 Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp);
382 AcpiPsFreeOp (Op);
383
384#ifdef ACPI_ASL_COMPILER
385 if (AcpiGbl_DisasmFlag && WalkState->Opcode == AML_EXTERNAL_OP &&
387 {
388 /*
389 * If parsing of AML_EXTERNAL_OP's name path fails, then skip
390 * past this opcode and keep parsing. This is a much better
391 * alternative than to abort the entire disassembler. At this
392 * point, the ParserState is at the end of the namepath of the
393 * external declaration opcode. Setting WalkState->Aml to
394 * WalkState->ParserState.Aml + 2 moves increments the
395 * WalkState->Aml past the object type and the paramcount of the
396 * external opcode.
397 */
398 WalkState->Aml = WalkState->ParserState.Aml + 2;
399 WalkState->ParserState.Aml = WalkState->Aml;
401 }
402#endif
403 if (ACPI_FAILURE (Status))
404 {
406 }
407
408 *NewOp = NamedOp;
410 }
411
412 /* Not a named opcode, just allocate Op and append to parent */
413
414 if (WalkState->OpInfo->Flags & AML_CREATE)
415 {
416 /*
417 * Backup to beginning of CreateXXXfield declaration
418 * BodyLength is unknown until we parse the body
419 */
420 Op->Named.Data = AmlOpStart;
421 Op->Named.Length = 0;
422 }
423
424 if (WalkState->Opcode == AML_BANK_FIELD_OP)
425 {
426 /*
427 * Backup to beginning of BankField declaration
428 * BodyLength is unknown until we parse the body
429 */
430 Op->Named.Data = AmlOpStart;
431 Op->Named.Length = 0;
432 }
433
434 ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState));
435 AcpiPsAppendArg (ParentScope, Op);
436
437 if (ParentScope)
438 {
439 OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode);
440 if (OpInfo->Flags & AML_HAS_TARGET)
441 {
442 ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type);
443 if (ParentScope->Common.ArgListLength > ArgumentCount)
444 {
445 Op->Common.Flags |= ACPI_PARSEOP_TARGET;
446 }
447 }
448
449 /*
450 * Special case for both Increment() and Decrement(), where
451 * the lone argument is both a source and a target.
452 */
453 else if ((ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) ||
454 (ParentScope->Common.AmlOpcode == AML_DECREMENT_OP))
455 {
456 Op->Common.Flags |= ACPI_PARSEOP_TARGET;
457 }
458 }
459
460 if (WalkState->DescendingCallback != NULL)
461 {
462 /*
463 * Find the object. This will either insert the object into
464 * the namespace or simply look it up
465 */
466 WalkState->Op = *NewOp = Op;
467
468 Status = WalkState->DescendingCallback (WalkState, &Op);
469 Status = AcpiPsNextParseState (WalkState, Op, Status);
470 if (Status == AE_CTRL_PENDING)
471 {
473 }
474 }
475
477}
unsigned char UINT8
#define AE_NOT_FOUND
Definition: acexcep.h:113
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ACPI_PARSEOP_TARGET
Definition: aclocal.h:1122
UINT8 AcpiPsGetArgumentCount(UINT32 OpType)
Definition: psopinfo.c:203
void AcpiPsFreeOp(ACPI_PARSE_OBJECT *Op)
Definition: psutils.c:212
ACPI_PARSE_OBJECT * AcpiPsGetParentScope(ACPI_PARSE_STATE *state)
Definition: psscope.c:65
ACPI_PARSE_OBJECT * AcpiPsAllocOp(UINT16 Opcode, UINT8 *Aml)
Definition: psutils.c:130
#define AML_DECREMENT_OP
Definition: amlcode.h:94
#define AML_BANK_FIELD_OP
Definition: amlcode.h:187
#define AML_EXTERNAL_OP
Definition: amlcode.h:65
#define AML_INCREMENT_OP
Definition: amlcode.h:93
#define AML_HAS_TARGET
Definition: amlcode.h:328
#define AML_CREATE
Definition: amlcode.h:320
#define AML_NAMED
Definition: amlcode.h:323
ACPI_STATUS AcpiPsBuildNamedOp(ACPI_WALK_STATE *WalkState, UINT8 *AmlOpStart, ACPI_PARSE_OBJECT *UnnamedOp, ACPI_PARSE_OBJECT **Op)
Definition: psobject.c:193
static ACPI_STATUS AcpiPsGetAmlOpcode(ACPI_WALK_STATE *WalkState)
Definition: psobject.c:75
UINT16 Flags
Definition: aclocal.h:873
UINT8 * Aml
Definition: acstruct.h:91
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079

Referenced by AcpiPsParseLoop().

◆ AcpiPsGetAmlOpcode()

static ACPI_STATUS AcpiPsGetAmlOpcode ( ACPI_WALK_STATE WalkState)
static

Definition at line 75 of file psobject.c.

77{
78 ACPI_ERROR_ONLY (UINT32 AmlOffset);
79
80
81 ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState);
82
83
84 WalkState->Aml = WalkState->ParserState.Aml;
85 WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState));
86
87 /*
88 * First cut to determine what we have found:
89 * 1) A valid AML opcode
90 * 2) A name string
91 * 3) An unknown/invalid opcode
92 */
93 WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
94
95 switch (WalkState->OpInfo->Class)
96 {
97 case AML_CLASS_ASCII:
99 /*
100 * Starts with a valid prefix or ASCII char, this is a name
101 * string. Convert the bare name string to a namepath.
102 */
103 WalkState->Opcode = AML_INT_NAMEPATH_OP;
104 WalkState->ArgTypes = ARGP_NAMESTRING;
105 break;
106
108
109 /* The opcode is unrecognized. Complain and skip unknown opcodes */
110
111 if (WalkState->PassNumber == 2)
112 {
113 ACPI_ERROR_ONLY(AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml,
114 WalkState->ParserState.AmlStart));
115
117 "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
118 WalkState->Opcode,
119 (UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER))));
120
121 ACPI_DUMP_BUFFER ((WalkState->ParserState.Aml - 16), 48);
122
123#ifdef ACPI_ASL_COMPILER
124 /*
125 * This is executed for the disassembler only. Output goes
126 * to the disassembled ASL output file.
127 */
129 "/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
130 WalkState->Opcode,
131 (UINT32) (AmlOffset + sizeof (ACPI_TABLE_HEADER)));
132
134 "Aborting disassembly, AML byte code is corrupt"));
135
136 /* Dump the context surrounding the invalid opcode */
137
138 AcpiUtDumpBuffer (((UINT8 *) WalkState->ParserState.Aml - 16),
139 48, DB_BYTE_DISPLAY,
140 (AmlOffset + sizeof (ACPI_TABLE_HEADER) - 16));
141 AcpiOsPrintf (" */\n");
142
143 /*
144 * Just abort the disassembly, cannot continue because the
145 * parser is essentially lost. The disassembler can then
146 * randomly fail because an ill-constructed parse tree
147 * can result.
148 */
150#endif
151 }
152
153 /* Increment past one-byte or two-byte opcode */
154
155 WalkState->ParserState.Aml++;
156 if (WalkState->Opcode > 0xFF) /* Can only happen if first byte is 0x5B */
157 {
158 WalkState->ParserState.Aml++;
159 }
160
162
163 default:
164
165 /* Found opcode info, this is a normal opcode */
166
167 WalkState->ParserState.Aml +=
168 AcpiPsGetOpcodeSize (WalkState->Opcode);
169 WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
170 break;
171 }
172
174}
unsigned int UINT32
#define AE_AML_BAD_OPCODE
Definition: acexcep.h:180
#define ACPI_ERROR_ONLY(s)
Definition: acmacros.h:467
#define ACPI_DUMP_BUFFER(a, b)
Definition: acoutput.h:489
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
UINT16 AcpiPsPeekOpcode(ACPI_PARSE_STATE *state)
Definition: psparse.c:108
UINT32 AcpiPsGetOpcodeSize(UINT32 Opcode)
Definition: psparse.c:78
void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf(const char *Format,...)
Definition: osl.c:851
#define ACPI_PTR_DIFF(a, b)
Definition: actypes.h:548
void AcpiUtDumpBuffer(UINT8 *Buffer, UINT32 Count, UINT32 Display, UINT32 Offset)
Definition: utbuffer.c:71
#define DB_BYTE_DISPLAY
Definition: acutils.h:186
#define AML_CLASS_ASCII
Definition: amlcode.h:405
#define AML_CLASS_PREFIX
Definition: amlcode.h:406
#define ARGP_NAMESTRING
Definition: amlcode.h:232
#define AML_INT_NAMEPATH_OP
Definition: amlcode.h:205
#define AML_CLASS_UNKNOWN
Definition: amlcode.h:410
UINT32 ParseArgs
Definition: aclocal.h:871
UINT8 * AmlStart
Definition: aclocal.h:1101
UINT8 PassNumber
Definition: acstruct.h:87
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by AcpiPsCreateOp().