/* Adds a record for dispatching specified arbitrary code into a specified boot script table. */
RETURN_STATUS EFIAPI S3BootScriptSaveDispatch2(IN VOID *EntryPoint, IN VOID *Context)
/* Adds a record for dispatching specified arbitrary code into a specified boot script table. */
RETURN_STATUS EFIAPI S3BootScriptSaveDispatch2(IN VOID *EntryPoint, IN VOID *Context)
{
  UINT8                       Length;
  UINT8                       *Script;
  EFI_BOOT_SCRIPT_DISPATCH_2  ScriptDispatch2;
  if (!mS3BootScriptAcpiS3Enable) {
    return RETURN_SUCCESS;
  }
  Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
  Script = S3BootScriptGetEntryAddAddress (Length);
  if (Script == NULL) {
    return RETURN_OUT_OF_RESOURCES;
  }
  ScriptDispatch2.OpCode     = EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE;
  ScriptDispatch2.Length     = Length;
  ScriptDispatch2.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;
  ScriptDispatch2.Context    =   (EFI_PHYSICAL_ADDRESS)(UINTN)Context;
  CopyMem ((VOID *)Script, (VOID *)&ScriptDispatch2, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
  SyncBootScript (Script);
  return RETURN_SUCCESS;
}