Implement ArcGetTime() and ArcGetRelativeTime()

svn path=/trunk/; revision=40686
This commit is contained in:
Hervé Poussineau 2009-04-24 20:35:11 +00:00
parent 7d9f43ff96
commit ee3fc1bc60
16 changed files with 163 additions and 272 deletions

View file

@ -54,7 +54,7 @@ MachInit(const char *CmdLine)
MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry; MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry;
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry; MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount; MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;
MachVtbl.RTCGetCurrentDateTime = PcRTCGetCurrentDateTime; MachVtbl.GetTime = PcGetTime;
MachVtbl.HwDetect = PcHwDetect; MachVtbl.HwDetect = PcHwDetect;
} }

View file

@ -1,104 +1,5 @@
/* $Id: pcrtc.c 21339 2006-03-18 22:09:16Z peterw $ /* No need to duplicate code ; import the i386 version */
*
* FreeLoader
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <freeldr.h> #include "../i386/pcrtc.c"
#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
VOID
PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
{
REGS Regs;
if (NULL != Year || NULL != Month || NULL != Day)
{
/* Some BIOSes, such es the 1998/07/25 system ROM
* in the Compaq Deskpro EP/SB, leave CF unchanged
* if successful, so CF should be cleared before
* calling this function. */
__asm__ ("clc");
/* Int 1Ah AH=04h
* TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
*
* AH = 04h
* CF clear to avoid bug
* Return:
* CF clear if successful
* CH = century (BCD)
* CL = year (BCD)
* DH = month (BCD)
* DL = day (BCD)
* CF set on error
*/
Regs.b.ah = 0x04;
Int386(0x1A, &Regs, &Regs);
if (NULL != Year)
{
*Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl);
}
if (NULL != Month)
{
*Month = BCD_INT(Regs.b.dh);
}
if (NULL != Day)
{
*Day = BCD_INT(Regs.b.dl);
}
}
if (NULL != Hour || NULL != Minute || NULL != Second)
{
/* Some BIOSes leave CF unchanged if successful,
* so CF should be cleared before calling this function. */
__asm__ ("clc");
/* Int 1Ah AH=02h
* TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
*
* AH = 02h
* CF clear to avoid bug
* Return:
* CF clear if successful
* CH = hour (BCD)
* CL = minutes (BCD)
* DH = seconds (BCD)
* DL = daylight savings flag (00h standard time, 01h daylight time)
* CF set on error (i.e. clock not running or in middle of update)
*/
Regs.b.ah = 0x02;
Int386(0x1A, &Regs, &Regs);
if (NULL != Hour)
{
*Hour = BCD_INT(Regs.b.ch);
}
if (NULL != Minute)
{
*Minute = BCD_INT(Regs.b.cl);
}
if (NULL != Second)
{
*Second = BCD_INT(Regs.b.dh);
}
}
}
/* EOF */ /* EOF */

View file

@ -54,7 +54,7 @@ PcMachInit(const char *CmdLine)
MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry; MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry;
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry; MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount; MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;
MachVtbl.RTCGetCurrentDateTime = PcRTCGetCurrentDateTime; MachVtbl.GetTime = PcGetTime;
MachVtbl.HwDetect = PcHwDetect; MachVtbl.HwDetect = PcHwDetect;
} }

View file

@ -57,7 +57,7 @@ XboxMachInit(const char *CmdLine)
MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry; MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry; MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount; MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount;
MachVtbl.RTCGetCurrentDateTime = XboxRTCGetCurrentDateTime; MachVtbl.GetTime = XboxGetTime;
MachVtbl.HwDetect = XboxHwDetect; MachVtbl.HwDetect = XboxHwDetect;
/* Set LEDs to orange after init */ /* Set LEDs to orange after init */

View file

@ -21,84 +21,63 @@
#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f)) #define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
VOID TIMEINFO*
PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second) PcGetTime(VOID)
{ {
REGS Regs; static TIMEINFO TimeInfo;
REGS Regs;
if (NULL != Year || NULL != Month || NULL != Day) /* Some BIOSes, such as the 1998/07/25 system ROM
{ * in the Compaq Deskpro EP/SB, leave CF unchanged
/* Some BIOSes, such es the 1998/07/25 system ROM * if successful, so CF should be cleared before
* in the Compaq Deskpro EP/SB, leave CF unchanged * calling this function. */
* if successful, so CF should be cleared before __asm__ ("clc");
* calling this function. */
__asm__ ("clc");
/* Int 1Ah AH=04h /* Int 1Ah AH=04h
* TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS) * TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS)
* *
* AH = 04h * AH = 04h
* CF clear to avoid bug * CF clear to avoid bug
* Return: * Return:
* CF clear if successful * CF clear if successful
* CH = century (BCD) * CH = century (BCD)
* CL = year (BCD) * CL = year (BCD)
* DH = month (BCD) * DH = month (BCD)
* DL = day (BCD) * DL = day (BCD)
* CF set on error * CF set on error
*/ */
Regs.b.ah = 0x04; Regs.b.ah = 0x04;
Int386(0x1A, &Regs, &Regs); Int386(0x1A, &Regs, &Regs);
if (NULL != Year) TimeInfo.Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl);
{ TimeInfo.Month = BCD_INT(Regs.b.dh);
*Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl); TimeInfo.Day = BCD_INT(Regs.b.dl);
}
if (NULL != Month)
{
*Month = BCD_INT(Regs.b.dh);
}
if (NULL != Day)
{
*Day = BCD_INT(Regs.b.dl);
}
}
if (NULL != Hour || NULL != Minute || NULL != Second) /* Some BIOSes leave CF unchanged if successful,
{ * so CF should be cleared before calling this function. */
/* Some BIOSes leave CF unchanged if successful, __asm__ ("clc");
* so CF should be cleared before calling this function. */
__asm__ ("clc");
/* Int 1Ah AH=02h /* Int 1Ah AH=02h
* TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS) * TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS)
* *
* AH = 02h * AH = 02h
* CF clear to avoid bug * CF clear to avoid bug
* Return: * Return:
* CF clear if successful * CF clear if successful
* CH = hour (BCD) * CH = hour (BCD)
* CL = minutes (BCD) * CL = minutes (BCD)
* DH = seconds (BCD) * DH = seconds (BCD)
* DL = daylight savings flag (00h standard time, 01h daylight time) * DL = daylight savings flag (00h standard time, 01h daylight time)
* CF set on error (i.e. clock not running or in middle of update) * CF set on error (i.e. clock not running or in middle of update)
*/ */
Regs.b.ah = 0x02; Regs.b.ah = 0x02;
Int386(0x1A, &Regs, &Regs); Int386(0x1A, &Regs, &Regs);
if (NULL != Hour) TimeInfo.Hour = BCD_INT(Regs.b.ch);
{ TimeInfo.Minute = BCD_INT(Regs.b.cl);
*Hour = BCD_INT(Regs.b.ch); TimeInfo.Second = BCD_INT(Regs.b.dh);
}
if (NULL != Minute) return &TimeInfo;
{
*Minute = BCD_INT(Regs.b.cl);
}
if (NULL != Second)
{
*Second = BCD_INT(Regs.b.dh);
}
}
} }
/* EOF */ /* EOF */

View file

@ -37,46 +37,28 @@ HalpQueryCMOS(UCHAR Reg)
return(Val); return(Val);
} }
VOID TIMEINFO*
XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second) XboxGetTime(VOID)
{ {
while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP) static TIMEINFO TimeInfo;
while (HalpQueryCMOS (RTC_REGISTER_A) & RTC_REG_A_UIP)
{ {
; ;
} }
if (NULL != Second) TimeInfo.Second = BCD_INT(HalpQueryCMOS(0));
{ TimeInfo.Minute = BCD_INT(HalpQueryCMOS(2));
*Second = BCD_INT(HalpQueryCMOS(0)); TimeInfo.Hour = BCD_INT(HalpQueryCMOS(4));
} TimeInfo.Day = BCD_INT(HalpQueryCMOS(7));
if (NULL != Minute) TimeInfo.Month = BCD_INT(HalpQueryCMOS(8));
{ TimeInfo.Year = BCD_INT(HalpQueryCMOS(9));
*Minute = BCD_INT(HalpQueryCMOS(2)); if (TimeInfo.Year > 80)
} TimeInfo.Year += 1900;
if (NULL != Hour) else
{ TimeInfo.Year += 2000;
*Hour = BCD_INT(HalpQueryCMOS(4));
} return &TimeInfo;
if (NULL != Day)
{
*Day = BCD_INT(HalpQueryCMOS(7));
}
if (NULL != Month)
{
*Month = BCD_INT(HalpQueryCMOS(8));
}
if (NULL != Year)
{
*Year = BCD_INT(HalpQueryCMOS(9));
if (*Year > 80)
{
*Year += 1900;
}
else
{
*Year += 2000;
}
}
} }
/* EOF */ /* EOF */

View file

@ -342,9 +342,12 @@ ULONG PpcDiskGetCacheableBlockCount( ULONG DriveNumber ) {
return 1; return 1;
} }
VOID PpcRTCGetCurrentDateTime( PULONG Hear, PULONG Month, PULONG Day, TIMEINFO*
PULONG Hour, PULONG Minute, PULONG Second ) { PpcGetTime(VOID)
//printf("RTCGeturrentDateTime\n"); {
static TIMEINFO TimeInfo;
//printf("PpcGetTime\n");
return &TimeInfo;
} }
VOID NarrowToWide(WCHAR *wide_name, char *name) VOID NarrowToWide(WCHAR *wide_name, char *name)
@ -534,7 +537,7 @@ void PpcDefaultMachVtbl()
MachVtbl.DiskGetDriveGeometry = PpcDiskGetDriveGeometry; MachVtbl.DiskGetDriveGeometry = PpcDiskGetDriveGeometry;
MachVtbl.DiskGetCacheableBlockCount = PpcDiskGetCacheableBlockCount; MachVtbl.DiskGetCacheableBlockCount = PpcDiskGetCacheableBlockCount;
MachVtbl.RTCGetCurrentDateTime = PpcRTCGetCurrentDateTime; MachVtbl.GetTime = PpcGetTime;
MachVtbl.HwDetect = PpcHwDetect; MachVtbl.HwDetect = PpcHwDetect;
} }

View file

@ -79,7 +79,7 @@ VOID OptionMenuCustomBootDisk(VOID)
CHAR SectionName[100]; CHAR SectionName[100];
CHAR BootDriveString[20]; CHAR BootDriveString[20];
ULONG SectionId; ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second; TIMEINFO* TimeInfo;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -90,8 +90,8 @@ VOID OptionMenuCustomBootDisk(VOID)
} }
// Generate a unique section name // Generate a unique section name
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomBootDisk%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second); sprintf(SectionName, "CustomBootDisk%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section // Add the section
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
@ -122,7 +122,7 @@ VOID OptionMenuCustomBootPartition(VOID)
CHAR BootDriveString[20]; CHAR BootDriveString[20];
CHAR BootPartitionString[20]; CHAR BootPartitionString[20];
ULONG SectionId; ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second; TIMEINFO* TimeInfo;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -139,8 +139,8 @@ VOID OptionMenuCustomBootPartition(VOID)
} }
// Generate a unique section name // Generate a unique section name
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomBootPartition%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second); sprintf(SectionName, "CustomBootPartition%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section // Add the section
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
@ -178,7 +178,7 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
CHAR BootPartitionString[20]; CHAR BootPartitionString[20];
CHAR BootSectorFileString[200]; CHAR BootSectorFileString[200];
ULONG SectionId; ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second; TIMEINFO* TimeInfo;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -201,8 +201,8 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
} }
// Generate a unique section name // Generate a unique section name
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomBootSectorFile%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second); sprintf(SectionName, "CustomBootSectorFile%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section // Add the section
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
@ -248,7 +248,7 @@ VOID OptionMenuCustomBootReactOS(VOID)
CHAR ReactOSARCPath[200]; CHAR ReactOSARCPath[200];
CHAR ReactOSOptions[200]; CHAR ReactOSOptions[200];
ULONG SectionId; ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second; TIMEINFO* TimeInfo;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -277,8 +277,8 @@ VOID OptionMenuCustomBootReactOS(VOID)
} }
// Generate a unique section name // Generate a unique section name
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomReactOS%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second); sprintf(SectionName, "CustomReactOS%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section // Add the section
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))
@ -321,7 +321,7 @@ VOID OptionMenuCustomBootLinux(VOID)
CHAR LinuxInitrdString[200]; CHAR LinuxInitrdString[200];
CHAR LinuxCommandLineString[200]; CHAR LinuxCommandLineString[200];
ULONG SectionId; ULONG SectionId;
ULONG Year, Month, Day, Hour, Minute, Second; TIMEINFO* TimeInfo;
RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(SectionName, sizeof(SectionName));
RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
@ -356,8 +356,8 @@ VOID OptionMenuCustomBootLinux(VOID)
} }
// Generate a unique section name // Generate a unique section name
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second); TimeInfo = ArcGetTime();
sprintf(SectionName, "CustomLinux%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second); sprintf(SectionName, "CustomLinux%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
// Add the section // Add the section
if (!IniAddSection(SectionName, &SectionId)) if (!IniAddSection(SectionName, &SectionId))

View file

@ -55,7 +55,7 @@ BOOLEAN PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTI
BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry); BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG PcDiskGetCacheableBlockCount(ULONG DriveNumber); ULONG PcDiskGetCacheableBlockCount(ULONG DriveNumber);
VOID PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second); TIMEINFO* PcGetTime(VOID);
PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID); PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID);

View file

@ -54,7 +54,7 @@ BOOLEAN PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTI
BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry); BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG PcDiskGetCacheableBlockCount(ULONG DriveNumber); ULONG PcDiskGetCacheableBlockCount(ULONG DriveNumber);
VOID PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second); TIMEINFO* PcGetTime(VOID);
PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID); PCONFIGURATION_COMPONENT_DATA PcHwDetect(VOID);

View file

@ -57,7 +57,7 @@ BOOLEAN XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPAR
BOOLEAN XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry); BOOLEAN XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG XboxDiskGetCacheableBlockCount(ULONG DriveNumber); ULONG XboxDiskGetCacheableBlockCount(ULONG DriveNumber);
VOID XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second); TIMEINFO* XboxGetTime(VOID);
PCONFIGURATION_COMPONENT_DATA XboxHwDetect(VOID); PCONFIGURATION_COMPONENT_DATA XboxHwDetect(VOID);

View file

@ -72,7 +72,8 @@ typedef struct tagMACHVTBL
BOOLEAN (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry); BOOLEAN (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG (*DiskGetCacheableBlockCount)(ULONG DriveNumber); ULONG (*DiskGetCacheableBlockCount)(ULONG DriveNumber);
VOID (*RTCGetCurrentDateTime)(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second); TIMEINFO* (*GetTime)(VOID);
ULONG (*GetRelativeTime)(VOID);
PCONFIGURATION_COMPONENT_DATA (*HwDetect)(VOID); PCONFIGURATION_COMPONENT_DATA (*HwDetect)(VOID);
} MACHVTBL, *PMACHVTBL; } MACHVTBL, *PMACHVTBL;
@ -115,7 +116,8 @@ BOOLEAN MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, UL
BOOLEAN MachDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry); BOOLEAN MachDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOLEAN MachDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry); BOOLEAN MachDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
ULONG MachDiskGetCacheableBlockCount(ULONG DriveNumber); ULONG MachDiskGetCacheableBlockCount(ULONG DriveNumber);
VOID MachRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second); TIMEINFO* ArcGetTime(VOID);
ULONG ArcGetRelativeTime(VOID);
VOID MachHwDetect(VOID); VOID MachHwDetect(VOID);
VOID MachPrepareForReactOS(IN BOOLEAN Setup); VOID MachPrepareForReactOS(IN BOOLEAN Setup);
@ -147,7 +149,6 @@ VOID MachPrepareForReactOS(IN BOOLEAN Setup);
#define MachDiskGetPartitionEntry(Drive, Part, Entry) MachVtbl.DiskGetPartitionEntry((Drive), (Part), (Entry)) #define MachDiskGetPartitionEntry(Drive, Part, Entry) MachVtbl.DiskGetPartitionEntry((Drive), (Part), (Entry))
#define MachDiskGetDriveGeometry(Drive, Geom) MachVtbl.DiskGetDriveGeometry((Drive), (Geom)) #define MachDiskGetDriveGeometry(Drive, Geom) MachVtbl.DiskGetDriveGeometry((Drive), (Geom))
#define MachDiskGetCacheableBlockCount(Drive) MachVtbl.DiskGetCacheableBlockCount(Drive) #define MachDiskGetCacheableBlockCount(Drive) MachVtbl.DiskGetCacheableBlockCount(Drive)
#define MachRTCGetCurrentDateTime(Y, Mo, D, H, Mi, S) MachVtbl.RTCGetCurrentDateTime((Y), (Mo), (D), (H), (Mi), (S));
#define MachHwDetect() MachVtbl.HwDetect() #define MachHwDetect() MachVtbl.HwDetect()
#endif /* __MACHINE_H_ */ #endif /* __MACHINE_H_ */

View file

@ -47,7 +47,6 @@
#undef MachDiskGetPartitionEntry #undef MachDiskGetPartitionEntry
#undef MachDiskGetDriveGeometry #undef MachDiskGetDriveGeometry
#undef MachDiskGetCacheableBlockCount #undef MachDiskGetCacheableBlockCount
#undef MachRTCGetCurrentDateTime
#undef MachHwDetect #undef MachHwDetect
MACHVTBL MachVtbl; MACHVTBL MachVtbl;
@ -228,10 +227,24 @@ MachDiskGetCacheableBlockCount(ULONG DriveNumber)
return MachVtbl.DiskGetCacheableBlockCount(DriveNumber); return MachVtbl.DiskGetCacheableBlockCount(DriveNumber);
} }
VOID TIMEINFO*
MachRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second) ArcGetTime(VOID)
{ {
MachVtbl.RTCGetCurrentDateTime(Year, Month, Day, Hour, Minute, Second); return MachVtbl.GetTime();
}
ULONG
ArcGetRelativeTime(VOID)
{
TIMEINFO* TimeInfo;
ULONG ret;
if (MachVtbl.GetRelativeTime)
return MachVtbl.GetRelativeTime();
TimeInfo = ArcGetTime();
ret = ((TimeInfo->Hour * 24) + TimeInfo->Minute) * 60 + TimeInfo->Second;
return ret;
} }
VOID VOID

View file

@ -442,9 +442,8 @@ VOID TuiDrawStatusText(PCSTR StatusText)
VOID TuiUpdateDateTime(VOID) VOID TuiUpdateDateTime(VOID)
{ {
ULONG Year, Month, Day; TIMEINFO* TimeInfo;
ULONG Hour, Minute, Second; char DateString[40];
CHAR DateString[40];
CHAR TimeString[40]; CHAR TimeString[40];
CHAR TempString[20]; CHAR TempString[20];
BOOLEAN PMHour = FALSE; BOOLEAN PMHour = FALSE;
@ -452,27 +451,31 @@ VOID TuiUpdateDateTime(VOID)
/* Don't draw the time if this has been disabled */ /* Don't draw the time if this has been disabled */
if (!UiDrawTime) return; if (!UiDrawTime) return;
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second); TimeInfo = ArcGetTime();
if (Year < 1 || 9999 < Year || Month < 1 || 12 < Month || Day < 1 || if (TimeInfo->Year < 1 || 9999 < TimeInfo->Year ||
31 < Day || 23 < Hour || 59 < Minute || 59 < Second) TimeInfo->Month < 1 || 12 < TimeInfo->Month ||
TimeInfo->Day < 1 || 31 < TimeInfo->Day ||
23 < TimeInfo->Hour ||
59 < TimeInfo->Minute ||
59 < TimeInfo->Second)
{ {
/* This happens on QEmu sometimes. We just skip updating */ /* This happens on QEmu sometimes. We just skip updating */
return; return;
} }
// Get the month name // Get the month name
strcpy(DateString, UiMonthNames[Month - 1]); strcpy(DateString, UiMonthNames[TimeInfo->Month - 1]);
// Get the day // Get the day
_itoa(Day, TempString, 10); _itoa(TimeInfo->Day, TempString, 10);
// Get the day postfix // Get the day postfix
if (1 == Day || 21 == Day || 31 == Day) if (1 == TimeInfo->Day || 21 == TimeInfo->Day || 31 == TimeInfo->Day)
{ {
strcat(TempString, "st"); strcat(TempString, "st");
} }
else if (2 == Day || 22 == Day) else if (2 == TimeInfo->Day || 22 == TimeInfo->Day)
{ {
strcat(TempString, "nd"); strcat(TempString, "nd");
} }
else if (3 == Day || 23 == Day) else if (3 == TimeInfo->Day || 23 == TimeInfo->Day)
{ {
strcat(TempString, "rd"); strcat(TempString, "rd");
} }
@ -486,35 +489,35 @@ VOID TuiUpdateDateTime(VOID)
strcat(DateString, " "); strcat(DateString, " ");
// Get the year and add it to the date // Get the year and add it to the date
_itoa(Year, TempString, 10); _itoa(TimeInfo->Year, TempString, 10);
strcat(DateString, TempString); strcat(DateString, TempString);
// Draw the date // Draw the date
TuiDrawText(UiScreenWidth-strlen(DateString)-2, 1, DateString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor)); TuiDrawText(UiScreenWidth-strlen(DateString)-2, 1, DateString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
// Get the hour and change from 24-hour mode to 12-hour // Get the hour and change from 24-hour mode to 12-hour
if (Hour > 12) if (TimeInfo->Hour > 12)
{ {
Hour -= 12; TimeInfo->Hour -= 12;
PMHour = TRUE; PMHour = TRUE;
} }
if (Hour == 0) if (TimeInfo->Hour == 0)
{ {
Hour = 12; TimeInfo->Hour = 12;
} }
_itoa(Hour, TempString, 10); _itoa(TimeInfo->Hour, TempString, 10);
strcpy(TimeString, " "); strcpy(TimeString, " ");
strcat(TimeString, TempString); strcat(TimeString, TempString);
strcat(TimeString, ":"); strcat(TimeString, ":");
_itoa(Minute, TempString, 10); _itoa(TimeInfo->Minute, TempString, 10);
if (Minute < 10) if (TimeInfo->Minute < 10)
{ {
strcat(TimeString, "0"); strcat(TimeString, "0");
} }
strcat(TimeString, TempString); strcat(TimeString, TempString);
strcat(TimeString, ":"); strcat(TimeString, ":");
_itoa(Second, TempString, 10); _itoa(TimeInfo->Second, TempString, 10);
if (Second < 10) if (TimeInfo->Second < 10)
{ {
strcat(TimeString, "0"); strcat(TimeString, "0");
} }

View file

@ -23,6 +23,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
UiMenuKeyPressFilterCallback KeyPressFilter) UiMenuKeyPressFilterCallback KeyPressFilter)
{ {
UI_MENU_INFO MenuInformation; UI_MENU_INFO MenuInformation;
ULONG InitialClockSecond;
ULONG LastClockSecond; ULONG LastClockSecond;
ULONG CurrentClockSecond; ULONG CurrentClockSecond;
ULONG KeyPress; ULONG KeyPress;
@ -59,7 +60,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
// //
// Get the current second of time // Get the current second of time
// //
MachRTCGetCurrentDateTime(NULL, NULL, NULL, NULL, NULL, &LastClockSecond); InitialClockSecond = LastClockSecond = ArcGetRelativeTime();
// //
// Process keys // Process keys
@ -87,17 +88,12 @@ TuiDisplayMenu(PCSTR MenuItemList[],
// //
// Check if there is a countdown // Check if there is a countdown
// //
if (MenuInformation.MenuTimeRemaining) if (MenuInformation.MenuTimeRemaining != -1)
{ {
// //
// Get the updated time, seconds only // Get the updated time
// //
MachRTCGetCurrentDateTime(NULL, CurrentClockSecond = ArcGetRelativeTime();
NULL,
NULL,
NULL,
NULL,
&CurrentClockSecond);
// //
// Check if more then a second has now elapsed // Check if more then a second has now elapsed
@ -108,7 +104,10 @@ TuiDisplayMenu(PCSTR MenuItemList[],
// Update the time information // Update the time information
// //
LastClockSecond = CurrentClockSecond; LastClockSecond = CurrentClockSecond;
MenuInformation.MenuTimeRemaining--; MenuInformation.MenuTimeRemaining =
InitialClockSecond + MenuTimeOut - LastClockSecond;
if (MenuInformation.MenuTimeRemaining < 0)
MenuInformation.MenuTimeRemaining = 0;
// //
// Update the menu // Update the menu
@ -117,7 +116,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
VideoCopyOffScreenBufferToVRAM(); VideoCopyOffScreenBufferToVRAM();
} }
} }
else else if (MenuInformation.MenuTimeRemaining == 0)
{ {
// //
// A time out occurred, exit this loop and return default OS // A time out occurred, exit this loop and return default OS

View file

@ -121,6 +121,16 @@ typedef enum _MEMORY_TYPE
MemoryMaximum MemoryMaximum
} MEMORY_TYPE; } MEMORY_TYPE;
typedef struct _TIMEINFO
{
USHORT Year;
USHORT Month;
USHORT Day;
USHORT Hour;
USHORT Minute;
USHORT Second;
} TIMEINFO;
typedef struct _MEMORY_DESCRIPTOR typedef struct _MEMORY_DESCRIPTOR
{ {
MEMORY_TYPE MemoryType; MEMORY_TYPE MemoryType;