ReactOS  0.4.14-dev-323-g6fe6a88
acparser.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OP_HAS_RETURN_VALUE   1
 
#define ACPI_VAR_ARGS   ACPI_UINT32_MAX
 
#define ACPI_PARSE_DELETE_TREE   0x0001
 
#define ACPI_PARSE_NO_TREE_DELETE   0x0000
 
#define ACPI_PARSE_TREE_MASK   0x0001
 
#define ACPI_PARSE_LOAD_PASS1   0x0010
 
#define ACPI_PARSE_LOAD_PASS2   0x0020
 
#define ACPI_PARSE_EXECUTE   0x0030
 
#define ACPI_PARSE_MODE_MASK   0x0030
 
#define ACPI_PARSE_DEFERRED_OP   0x0100
 
#define ACPI_PARSE_DISASSEMBLE   0x0200
 
#define ACPI_PARSE_MODULE_LEVEL   0x0400
 
#define ACPI_NOT_METHOD_CALL   FALSE
 
#define ACPI_POSSIBLE_METHOD_CALL   TRUE
 

Functions

ACPI_STATUS AcpiPsExecuteMethod (ACPI_EVALUATE_INFO *Info)
 
ACPI_STATUS AcpiPsExecuteTable (ACPI_EVALUATE_INFO *Info)
 
UINT8AcpiPsGetNextPackageEnd (ACPI_PARSE_STATE *ParserState)
 
charAcpiPsGetNextNamestring (ACPI_PARSE_STATE *ParserState)
 
void AcpiPsGetNextSimpleArg (ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT *Arg)
 
ACPI_STATUS AcpiPsGetNextNamepath (ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Arg, BOOLEAN PossibleMethodCall)
 
ACPI_STATUS AcpiPsGetNextArg (ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT **ReturnArg)
 
ACPI_PARSE_OBJECTAcpiPsFindName (ACPI_PARSE_OBJECT *Scope, UINT32 Name, UINT32 Opcode)
 
ACPI_PARSE_OBJECTAcpiPsGetParent (ACPI_PARSE_OBJECT *Op)
 
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)
 
const ACPI_OPCODE_INFOAcpiPsGetOpcodeInfo (UINT16 Opcode)
 
const charAcpiPsGetOpcodeName (UINT16 Opcode)
 
UINT8 AcpiPsGetArgumentCount (UINT32 OpType)
 
ACPI_STATUS AcpiPsParseAml (ACPI_WALK_STATE *WalkState)
 
UINT32 AcpiPsGetOpcodeSize (UINT32 Opcode)
 
UINT16 AcpiPsPeekOpcode (ACPI_PARSE_STATE *state)
 
ACPI_STATUS AcpiPsCompleteThisOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiPsNextParseState (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS CallbackStatus)
 
ACPI_STATUS AcpiPsParseLoop (ACPI_WALK_STATE *WalkState)
 
ACPI_STATUS AcpiPsInitScope (ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Root)
 
ACPI_PARSE_OBJECTAcpiPsGetParentScope (ACPI_PARSE_STATE *state)
 
BOOLEAN AcpiPsHasCompletedScope (ACPI_PARSE_STATE *ParserState)
 
void AcpiPsPopScope (ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT **Op, UINT32 *ArgList, UINT32 *ArgCount)
 
ACPI_STATUS AcpiPsPushScope (ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Op, UINT32 RemainingArgs, UINT32 ArgCount)
 
void AcpiPsCleanupScope (ACPI_PARSE_STATE *state)
 
void AcpiPsAppendArg (ACPI_PARSE_OBJECT *op, ACPI_PARSE_OBJECT *arg)
 
ACPI_PARSE_OBJECTAcpiPsFind (ACPI_PARSE_OBJECT *Scope, char *Path, UINT16 Opcode, UINT32 Create)
 
ACPI_PARSE_OBJECTAcpiPsGetArg (ACPI_PARSE_OBJECT *op, UINT32 argn)
 
ACPI_PARSE_OBJECTAcpiPsGetDepthNext (ACPI_PARSE_OBJECT *Origin, ACPI_PARSE_OBJECT *Op)
 
ACPI_STATUS AcpiPsWalkParsedAml (ACPI_PARSE_OBJECT *StartOp, ACPI_PARSE_OBJECT *EndOp, ACPI_OPERAND_OBJECT *MthDesc, ACPI_NAMESPACE_NODE *StartNode, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **CallerReturnDesc, ACPI_OWNER_ID OwnerId, ACPI_PARSE_DOWNWARDS DescendingCallback, ACPI_PARSE_UPWARDS AscendingCallback)
 
ACPI_STATUS AcpiPsGetNextWalkOp (ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_PARSE_UPWARDS AscendingCallback)
 
ACPI_STATUS AcpiPsDeleteCompletedOp (ACPI_WALK_STATE *WalkState)
 
void AcpiPsDeleteParseTree (ACPI_PARSE_OBJECT *root)
 
ACPI_PARSE_OBJECTAcpiPsCreateScopeOp (UINT8 *Aml)
 
void AcpiPsInitOp (ACPI_PARSE_OBJECT *op, UINT16 opcode)
 
ACPI_PARSE_OBJECTAcpiPsAllocOp (UINT16 Opcode, UINT8 *Aml)
 
void AcpiPsFreeOp (ACPI_PARSE_OBJECT *Op)
 
BOOLEAN AcpiPsIsLeadingChar (UINT32 c)
 
UINT32 AcpiPsGetName (ACPI_PARSE_OBJECT *op)
 
void AcpiPsSetName (ACPI_PARSE_OBJECT *op, UINT32 name)
 
UINT32 AcpiPsSprintPath (char *BufferStart, UINT32 BufferSize, ACPI_PARSE_OBJECT *Op)
 
UINT32 AcpiPsSprintOp (char *BufferStart, UINT32 BufferSize, ACPI_PARSE_OBJECT *Op)
 
void AcpiPsShow (ACPI_PARSE_OBJECT *op)
 

Variables

const UINT8 AcpiGbl_ShortOpIndex []
 
const UINT8 AcpiGbl_LongOpIndex []
 

Macro Definition Documentation

◆ ACPI_NOT_METHOD_CALL

#define ACPI_NOT_METHOD_CALL   FALSE

Definition at line 117 of file acparser.h.

◆ ACPI_PARSE_DEFERRED_OP

#define ACPI_PARSE_DEFERRED_OP   0x0100

Definition at line 64 of file acparser.h.

◆ ACPI_PARSE_DELETE_TREE

#define ACPI_PARSE_DELETE_TREE   0x0001

Definition at line 55 of file acparser.h.

◆ ACPI_PARSE_DISASSEMBLE

#define ACPI_PARSE_DISASSEMBLE   0x0200

Definition at line 65 of file acparser.h.

◆ ACPI_PARSE_EXECUTE

#define ACPI_PARSE_EXECUTE   0x0030

Definition at line 61 of file acparser.h.

◆ ACPI_PARSE_LOAD_PASS1

#define ACPI_PARSE_LOAD_PASS1   0x0010

Definition at line 59 of file acparser.h.

◆ ACPI_PARSE_LOAD_PASS2

#define ACPI_PARSE_LOAD_PASS2   0x0020

Definition at line 60 of file acparser.h.

◆ ACPI_PARSE_MODE_MASK

#define ACPI_PARSE_MODE_MASK   0x0030

Definition at line 62 of file acparser.h.

◆ ACPI_PARSE_MODULE_LEVEL

#define ACPI_PARSE_MODULE_LEVEL   0x0400

Definition at line 67 of file acparser.h.

◆ ACPI_PARSE_NO_TREE_DELETE

#define ACPI_PARSE_NO_TREE_DELETE   0x0000

Definition at line 56 of file acparser.h.

◆ ACPI_PARSE_TREE_MASK

#define ACPI_PARSE_TREE_MASK   0x0001

Definition at line 57 of file acparser.h.

◆ ACPI_POSSIBLE_METHOD_CALL

#define ACPI_POSSIBLE_METHOD_CALL   TRUE

Definition at line 118 of file acparser.h.

◆ ACPI_VAR_ARGS

#define ACPI_VAR_ARGS   ACPI_UINT32_MAX

Definition at line 52 of file acparser.h.

◆ OP_HAS_RETURN_VALUE

#define OP_HAS_RETURN_VALUE   1

Definition at line 48 of file acparser.h.

Function Documentation

◆ AcpiPsAllocOp()

ACPI_PARSE_OBJECT* AcpiPsAllocOp ( UINT16  Opcode,
UINT8 Aml 
)

Definition at line 130 of file psutils.c.

133 {
134  ACPI_PARSE_OBJECT *Op;
135  const ACPI_OPCODE_INFO *OpInfo;
137 
138 
140 
141 
142  OpInfo = AcpiPsGetOpcodeInfo (Opcode);
143 
144  /* Determine type of ParseOp required */
145 
146  if (OpInfo->Flags & AML_DEFER)
147  {
149  }
150  else if (OpInfo->Flags & AML_NAMED)
151  {
153  }
154  else if (Opcode == AML_INT_BYTELIST_OP)
155  {
157  }
158 
159  /* Allocate the minimum required size object */
160 
162  {
163  /* The generic op (default) is by far the most common (16 to 1) */
164 
165  Op = AcpiOsAcquireObject (AcpiGbl_PsNodeCache);
166  }
167  else
168  {
169  /* Extended parseop */
170 
171  Op = AcpiOsAcquireObject (AcpiGbl_PsNodeExtCache);
172  }
173 
174  /* Initialize the Op */
175 
176  if (Op)
177  {
178  AcpiPsInitOp (Op, Opcode);
179  Op->Common.Aml = Aml;
180  Op->Common.Flags = Flags;
182 
183  if (Opcode == AML_SCOPE_OP)
184  {
185  AcpiGbl_CurrentScope = Op;
186  }
187 
188  if (AcpiGbl_CaptureComments)
189  {
191  }
192  }
193 
194  return (Op);
195 }
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
#define AML_NAMED
Definition: amlcode.h:323
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:330
#define ACPI_PARSEOP_BYTELIST
Definition: aclocal.h:1120
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ASL_CV_CLEAR_OP_COMMENTS(a)
Definition: acmacros.h:531
#define ASL_CV_TRANSFER_COMMENTS(a)
Definition: acmacros.h:527
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define AML_SCOPE_OP
Definition: amlcode.h:60
#define ACPI_PARSEOP_GENERIC
Definition: aclocal.h:1117
#define ACPI_PARSEOP_DEFERRED
Definition: aclocal.h:1119
#define AML_DEFER
Definition: amlcode.h:322
void * AcpiOsAcquireObject(ACPI_CACHE_T *Cache)
void AcpiPsInitOp(ACPI_PARSE_OBJECT *Op, UINT16 Opcode)
Definition: psutils.c:98
#define AML_INT_BYTELIST_OP
Definition: amlcode.h:209
unsigned char UINT8
UINT16 Flags
Definition: aclocal.h:873
#define ACPI_PARSEOP_NAMED_OBJECT
Definition: aclocal.h:1118
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN UINT8 * Aml
Definition: acpixf.h:1287

Referenced by AcpiDsAutoSerializeMethod(), AcpiDsExecuteArguments(), AcpiDsLoad1BeginOp(), AcpiDsLoad2BeginOp(), AcpiPsCompleteThisOp(), AcpiPsCreateOp(), AcpiPsCreateScopeOp(), AcpiPsGetNextArg(), AcpiPsGetNextField(), and AcpiPsGetNextNamepath().

◆ AcpiPsAppendArg()

void AcpiPsAppendArg ( ACPI_PARSE_OBJECT op,
ACPI_PARSE_OBJECT arg 
)

Definition at line 138 of file pstree.c.

141 {
142  ACPI_PARSE_OBJECT *PrevArg;
143  const ACPI_OPCODE_INFO *OpInfo;
144 
145 
146  ACPI_FUNCTION_TRACE (PsAppendArg);
147 
148 
149  if (!Op)
150  {
151  return_VOID;
152  }
153 
154  /* Get the info structure for this opcode */
155 
156  OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
157  if (OpInfo->Class == AML_CLASS_UNKNOWN)
158  {
159  /* Invalid opcode */
160 
161  ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
162  Op->Common.AmlOpcode));
163  return_VOID;
164  }
165 
166  /* Check if this opcode requires argument sub-objects */
167 
168  if (!(OpInfo->Flags & AML_HAS_ARGS))
169  {
170  /* Has no linked argument objects */
171 
172  return_VOID;
173  }
174 
175  /* Append the argument to the linked argument list */
176 
177  if (Op->Common.Value.Arg)
178  {
179  /* Append to existing argument list */
180 
181  PrevArg = Op->Common.Value.Arg;
182  while (PrevArg->Common.Next)
183  {
184  PrevArg = PrevArg->Common.Next;
185  }
186  PrevArg->Common.Next = Arg;
187  }
188  else
189  {
190  /* No argument list, this will be the first argument */
191 
192  Op->Common.Value.Arg = Arg;
193  }
194 
195  /* Set the parent in this arg and any args linked after it */
196 
197  while (Arg)
198  {
199  Arg->Common.Parent = Op;
200  Arg = Arg->Common.Next;
201 
202  Op->Common.ArgListLength++;
203  }
204 
205  return_VOID;
206 }
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
#define AML_CLASS_UNKNOWN
Definition: amlcode.h:410
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
#define AE_INFO
Definition: acoutput.h:230
#define return_VOID
Definition: acoutput.h:495
#define AML_HAS_ARGS
Definition: amlcode.h:329
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
UINT16 Flags
Definition: aclocal.h:873

Referenced by AcpiDsLoad1BeginOp(), AcpiPsBuildNamedOp(), AcpiPsCreateOp(), AcpiPsGetArguments(), AcpiPsGetNextField(), and AcpiPsGetNextNamepath().

◆ 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  {
262  if (Status != AE_CTRL_TERMINATE)
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 ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define AE_CTRL_PARSE_PENDING
Definition: acexcep.h:235
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
ACPI_STATUS AcpiPsGetNextArg(ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT **ReturnArg)
Definition: psargs.c:785
#define AE_AML_NO_OPERAND
Definition: acexcep.h:181
UINT32 ArgTypes
Definition: acstruct.h:92
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AML_REGION_OP
Definition: amlcode.h:180
#define AE_CTRL_PENDING
Definition: acexcep.h:225
#define ASL_CV_CAPTURE_COMMENTS(a)
Definition: acmacros.h:526
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
#define AE_CTRL_PARSE_CONTINUE
Definition: acexcep.h:234
ACPI_STATUS AcpiPsNextParseState(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS CallbackStatus)
Definition: psparse.c:337
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118
void AcpiPsAppendArg(ACPI_PARSE_OBJECT *op, ACPI_PARSE_OBJECT *arg)
Definition: pstree.c:138
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
Status
Definition: gdiplustypes.h:24
ACPI_PARSE_DOWNWARDS DescendingCallback
Definition: acstruct.h:128
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define GET_CURRENT_ARG_TYPE(List)
Definition: acmacros.h:450
#define INCREMENT_ARG_LIST(List)
Definition: acmacros.h:451
UINT16 Opcode
Definition: acstruct.h:78
#define ARGP_NAME
Definition: amlcode.h:231
#define AML_DATA_REGION_OP
Definition: amlcode.h:188
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiPsCreateOp().

◆ AcpiPsCleanupScope()

void AcpiPsCleanupScope ( ACPI_PARSE_STATE state)

Definition at line 277 of file psscope.c.

279 {
280  ACPI_GENERIC_STATE *Scope;
281 
282 
283  ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState);
284 
285 
286  if (!ParserState)
287  {
288  return_VOID;
289  }
290 
291  /* Delete anything on the scope stack */
292 
293  while (ParserState->Scope)
294  {
295  Scope = AcpiUtPopGenericState (&ParserState->Scope);
296  AcpiUtDeleteGenericState (Scope);
297  }
298 
299  return_VOID;
300 }
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
ACPI_GENERIC_STATE * AcpiUtPopGenericState(ACPI_GENERIC_STATE **ListHead)
Definition: utstate.c:93
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
#define return_VOID
Definition: acoutput.h:495

Referenced by AcpiDsDeleteWalkState(), AcpiPsExecuteMethod(), and AcpiPsParseAml().

◆ AcpiPsCompleteFinalOp()

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

Definition at line 707 of file psobject.c.

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

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  Status = 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  Status = AE_OK;
557  break;
558 
559  case AE_CTRL_BREAK:
560  case AE_CTRL_CONTINUE:
561 
562  /* Pop off scopes until we find the While */
563 
564  while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP))
565  {
566  AcpiPsPopScope (&(WalkState->ParserState), Op,
567  &WalkState->ArgTypes, &WalkState->ArgCount);
568  }
569 
570  /* Close this iteration of the While loop */
571 
572  WalkState->Op = *Op;
573  WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode);
574  WalkState->Opcode = (*Op)->Common.AmlOpcode;
575 
576  Status = WalkState->AscendingCallback (WalkState);
577  Status = AcpiPsNextParseState (WalkState, *Op, Status);
578 
579  Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
580  if (ACPI_FAILURE (Status2))
581  {
582  return_ACPI_STATUS (Status2);
583  }
584 
585  Status = AE_OK;
586  break;
587 
588  case AE_CTRL_TERMINATE:
589 
590  /* Clean up */
591  do
592  {
593  if (*Op)
594  {
595  Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
596  if (ACPI_FAILURE (Status2))
597  {
598  return_ACPI_STATUS (Status2);
599  }
600 
602  AcpiUtPopGenericState (&WalkState->ControlState));
603  }
604 
605  AcpiPsPopScope (&(WalkState->ParserState), Op,
606  &WalkState->ArgTypes, &WalkState->ArgCount);
607 
608  } while (*Op);
609 
611 
612  default: /* All other non-AE_OK status */
613 
614  do
615  {
616  if (*Op)
617  {
618  /*
619  * These Opcodes need to be removed from the namespace because they
620  * get created even if these opcodes cannot be created due to
621  * errors.
622  */
623  if (((*Op)->Common.AmlOpcode == AML_REGION_OP) ||
624  ((*Op)->Common.AmlOpcode == AML_DATA_REGION_OP))
625  {
626  AcpiNsDeleteChildren ((*Op)->Common.Node);
627  AcpiNsRemoveNode ((*Op)->Common.Node);
628  (*Op)->Common.Node = NULL;
629  AcpiPsDeleteParseTree (*Op);
630  }
631 
632  Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
633  if (ACPI_FAILURE (Status2))
634  {
635  return_ACPI_STATUS (Status2);
636  }
637  }
638 
639  AcpiPsPopScope (&(WalkState->ParserState), Op,
640  &WalkState->ArgTypes, &WalkState->ArgCount);
641 
642  } while (*Op);
643 
644 
645 #if 0
646  /*
647  * TBD: Cleanup parse ops on error
648  */
649  if (*Op == NULL)
650  {
651  AcpiPsPopScope (ParserState, Op,
652  &WalkState->ArgTypes, &WalkState->ArgCount);
653  }
654 #endif
655  WalkState->PrevOp = NULL;
656  WalkState->PrevArgTypes = WalkState->ArgTypes;
657 
658  if (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)
659  {
660  /*
661  * There was something that went wrong while executing code at the
662  * module-level. We need to skip parsing whatever caused the
663  * error and keep going. One runtime error during the table load
664  * should not cause the entire table to not be loaded. This is
665  * because there could be correct AML beyond the parts that caused
666  * the runtime error.
667  */
668  ACPI_INFO (("Ignoring error and continuing table load"));
670  }
672  }
673 
674  /* This scope complete? */
675 
676  if (AcpiPsHasCompletedScope (&(WalkState->ParserState)))
677  {
678  AcpiPsPopScope (&(WalkState->ParserState), Op,
679  &WalkState->ArgTypes, &WalkState->ArgCount);
680  ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op));
681  }
682  else
683  {
684  *Op = NULL;
685  }
686 
688 }
void AcpiNsRemoveNode(ACPI_NAMESPACE_NODE *Node)
Definition: nsalloc.c:188
#define AE_CTRL_END
Definition: acexcep.h:230
void AcpiPsDeleteParseTree(ACPI_PARSE_OBJECT *root)
Definition: pswalk.c:67
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
ACPI_PARSE_OBJECT * PrevOp
Definition: acstruct.h:125
ACPI_STATE_COMMON UINT32 ArgCount
Definition: aclocal.h:748
void AcpiNsDeleteChildren(ACPI_NAMESPACE_NODE *Parent)
Definition: nsalloc.c:341
#define AML_WHILE_OP
Definition: amlcode.h:136
UINT32 ArgTypes
Definition: acstruct.h:92
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
#define AE_CTRL_TRANSFER
Definition: acexcep.h:231
#define ACPI_DB_PARSE
Definition: acoutput.h:162
UINT32 ParseFlags
Definition: acstruct.h:95
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_GENERIC_STATE * ControlState
Definition: acstruct.h:110
#define AML_REGION_OP
Definition: amlcode.h:180
ACPI_GENERIC_STATE * AcpiUtPopGenericState(ACPI_GENERIC_STATE **ListHead)
Definition: utstate.c:93
void AcpiPsPopScope(ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT **Op, UINT32 *ArgList, UINT32 *ArgCount)
Definition: psscope.c:219
ACPI_PARSE_UPWARDS AscendingCallback
Definition: acstruct.h:129
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
ACPI_STATUS AcpiPsNextParseState(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS CallbackStatus)
Definition: psparse.c:337
smooth NULL
Definition: ftsmooth.c:416
#define AE_CTRL_CONTINUE
Definition: acexcep.h:233
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_STATUS AcpiPsCompleteThisOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op)
Definition: psparse.c:144
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118
BOOLEAN AcpiPsHasCompletedScope(ACPI_PARSE_STATE *ParserState)
Definition: psscope.c:88
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
#define ACPI_INFO(plist)
Definition: acoutput.h:237
Status
Definition: gdiplustypes.h:24
UINT32 ArgCount
Definition: acstruct.h:99
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define AE_CTRL_BREAK
Definition: acexcep.h:232
#define ACPI_PARSE_MODULE_LEVEL
Definition: acparser.h:67
ACPI_PSCOPE_STATE ParseScope
Definition: aclocal.h:826
union acpi_generic_state * Scope
Definition: aclocal.h:1108
UINT16 Opcode
Definition: acstruct.h:78
UINT32 PrevArgTypes
Definition: acstruct.h:98
#define AML_DATA_REGION_OP
Definition: amlcode.h:188
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiPsCompleteFinalOp(), and AcpiPsParseLoop().

◆ AcpiPsCompleteThisOp()

ACPI_STATUS AcpiPsCompleteThisOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op 
)

Definition at line 144 of file psparse.c.

147 {
148  ACPI_PARSE_OBJECT *Prev;
149  ACPI_PARSE_OBJECT *Next;
150  const ACPI_OPCODE_INFO *ParentInfo;
151  ACPI_PARSE_OBJECT *ReplacementOp = NULL;
153 
154 
155  ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op);
156 
157 
158  /* Check for null Op, can happen if AML code is corrupt */
159 
160  if (!Op)
161  {
162  return_ACPI_STATUS (AE_OK); /* OK for now */
163  }
164 
165  AcpiExStopTraceOpcode (Op, WalkState);
166 
167  /* Delete this op and the subtree below it if asked to */
168 
169  if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) ||
170  (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT))
171  {
173  }
174 
175  /* Make sure that we only delete this subtree */
176 
177  if (Op->Common.Parent)
178  {
179  Prev = Op->Common.Parent->Common.Value.Arg;
180  if (!Prev)
181  {
182  /* Nothing more to do */
183 
184  goto Cleanup;
185  }
186 
187  /*
188  * Check if we need to replace the operator and its subtree
189  * with a return value op (placeholder op)
190  */
191  ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
192 
193  switch (ParentInfo->Class)
194  {
195  case AML_CLASS_CONTROL:
196 
197  break;
198 
199  case AML_CLASS_CREATE:
200  /*
201  * These opcodes contain TermArg operands. The current
202  * op must be replaced by a placeholder return op
203  */
204  ReplacementOp = AcpiPsAllocOp (
206  if (!ReplacementOp)
207  {
209  }
210  break;
211 
213  /*
214  * These opcodes contain TermArg operands. The current
215  * op must be replaced by a placeholder return op
216  */
217  if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
218  (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
219  (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
220  (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
221  (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) ||
222  (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
223  {
224  ReplacementOp = AcpiPsAllocOp (
226  if (!ReplacementOp)
227  {
229  }
230  }
231  else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
232  (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2))
233  {
234  if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
235  (Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
236  (Op->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
237  {
238  ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode,
239  Op->Common.Aml);
240  if (!ReplacementOp)
241  {
243  }
244  else
245  {
246  ReplacementOp->Named.Data = Op->Named.Data;
247  ReplacementOp->Named.Length = Op->Named.Length;
248  }
249  }
250  }
251  break;
252 
253  default:
254 
255  ReplacementOp = AcpiPsAllocOp (
257  if (!ReplacementOp)
258  {
260  }
261  }
262 
263  /* We must unlink this op from the parent tree */
264 
265  if (Prev == Op)
266  {
267  /* This op is the first in the list */
268 
269  if (ReplacementOp)
270  {
271  ReplacementOp->Common.Parent = Op->Common.Parent;
272  ReplacementOp->Common.Value.Arg = NULL;
273  ReplacementOp->Common.Node = Op->Common.Node;
274  Op->Common.Parent->Common.Value.Arg = ReplacementOp;
275  ReplacementOp->Common.Next = Op->Common.Next;
276  }
277  else
278  {
279  Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
280  }
281  }
282 
283  /* Search the parent list */
284 
285  else while (Prev)
286  {
287  /* Traverse all siblings in the parent's argument list */
288 
289  Next = Prev->Common.Next;
290  if (Next == Op)
291  {
292  if (ReplacementOp)
293  {
294  ReplacementOp->Common.Parent = Op->Common.Parent;
295  ReplacementOp->Common.Value.Arg = NULL;
296  ReplacementOp->Common.Node = Op->Common.Node;
297  Prev->Common.Next = ReplacementOp;
298  ReplacementOp->Common.Next = Op->Common.Next;
299  Next = NULL;
300  }
301  else
302  {
303  Prev->Common.Next = Op->Common.Next;
304  Next = NULL;
305  }
306  }
307  Prev = Next;
308  }
309  }
310 
311 
312 Cleanup:
313 
314  /* Now we can actually delete the subtree rooted at Op */
315 
318 }
void AcpiPsDeleteParseTree(ACPI_PARSE_OBJECT *root)
Definition: pswalk.c:67
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AML_CLASS_CREATE
Definition: amlcode.h:401
#define AML_CLASS_CONTROL
Definition: amlcode.h:404
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
ACPI_PARSE_OBJECT * AcpiPsAllocOp(UINT16 Opcode, UINT8 *Aml)
Definition: psutils.c:130
UINT32 ParseFlags
Definition: acstruct.h:95
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AML_VARIABLE_PACKAGE_OP
Definition: amlcode.h:63
#define AML_REGION_OP
Definition: amlcode.h:180
#define AML_CLASS_NAMED_OBJECT
Definition: amlcode.h:403
#define AML_NAME_OP
Definition: amlcode.h:54
smooth NULL
Definition: ftsmooth.c:416
void AcpiExStopTraceOpcode(ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
Definition: extrace.c:385
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079
#define ACPI_PARSE_TREE_MASK
Definition: acparser.h:57
#define AML_BANK_FIELD_OP
Definition: amlcode.h:187
#define AML_INT_RETURN_VALUE_OP
Definition: amlcode.h:211
#define AML_CLASS_ARGUMENT
Definition: amlcode.h:402
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119
static const WCHAR Cleanup[]
Definition: register.c:80
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
UINT8 PassNumber
Definition: acstruct.h:87
#define AML_BUFFER_OP
Definition: amlcode.h:61
#define AML_DATA_REGION_OP
Definition: amlcode.h:188
#define AE_OK
Definition: acexcep.h:97
#define AML_PACKAGE_OP
Definition: amlcode.h:62
#define ACPI_PARSE_DELETE_TREE
Definition: acparser.h:55

Referenced by AcpiPsCompleteFinalOp(), and AcpiPsCompleteOp().

◆ AcpiPsCreateOp()

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

Definition at line 344 of file psobject.c.

348 {
350  ACPI_PARSE_OBJECT *Op;
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 &&
386  Status == AE_NOT_FOUND)
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 }
#define AE_CTRL_PARSE_PENDING
Definition: acexcep.h:235
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
#define AML_NAMED
Definition: amlcode.h:323
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ACPI_PARSEOP_TARGET
Definition: aclocal.h:1122
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
ACPI_PARSE_OBJECT * AcpiPsGetParentScope(ACPI_PARSE_STATE *state)
Definition: psscope.c:65
ACPI_PARSE_OBJECT * AcpiPsAllocOp(UINT16 Opcode, UINT8 *Aml)
Definition: psutils.c:130
UINT8 AcpiPsGetArgumentCount(UINT32 OpType)
Definition: psopinfo.c:203
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AML_EXTERNAL_OP
Definition: amlcode.h:65
#define AE_CTRL_PENDING
Definition: acexcep.h:225
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AML_HAS_TARGET
Definition: amlcode.h:328
#define AML_CREATE
Definition: amlcode.h:320
#define AE_CTRL_PARSE_CONTINUE
Definition: acexcep.h:234
ACPI_STATUS AcpiPsNextParseState(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS CallbackStatus)
Definition: psparse.c:337
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079
static ACPI_STATUS AcpiPsGetAmlOpcode(ACPI_WALK_STATE *WalkState)
Definition: psobject.c:75
#define AML_BANK_FIELD_OP
Definition: amlcode.h:187
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118
void AcpiPsAppendArg(ACPI_PARSE_OBJECT *op, ACPI_PARSE_OBJECT *arg)
Definition: pstree.c:138
#define AE_NOT_FOUND
Definition: acexcep.h:113
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119
ACPI_STATUS AcpiPsBuildNamedOp(ACPI_WALK_STATE *WalkState, UINT8 *AmlOpStart, ACPI_PARSE_OBJECT *UnnamedOp, ACPI_PARSE_OBJECT **Op)
Definition: psobject.c:193
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
Status
Definition: gdiplustypes.h:24
ACPI_PARSE_DOWNWARDS DescendingCallback
Definition: acstruct.h:128
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define AML_DECREMENT_OP
Definition: amlcode.h:94
#define AML_INCREMENT_OP
Definition: amlcode.h:93
void AcpiPsFreeOp(ACPI_PARSE_OBJECT *Op)
Definition: psutils.c:212
UINT16 Opcode
Definition: acstruct.h:78
unsigned char UINT8
#define AE_OK
Definition: acexcep.h:97
UINT16 Flags
Definition: aclocal.h:873
UINT8 * Aml
Definition: acstruct.h:91

Referenced by AcpiPsParseLoop().

◆ AcpiPsCreateScopeOp()

ACPI_PARSE_OBJECT* AcpiPsCreateScopeOp ( UINT8 Aml)

Definition at line 67 of file psutils.c.

69 {
70  ACPI_PARSE_OBJECT *ScopeOp;
71 
72 
73  ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP, Aml);
74  if (!ScopeOp)
75  {
76  return (NULL);
77  }
78 
79  ScopeOp->Named.Name = ACPI_ROOT_NAME;
80  return (ScopeOp);
81 }
ACPI_PARSE_OBJECT * AcpiPsAllocOp(UINT16 Opcode, UINT8 *Aml)
Definition: psutils.c:130
smooth NULL
Definition: ftsmooth.c:416
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079
#define ACPI_ROOT_NAME
Definition: acnames.h:91
#define AML_SCOPE_OP
Definition: amlcode.h:60
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN UINT8 * Aml
Definition: acpixf.h:1287

Referenced by AcpiNsOneCompleteParse(), AcpiPsExecuteMethod(), and AcpiPsExecuteTable().

◆ AcpiPsDeleteCompletedOp()

ACPI_STATUS AcpiPsDeleteCompletedOp ( ACPI_WALK_STATE WalkState)

◆ AcpiPsDeleteParseTree()

void AcpiPsDeleteParseTree ( ACPI_PARSE_OBJECT root)

Definition at line 67 of file pswalk.c.

69 {
70  ACPI_PARSE_OBJECT *Op = SubtreeRoot;
71  ACPI_PARSE_OBJECT *Next = NULL;
73  UINT32 Level = 0;
74 
75 
76  ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot);
77 
79  " root %p\n", SubtreeRoot));
80 
81  /* Visit all nodes in the subtree */
82 
83  while (Op)
84  {
85  if (Op != Parent)
86  {
87  /* This is the descending case */
88 
90  {
91  /* This debug option will print the entire parse tree */
92 
93  AcpiOsPrintf (" %*.s%s %p", (Level * 4), " ",
94  AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Op);
95 
96  if (Op->Named.AmlOpcode == AML_INT_NAMEPATH_OP)
97  {
98  AcpiOsPrintf (" %4.4s", Op->Common.Value.String);
99  }
100  if (Op->Named.AmlOpcode == AML_STRING_OP)
101  {
102  AcpiOsPrintf (" %s", Op->Common.Value.String);
103  }
104  AcpiOsPrintf ("\n");
105  }
106 
107  /* Look for an argument or child of the current op */
108 
109  Next = AcpiPsGetArg (Op, 0);
110  if (Next)
111  {
112  /* Still going downward in tree (Op is not completed yet) */
113 
114  Op = Next;
115  Level++;
116  continue;
117  }
118  }
119 
120  /* No more children, this Op is complete. */
121 
122  Next = Op->Common.Next;
123  Parent = Op->Common.Parent;
124 
125  AcpiPsFreeOp (Op);
126 
127  /* If we are back to the starting point, the walk is complete. */
128 
129  if (Op == SubtreeRoot)
130  {
131  return_VOID;
132  }
133 
134  if (Next)
135  {
136  Op = Next;
137  }
138  else
139  {
140  Level--;
141  Op = Parent;
142  }
143  }
144 
145  return_VOID;
146 }
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
const char * AcpiPsGetOpcodeName(UINT16 Opcode)
Definition: psopinfo.c:169
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
#define _COMPONENT
Definition: pswalk.c:48
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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 Parent
Definition: acpixf.h:722
#define AML_INT_NAMEPATH_OP
Definition: amlcode.h:205
#define AML_STRING_OP
Definition: amlcode.h:58
unsigned int UINT32
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079
#define ACPI_DB_PARSE_TREES
Definition: acoutput.h:172
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_LV_PARSE_TREES
Definition: acoutput.h:119
#define return_VOID
Definition: acoutput.h:495
void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf(const char *Format,...)
Definition: osl.c:851
ACPI_PARSE_OBJECT * AcpiPsGetArg(ACPI_PARSE_OBJECT *op, UINT32 argn)
Definition: pstree.c:76
void AcpiPsFreeOp(ACPI_PARSE_OBJECT *Op)
Definition: psutils.c:212
#define ACPI_IS_DEBUG_ENABLED(Level, Component)
Definition: acoutput.h:490

Referenced by AcpiDsAutoSerializeMethod(), AcpiDsExecuteArguments(), AcpiNsOneCompleteParse(), AcpiPsCompleteOp(), AcpiPsCompleteThisOp(), AcpiPsExecuteMethod(), and AcpiPsExecuteTable().

◆ AcpiPsExecuteMethod()

ACPI_STATUS AcpiPsExecuteMethod ( ACPI_EVALUATE_INFO Info)

Definition at line 131 of file psxface.c.

133 {
135  ACPI_PARSE_OBJECT *Op;
136  ACPI_WALK_STATE *WalkState;
137 
138 
139  ACPI_FUNCTION_TRACE (PsExecuteMethod);
140 
141 
142  /* Quick validation of DSDT header */
143 
145 
146  /* Validate the Info and method Node */
147 
148  if (!Info || !Info->Node)
149  {
151  }
152 
153  /* Init for new method, wait on concurrency semaphore */
154 
155  Status = AcpiDsBeginMethodExecution (Info->Node, Info->ObjDesc, NULL);
156  if (ACPI_FAILURE (Status))
157  {
159  }
160 
161  /*
162  * The caller "owns" the parameters, so give each one an extra reference
163  */
165 
166  /*
167  * Execute the method. Performs parse simultaneously
168  */
170  "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
171  Info->Node->Name.Ascii, Info->Node, Info->ObjDesc));
172 
173  /* Create and init a Root Node */
174 
175  Op = AcpiPsCreateScopeOp (Info->ObjDesc->Method.AmlStart);
176  if (!Op)
177  {
179  goto Cleanup;
180  }
181 
182  /* Create and initialize a new walk state */
183 
184  Info->PassNumber = ACPI_IMODE_EXECUTE;
185  WalkState = AcpiDsCreateWalkState (
186  Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL);
187  if (!WalkState)
188  {
190  goto Cleanup;
191  }
192 
193  Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
194  Info->ObjDesc->Method.AmlStart,
195  Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
196  if (ACPI_FAILURE (Status))
197  {
198  AcpiDsDeleteWalkState (WalkState);
199  goto Cleanup;
200  }
201 
202  WalkState->MethodPathname = Info->FullPathname;
203  WalkState->MethodIsNested = FALSE;
204 
205  if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
206  {
207  WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
208  }
209 
210  /* Invoke an internal method if necessary */
211 
212  if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
213  {
214  Status = Info->ObjDesc->Method.Dispatch.Implementation (WalkState);
215  Info->ReturnObject = WalkState->ReturnDesc;
216 
217  /* Cleanup states */
218 
219  AcpiDsScopeStackClear (WalkState);
220  AcpiPsCleanupScope (&WalkState->ParserState);
221  AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
222  AcpiDsDeleteWalkState (WalkState);
223  goto Cleanup;
224  }
225 
226  /*
227  * Start method evaluation with an implicit return of zero.
228  * This is done for Windows compatibility.
229  */
230  if (AcpiGbl_EnableInterpreterSlack)
231  {
232  WalkState->ImplicitReturnObj =
234  if (!WalkState->ImplicitReturnObj)
235  {
237  AcpiDsDeleteWalkState (WalkState);
238  goto Cleanup;
239  }
240  }
241 
242  /* Parse the AML */
243 
244  Status = AcpiPsParseAml (WalkState);
245 
246  /* WalkState was deleted by ParseAml */
247 
248 Cleanup:
250 
251  /* Take away the extra reference that we gave the parameters above */
252 
254 
255  /* Exit now if error above */
256 
257  if (ACPI_FAILURE (Status))
258  {
260  }
261 
262  /*
263  * If the method has returned an object, signal this to the caller with
264  * a control exception code
265  */
266  if (Info->ReturnObject)
267  {
268  ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
269  Info->ReturnObject));
270  ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
271 
273  }
274 
276 }
char * MethodPathname
Definition: acstruct.h:117
void AcpiPsDeleteParseTree(ACPI_PARSE_OBJECT *root)
Definition: pswalk.c:67
ACPI_STATUS AcpiDsInitAmlWalk(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, ACPI_EVALUATE_INFO *Info, UINT8 PassNumber)
Definition: dswstate.c:662
union acpi_operand_object * ImplicitReturnObj
Definition: acstruct.h:112
void AcpiDsDeleteWalkState(ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:780
ACPI_WALK_STATE * AcpiDsCreateWalkState(ACPI_OWNER_ID OwnerId, ACPI_PARSE_OBJECT *Origin, ACPI_OPERAND_OBJECT *MethodDesc, ACPI_THREAD_STATE *Thread)
Definition: dswstate.c:600
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_CTRL_RETURN_VALUE
Definition: acexcep.h:224
union acpi_operand_object * ReturnDesc
Definition: acstruct.h:123
#define ACPI_DB_PARSE
Definition: acoutput.h:162
UINT32 ParseFlags
Definition: acstruct.h:95
UINT32 ACPI_STATUS
Definition: actypes.h:460
void AcpiPsCleanupScope(ACPI_PARSE_STATE *state)
Definition: psscope.c:277
struct TraceInfo Info
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_METHOD_INTERNAL_ONLY
Definition: acobject.h:236
ACPI_STATUS AcpiDsBeginMethodExecution(ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState)
Definition: dsmethod.c:352
ACPI_PARSE_OBJECT * AcpiPsCreateScopeOp(UINT8 *Aml)
Definition: psutils.c:67
union acpi_operand_object * MethodDesc
Definition: acstruct.h:115
ACPI_OPERAND_OBJECT * AcpiUtCreateIntegerObject(UINT64 Value)
Definition: utobject.c:223
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DUMP_STACK_ENTRY(a)
Definition: acoutput.h:485
static void AcpiPsUpdateParameterList(ACPI_EVALUATE_INFO *Info, UINT16 Action)
Definition: psxface.c:391
void AcpiDsScopeStackClear(ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:67
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
void AcpiTbCheckDsdtHeader(void)
Definition: tbutils.c:124
#define ACPI_METHOD_MODULE_LEVEL
Definition: acobject.h:235
static const WCHAR Cleanup[]
Definition: register.c:80
Status
Definition: gdiplustypes.h:24
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_PARSE_MODULE_LEVEL
Definition: acparser.h:67
#define AE_NULL_ENTRY
Definition: acexcep.h:118
ACPI_STATUS AcpiPsParseAml(ACPI_WALK_STATE *WalkState)
Definition: psparse.c:453
#define REF_DECREMENT
Definition: acutils.h:181
unsigned long long UINT64
UINT8 MethodIsNested
Definition: acstruct.h:101
void AcpiDsTerminateControlMethod(ACPI_OPERAND_OBJECT *MethodDesc, ACPI_WALK_STATE *WalkState)
Definition: dsmethod.c:779
#define REF_INCREMENT
Definition: acutils.h:180

Referenced by AcpiNsEvaluate().

◆ AcpiPsExecuteTable()

ACPI_STATUS AcpiPsExecuteTable ( ACPI_EVALUATE_INFO Info)

Definition at line 297 of file psxface.c.

299 {
301  ACPI_PARSE_OBJECT *Op = NULL;
302  ACPI_WALK_STATE *WalkState = NULL;
303 
304 
305  ACPI_FUNCTION_TRACE (PsExecuteTable);
306 
307 
308  /* Create and init a Root Node */
309 
310  Op = AcpiPsCreateScopeOp (Info->ObjDesc->Method.AmlStart);
311  if (!Op)
312  {
314  goto Cleanup;
315  }
316 
317  /* Create and initialize a new walk state */
318 
319  WalkState = AcpiDsCreateWalkState (
320  Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL);
321  if (!WalkState)
322  {
324  goto Cleanup;
325  }
326 
327  Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
328  Info->ObjDesc->Method.AmlStart,
329  Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
330  if (ACPI_FAILURE (Status))
331  {
332  goto Cleanup;
333  }
334 
335  WalkState->MethodPathname = Info->FullPathname;
336  WalkState->MethodIsNested = FALSE;
337 
338  if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
339  {
340  WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
341  }
342 
343  /* Info->Node is the default location to load the table */
344 
345  if (Info->Node && Info->Node != AcpiGbl_RootNode)
346  {
348  Info->Node, ACPI_TYPE_METHOD, WalkState);
349  if (ACPI_FAILURE (Status))
350  {
351  goto Cleanup;
352  }
353  }
354 
355  /*
356  * Parse the AML, WalkState will be deleted by ParseAml
357  */
359  Status = AcpiPsParseAml (WalkState);
361  WalkState = NULL;
362 
363 Cleanup:
364  if (WalkState)
365  {
366  AcpiDsDeleteWalkState (WalkState);
367  }
368  if (Op)
369  {
371  }
373 }
char * MethodPathname
Definition: acstruct.h:117
void AcpiPsDeleteParseTree(ACPI_PARSE_OBJECT *root)
Definition: pswalk.c:67
ACPI_STATUS AcpiDsInitAmlWalk(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, ACPI_EVALUATE_INFO *Info, UINT8 PassNumber)
Definition: dswstate.c:662
void AcpiDsDeleteWalkState(ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:780
ACPI_WALK_STATE * AcpiDsCreateWalkState(ACPI_OWNER_ID OwnerId, ACPI_PARSE_OBJECT *Origin, ACPI_OPERAND_OBJECT *MethodDesc, ACPI_THREAD_STATE *Thread)
Definition: dswstate.c:600
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_STATUS AcpiDsScopeStackPush(ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:107
UINT32 ParseFlags
Definition: acstruct.h:95
UINT32 ACPI_STATUS
Definition: actypes.h:460
struct TraceInfo Info
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_TYPE_METHOD
Definition: actypes.h:686
ACPI_PARSE_OBJECT * AcpiPsCreateScopeOp(UINT8 *Aml)
Definition: psutils.c:67
#define ACPI_METHOD_MODULE_LEVEL
Definition: acobject.h:235
static const WCHAR Cleanup[]
Definition: register.c:80
Status
Definition: gdiplustypes.h:24
void AcpiExExitInterpreter(void)
Definition: exutils.c:139
void AcpiExEnterInterpreter(void)
Definition: exutils.c:91
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_PARSE_MODULE_LEVEL
Definition: acparser.h:67
ACPI_STATUS AcpiPsParseAml(ACPI_WALK_STATE *WalkState)
Definition: psparse.c:453
UINT8 MethodIsNested
Definition: acstruct.h:101

Referenced by AcpiNsExecuteTable().

◆ AcpiPsFind()

ACPI_PARSE_OBJECT* AcpiPsFind ( ACPI_PARSE_OBJECT Scope,
char Path,
UINT16  Opcode,
UINT32  Create 
)

◆ AcpiPsFindName()

ACPI_PARSE_OBJECT* AcpiPsFindName ( ACPI_PARSE_OBJECT Scope,
UINT32  Name,
UINT32  Opcode 
)

◆ AcpiPsFreeOp()

void AcpiPsFreeOp ( ACPI_PARSE_OBJECT Op)

Definition at line 212 of file psutils.c.

214 {
215  ACPI_FUNCTION_NAME (PsFreeOp);
216 
217 
219  if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
220  {
222  "Free retval op: %p\n", Op));
223  }
224 
225  if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
226  {
227  (void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op);
228  }
229  else
230  {
231  (void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op);
232  }
233 }
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define ASL_CV_CLEAR_OP_COMMENTS(a)
Definition: acmacros.h:531
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define AML_INT_RETURN_VALUE_OP
Definition: amlcode.h:211
#define ACPI_PARSEOP_GENERIC
Definition: aclocal.h:1117
ACPI_STATUS AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object)
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
#define ACPI_DB_ALLOCATIONS
Definition: acoutput.h:175

Referenced by AcpiDsAutoSerializeMethod(), AcpiNsOneCompleteParse(), AcpiPsCreateOp(), AcpiPsDeleteParseTree(), AcpiPsGetNextArg(), and AcpiPsGetNextField().

◆ AcpiPsGetArg()

ACPI_PARSE_OBJECT* AcpiPsGetArg ( ACPI_PARSE_OBJECT op,
UINT32  argn 
)

Definition at line 76 of file pstree.c.

79 {
80  ACPI_PARSE_OBJECT *Arg = NULL;
81  const ACPI_OPCODE_INFO *OpInfo;
82 
83 
85 
86 /*
87  if (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP)
88  {
89  return (Op->Common.Value.Arg);
90  }
91 */
92  /* Get the info structure for this opcode */
93 
94  OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
95  if (OpInfo->Class == AML_CLASS_UNKNOWN)
96  {
97  /* Invalid opcode or ASCII character */
98 
99  return (NULL);
100  }
101 
102  /* Check if this opcode requires argument sub-objects */
103 
104  if (!(OpInfo->Flags & AML_HAS_ARGS))
105  {
106  /* Has no linked argument objects */
107 
108  return (NULL);
109  }
110 
111  /* Get the requested argument object */
112 
113  Arg = Op->Common.Value.Arg;
114  while (Arg && Argn)
115  {
116  Argn--;
117  Arg = Arg->Common.Next;
118  }
119 
120  return (Arg);
121 }
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
#define AML_CLASS_UNKNOWN
Definition: amlcode.h:410
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define AML_HAS_ARGS
Definition: amlcode.h:329
UINT16 Flags
Definition: aclocal.h:873

Referenced by AcpiDsCreateBufferField(), AcpiDsEvalBankFieldOperands(), AcpiDsInitFieldObjects(), AcpiPsDeleteParseTree(), and AcpiPsGetDepthNext().

◆ AcpiPsGetArgumentCount()

UINT8 AcpiPsGetArgumentCount ( UINT32  OpType)

Definition at line 203 of file psopinfo.c.

205 {
206 
207  if (OpType <= AML_TYPE_EXEC_6A_0T_1R)
208  {
209  return (AcpiGbl_ArgumentCount[OpType]);
210  }
211 
212  return (0);
213 }
#define AML_TYPE_EXEC_6A_0T_1R
Definition: amlcode.h:364
static const UINT8 AcpiGbl_ArgumentCount[]
Definition: psopinfo.c:55

Referenced by AcpiPsCreateOp().

◆ AcpiPsGetDepthNext()

ACPI_PARSE_OBJECT* AcpiPsGetDepthNext ( ACPI_PARSE_OBJECT Origin,
ACPI_PARSE_OBJECT Op 
)

Definition at line 224 of file pstree.c.

227 {
228  ACPI_PARSE_OBJECT *Next = NULL;
230  ACPI_PARSE_OBJECT *Arg;
231 
232 
234 
235 
236  if (!Op)
237  {
238  return (NULL);
239  }
240 
241  /* Look for an argument or child */
242 
243  Next = AcpiPsGetArg (Op, 0);
244  if (Next)
245  {
246  ASL_CV_LABEL_FILENODE (Next);
247  return (Next);
248  }
249 
250  /* Look for a sibling */
251 
252  Next = Op->Common.Next;
253  if (Next)
254  {
255  ASL_CV_LABEL_FILENODE (Next);
256  return (Next);
257  }
258 
259  /* Look for a sibling of parent */
260 
261  Parent = Op->Common.Parent;
262 
263  while (Parent)
264  {
265  Arg = AcpiPsGetArg (Parent, 0);
266  while (Arg && (Arg != Origin) && (Arg != Op))
267  {
268 
269  ASL_CV_LABEL_FILENODE (Arg);
270  Arg = Arg->Common.Next;
271  }
272 
273  if (Arg == Origin)
274  {
275  /* Reached parent of origin, end search */
276 
277  return (NULL);
278  }
279 
280  if (Parent->Common.Next)
281  {
282  /* Found sibling of parent */
283 
284  ASL_CV_LABEL_FILENODE (Parent->Common.Next);
285  return (Parent->Common.Next);
286  }
287 
288  Op = Parent;
289  Parent = Parent->Common.Parent;
290  }
291 
292  ASL_CV_LABEL_FILENODE (Next);
293  return (Next);
294 }
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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 Parent
Definition: acpixf.h:722
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
ACPI_PARSE_OBJECT * AcpiPsGetArg(ACPI_PARSE_OBJECT *Op, UINT32 Argn)
Definition: pstree.c:76
#define ASL_CV_LABEL_FILENODE(a)
Definition: acmacros.h:524

◆ AcpiPsGetName()

UINT32 AcpiPsGetName ( ACPI_PARSE_OBJECT op)

Definition at line 260 of file psutils.c.

262 {
263 
264  /* The "generic" object has no name associated with it */
265 
266  if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
267  {
268  return (0);
269  }
270 
271  /* Only the "Extended" parse objects have a name */
272 
273  return (Op->Named.Name);
274 }
#define ACPI_PARSEOP_GENERIC
Definition: aclocal.h:1117

◆ AcpiPsGetNextArg()

ACPI_STATUS AcpiPsGetNextArg ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_STATE ParserState,
UINT32  ArgType,
ACPI_PARSE_OBJECT **  ReturnArg 
)

Definition at line 785 of file psargs.c.

790 {
791  ACPI_PARSE_OBJECT *Arg = NULL;
792  ACPI_PARSE_OBJECT *Prev = NULL;
794  UINT32 Subop;
796 
797 
798  ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
799 
800 
802  "Expected argument type ARGP: %s (%2.2X)\n",
803  AcpiUtGetArgumentTypeName (ArgType), ArgType));
804 
805  switch (ArgType)
806  {
807  case ARGP_BYTEDATA:
808  case ARGP_WORDDATA:
809  case ARGP_DWORDDATA:
810  case ARGP_CHARLIST:
811  case ARGP_NAME:
812  case ARGP_NAMESTRING:
813 
814  /* Constants, strings, and namestrings are all the same size */
815 
816  Arg = AcpiPsAllocOp (AML_BYTE_OP, ParserState->Aml);
817  if (!Arg)
818  {
820  }
821 
822  AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg);
823  break;
824 
825  case ARGP_PKGLENGTH:
826 
827  /* Package length, nothing returned */
828 
829  ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState);
830  break;
831 
832  case ARGP_FIELDLIST:
833 
834  if (ParserState->Aml < ParserState->PkgEnd)
835  {
836  /* Non-empty list */
837 
838  while (ParserState->Aml < ParserState->PkgEnd)
839  {
840  Field = AcpiPsGetNextField (ParserState);
841  if (!Field)
842  {
844  }
845 
846  if (Prev)
847  {
848  Prev->Common.Next = Field;
849  }
850  else
851  {
852  Arg = Field;
853  }
854  Prev = Field;
855  }
856 
857  /* Skip to End of byte data */
858 
859  ParserState->Aml = ParserState->PkgEnd;
860  }
861  break;
862 
863  case ARGP_BYTELIST:
864 
865  if (ParserState->Aml < ParserState->PkgEnd)
866  {
867  /* Non-empty list */
868 
870  ParserState->Aml);
871  if (!Arg)
872  {
874  }
875 
876  /* Fill in bytelist data */
877 
878  Arg->Common.Value.Size = (UINT32)
879  ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml);
880  Arg->Named.Data = ParserState->Aml;
881 
882  /* Skip to End of byte data */
883 
884  ParserState->Aml = ParserState->PkgEnd;
885  }
886  break;
887 
888  case ARGP_SIMPLENAME:
889  case ARGP_NAME_OR_REF:
890 
892  "**** SimpleName/NameOrRef: %s (%2.2X)\n",
893  AcpiUtGetArgumentTypeName (ArgType), ArgType));
894 
895  Subop = AcpiPsPeekOpcode (ParserState);
896  if (Subop == 0 ||
897  AcpiPsIsLeadingChar (Subop) ||
898  ACPI_IS_ROOT_PREFIX (Subop) ||
899  ACPI_IS_PARENT_PREFIX (Subop))
900  {
901  /* NullName or NameString */
902 
903  Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml);
904  if (!Arg)
905  {
907  }
908 
909  Status = AcpiPsGetNextNamepath (WalkState, ParserState,
910  Arg, ACPI_NOT_METHOD_CALL);
911  }
912  else
913  {
914  /* Single complex argument, nothing returned */
915 
916  WalkState->ArgCount = 1;
917  }
918  break;
919 
920  case ARGP_TARGET:
921  case ARGP_SUPERNAME:
922 
924  "**** Target/Supername: %s (%2.2X)\n",
925  AcpiUtGetArgumentTypeName (ArgType), ArgType));
926 
927  Subop = AcpiPsPeekOpcode (ParserState);
928  if (Subop == 0 ||
929  AcpiPsIsLeadingChar (Subop) ||
930  ACPI_IS_ROOT_PREFIX (Subop) ||
931  ACPI_IS_PARENT_PREFIX (Subop))
932  {
933  /* NULL target (zero). Convert to a NULL namepath */
934 
935  Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml);
936  if (!Arg)
937  {
939  }
940 
941  Status = AcpiPsGetNextNamepath (WalkState, ParserState,
943 
944  if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
945  {
946  /* Free method call op and corresponding namestring sub-ob */
947 
948  AcpiPsFreeOp (Arg->Common.Value.Arg);
949  AcpiPsFreeOp (Arg);
950  Arg = NULL;
951  WalkState->ArgCount = 1;
952  }
953  }
954  else
955  {
956  /* Single complex argument, nothing returned */
957 
958  WalkState->ArgCount = 1;
959  }
960  break;
961 
962  case ARGP_DATAOBJ:
963  case ARGP_TERMARG:
964 
966  "**** TermArg/DataObj: %s (%2.2X)\n",
967  AcpiUtGetArgumentTypeName (ArgType), ArgType));
968 
969  /* Single complex argument, nothing returned */
970 
971  WalkState->ArgCount = 1;
972  break;
973 
974  case ARGP_DATAOBJLIST:
975  case ARGP_TERMLIST:
976  case ARGP_OBJLIST:
977 
978  if (ParserState->Aml < ParserState->PkgEnd)
979  {
980  /* Non-empty list of variable arguments, nothing returned */
981 
982  WalkState->ArgCount = ACPI_VAR_ARGS;
983  }
984  break;
985 
986  default:
987 
988  ACPI_ERROR ((AE_INFO, "Invalid ArgType: 0x%X", ArgType));
990  break;
991  }
992 
993  *ReturnArg = Arg;
995 }
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
#define ARGP_DATAOBJ
Definition: amlcode.h:227
UINT8 * PkgEnd
Definition: aclocal.h:1105
void AcpiPsGetNextSimpleArg(ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT *Arg)
Definition: psargs.c:428
#define ARGP_TERMLIST
Definition: amlcode.h:238
#define ARGP_NAMESTRING
Definition: amlcode.h:232
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ARGP_SUPERNAME
Definition: amlcode.h:235
#define AML_BYTE_OP
Definition: amlcode.h:55
#define ACPI_VAR_ARGS
Definition: acparser.h:52
#define AML_INT_METHODCALL_OP
Definition: amlcode.h:210
#define ACPI_PTR_DIFF(a, b)
Definition: actypes.h:548
ACPI_PARSE_OBJECT * AcpiPsAllocOp(UINT16 Opcode, UINT8 *Aml)
Definition: psutils.c:130
#define ACPI_DB_PARSE
Definition: acoutput.h:162
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_STATUS AcpiPsGetNextNamepath(ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Arg, BOOLEAN PossibleMethodCall)
Definition: psargs.c:254
#define ARGP_OBJLIST
Definition: amlcode.h:233
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define AML_INT_NAMEPATH_OP
Definition: amlcode.h:205
UINT8 * AcpiPsGetNextPackageEnd(ACPI_PARSE_STATE *ParserState)
Definition: psargs.c:138
#define ARGP_SIMPLENAME
Definition: amlcode.h:241
#define ARGP_TARGET
Definition: amlcode.h:236
unsigned int UINT32
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
#define ARGP_BYTEDATA
Definition: amlcode.h:224
#define ARGP_BYTELIST
Definition: amlcode.h:225
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079
UINT16 AcpiPsPeekOpcode(ACPI_PARSE_STATE *state)
Definition: psparse.c:108
#define ACPI_NOT_METHOD_CALL
Definition: acparser.h:117
#define ARGP_WORDDATA
Definition: amlcode.h:239
#define ARGP_PKGLENGTH
Definition: amlcode.h:234
static ACPI_PARSE_OBJECT * AcpiPsGetNextField(ACPI_PARSE_STATE *ParserState)
Definition: psargs.c:528
#define ARGP_DATAOBJLIST
Definition: amlcode.h:228
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ARGP_NAME_OR_REF
Definition: amlcode.h:242
#define ACPI_IS_PARENT_PREFIX(c)
Definition: acmacros.h:402
Status
Definition: gdiplustypes.h:24
UINT32 ArgCount
Definition: acstruct.h:99
#define ARGP_DWORDDATA
Definition: amlcode.h:229
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ARGP_FIELDLIST
Definition: amlcode.h:230
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define ARGP_TERMARG
Definition: amlcode.h:237
void AcpiPsFreeOp(ACPI_PARSE_OBJECT *Op)
Definition: psutils.c:212
#define ARGP_CHARLIST
Definition: amlcode.h:226
ACPI_OBJECT_REGION_FIELD Field
Definition: acobject.h:531
#define AML_INT_BYTELIST_OP
Definition: amlcode.h:209
#define ACPI_POSSIBLE_METHOD_CALL
Definition: acparser.h:118
const char * AcpiUtGetArgumentTypeName(UINT32 ArgType)
#define ACPI_IS_ROOT_PREFIX(c)
Definition: acmacros.h:401
#define ARGP_NAME
Definition: amlcode.h:231
#define AE_OK
Definition: acexcep.h:97
BOOLEAN AcpiPsIsLeadingChar(UINT32 c)
Definition: psutils.c:249

Referenced by AcpiPsBuildNamedOp(), and AcpiPsGetArguments().

◆ AcpiPsGetNextNamepath()

ACPI_STATUS AcpiPsGetNextNamepath ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_STATE ParserState,
ACPI_PARSE_OBJECT Arg,
BOOLEAN  PossibleMethodCall 
)

Definition at line 254 of file psargs.c.

259 {
261  char *Path;
262  ACPI_PARSE_OBJECT *NameOp;
263  ACPI_OPERAND_OBJECT *MethodDesc;
265  UINT8 *Start = ParserState->Aml;
266 
267 
268  ACPI_FUNCTION_TRACE (PsGetNextNamepath);
269 
270 
271  Path = AcpiPsGetNextNamestring (ParserState);
273 
274  /* Null path case is allowed, just exit */
275 
276  if (!Path)
277  {
278  Arg->Common.Value.Name = Path;
280  }
281 
282  /*
283  * Lookup the name in the internal namespace, starting with the current
284  * scope. We don't want to add anything new to the namespace here,
285  * however, so we use MODE_EXECUTE.
286  * Allow searching of the parent tree, but don't open a new scope -
287  * we just want to lookup the object (must be mode EXECUTE to perform
288  * the upsearch)
289  */
290  Status = AcpiNsLookup (WalkState->ScopeInfo, Path,
293 
294  /*
295  * If this name is a control method invocation, we must
296  * setup the method call
297  */
298  if (ACPI_SUCCESS (Status) &&
299  PossibleMethodCall &&
300  (Node->Type == ACPI_TYPE_METHOD))
301  {
302  if ((GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_SUPERNAME) ||
303  (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_TARGET))
304  {
305  /*
306  * AcpiPsGetNextNamestring has increased the AML pointer past
307  * the method invocation namestring, so we need to restore the
308  * saved AML pointer back to the original method invocation
309  * namestring.
310  */
311  WalkState->ParserState.Aml = Start;
312  WalkState->ArgCount = 1;
314  }
315 
316  /* This name is actually a control method invocation */
317 
318  MethodDesc = AcpiNsGetAttachedObject (Node);
320  "Control Method invocation %4.4s - %p Desc %p Path=%p\n",
321  Node->Name.Ascii, Node, MethodDesc, Path));
322 
324  if (!NameOp)
325  {
327  }
328 
329  /* Change Arg into a METHOD CALL and attach name to it */
330 
332  NameOp->Common.Value.Name = Path;
333 
334  /* Point METHODCALL/NAME to the METHOD Node */
335 
336  NameOp->Common.Node = Node;
337  AcpiPsAppendArg (Arg, NameOp);
338 
339  if (!MethodDesc)
340  {
342  "Control Method %p has no attached object",
343  Node));
345  }
346 
348  "Control Method - %p Args %X\n",
349  Node, MethodDesc->Method.ParamCount));
350 
351  /* Get the number of arguments to expect */
352 
353  WalkState->ArgCount = MethodDesc->Method.ParamCount;
355  }
356 
357  /*
358  * Special handling if the name was not found during the lookup -
359  * some NotFound cases are allowed
360  */
361  if (Status == AE_NOT_FOUND)
362  {
363  /* 1) NotFound is ok during load pass 1/2 (allow forward references) */
364 
365  if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) !=
367  {
368  Status = AE_OK;
369  }
370 
371  /* 2) NotFound during a CondRefOf(x) is ok by definition */
372 
373  else if (WalkState->Op->Common.AmlOpcode == AML_CONDITIONAL_REF_OF_OP)
374  {
375  Status = AE_OK;
376  }
377 
378  /*
379  * 3) NotFound while building a Package is ok at this point, we
380  * may flag as an error later if slack mode is not enabled.
381  * (Some ASL code depends on allowing this behavior)
382  */
383  else if ((Arg->Common.Parent) &&
384  ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
385  (Arg->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
386  {
387  Status = AE_OK;
388  }
389  }
390 
391  /* Final exception check (may have been changed from code above) */
392 
393  if (ACPI_FAILURE (Status))
394  {
395  ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo, Path, Status);
396 
397  if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
399  {
400  /* Report a control method execution error */
401 
402  Status = AcpiDsMethodError (Status, WalkState);
403  }
404  }
405 
406  /* Save the namepath */
407 
408  Arg->Common.Value.Name = Path;
410 }
#define ACPI_NS_SEARCH_PARENT
Definition: acnamesp.h:63
ACPI_STATUS AcpiDsMethodError(ACPI_STATUS Status, ACPI_WALK_STATE *WalkState)
Definition: dsmethod.c:223
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
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:329
#define AE_NO_MEMORY
Definition: acexcep.h:112
void AcpiPsInitOp(ACPI_PARSE_OBJECT *op, UINT16 opcode)
Definition: psutils.c:98
#define ARGP_SUPERNAME
Definition: amlcode.h:235
#define AE_AML_INTERNAL
Definition: acexcep.h:194
#define AML_INT_METHODCALL_OP
Definition: amlcode.h:210
UINT32 ArgTypes
Definition: acstruct.h:92
ACPI_PARSE_OBJECT * AcpiPsAllocOp(UINT16 Opcode, UINT8 *Aml)
Definition: psutils.c:130
#define ACPI_DB_PARSE
Definition: acoutput.h:162
UINT32 ParseFlags
Definition: acstruct.h:95
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_PARSE_EXECUTE
Definition: acparser.h:61
#define AML_VARIABLE_PACKAGE_OP
Definition: amlcode.h:63
#define AML_INT_NAMEPATH_OP
Definition: amlcode.h:205
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ARGP_TARGET
Definition: amlcode.h:236
union node Node
Definition: types.h:1255
#define ACPI_NS_DONT_OPEN_SCOPE
Definition: acnamesp.h:64
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_TYPE_METHOD
Definition: actypes.h:686
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
char * AcpiPsGetNextNamestring(ACPI_PARSE_STATE *ParserState)
Definition: psargs.c:172
void AcpiPsAppendArg(ACPI_PARSE_OBJECT *op, ACPI_PARSE_OBJECT *arg)
Definition: pstree.c:138
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
#define AE_NOT_FOUND
Definition: acexcep.h:113
Definition: partlist.h:33
ACPI_GENERIC_STATE * ScopeInfo
Definition: acstruct.h:124
#define ACPI_TYPE_ANY
Definition: actypes.h:678
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
#define AML_CONDITIONAL_REF_OF_OP
Definition: amlcode.h:162
Status
Definition: gdiplustypes.h:24
ACPI_OBJECT_METHOD Method
Definition: acobject.h:522
#define ACPI_PARSE_MODE_MASK
Definition: acparser.h:62
UINT32 ArgCount
Definition: acstruct.h:99
PRTL_UNICODE_STRING_BUFFER Path
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define GET_CURRENT_ARG_TYPE(List)
Definition: acmacros.h:450
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define ACPI_ERROR_NAMESPACE(s, p, e)
Definition: acmacros.h:462
unsigned char UINT8
#define AE_OK
Definition: acexcep.h:97
#define AML_PACKAGE_OP
Definition: amlcode.h:62
Definition: dlist.c:348

Referenced by AcpiPsGetArguments(), and AcpiPsGetNextArg().

◆ AcpiPsGetNextNamestring()

char* AcpiPsGetNextNamestring ( ACPI_PARSE_STATE ParserState)

Definition at line 172 of file psargs.c.

174 {
175  UINT8 *Start = ParserState->Aml;
176  UINT8 *End = ParserState->Aml;
177 
178 
179  ACPI_FUNCTION_TRACE (PsGetNextNamestring);
180 
181 
182  /* Point past any namestring prefix characters (backslash or carat) */
183 
184  while (ACPI_IS_ROOT_PREFIX (*End) ||
185  ACPI_IS_PARENT_PREFIX (*End))
186  {
187  End++;
188  }
189 
190  /* Decode the path prefix character */
191 
192  switch (*End)
193  {
194  case 0:
195 
196  /* NullName */
197 
198  if (End == Start)
199  {
200  Start = NULL;
201  }
202  End++;
203  break;
204 
206 
207  /* Two name segments */
208 
209  End += 1 + (2 * ACPI_NAMESEG_SIZE);
210  break;
211 
213 
214  /* Multiple name segments, 4 chars each, count in next byte */
215 
216  End += 2 + (*(End + 1) * ACPI_NAMESEG_SIZE);
217  break;
218 
219  default:
220 
221  /* Single name segment */
222 
223  End += ACPI_NAMESEG_SIZE;
224  break;
225  }
226 
227  ParserState->Aml = End;
228  return_PTR ((char *) Start);
229 }
#define return_PTR(s)
Definition: acoutput.h:497
#define AML_DUAL_NAME_PREFIX
Definition: amlcode.h:66
smooth NULL
Definition: ftsmooth.c:416
Definition: partlist.h:33
#define ACPI_IS_PARENT_PREFIX(c)
Definition: acmacros.h:402
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AML_MULTI_NAME_PREFIX
Definition: amlcode.h:67
#define ACPI_IS_ROOT_PREFIX(c)
Definition: acmacros.h:401
#define ACPI_NAMESEG_SIZE
Definition: actypes.h:415
unsigned char UINT8

Referenced by AcpiDsLoad1BeginOp(), AcpiDsLoad2BeginOp(), AcpiInstallMethod(), AcpiPsGetNextField(), AcpiPsGetNextNamepath(), and AcpiPsGetNextSimpleArg().

◆ AcpiPsGetNextPackageEnd()

UINT8* AcpiPsGetNextPackageEnd ( ACPI_PARSE_STATE ParserState)

Definition at line 138 of file psargs.c.

140 {
141  UINT8 *Start = ParserState->Aml;
142  UINT32 PackageLength;
143 
144 
145  ACPI_FUNCTION_TRACE (PsGetNextPackageEnd);
146 
147 
148  /* Function below updates ParserState->Aml */
149 
150  PackageLength = AcpiPsGetNextPackageLength (ParserState);
151 
152  return_PTR (Start + PackageLength); /* end of package */
153 }
static UINT32 AcpiPsGetNextPackageLength(ACPI_PARSE_STATE *ParserState)
Definition: psargs.c:81
#define return_PTR(s)
Definition: acoutput.h:497
unsigned int UINT32
Definition: partlist.h:33
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
unsigned char UINT8

Referenced by AcpiInstallMethod(), AcpiPsGetNextArg(), AcpiPsNextParseState(), and AcpiPsParseLoop().

◆ AcpiPsGetNextSimpleArg()

void AcpiPsGetNextSimpleArg ( ACPI_PARSE_STATE ParserState,
UINT32  ArgType,
ACPI_PARSE_OBJECT Arg 
)

Definition at line 428 of file psargs.c.

432 {
433  UINT32 Length;
434  UINT16 Opcode;
435  UINT8 *Aml = ParserState->Aml;
436 
437 
438  ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType);
439 
440 
441  switch (ArgType)
442  {
443  case ARGP_BYTEDATA:
444 
445  /* Get 1 byte from the AML stream */
446 
448  Arg->Common.Value.Integer = (UINT64) *Aml;
449  Length = 1;
450  break;
451 
452  case ARGP_WORDDATA:
453 
454  /* Get 2 bytes from the AML stream */
455 
457  ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml);
458  Length = 2;
459  break;
460 
461  case ARGP_DWORDDATA:
462 
463  /* Get 4 bytes from the AML stream */
464 
466  ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml);
467  Length = 4;
468  break;
469 
470  case ARGP_QWORDDATA:
471 
472  /* Get 8 bytes from the AML stream */
473 
475  ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml);
476  Length = 8;
477  break;
478 
479  case ARGP_CHARLIST:
480 
481  /* Get a pointer to the string, point past the string */
482 
484  Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml);
485 
486  /* Find the null terminator */
487 
488  Length = 0;
489  while (Aml[Length])
490  {
491  Length++;
492  }
493  Length++;
494  break;
495 
496  case ARGP_NAME:
497  case ARGP_NAMESTRING:
498 
500  Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState);
501  return_VOID;
502 
503  default:
504 
505  ACPI_ERROR ((AE_INFO, "Invalid ArgType 0x%X", ArgType));
506  return_VOID;
507  }
508 
509  AcpiPsInitOp (Arg, Opcode);
510  ParserState->Aml += Length;
511  return_VOID;
512 }
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:330
#define ARGP_NAMESTRING
Definition: amlcode.h:232
void AcpiPsInitOp(ACPI_PARSE_OBJECT *op, UINT16 opcode)
Definition: psutils.c:98
#define ACPI_MOVE_16_TO_64(d, s)
Definition: acmacros.h:143
#define AML_BYTE_OP
Definition: amlcode.h:55
#define ACPI_FUNCTION_TRACE_U32(a, b)
Definition: acoutput.h:482
#define AML_QWORD_OP
Definition: amlcode.h:59
#define AML_DWORD_OP
Definition: amlcode.h:57
#define AML_INT_NAMEPATH_OP
Definition: amlcode.h:205
#define AML_STRING_OP
Definition: amlcode.h:58
unsigned int UINT32
#define AML_WORD_OP
Definition: amlcode.h:56
#define AE_INFO
Definition: acoutput.h:230
#define ARGP_BYTEDATA
Definition: amlcode.h:224
#define ACPI_MOVE_32_TO_64(d, s)
Definition: acmacros.h:149
#define ARGP_WORDDATA
Definition: amlcode.h:239
#define ARGP_QWORDDATA
Definition: amlcode.h:240
char * AcpiPsGetNextNamestring(ACPI_PARSE_STATE *ParserState)
Definition: psargs.c:172
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define return_VOID
Definition: acoutput.h:495
#define ARGP_DWORDDATA
Definition: amlcode.h:229
unsigned short UINT16
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define ARGP_CHARLIST
Definition: amlcode.h:226
#define ACPI_MOVE_64_TO_64(d, s)
Definition: acmacros.h:155
unsigned long long UINT64
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
unsigned char UINT8
#define ARGP_NAME
Definition: amlcode.h:231
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN UINT8 * Aml
Definition: acpixf.h:1287

Referenced by AcpiPsGetArguments(), and AcpiPsGetNextArg().

◆ AcpiPsGetNextWalkOp()

ACPI_STATUS AcpiPsGetNextWalkOp ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
ACPI_PARSE_UPWARDS  AscendingCallback 
)

◆ AcpiPsGetOpcodeInfo()

const ACPI_OPCODE_INFO* AcpiPsGetOpcodeInfo ( UINT16  Opcode)

Definition at line 72 of file psopinfo.c.

74 {
75 #ifdef ACPI_DEBUG_OUTPUT
76  const char *OpcodeName = "Unknown AML opcode";
77 #endif
78 
79  ACPI_FUNCTION_NAME (PsGetOpcodeInfo);
80 
81 
82  /*
83  * Detect normal 8-bit opcode or extended 16-bit opcode
84  */
85  if (!(Opcode & 0xFF00))
86  {
87  /* Simple (8-bit) opcode: 0-255, can't index beyond table */
88 
90  }
91 
92  if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
94  {
95  /* Valid extended (16-bit) opcode */
96 
98  }
99 
100 #if defined ACPI_ASL_COMPILER && defined ACPI_DEBUG_OUTPUT
101 #include "asldefine.h"
102 
103  switch (Opcode)
104  {
105  case AML_RAW_DATA_BYTE:
106  OpcodeName = "-Raw Data Byte-";
107  break;
108 
109  case AML_RAW_DATA_WORD:
110  OpcodeName = "-Raw Data Word-";
111  break;
112 
113  case AML_RAW_DATA_DWORD:
114  OpcodeName = "-Raw Data Dword-";
115  break;
116 
117  case AML_RAW_DATA_QWORD:
118  OpcodeName = "-Raw Data Qword-";
119  break;
120 
121  case AML_RAW_DATA_BUFFER:
122  OpcodeName = "-Raw Data Buffer-";
123  break;
124 
125  case AML_RAW_DATA_CHAIN:
126  OpcodeName = "-Raw Data Buffer Chain-";
127  break;
128 
129  case AML_PACKAGE_LENGTH:
130  OpcodeName = "-Package Length-";
131  break;
132 
133  case AML_UNASSIGNED_OPCODE:
134  OpcodeName = "-Unassigned Opcode-";
135  break;
136 
137  case AML_DEFAULT_ARG_OP:
138  OpcodeName = "-Default Arg-";
139  break;
140 
141  default:
142  break;
143  }
144 #endif
145 
146  /* Unknown AML opcode */
147 
149  "%s [%4.4X]\n", OpcodeName, Opcode));
150 
151  return (&AcpiGbl_AmlOpInfo [_UNK]);
152 }
const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]
Definition: psopcode.c:188
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:330
#define _UNK
Definition: acopcode.h:54
const UINT8 AcpiGbl_ShortOpIndex[256]
Definition: psopinfo.c:220
#define MAX_EXTENDED_OPCODE
Definition: acopcode.h:47
#define AML_EXTENDED_OPCODE
Definition: amlcode.h:156
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE]
Definition: psopinfo.c:262
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
unsigned char UINT8

Referenced by AcpiDsBuildInternalObject(), AcpiDsCreateOperand(), AcpiDsExecBeginOp(), AcpiDsInitObjectFromOp(), AcpiDsIsResultUsed(), AcpiDsLoad1EndOp(), AcpiExResolveOperands(), AcpiPsAllocOp(), AcpiPsAppendArg(), AcpiPsCompleteFinalOp(), AcpiPsCompleteOp(), AcpiPsCompleteThisOp(), AcpiPsCreateOp(), AcpiPsGetAmlOpcode(), AcpiPsGetArg(), AcpiPsGetOpcodeName(), AcpiPsInitOp(), and AcpiPsParseLoop().

◆ AcpiPsGetOpcodeName()

const char* AcpiPsGetOpcodeName ( UINT16  Opcode)

Definition at line 169 of file psopinfo.c.

171 {
172 #if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
173 
174  const ACPI_OPCODE_INFO *Op;
175 
176 
178 
179  /* Always guaranteed to return a valid pointer */
180 
181  return (Op->Name);
182 
183 #else
184  return ("OpcodeName unavailable");
185 
186 #endif
187 }
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:330
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72

Referenced by AcpiDsEvalBankFieldOperands(), AcpiDsEvalBufferFieldOperands(), AcpiDsExecEndOp(), AcpiDsInitBufferField(), AcpiDsIsResultUsed(), AcpiDsLoad2EndOp(), AcpiExOpcode_0A_0T_1R(), AcpiExOpcode_1A_0T_0R(), AcpiExOpcode_1A_0T_1R(), AcpiExOpcode_1A_1T_0R(), AcpiExOpcode_1A_1T_1R(), AcpiExOpcode_2A_0T_0R(), AcpiExOpcode_2A_0T_1R(), AcpiExOpcode_2A_1T_1R(), AcpiExOpcode_2A_2T_1R(), AcpiExOpcode_3A_0T_0R(), AcpiExOpcode_3A_1T_1R(), AcpiExOpcode_6A_0T_1R(), AcpiExResolveOperands(), AcpiPsDeleteParseTree(), and AcpiPsParseLoop().

◆ AcpiPsGetOpcodeSize()

UINT32 AcpiPsGetOpcodeSize ( UINT32  Opcode)

Definition at line 78 of file psparse.c.

80 {
81 
82  /* Extended (2-byte) opcode if > 255 */
83 
84  if (Opcode > 0x00FF)
85  {
86  return (2);
87  }
88 
89  /* Otherwise, just a single byte opcode */
90 
91  return (1);
92 }
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:330

Referenced by AcpiInstallMethod(), and AcpiPsGetAmlOpcode().

◆ AcpiPsGetParent()

ACPI_PARSE_OBJECT* AcpiPsGetParent ( ACPI_PARSE_OBJECT Op)

◆ AcpiPsGetParentScope()

ACPI_PARSE_OBJECT* AcpiPsGetParentScope ( ACPI_PARSE_STATE state)

Definition at line 65 of file psscope.c.

67 {
68 
69  return (ParserState->Scope->ParseScope.Op);
70 }

Referenced by AcpiDsLoad1BeginOp(), and AcpiPsCreateOp().

◆ AcpiPsHasCompletedScope()

BOOLEAN AcpiPsHasCompletedScope ( ACPI_PARSE_STATE ParserState)

Definition at line 88 of file psscope.c.

90 {
91 
92  return ((BOOLEAN)
93  ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd ||
94  !ParserState->Scope->ParseScope.ArgCount)));
95 }
ACPI_STATE_COMMON UINT32 ArgCount
Definition: aclocal.h:748
unsigned char BOOLEAN
ACPI_PSCOPE_STATE ParseScope
Definition: aclocal.h:826
union acpi_generic_state * Scope
Definition: aclocal.h:1108
UINT8 * ArgEnd
Definition: aclocal.h:750

Referenced by AcpiPsCompleteOp(), and AcpiPsParseLoop().

◆ AcpiPsInitOp()

void AcpiPsInitOp ( ACPI_PARSE_OBJECT op,
UINT16  opcode 
)

Definition at line 98 of file psutils.c.

101 {
103 
104 
105  Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER;
106  Op->Common.AmlOpcode = Opcode;
107 
108  ACPI_DISASM_ONLY_MEMBERS (AcpiUtSafeStrncpy (Op->Common.AmlOpName,
110  sizeof (Op->Common.AmlOpName)));
111 }
#define ACPI_DISASM_ONLY_MEMBERS(a)
Definition: aclocal.h:907
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:330
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define ACPI_DESC_TYPE_PARSER
Definition: acobject.h:572

Referenced by AcpiPsAllocOp(), AcpiPsGetNextNamepath(), and AcpiPsGetNextSimpleArg().

◆ AcpiPsInitScope()

ACPI_STATUS AcpiPsInitScope ( ACPI_PARSE_STATE ParserState,
ACPI_PARSE_OBJECT Root 
)

Definition at line 112 of file psscope.c.

115 {
116  ACPI_GENERIC_STATE *Scope;
117 
118 
119  ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp);
120 
121 
122  Scope = AcpiUtCreateGenericState ();
123  if (!Scope)
124  {
126  }
127 
128  Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE;
129  Scope->ParseScope.Op = RootOp;
131  Scope->ParseScope.ArgEnd = ParserState->AmlEnd;
132  Scope->ParseScope.PkgEnd = ParserState->AmlEnd;
133 
134  ParserState->Scope = Scope;
135  ParserState->StartOp = RootOp;
136 
138 }
ACPI_STATE_COMMON UINT32 ArgCount
Definition: aclocal.h:748
UINT8 * PkgEnd
Definition: aclocal.h:751
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_GENERIC_STATE * AcpiUtCreateGenericState(void)
Definition: utstate.c:130
#define ACPI_VAR_ARGS
Definition: acparser.h:52
#define ACPI_DESC_TYPE_STATE_RPSCOPE
Definition: acobject.h:565
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
UINT8 * AmlEnd
Definition: aclocal.h:1103
union acpi_parse_object * StartOp
Definition: aclocal.h:1106
ACPI_COMMON_STATE Common
Definition: aclocal.h:822
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
union acpi_parse_object * Op
Definition: aclocal.h:749
ACPI_PSCOPE_STATE ParseScope
Definition: aclocal.h:826
union acpi_generic_state * Scope
Definition: aclocal.h:1108
UINT8 * ArgEnd
Definition: aclocal.h:750
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiDsInitAmlWalk().

◆ AcpiPsIsLeadingChar()

BOOLEAN AcpiPsIsLeadingChar ( UINT32  c)

Definition at line 249 of file psutils.c.

251 {
252  return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z')));
253 }
unsigned char BOOLEAN
const GLubyte * c
Definition: glext.h:8905

Referenced by AcpiPsGetNextArg().

◆ AcpiPsNextParseState()

ACPI_STATUS AcpiPsNextParseState ( ACPI_WALK_STATE WalkState,
ACPI_PARSE_OBJECT Op,
ACPI_STATUS  CallbackStatus 
)

Definition at line 337 of file psparse.c.

341 {
342  ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
344 
345 
346  ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op);
347 
348 
349  switch (CallbackStatus)
350  {
351  case AE_CTRL_TERMINATE:
352  /*
353  * A control method was terminated via a RETURN statement.
354  * The walk of this method is complete.
355  */
356  ParserState->Aml = ParserState->AmlEnd;
358  break;
359 
360  case AE_CTRL_BREAK:
361 
362  ParserState->Aml = WalkState->AmlLastWhile;
363  WalkState->ControlState->Common.Value = FALSE;
365  break;
366 
367  case AE_CTRL_CONTINUE:
368 
369  ParserState->Aml = WalkState->AmlLastWhile;
371  break;
372 
373  case AE_CTRL_PENDING:
374 
375  ParserState->Aml = WalkState->AmlLastWhile;
376  break;
377 
378 #if 0
379  case AE_CTRL_SKIP:
380 
381  ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
382  Status = AE_OK;
383  break;
384 #endif
385 
386  case AE_CTRL_TRUE:
387  /*
388  * Predicate of an IF was true, and we are at the matching ELSE.
389  * Just close out this package
390  */
391  ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
393  break;
394 
395  case AE_CTRL_FALSE:
396  /*
397  * Either an IF/WHILE Predicate was false or we encountered a BREAK
398  * opcode. In both cases, we do not execute the rest of the
399  * package; We simply close out the parent (finishing the walk of
400  * this branch of the tree) and continue execution at the parent
401  * level.
402  */
403  ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
404 
405  /* In the case of a BREAK, just force a predicate (if any) to FALSE */
406 
407  WalkState->ControlState->Common.Value = FALSE;
409  break;
410 
411  case AE_CTRL_TRANSFER:
412 
413  /* A method call (invocation) -- transfer control */
414 
416  WalkState->PrevOp = Op;
417  WalkState->MethodCallOp = Op;
418  WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
419 
420  /* Will return value (if any) be used by the caller? */
421 
422  WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
423  break;
424 
425  default:
426 
429  {
430  Status = AE_OK;
431  }
432  break;
433  }
434 
436 }
#define AE_CODE_MASK
Definition: acexcep.h:60
#define AE_CTRL_END
Definition: acexcep.h:230
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
ACPI_PARSE_OBJECT * PrevOp
Definition: acstruct.h:125
UINT8 * PkgEnd
Definition: aclocal.h:751
BOOLEAN AcpiDsIsResultUsed(ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
Definition: dsutils.c:187
#define AE_CTRL_TRANSFER
Definition: acexcep.h:231
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_GENERIC_STATE * ControlState
Definition: acstruct.h:110
#define AE_CTRL_PENDING
Definition: acexcep.h:225
#define AE_CTRL_FALSE
Definition: acexcep.h:228
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
struct acpi_namespace_node * MethodCallNode
Definition: acstruct.h:113
#define AE_CTRL_CONTINUE
Definition: acexcep.h:233
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
UINT8 * AmlEnd
Definition: aclocal.h:1103
#define AE_CTRL_TRUE
Definition: acexcep.h:227
UINT8 * AcpiPsGetNextPackageEnd(ACPI_PARSE_STATE *ParserState)
Definition: psargs.c:138
ACPI_PARSE_OBJECT * MethodCallOp
Definition: acstruct.h:114
_In_ FLT_PREOP_CALLBACK_STATUS CallbackStatus
Definition: fltkernel.h:1020
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
ACPI_COMMON_STATE Common
Definition: aclocal.h:822
Status
Definition: gdiplustypes.h:24
UINT8 ReturnUsed
Definition: acstruct.h:85
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define AE_CTRL_BREAK
Definition: acexcep.h:232
ACPI_OBJECT_COMMON Common
Definition: acobject.h:516
#define AE_CODE_CONTROL
Definition: acexcep.h:57
ACPI_PSCOPE_STATE ParseScope
Definition: aclocal.h:826
union acpi_generic_state * Scope
Definition: aclocal.h:1108
UINT8 * AmlLastWhile
Definition: acstruct.h:108
#define AE_OK
Definition: acexcep.h:97

Referenced by AcpiPsBuildNamedOp(), AcpiPsCompleteFinalOp(), AcpiPsCompleteOp(), AcpiPsCreateOp(), and AcpiPsParseLoop().

◆ AcpiPsParseAml()

ACPI_STATUS AcpiPsParseAml ( ACPI_WALK_STATE WalkState)

Definition at line 453 of file psparse.c.

455 {
458  ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList;
459  ACPI_WALK_STATE *PreviousWalkState;
460 
461 
462  ACPI_FUNCTION_TRACE (PsParseAml);
463 
465  "Entered with WalkState=%p Aml=%p size=%X\n",
466  WalkState, WalkState->ParserState.Aml,
467  WalkState->ParserState.AmlSize));
468 
469  if (!WalkState->ParserState.Aml)
470  {
472  }
473 
474  /* Create and initialize a new thread state */
475 
477  if (!Thread)
478  {
479  if (WalkState->MethodDesc)
480  {
481  /* Executing a control method - additional cleanup */
482 
483  AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
484  }
485 
486  AcpiDsDeleteWalkState (WalkState);
488  }
489 
490  WalkState->Thread = Thread;
491 
492  /*
493  * If executing a method, the starting SyncLevel is this method's
494  * SyncLevel
495  */
496  if (WalkState->MethodDesc)
497  {
498  WalkState->Thread->CurrentSyncLevel =
499  WalkState->MethodDesc->Method.SyncLevel;
500  }
501 
502  AcpiDsPushWalkState (WalkState, Thread);
503 
504  /*
505  * This global allows the AML debugger to get a handle to the currently
506  * executing control method.
507  */
508  AcpiGbl_CurrentWalkList = Thread;
509 
510  /*
511  * Execute the walk loop as long as there is a valid Walk State. This
512  * handles nested control method invocations without recursion.
513  */
514  ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
515 
516  Status = AE_OK;
517  while (WalkState)
518  {
519  if (ACPI_SUCCESS (Status))
520  {
521  /*
522  * The ParseLoop executes AML until the method terminates
523  * or calls another method.
524  */
525  Status = AcpiPsParseLoop (WalkState);
526  }
527 
529  "Completed one call to walk loop, %s State=%p\n",
530  AcpiFormatException (Status), WalkState));
531 
532  if (WalkState->MethodPathname && WalkState->MethodIsNested)
533  {
534  /* Optional object evaluation log */
535 
536  ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EVALUATION, "%-26s: %*s%s\n",
537  " Exit nested method",
538  (WalkState->MethodNestingDepth + 1) * 3, " ",
539  &WalkState->MethodPathname[1]));
540 
541  ACPI_FREE (WalkState->MethodPathname);
542  WalkState->MethodIsNested = FALSE;
543  }
544  if (Status == AE_CTRL_TRANSFER)
545  {
546  /*
547  * A method call was detected.
548  * Transfer control to the called control method
549  */
550  Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
551  if (ACPI_FAILURE (Status))
552  {
553  Status = AcpiDsMethodError (Status, WalkState);
554  }
555 
556  /*
557  * If the transfer to the new method method call worked
558  *, a new walk state was created -- get it
559  */
560  WalkState = AcpiDsGetCurrentWalkState (Thread);
561  continue;
562  }
563  else if (Status == AE_CTRL_TERMINATE)
564  {
565  Status = AE_OK;
566  }
567  else if ((Status != AE_OK) && (WalkState->MethodDesc))
568  {
569  /* Either the method parse or actual execution failed */
570 
572  if (Status == AE_ABORT_METHOD)
573  {
575  WalkState->MethodNode, "Aborting method");
576  AcpiOsPrintf ("\n");
577  }
578  else
579  {
580  ACPI_ERROR_METHOD ("Aborting method",
581  WalkState->MethodNode, NULL, Status);
582  }
584 
585  /* Check for possible multi-thread reentrancy problem */
586 
587  if ((Status == AE_ALREADY_EXISTS) &&
588  (!(WalkState->MethodDesc->Method.InfoFlags &
590  {
591  /*
592  * Method is not serialized and tried to create an object
593  * twice. The probable cause is that the method cannot
594  * handle reentrancy. Mark as "pending serialized" now, and
595  * then mark "serialized" when the last thread exits.
596  */
597  WalkState->MethodDesc->Method.InfoFlags |=
599  }
600  }
601 
602  /* We are done with this walk, move on to the parent if any */
603 
604  WalkState = AcpiDsPopWalkState (Thread);
605 
606  /* Reset the current scope to the beginning of scope stack */
607 
608  AcpiDsScopeStackClear (WalkState);
609 
610  /*
611  * If we just returned from the execution of a control method or if we
612  * encountered an error during the method parse phase, there's lots of
613  * cleanup to do
614  */
615  if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) ==
617  !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) ||
618  (ACPI_FAILURE (Status)))
619  {
620  AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
621  }
622 
623  /* Delete this walk state and all linked control states */
624 
625  AcpiPsCleanupScope (&WalkState->ParserState);
626  PreviousWalkState = WalkState;
627 
629  "ReturnValue=%p, ImplicitValue=%p State=%p\n",
630  WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState));
631 
632  /* Check if we have restarted a preempted walk */
633 
634  WalkState = AcpiDsGetCurrentWalkState (Thread);
635  if (WalkState)
636  {
637  if (ACPI_SUCCESS (Status))
638  {
639  /*
640  * There is another walk state, restart it.
641  * If the method return value is not used by the parent,
642  * The object is deleted
643  */
644  if (!PreviousWalkState->ReturnDesc)
645  {
646  /*
647  * In slack mode execution, if there is no return value
648  * we should implicitly return zero (0) as a default value.
649  */
650  if (AcpiGbl_EnableInterpreterSlack &&
651  !PreviousWalkState->ImplicitReturnObj)
652  {
653  PreviousWalkState->ImplicitReturnObj =
655  if (!PreviousWalkState->ImplicitReturnObj)
656  {
658  }
659  }
660 
661  /* Restart the calling control method */
662 
663  Status = AcpiDsRestartControlMethod (WalkState,
664  PreviousWalkState->ImplicitReturnObj);
665  }
666  else
667  {
668  /*
669  * We have a valid return value, delete any implicit
670  * return value.
671  */
672  AcpiDsClearImplicitReturn (PreviousWalkState);
673 
674  Status = AcpiDsRestartControlMethod (WalkState,
675  PreviousWalkState->ReturnDesc);
676  }
677  if (ACPI_SUCCESS (Status))
678  {
679  WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
680  }
681  }
682  else
683  {
684  /* On error, delete any return object or implicit return */
685 
686  AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
687  AcpiDsClearImplicitReturn (PreviousWalkState);
688  }
689  }
690 
691  /*
692  * Just completed a 1st-level method, save the final internal return
693  * value (if any)
694  */
695  else if (PreviousWalkState->CallerReturnDesc)
696  {
697  if (PreviousWalkState->ImplicitReturnObj)
698  {
699  *(PreviousWalkState->CallerReturnDesc) =
700  PreviousWalkState->ImplicitReturnObj;
701  }
702  else
703  {
704  /* NULL if no return value */
705 
706  *(PreviousWalkState->CallerReturnDesc) =
707  PreviousWalkState->ReturnDesc;
708  }
709  }
710  else
711  {
712  if (PreviousWalkState->ReturnDesc)
713  {
714  /* Caller doesn't want it, must delete it */
715 
716  AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
717  }
718  if (PreviousWalkState->ImplicitReturnObj)
719  {
720  /* Caller doesn't want it, must delete it */
721 
722  AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj);
723  }
724  }
725 
726  AcpiDsDeleteWalkState (PreviousWalkState);
727  }
728 
729  /* Normal exit */
730 
733  AcpiGbl_CurrentWalkList = PrevWalkList;
735 }
#define ACPI_DEBUG_PRINT_RAW(pl)
Definition: acoutput.h:476
#define ACPI_FREE(a)
Definition: actypes.h:386
ACPI_THREAD_STATE * Thread
Definition: acstruct.h:127
ACPI_STATUS AcpiDsMethodError(ACPI_STATUS Status, ACPI_WALK_STATE *WalkState)
Definition: dsmethod.c:223
char * MethodPathname
Definition: acstruct.h:117
void AcpiDsPushWalkState(ACPI_WALK_STATE *WalkState, ACPI_THREAD_STATE *Thread)
Definition: dswstate.c:526
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
union acpi_operand_object * ImplicitReturnObj
Definition: acstruct.h:112
void AcpiDsDeleteWalkState(ACPI_WALK_STATE *WalkState)
Definition: dswstate.c:780
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ACPI_METHOD_SERIALIZED
Definition: acobject.h:237
ACPI_OBJECT_COMMON_HEADER UINT8 InfoFlags
Definition: acobject.h:215
#define AE_ABORT_METHOD
Definition: acexcep.h:132
ACPI_THREAD_STATE * AcpiUtCreateThreadState(void)
Definition: utstate.c:164
#define AE_CTRL_TRANSFER
Definition: acexcep.h:231
ACPI_STATUS AcpiDsRestartControlMethod(ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ReturnDesc)
Definition: dsmethod.c:685
union acpi_operand_object * ReturnDesc
Definition: acstruct.h:123
#define ACPI_DB_PARSE
Definition: acoutput.h:162
UINT32 ParseFlags
Definition: acstruct.h:95
UINT32 ACPI_STATUS
Definition: actypes.h:460
void AcpiExReleaseAllMutexes(ACPI_THREAD_STATE *Thread)
Definition: exmutex.c:536
void AcpiPsCleanupScope(ACPI_PARSE_STATE *state)
Definition: psscope.c:277
#define ACPI_PARSE_EXECUTE
Definition: acparser.h:61
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
const char * AcpiFormatException(ACPI_STATUS Status)
Definition: utexcep.c:70
ACPI_WALK_STATE * AcpiDsPopWalkState(ACPI_THREAD_STATE *Thread)
Definition: dswstate.c:555
smooth NULL
Definition: ftsmooth.c:416
#define AE_BAD_ADDRESS
Definition: acexcep.h:159
#define ACPI_METHOD_SERIALIZED_PENDING
Definition: acobject.h:238
UINT8 WalkType
Definition: acstruct.h:77
void AcpiNsPrintNodePathname(ACPI_NAMESPACE_NODE *Node, const char *Msg)
Definition: nsutils.c:75
ACPI_WALK_STATE * AcpiDsGetCurrentWalkState(ACPI_THREAD_STATE *Thread)
Definition: dswstate.c:494
ACPI_STATE_COMMON UINT8 CurrentSyncLevel
Definition: aclocal.h:764
UINT16 MethodNestingDepth
Definition: acstruct.h:100
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
union acpi_operand_object * MethodDesc
Definition: acstruct.h:115
ACPI_OPERAND_OBJECT * AcpiUtCreateIntegerObject(UINT64 Value)
Definition: utobject.c:223
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define ACPI_ERROR_METHOD(s, n, p, e)
Definition: acmacros.h:463
void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf(const char *Format,...)
Definition: osl.c:851
void AcpiDsScopeStackClear(ACPI_WALK_STATE *WalkState)
Definition: dswscope.c:67
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
struct acpi_namespace_node * MethodNode
Definition: acstruct.h:116
Status
Definition: gdiplustypes.h:24
ACPI_OBJECT_METHOD Method
Definition: acobject.h:522
#define ACPI_PARSE_MODE_MASK
Definition: acparser.h:62
void AcpiExExitInterpreter(void)
Definition: exutils.c:139
void AcpiExEnterInterpreter(void)
Definition: exutils.c:91
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_PARSE_MODULE_LEVEL
Definition: acparser.h:67
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
union acpi_operand_object ** CallerReturnDesc
Definition: acstruct.h:109
ACPI_STATUS AcpiDsCallControlMethod(ACPI_THREAD_STATE *Thread, ACPI_WALK_STATE *ThisWalkState, ACPI_PARSE_OBJECT *Op)
Definition: dsmethod.c:531
#define ACPI_DB_EVALUATION
Definition: acoutput.h:181
unsigned long long UINT64
#define ACPI_WALK_METHOD_RESTART
Definition: acstruct.h:70
UINT8 MethodIsNested
Definition: acstruct.h:101
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
ACPI_STATUS AcpiPsParseLoop(ACPI_WALK_STATE *WalkState)
Definition: psloop.c:259
UINT32 AmlSize
Definition: aclocal.h:1110
#define AE_OK
Definition: acexcep.h:97
void AcpiDsTerminateControlMethod(ACPI_OPERAND_OBJECT *MethodDesc, ACPI_WALK_STATE *WalkState)
Definition: dsmethod.c:779
void AcpiDsClearImplicitReturn(ACPI_WALK_STATE *WalkState)
Definition: dsutils.c:73

Referenced by AcpiDsAutoSerializeMethod(), AcpiDsExecuteArguments(), AcpiNsOneCompleteParse(), AcpiPsExecuteMethod(), and AcpiPsExecuteTable().

◆ AcpiPsParseLoop()

ACPI_STATUS AcpiPsParseLoop ( ACPI_WALK_STATE WalkState)

Definition at line 259 of file psloop.c.

261 {
263  ACPI_PARSE_OBJECT *Op = NULL; /* current op */
264  ACPI_PARSE_STATE *ParserState;
265  UINT8 *AmlOpStart = NULL;
266  UINT8 OpcodeLength;
267 
268 
269  ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState);
270 
271 
272  if (WalkState->DescendingCallback == NULL)
273  {
275  }
276 
277  ParserState = &WalkState->ParserState;
278  WalkState->ArgTypes = 0;
279 
280 #ifndef ACPI_CONSTANT_EVAL_ONLY
281 
282  if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART)
283  {
284  /* We are restarting a preempted control method */
285 
286  if (AcpiPsHasCompletedScope (ParserState))
287  {
288  /*
289  * We must check if a predicate to an IF or WHILE statement
290  * was just completed
291  */
292  if ((ParserState->Scope->ParseScope.Op) &&
293  ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) ||
294  (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) &&
295  (WalkState->ControlState) &&
296  (WalkState->ControlState->Common.State ==
298  {
299  /*
300  * A predicate was just completed, get the value of the
301  * predicate and branch based on that value
302  */
303  WalkState->Op = NULL;
305  if (ACPI_FAILURE (Status) &&
307  {
309  {
311  "Invoked method did not return a value"));
312  }
313 
314  ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed"));
316  }
317 
318  Status = AcpiPsNextParseState (WalkState, Op, Status);
319  }
320 
321  AcpiPsPopScope (ParserState, &Op,
322  &WalkState->ArgTypes, &WalkState->ArgCount);
323  ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
324  }
325  else if (WalkState->PrevOp)
326  {
327  /* We were in the middle of an op */
328 
329  Op = WalkState->PrevOp;
330  WalkState->ArgTypes = WalkState->PrevArgTypes;
331  }
332  }
333 #endif
334 
335  /* Iterative parsing loop, while there is more AML to process: */
336 
337  while ((ParserState->Aml < ParserState->AmlEnd) || (Op))
338  {
339  ASL_CV_CAPTURE_COMMENTS (WalkState);
340 
341  AmlOpStart = ParserState->Aml;
342  if (!Op)
343  {
344  Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op);
345  if (ACPI_FAILURE (Status))
346  {
347  /*
348  * ACPI_PARSE_MODULE_LEVEL means that we are loading a table by
349  * executing it as a control method. However, if we encounter
350  * an error while loading the table, we need to keep trying to
351  * load the table rather than aborting the table load. Set the
352  * status to AE_OK to proceed with the table load.
353  */
354  if ((WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL) &&
356  {
357  Status = AE_OK;
358  }
360  {
361  continue;
362  }
363 
365  {
366  Status = AE_OK;
367  }
368 
369  if (Status == AE_CTRL_TERMINATE)
370  {
372  }
373 
374  Status = AcpiPsCompleteOp (WalkState, &Op, Status);
375  if (ACPI_FAILURE (Status))
376  {
378  }
379  if (AcpiNsOpensScope (
380  AcpiPsGetOpcodeInfo (WalkState->Opcode)->ObjectType))
381  {
382  /*
383  * If the scope/device op fails to parse, skip the body of
384  * the scope op because the parse failure indicates that
385  * the device may not exist.
386  */
387  ACPI_INFO (("Skipping parse of AML opcode: %s (0x%4.4X)",
388  AcpiPsGetOpcodeName (WalkState->Opcode), WalkState->Opcode));
389 
390  /*
391  * Determine the opcode length before skipping the opcode.
392  * An opcode can be 1 byte or 2 bytes in length.
393  */
394  OpcodeLength = 1;
395  if ((WalkState->Opcode & 0xFF00) == AML_EXTENDED_OPCODE)
396  {
397  OpcodeLength = 2;
398  }
399  WalkState->ParserState.Aml = WalkState->Aml + OpcodeLength;
400 
401  WalkState->ParserState.Aml =
403  WalkState->Aml = WalkState->ParserState.Aml;
404  }
405 
406  continue;
407  }
408 
409  AcpiExStartTraceOpcode (Op, WalkState);
410  }
411 
412  /*
413  * Start ArgCount at zero because we don't know if there are
414  * any args yet
415  */
416  WalkState->ArgCount = 0;
417 
418  switch (Op->Common.AmlOpcode)
419  {
420  case AML_BYTE_OP:
421  case AML_WORD_OP:
422  case AML_DWORD_OP:
423  case AML_QWORD_OP:
424 
425  break;
426 
427  default:
428 
429  ASL_CV_CAPTURE_COMMENTS (WalkState);
430  break;
431  }
432 
433  /* Are there any arguments that must be processed? */
434 
435  if (WalkState->ArgTypes)
436  {
437  /* Get arguments */
438 
439  Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op);
440  if (ACPI_FAILURE (Status))
441  {
442  Status = AcpiPsCompleteOp (WalkState, &Op, Status);
443  if (ACPI_FAILURE (Status))
444  {
446  }
447  if ((WalkState->ControlState) &&
448  ((WalkState->ControlState->Control.Opcode == AML_IF_OP) ||
449  (WalkState->ControlState->Control.Opcode == AML_WHILE_OP)))
450  {
451  /*
452  * If the if/while op fails to parse, we will skip parsing
453  * the body of the op.
454  */
455  ParserState->Aml =
456  WalkState->ControlState->Control.AmlPredicateStart + 1;
457  ParserState->Aml =
458  AcpiPsGetNextPackageEnd (ParserState);
459  WalkState->Aml = ParserState->Aml;
460 
461  ACPI_ERROR ((AE_INFO, "Skipping While/If block"));
462  if (*WalkState->Aml == AML_ELSE_OP)
463  {
464  ACPI_ERROR ((AE_INFO, "Skipping Else block"));
465  WalkState->ParserState.Aml = WalkState->Aml + 1;
466  WalkState->ParserState.Aml =
467  AcpiPsGetNextPackageEnd (ParserState);
468  WalkState->Aml = ParserState->Aml;
469  }
471  }
472  Op = NULL;
473  continue;
474  }
475  }
476 
477  /* Check for arguments that need to be processed */
478 
480  "Parseloop: argument count: %8.8X\n", WalkState->ArgCount));
481 
482  if (WalkState->ArgCount)
483  {
484  /*
485  * There are arguments (complex ones), push Op and
486  * prepare for argument
487  */
488  Status = AcpiPsPushScope (ParserState, Op,
489  WalkState->ArgTypes, WalkState->ArgCount);
490  if (ACPI_FAILURE (Status))
491  {
492  Status = AcpiPsCompleteOp (WalkState, &Op, Status);
493  if (ACPI_FAILURE (Status))
494  {
496  }
497 
498  continue;
499  }
500 
501  Op = NULL;
502  continue;
503  }
504 
505  /*
506  * All arguments have been processed -- Op is complete,
507  * prepare for next
508  */
509  WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
510  if (WalkState->OpInfo->Flags & AML_NAMED)
511  {
512  if (Op->Common.AmlOpcode == AML_REGION_OP ||
513  Op->Common.AmlOpcode == AML_DATA_REGION_OP)
514  {
515  /*
516  * Skip parsing of control method or opregion body,
517  * because we don't have enough info in the first pass
518  * to parse them correctly.
519  *
520  * Completed parsing an OpRegion declaration, we now
521  * know the length.
522  */
523  Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
524  }
525  }
526 
527  if (WalkState->OpInfo->Flags & AML_CREATE)
528  {
529  /*
530  * Backup to beginning of CreateXXXfield declaration (1 for
531  * Opcode)
532  *
533  * BodyLength is unknown until we parse the body
534  */
535  Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
536  }
537 
538  if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
539  {
540  /*
541  * Backup to beginning of BankField declaration
542  *
543  * BodyLength is unknown until we parse the body
544  */
545  Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
546  }
547 
548  /* This op complete, notify the dispatcher */
549 
550  if (WalkState->AscendingCallback != NULL)
551  {
552  WalkState->Op = Op;
553  WalkState->Opcode = Op->Common.AmlOpcode;
554 
555  Status = WalkState->AscendingCallback (WalkState);
556  Status = AcpiPsNextParseState (WalkState, Op, Status);
557  if (Status == AE_CTRL_PENDING)
558  {
559  Status = AE_OK;
560  }
561  else if ((WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL) &&
563  Status == AE_NOT_FOUND))
564  {
565  /*
566  * ACPI_PARSE_MODULE_LEVEL flag means that we are currently
567  * loading a table by executing it as a control method.
568  * However, if we encounter an error while loading the table,
569  * we need to keep trying to load the table rather than
570  * aborting the table load (setting the status to AE_OK
571  * continues the table load). If we get a failure at this
572  * point, it means that the dispatcher got an error while
573  * trying to execute the Op.
574  */
575  Status = AE_OK;
576  }
577  }
578 
579  Status = AcpiPsCompleteOp (WalkState, &Op, Status);
580  if (ACPI_FAILURE (Status))
581  {
583  }
584 
585  } /* while ParserState->Aml */
586 
587  Status = AcpiPsCompleteFinalOp (WalkState, Op, Status);
589 }
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define AE_CODE_MASK
Definition: acexcep.h:60
#define ACPI_FREE(a)
Definition: actypes.h:386
#define AE_CTRL_PARSE_PENDING
Definition: acexcep.h:235
ACPI_PARSE_OBJ_COMMON Common
Definition: aclocal.h:1078
#define AML_NAMED
Definition: amlcode.h:323
#define AML_ELSE_OP
Definition: amlcode.h:135
ACPI_STATE_COMMON UINT16 Opcode
Definition: aclocal.h:725
#define TRUE
Definition: types.h:120
const char * AcpiPsGetOpcodeName(UINT16 Opcode)
Definition: psopinfo.c:169
ACPI_PARSE_OBJECT * PrevOp
Definition: acstruct.h:125
#define AML_IF_OP
Definition: amlcode.h:134
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AML_WHILE_OP
Definition: amlcode.h:136
#define AML_BYTE_OP
Definition: amlcode.h:55
UINT8 ObjectType
Definition: aclocal.h:874
UINT32 ArgTypes
Definition: acstruct.h:92
const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo(UINT16 Opcode)
Definition: psopinfo.c:72
#define ACPI_DB_PARSE
Definition: acoutput.h:162
UINT32 ParseFlags
Definition: acstruct.h:95
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define AML_QWORD_OP
Definition: amlcode.h:59
ACPI_GENERIC_STATE * ControlState
Definition: acstruct.h:110
#define AML_DWORD_OP
Definition: amlcode.h:57
#define AML_REGION_OP
Definition: amlcode.h:180
#define AE_CTRL_PENDING
Definition: acexcep.h:225
ACPI_GENERIC_STATE * AcpiUtPopGenericState(ACPI_GENERIC_STATE **ListHead)
Definition: utstate.c:93
#define ASL_CV_CAPTURE_COMMENTS(a)
Definition: acmacros.h:526
void AcpiPsPopScope(ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT **Op, UINT32 *ArgList, UINT32 *ArgCount)
Definition: psscope.c:219
ACPI_PARSE_UPWARDS AscendingCallback
Definition: acstruct.h:129
#define ACPI_TO_POINTER(i)
Definition: actypes.h:552
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AML_CREATE
Definition: amlcode.h:320
#define AE_CTRL_TERMINATE
Definition: acexcep.h:226
#define ACPI_CONTROL_PREDICATE_EXECUTING
Definition: aclocal.h:671
unsigned int UINT32
#define AML_EXTENDED_OPCODE
Definition: amlcode.h:156
#define AML_WORD_OP
Definition: amlcode.h:56
UINT8 * AmlPredicateStart
Definition: aclocal.h:727
#define AE_CTRL_PARSE_CONTINUE
Definition: acexcep.h:234
ACPI_STATUS AcpiPsNextParseState(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS CallbackStatus)
Definition: psparse.c:337
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
UINT8 WalkType
Definition: acstruct.h:77
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_STATUS AcpiPsPushScope(ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Op, UINT32 RemainingArgs, UINT32 ArgCount)
Definition: psscope.c:157
UINT8 * AmlEnd
Definition: aclocal.h:1103
ACPI_PARSE_OBJ_NAMED Named
Definition: aclocal.h:1079
#define AE_AML_NO_RETURN_VALUE
Definition: acexcep.h:197
UINT32 AcpiNsOpensScope(ACPI_OBJECT_TYPE Type)
Definition: nsutils.c:736
ACPI_CONTROL_STATE Control
Definition: aclocal.h:823
#define AML_BANK_FIELD_OP
Definition: amlcode.h:187
static ACPI_STATUS AcpiPsGetArguments(ACPI_WALK_STATE *WalkState, UINT8 *AmlOpStart, ACPI_PARSE_OBJECT *Op)
Definition: psloop.c:89
ACPI_PARSE_OBJECT * Op
Definition: acstruct.h:118
BOOLEAN AcpiPsHasCompletedScope(ACPI_PARSE_STATE *ParserState)
Definition: psscope.c:88
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
ACPI_STATUS AcpiPsCreateOp(ACPI_WALK_STATE *WalkState, UINT8 *AmlOpStart, ACPI_PARSE_OBJECT **NewOp)
Definition: psobject.c:344
UINT8 * AcpiPsGetNextPackageEnd(ACPI_PARSE_STATE *ParserState)
Definition: psargs.c:138
#define AE_NOT_FOUND
Definition: acexcep.h:113
const ACPI_OPCODE_INFO * OpInfo
Definition: acstruct.h:119
ACPI_PARSE_STATE ParserState
Definition: acstruct.h:97
#define ACPI_AML_EXCEPTION(Status)
Definition: acexcep.h:100
ACPI_COMMON_STATE Common
Definition: aclocal.h:822
#define ACPI_INFO(plist)
Definition: acoutput.h:237
Status
Definition: gdiplustypes.h:24
ACPI_PARSE_DOWNWARDS DescendingCallback
Definition: acstruct.h:128
UINT32 ArgCount
Definition: acstruct.h:99
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_PARSE_MODULE_LEVEL
Definition: acparser.h:67
union acpi_parse_object * Op
Definition: aclocal.h:749
#define AE_CODE_CONTROL
Definition: acexcep.h:57
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
ACPI_PSCOPE_STATE ParseScope
Definition: aclocal.h:826
union acpi_generic_state * Scope
Definition: aclocal.h:1108
ACPI_STATUS AcpiDsGetPredicateValue(ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ResultObj)
Definition: dswexec.c:92
UINT16 Opcode
Definition: acstruct.h:78
ACPI_STATUS AcpiPsCompleteOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **Op, ACPI_STATUS Status)
Definition: psobject.c:495
#define ACPI_WALK_METHOD_RESTART
Definition: acstruct.h:70
UINT32 PrevArgTypes
Definition: acstruct.h:98
unsigned char UINT8
#define AML_DATA_REGION_OP
Definition: amlcode.h:188
#define AE_OK
Definition: acexcep.h:97
UINT16 Flags
Definition: aclocal.h:873
ACPI_STATUS AcpiPsCompleteFinalOp(ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS Status)
Definition: psobject.c:707
void AcpiExStartTraceOpcode(ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState)
Definition: extrace.c:353
UINT8 * Aml
Definition: acstruct.h:91

Referenced by AcpiPsParseAml().

◆ AcpiPsPeekOpcode()

UINT16 AcpiPsPeekOpcode ( ACPI_PARSE_STATE state)

Definition at line 108 of file psparse.c.

110 {
111  UINT8 *Aml;
112  UINT16 Opcode;
113 
114 
115  Aml = ParserState->Aml;
116  Opcode = (UINT16) ACPI_GET8 (Aml);
117 
119  {
120  /* Extended opcode, get the second opcode byte */
121 
122  Aml++;
123  Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
124  }
125 
126  return (Opcode);
127 }
_In_ PVOID _In_ ULONG Opcode
Definition: hubbusif.h:330
#define ACPI_GET8(ptr)
Definition: acmacros.h:57
#define AML_EXTENDED_PREFIX
Definition: amlcode.h:68
unsigned short UINT16
unsigned char UINT8
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 const char BOOLEAN UINT8 * Aml
Definition: acpixf.h:1287

Referenced by AcpiInstallMethod(), AcpiPsGetAmlOpcode(), and AcpiPsGetNextArg().

◆ AcpiPsPopScope()

void AcpiPsPopScope ( ACPI_PARSE_STATE ParserState,
ACPI_PARSE_OBJECT **  Op,
UINT32 ArgList,
UINT32 ArgCount 
)

Definition at line 219 of file psscope.c.

224 {
225  ACPI_GENERIC_STATE *Scope = ParserState->Scope;
226 
227 
228  ACPI_FUNCTION_TRACE (PsPopScope);
229 
230 
231  /* Only pop the scope if there is in fact a next scope */
232 
233  if (Scope->Common.Next)
234  {
235  Scope = AcpiUtPopGenericState (&ParserState->Scope);
236 
237  /* Return to parsing previous op */
238 
239  *Op = Scope->ParseScope.Op;
240  *ArgList = Scope->ParseScope.ArgList;
241  *ArgCount = Scope->ParseScope.ArgCount;
242  ParserState->PkgEnd = Scope->ParseScope.PkgEnd;
243 
244  /* All done with this scope state structure */
245 
246  AcpiUtDeleteGenericState (Scope);
247  }
248  else
249  {
250  /* Empty parse stack, prepare to fetch next opcode */
251 
252  *Op = NULL;
253  *ArgList = 0;
254  *ArgCount = 0;
255  }
256 
258  "Popped Op %p Args %X\n", *Op, *ArgCount));
259  return_VOID;
260 }
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
UINT8 * PkgEnd
Definition: aclocal.h:1105
ACPI_STATE_COMMON UINT32 ArgCount
Definition: aclocal.h:748
UINT8 * PkgEnd
Definition: aclocal.h:751
#define ACPI_DB_PARSE
Definition: acoutput.h:162
ACPI_GENERIC_STATE * AcpiUtPopGenericState(ACPI_GENERIC_STATE **ListHead)
Definition: utstate.c:93
smooth NULL
Definition: ftsmooth.c:416
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define return_VOID
Definition: acoutput.h:495
ACPI_COMMON_STATE Common
Definition: aclocal.h:822
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
union acpi_parse_object * Op
Definition: aclocal.h:749
ACPI_PSCOPE_STATE ParseScope
Definition: aclocal.h:826
union acpi_generic_state * Scope
Definition: aclocal.h:1108
UINT32 ArgList
Definition: aclocal.h:752

Referenced by AcpiPsCompleteFinalOp(), AcpiPsCompleteOp(), and AcpiPsParseLoop().

◆ AcpiPsPushScope()

ACPI_STATUS AcpiPsPushScope ( ACPI_PARSE_STATE ParserState,
ACPI_PARSE_OBJECT Op,
UINT32  RemainingArgs,
UINT32  ArgCount 
)

Definition at line 157 of file psscope.c.

162 {
163  ACPI_GENERIC_STATE *Scope;
164 
165 
166  ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op);
167 
168 
169  Scope = AcpiUtCreateGenericState ();
170  if (!Scope)
171  {
173  }
174 
175  Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE;
176  Scope->ParseScope.Op = Op;
177  Scope->ParseScope.ArgList = RemainingArgs;
178  Scope->ParseScope.ArgCount = ArgCount;
179  Scope->ParseScope.PkgEnd = ParserState->PkgEnd;
180 
181  /* Push onto scope stack */
182 
183  AcpiUtPushGenericState (&ParserState->Scope, Scope);
184 
185  if (ArgCount == ACPI_VAR_ARGS)
186  {
187  /* Multiple arguments */
188 
189  Scope->ParseScope.ArgEnd = ParserState->PkgEnd;
190  }
191  else
192  {
193  /* Single argument */
194 
195  Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR);
196  }
197 
199 }
UINT8 * PkgEnd
Definition: aclocal.h:1105
ACPI_STATE_COMMON UINT32 ArgCount
Definition: aclocal.h:748
UINT8 * PkgEnd
Definition: aclocal.h:751
#define AE_NO_MEMORY
Definition: acexcep.h:112
ACPI_GENERIC_STATE * AcpiUtCreateGenericState(void)
Definition: utstate.c:130
#define ACPI_VAR_ARGS
Definition: acparser.h:52
#define ACPI_DESC_TYPE_STATE_PSCOPE
Definition: acobject.h:566
void AcpiUtPushGenericState(ACPI_GENERIC_STATE **ListHead, ACPI_GENERIC_STATE *State)
Definition: utstate.c:65
#define ACPI_TO_POINTER(i)
Definition: actypes.h:552
#define ACPI_FUNCTION_TRACE_PTR(a, b)
Definition: acoutput.h:481
ACPI_COMMON_STATE Common
Definition: aclocal.h:822
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
union acpi_parse_object * Op
Definition: aclocal.h:749
ACPI_PSCOPE_STATE ParseScope
Definition: aclocal.h:826
union acpi_generic_state * Scope
Definition: aclocal.h:1108
UINT8 * ArgEnd
Definition: aclocal.h:750
#define AE_OK
Definition: acexcep.h:97
UINT32 ArgList
Definition: aclocal.h:752

Referenced by AcpiPsParseLoop().

◆ AcpiPsSetName()

void AcpiPsSetName ( ACPI_PARSE_OBJECT op,
UINT32  name 
)

Definition at line 281 of file psutils.c.

284 {
285 
286  /* The "generic" object has no name associated with it */
287 
288  if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
289  {
290  return;
291  }
292 
293  Op->Named.Name = name;
294 }
#define ACPI_PARSEOP_GENERIC
Definition: aclocal.h:1117
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by AcpiDsAutoSerializeMethod(), and AcpiPsGetNextField().

◆ AcpiPsShow()

void AcpiPsShow ( ACPI_PARSE_OBJECT op)

◆ AcpiPsSprintOp()

UINT32 AcpiPsSprintOp ( char BufferStart,
UINT32  BufferSize,
ACPI_PARSE_OBJECT Op 
)

◆ AcpiPsSprintPath()

UINT32 AcpiPsSprintPath ( char BufferStart,
UINT32  BufferSize,
ACPI_PARSE_OBJECT Op 
)

◆ AcpiPsWalkParsedAml()

ACPI_STATUS AcpiPsWalkParsedAml ( ACPI_PARSE_OBJECT StartOp,
ACPI_PARSE_OBJECT EndOp,
ACPI_OPERAND_OBJECT MthDesc,
ACPI_NAMESPACE_NODE StartNode,
ACPI_OPERAND_OBJECT **  Params,
ACPI_OPERAND_OBJECT **  CallerReturnDesc,
ACPI_OWNER_ID  OwnerId,
ACPI_PARSE_DOWNWARDS  DescendingCallback,
ACPI_PARSE_UPWARDS  AscendingCallback 
)

Variable Documentation

◆ AcpiGbl_LongOpIndex

const UINT8 AcpiGbl_LongOpIndex[]

Definition at line 262 of file psopinfo.c.

Referenced by AcpiPsGetOpcodeInfo().

◆ AcpiGbl_ShortOpIndex

const UINT8 AcpiGbl_ShortOpIndex[]

Definition at line 220 of file psopinfo.c.

Referenced by AcpiPsGetOpcodeInfo().