/* This is an internal function to add a terminate node the entry, recalculate the table length and fill into the table. */
UINT8* S3BootScriptInternalCloseTable(VOID)
/* This is an internal function to add a terminate node the entry, recalculate the table length and fill into the table. */
UINT8* S3BootScriptInternalCloseTable(VOID)
{
  UINT8                         *S3TableBase;
  EFI_BOOT_SCRIPT_TERMINATE     ScriptTerminate;
  EFI_BOOT_SCRIPT_TABLE_HEADER  *ScriptTableInfo;
  S3TableBase = mS3BootScriptTablePtr->TableBase;
  if (S3TableBase == NULL) {
    return S3TableBase;
  }
  ScriptTerminate.OpCode = S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE;
  ScriptTerminate.Length = (UINT8)sizeof (EFI_BOOT_SCRIPT_TERMINATE);
  CopyMem (mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength, &ScriptTerminate, sizeof (EFI_BOOT_SCRIPT_TERMINATE));
  ScriptTableInfo              = (EFI_BOOT_SCRIPT_TABLE_HEADER *)(mS3BootScriptTablePtr->TableBase);
  ScriptTableInfo->TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);
  return S3TableBase;
}