- Add PL031 RTC code for Versatile.

- Add RTC time to TimeInfo convert.
- Implement FirmWare GetTime function. Countdown in FreeLDR now working.


svn path=/trunk/; revision=45414
This commit is contained in:
evb 2010-02-04 07:22:03 +00:00
parent 1dc4d1bc2e
commit d598e90edb
7 changed files with 129 additions and 6 deletions

View file

@ -26,6 +26,7 @@
<directory name="hw">
<file>keyboard.c</file>
<file>serial.c</file>
<file>time.c</file>
<file>video.c</file>
<if property="SARCH" value="omap3">
<directory name="omap3">

View file

@ -171,12 +171,11 @@ LlbFwVideoSync(VOID)
return;
}
VOID
TIMEINFO*
LlbFwGetTime(VOID)
{
printf("%s is UNIMPLEMENTED", __FUNCTION__);
while (TRUE);
return;
/* Call existing function */
return LlbGetTime();
}
/* EOF */

91
reactos/boot/armllb/hw/time.c Executable file
View file

@ -0,0 +1,91 @@
/*
* PROJECT: ReactOS Boot Loader
* LICENSE: BSD - See COPYING.ARM in the top level directory
* FILE: boot/armllb/hw/time.c
* PURPOSE: LLB Time Routines
* PROGRAMMERS: ReactOS Portable Systems Group
*/
#include "precomp.h"
#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
UCHAR LlbDaysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
TIMEINFO LlbTime;
BOOLEAN
NTAPI
LlbIsLeapYear(IN ULONG Year)
{
/* Every 4, 100, or 400 years */
return (!(Year % 4) && (Year % 100)) || !(Year % 400);
}
ULONG
NTAPI
LlbDayOfMonth(IN ULONG Month,
IN ULONG Year)
{
/* Check how many days a month has, accounting for leap yearS */
return LlbDaysInMonth[Month] + (LlbIsLeapYear(Year) && Month == 1);
}
VOID
NTAPI
LlbConvertRtcTime(IN ULONG RtcTime,
OUT TIMEINFO* TimeInfo)
{
ULONG Month, Year, Days, DaysLeft;
/* Count the days, keep the minutes */
Days = RtcTime / 86400;
RtcTime -= Days * 86400;
/* Get the year, based on days since 1970 */
Year = 1970 + Days / 365;
/* Account for leap years which changed the number of days/year */
Days -= (Year - 1970) * 365 + LEAPS_THRU_END_OF(Year - 1) - LEAPS_THRU_END_OF(1970 - 1);
if (Days < 0)
{
/* We hit a leap year, so fixup the math */
Year--;
Days += 365 + LlbIsLeapYear(Year);
}
/* Count months */
for (Month = 0; Month < 11; Month++)
{
/* How many days in this month? */
DaysLeft = Days - LlbDayOfMonth(Month, Year);
if (DaysLeft < 0) break;
/* How many days left total? */
Days = DaysLeft;
}
/* Write the structure */
TimeInfo->Year = Year;
TimeInfo->Day = Days + 1;
TimeInfo->Month = Month + 1;
TimeInfo->Hour = RtcTime / 3600;
RtcTime -= TimeInfo->Hour * 3600;
TimeInfo->Minute = RtcTime / 60;
TimeInfo->Second = RtcTime - TimeInfo->Minute * 60;
}
TIMEINFO*
NTAPI
LlbGetTime(VOID)
{
ULONG RtcTime;
/* Read RTC time */
RtcTime = LlbHwRtcRead();
/* Convert it */
LlbConvertRtcTime(RtcTime, &LlbTime);
return &LlbTime;
}
/* EOF */

View file

@ -8,6 +8,9 @@
#include "precomp.h"
#define PL031_RTC_DR (LlbHwVersaRtcBase + 0x00)
static const ULONG LlbHwVersaRtcBase = 0x101E8000;
ULONG
NTAPI
LlbHwGetBoardType(VOID)
@ -44,4 +47,10 @@ LlbHwBuildMemoryMap(IN PBIOS_MEMORY_MAP MemoryMap)
LlbAllocateMemoryEntry(BiosMemoryReserved, 0x10000000, 128 * 1024 * 1024);
}
ULONG
LlbHwRtcRead(VOID)
{
/* Read RTC value */
return READ_REGISTER_ULONG(PL031_RTC_DR);
}
/* EOF */

View file

@ -6,6 +6,16 @@
* PROGRAMMERS: ReactOS Portable Systems Group
*/
typedef struct _TIMEINFO
{
USHORT Year;
USHORT Month;
USHORT Day;
USHORT Hour;
USHORT Minute;
USHORT Second;
} TIMEINFO;
VOID
LlbFwPutChar(
INT Ch
@ -94,7 +104,7 @@ LlbFwVideoSync(
VOID
);
VOID
TIMEINFO*
LlbFwGetTime(
VOID
);

View file

@ -104,6 +104,19 @@ LlbHwLoadOsLoaderFromRam(
VOID
);
ULONG
NTAPI
LlbHwRtcRead(
VOID
);
//fix
TIMEINFO*
NTAPI
LlbGetTime(
VOID
);
#ifdef _VERSATILE_
#include "versa.h"
#elif _OMAP3_

View file

@ -11,8 +11,8 @@
#include "ioaccess.h"
#include "machtype.h"
#include "osloader.h"
#include "hw.h"
#include "fw.h"
#include "hw.h"
#include "serial.h"
#include "video.h"
#include "keyboard.h"