/* This function also allow to identify whether a node is a method invocation node. If the input node is not a method invocation node, just return. */
EFI_STATUS EFIAPI AmlGetMethodInvocationArgCount(IN CONST AML_OBJECT_NODE *MethodInvocationNode, OUT BOOLEAN *IsMethodInvocation, OUT UINT8 *ArgCount)
/* This function also allow to identify whether a node is a method invocation node. If the input node is not a method invocation node, just return. */
EFI_STATUS EFIAPI AmlGetMethodInvocationArgCount(IN CONST AML_OBJECT_NODE *MethodInvocationNode, OUT BOOLEAN *IsMethodInvocation, OUT UINT8 *ArgCount)
{
  AML_DATA_NODE  *NumArgsNode;
  if (!IS_AML_NODE_VALID (MethodInvocationNode) ||
      (IsMethodInvocation == NULL)              ||
      (ArgCount == NULL))
  {
    ASSERT (0);
    return EFI_INVALID_PARAMETER;
  }
  if (!AmlNodeCompareOpCode (MethodInvocationNode, AML_METHOD_INVOC_OP, 0)) {
    *IsMethodInvocation = FALSE;
    *ArgCount           = 0;
    return EFI_SUCCESS;
  }
  NumArgsNode = (AML_DATA_NODE *)AmlGetFixedArgument (
                                   (AML_OBJECT_NODE *)MethodInvocationNode,
                                   EAmlParseIndexTerm1
                                   );
  if (!IS_AML_NODE_VALID (NumArgsNode)                ||
      (NumArgsNode->Buffer == NULL)                   ||
      (NumArgsNode->DataType != EAmlNodeDataTypeUInt) ||
      (NumArgsNode->Size != 1))
  {
    ASSERT (0);
    return EFI_INVALID_PARAMETER;
  }
  *ArgCount = *NumArgsNode->Buffer;
  *IsMethodInvocation = TRUE;
  return EFI_SUCCESS;
}