/* A Buffer is allocated to store the raw AML absolute path. */
STATIC EFI_STATUS EFIAPI AmlCreateMethodRefNode(IN CONST AML_OBJECT_NODE *ObjectNode, IN CONST CHAR8 *RawAbsolutePath, IN UINT32 RawAbsolutePathSize, OUT AML_NAMESPACE_REF_NODE **NameSpaceRefNodePtr)
/* A Buffer is allocated to store the raw AML absolute path. */
STATIC EFI_STATUS EFIAPI AmlCreateMethodRefNode(IN CONST AML_OBJECT_NODE *ObjectNode, IN CONST CHAR8 *RawAbsolutePath, IN UINT32 RawAbsolutePathSize, OUT AML_NAMESPACE_REF_NODE **NameSpaceRefNodePtr)
{
  AML_NAMESPACE_REF_NODE  *NameSpaceRefNode;
  if (!AmlNodeHasAttribute (ObjectNode, AML_IN_NAMESPACE) ||
      (RawAbsolutePath == NULL)                           ||
      (RawAbsolutePathSize == 0)                          ||
      (NameSpaceRefNodePtr == NULL))
  {
    ASSERT (0);
    return EFI_INVALID_PARAMETER;
  }
  NameSpaceRefNode = AllocateZeroPool (sizeof (AML_NAMESPACE_REF_NODE));
  if (NameSpaceRefNode == NULL) {
    ASSERT (0);
    return EFI_OUT_OF_RESOURCES;
  }
  NameSpaceRefNode->RawAbsolutePathSize = RawAbsolutePathSize;
  NameSpaceRefNode->RawAbsolutePath     = AllocateCopyPool (
                                            RawAbsolutePathSize,
                                            RawAbsolutePath
                                            );
  if (NameSpaceRefNode->RawAbsolutePath == NULL) {
    FreePool (NameSpaceRefNode);
    ASSERT (0);
    return EFI_OUT_OF_RESOURCES;
  }
  InitializeListHead (&NameSpaceRefNode->Link);
  NameSpaceRefNode->NodeRef = ObjectNode;
  *NameSpaceRefNodePtr      = NameSpaceRefNode;
  return EFI_SUCCESS;
}