/* Adds an integer or register to the package */
STATIC EFI_STATUS EFIAPI AmlAddRegisterOrIntegerToPackage(IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register OPTIONAL, IN UINT32 Integer, IN AML_OBJECT_NODE_HANDLE PackageNode)
/* Adds an integer or register to the package */
STATIC EFI_STATUS EFIAPI AmlAddRegisterOrIntegerToPackage(IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register OPTIONAL, IN UINT32 Integer, IN AML_OBJECT_NODE_HANDLE PackageNode)
{
  EFI_STATUS              Status;
  AML_OBJECT_NODE_HANDLE  IntegerNode;
  IntegerNode = NULL;
  if (!IsNullGenericAddress (Register)) {
    Status = AmlAddRegisterToPackage (Register, PackageNode);
  } else {
    Status = AmlCodeGenInteger (Integer, &IntegerNode);
    if (EFI_ERROR (Status)) {
      ASSERT_EFI_ERROR (Status);
      return Status;
    }
    Status = AmlVarListAddTail (
               (AML_NODE_HANDLE)PackageNode,
               (AML_NODE_HANDLE)IntegerNode
               );
  }
  if (EFI_ERROR (Status)) {
    ASSERT_EFI_ERROR (Status);
    if (IntegerNode != NULL) {
      AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode);
    }
  }
  return Status;
}