/* Wait for a period for the RTC to be ready. */
EFI_STATUS RtcWaitToUpdate(UINTN Timeout)
/* Wait for a period for the RTC to be ready. */
EFI_STATUS RtcWaitToUpdate(UINTN Timeout)
{
  RTC_REGISTER_A  RegisterA;
  RTC_REGISTER_D  RegisterD;
  RegisterD.Data = RtcRead (RTC_ADDRESS_REGISTER_D);
  if (RegisterD.Bits.Vrt == 0) {
    return EFI_DEVICE_ERROR;
  }
  Timeout        = (Timeout / 10) + 1;
  RegisterA.Data = RtcRead (RTC_ADDRESS_REGISTER_A);
  while (RegisterA.Bits.Uip == 1 && Timeout > 0) {
    MicroSecondDelay (10);
    RegisterA.Data = RtcRead (RTC_ADDRESS_REGISTER_A);
    Timeout--;
  }
  RegisterD.Data = RtcRead (RTC_ADDRESS_REGISTER_D);
  if ((Timeout == 0) || (RegisterD.Bits.Vrt == 0)) {
    return EFI_DEVICE_ERROR;
  }
  return EFI_SUCCESS;
}