RealTimeClock.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
C Run-Time Libraries (CRT) Time Management Routines Wrapper Implementation
for OpenSSL-based Cryptographic Library (used in SMM).
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <OpenSslSupport.h>
#define PCAT_RTC_ADDRESS_REGISTER 0x70
#define PCAT_RTC_DATA_REGISTER 0x71
#define RTC_ADDRESS_SECONDS 0 // R/W Range 0..59
//
// Register A
//
typedef struct {
typedef union {
//
// Register B
//
typedef struct {
typedef union {
//
// -- Time Management Routines --
//
#define SECSPERMIN (60)
//
// The arrays give the cumulative number of days up to the first of the
// month number used as the index (1 -> 12) for regular and leap years.
// The value at index 13 is for the whole year.
//
{
0,
0,
31,
31 + 28,
31 + 28 + 31,
31 + 28 + 31 + 30,
31 + 28 + 31 + 30 + 31,
31 + 28 + 31 + 30 + 31 + 30,
31 + 28 + 31 + 30 + 31 + 30 + 31,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31
},
{
0,
0,
31,
31 + 29,
31 + 29 + 31,
31 + 29 + 31 + 30,
31 + 29 + 31 + 30 + 31,
31 + 29 + 31 + 30 + 31 + 30,
31 + 29 + 31 + 30 + 31 + 30 + 31,
31 + 29 + 31 + 30 + 31 + 30 + 31 + 31,
31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30,
31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31
}
};
/**
Read RTC content through its registers.
@param Address Address offset of RTC. It is recommended to use macros such as
RTC_ADDRESS_SECONDS.
@return The data of UINT8 type read from RTC.
**/
RtcRead (
)
{
IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, (UINT8) (Address | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & BIT7)));
return IoRead8 (PCAT_RTC_DATA_REGISTER);
}
/* Get the system time as seconds elapsed since midnight, January 1, 1970. */
//INTN time(
// INTN *timer
// )
{
CpuPause();
}
} else {
}
}
//
// If time is in 12 hour format, convert it to 24 hour format
//
}
Hour = 0;
}
}
//
// Years Handling
// UTime should now be set to 00:00:00 on Jan 1 of the current year.
//
}
//
// Add in number of seconds for current Month, Day, Hour, Minute, Seconds, and TimeZone adjustment
//
return *timer;
}
//
// Convert a time value from type time_t to struct tm.
//
{
return NULL;
}
return NULL;
}
YearNo++;
} else {
break;
}
}
break;
}
}
return GmTime;
}