mirror of
https://github.com/reactos/reactos.git
synced 2025-04-26 08:30:21 +00:00
Implement ArcGetTime() and ArcGetRelativeTime()
svn path=/trunk/; revision=40686
This commit is contained in:
parent
7d9f43ff96
commit
ee3fc1bc60
16 changed files with 163 additions and 272 deletions
|
@ -54,7 +54,7 @@ MachInit(const char *CmdLine)
|
|||
MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry;
|
||||
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
|
||||
MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;
|
||||
MachVtbl.RTCGetCurrentDateTime = PcRTCGetCurrentDateTime;
|
||||
MachVtbl.GetTime = PcGetTime;
|
||||
MachVtbl.HwDetect = PcHwDetect;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,104 +1,5 @@
|
|||
/* $Id: pcrtc.c 21339 2006-03-18 22:09:16Z peterw $
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/* No need to duplicate code ; import the i386 version */
|
||||
|
||||
#include <freeldr.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "../i386/pcrtc.c"
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -54,7 +54,7 @@ PcMachInit(const char *CmdLine)
|
|||
MachVtbl.DiskGetPartitionEntry = DiskGetPartitionEntry;
|
||||
MachVtbl.DiskGetDriveGeometry = PcDiskGetDriveGeometry;
|
||||
MachVtbl.DiskGetCacheableBlockCount = PcDiskGetCacheableBlockCount;
|
||||
MachVtbl.RTCGetCurrentDateTime = PcRTCGetCurrentDateTime;
|
||||
MachVtbl.GetTime = PcGetTime;
|
||||
MachVtbl.HwDetect = PcHwDetect;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ XboxMachInit(const char *CmdLine)
|
|||
MachVtbl.DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
|
||||
MachVtbl.DiskGetDriveGeometry = XboxDiskGetDriveGeometry;
|
||||
MachVtbl.DiskGetCacheableBlockCount = XboxDiskGetCacheableBlockCount;
|
||||
MachVtbl.RTCGetCurrentDateTime = XboxRTCGetCurrentDateTime;
|
||||
MachVtbl.GetTime = XboxGetTime;
|
||||
MachVtbl.HwDetect = XboxHwDetect;
|
||||
|
||||
/* Set LEDs to orange after init */
|
||||
|
|
|
@ -21,84 +21,63 @@
|
|||
|
||||
#define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
|
||||
|
||||
VOID
|
||||
PcRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
|
||||
TIMEINFO*
|
||||
PcGetTime(VOID)
|
||||
{
|
||||
REGS Regs;
|
||||
static TIMEINFO TimeInfo;
|
||||
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");
|
||||
/* Some BIOSes, such as 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);
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
TimeInfo.Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl);
|
||||
TimeInfo.Month = BCD_INT(Regs.b.dh);
|
||||
TimeInfo.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");
|
||||
/* 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);
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
TimeInfo.Hour = BCD_INT(Regs.b.ch);
|
||||
TimeInfo.Minute = BCD_INT(Regs.b.cl);
|
||||
TimeInfo.Second = BCD_INT(Regs.b.dh);
|
||||
|
||||
return &TimeInfo;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -37,46 +37,28 @@ HalpQueryCMOS(UCHAR Reg)
|
|||
return(Val);
|
||||
}
|
||||
|
||||
VOID
|
||||
XboxRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
|
||||
TIMEINFO*
|
||||
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)
|
||||
{
|
||||
*Second = BCD_INT(HalpQueryCMOS(0));
|
||||
}
|
||||
if (NULL != Minute)
|
||||
{
|
||||
*Minute = BCD_INT(HalpQueryCMOS(2));
|
||||
}
|
||||
if (NULL != Hour)
|
||||
{
|
||||
*Hour = BCD_INT(HalpQueryCMOS(4));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
TimeInfo.Second = BCD_INT(HalpQueryCMOS(0));
|
||||
TimeInfo.Minute = BCD_INT(HalpQueryCMOS(2));
|
||||
TimeInfo.Hour = BCD_INT(HalpQueryCMOS(4));
|
||||
TimeInfo.Day = BCD_INT(HalpQueryCMOS(7));
|
||||
TimeInfo.Month = BCD_INT(HalpQueryCMOS(8));
|
||||
TimeInfo.Year = BCD_INT(HalpQueryCMOS(9));
|
||||
if (TimeInfo.Year > 80)
|
||||
TimeInfo.Year += 1900;
|
||||
else
|
||||
TimeInfo.Year += 2000;
|
||||
|
||||
return &TimeInfo;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -342,9 +342,12 @@ ULONG PpcDiskGetCacheableBlockCount( ULONG DriveNumber ) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
VOID PpcRTCGetCurrentDateTime( PULONG Hear, PULONG Month, PULONG Day,
|
||||
PULONG Hour, PULONG Minute, PULONG Second ) {
|
||||
//printf("RTCGeturrentDateTime\n");
|
||||
TIMEINFO*
|
||||
PpcGetTime(VOID)
|
||||
{
|
||||
static TIMEINFO TimeInfo;
|
||||
//printf("PpcGetTime\n");
|
||||
return &TimeInfo;
|
||||
}
|
||||
|
||||
VOID NarrowToWide(WCHAR *wide_name, char *name)
|
||||
|
@ -534,7 +537,7 @@ void PpcDefaultMachVtbl()
|
|||
MachVtbl.DiskGetDriveGeometry = PpcDiskGetDriveGeometry;
|
||||
MachVtbl.DiskGetCacheableBlockCount = PpcDiskGetCacheableBlockCount;
|
||||
|
||||
MachVtbl.RTCGetCurrentDateTime = PpcRTCGetCurrentDateTime;
|
||||
MachVtbl.GetTime = PpcGetTime;
|
||||
|
||||
MachVtbl.HwDetect = PpcHwDetect;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ VOID OptionMenuCustomBootDisk(VOID)
|
|||
CHAR SectionName[100];
|
||||
CHAR BootDriveString[20];
|
||||
ULONG SectionId;
|
||||
ULONG Year, Month, Day, Hour, Minute, Second;
|
||||
TIMEINFO* TimeInfo;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
|
@ -90,8 +90,8 @@ VOID OptionMenuCustomBootDisk(VOID)
|
|||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomBootDisk%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second);
|
||||
TimeInfo = ArcGetTime();
|
||||
sprintf(SectionName, "CustomBootDisk%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
|
@ -122,7 +122,7 @@ VOID OptionMenuCustomBootPartition(VOID)
|
|||
CHAR BootDriveString[20];
|
||||
CHAR BootPartitionString[20];
|
||||
ULONG SectionId;
|
||||
ULONG Year, Month, Day, Hour, Minute, Second;
|
||||
TIMEINFO* TimeInfo;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
|
@ -139,8 +139,8 @@ VOID OptionMenuCustomBootPartition(VOID)
|
|||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomBootPartition%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second);
|
||||
TimeInfo = ArcGetTime();
|
||||
sprintf(SectionName, "CustomBootPartition%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
|
@ -178,7 +178,7 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
|
|||
CHAR BootPartitionString[20];
|
||||
CHAR BootSectorFileString[200];
|
||||
ULONG SectionId;
|
||||
ULONG Year, Month, Day, Hour, Minute, Second;
|
||||
TIMEINFO* TimeInfo;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
|
@ -201,8 +201,8 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
|
|||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomBootSectorFile%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second);
|
||||
TimeInfo = ArcGetTime();
|
||||
sprintf(SectionName, "CustomBootSectorFile%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
|
@ -248,7 +248,7 @@ VOID OptionMenuCustomBootReactOS(VOID)
|
|||
CHAR ReactOSARCPath[200];
|
||||
CHAR ReactOSOptions[200];
|
||||
ULONG SectionId;
|
||||
ULONG Year, Month, Day, Hour, Minute, Second;
|
||||
TIMEINFO* TimeInfo;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
|
@ -277,8 +277,8 @@ VOID OptionMenuCustomBootReactOS(VOID)
|
|||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomReactOS%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second);
|
||||
TimeInfo = ArcGetTime();
|
||||
sprintf(SectionName, "CustomReactOS%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
|
@ -321,7 +321,7 @@ VOID OptionMenuCustomBootLinux(VOID)
|
|||
CHAR LinuxInitrdString[200];
|
||||
CHAR LinuxCommandLineString[200];
|
||||
ULONG SectionId;
|
||||
ULONG Year, Month, Day, Hour, Minute, Second;
|
||||
TIMEINFO* TimeInfo;
|
||||
|
||||
RtlZeroMemory(SectionName, sizeof(SectionName));
|
||||
RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
|
||||
|
@ -356,8 +356,8 @@ VOID OptionMenuCustomBootLinux(VOID)
|
|||
}
|
||||
|
||||
// Generate a unique section name
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
sprintf(SectionName, "CustomLinux%ld%ld%ld%ld%ld%ld", Year, Day, Month, Hour, Minute, Second);
|
||||
TimeInfo = ArcGetTime();
|
||||
sprintf(SectionName, "CustomLinux%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
|
||||
|
||||
// Add the section
|
||||
if (!IniAddSection(SectionName, &SectionId))
|
||||
|
|
|
@ -55,7 +55,7 @@ BOOLEAN PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTI
|
|||
BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
|
||||
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);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ BOOLEAN PcDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTI
|
|||
BOOLEAN PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
|
||||
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);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ BOOLEAN XboxDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPAR
|
|||
BOOLEAN XboxDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
|
||||
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);
|
||||
|
||||
|
|
|
@ -72,7 +72,8 @@ typedef struct tagMACHVTBL
|
|||
BOOLEAN (*DiskGetDriveGeometry)(ULONG DriveNumber, PGEOMETRY DriveGeometry);
|
||||
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);
|
||||
} MACHVTBL, *PMACHVTBL;
|
||||
|
@ -115,7 +116,8 @@ BOOLEAN MachDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, UL
|
|||
BOOLEAN MachDiskGetPartitionEntry(ULONG DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
|
||||
BOOLEAN MachDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY DriveGeometry);
|
||||
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 MachPrepareForReactOS(IN BOOLEAN Setup);
|
||||
|
||||
|
@ -147,7 +149,6 @@ VOID MachPrepareForReactOS(IN BOOLEAN Setup);
|
|||
#define MachDiskGetPartitionEntry(Drive, Part, Entry) MachVtbl.DiskGetPartitionEntry((Drive), (Part), (Entry))
|
||||
#define MachDiskGetDriveGeometry(Drive, Geom) MachVtbl.DiskGetDriveGeometry((Drive), (Geom))
|
||||
#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()
|
||||
|
||||
#endif /* __MACHINE_H_ */
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#undef MachDiskGetPartitionEntry
|
||||
#undef MachDiskGetDriveGeometry
|
||||
#undef MachDiskGetCacheableBlockCount
|
||||
#undef MachRTCGetCurrentDateTime
|
||||
#undef MachHwDetect
|
||||
|
||||
MACHVTBL MachVtbl;
|
||||
|
@ -228,10 +227,24 @@ MachDiskGetCacheableBlockCount(ULONG DriveNumber)
|
|||
return MachVtbl.DiskGetCacheableBlockCount(DriveNumber);
|
||||
}
|
||||
|
||||
VOID
|
||||
MachRTCGetCurrentDateTime(PULONG Year, PULONG Month, PULONG Day, PULONG Hour, PULONG Minute, PULONG Second)
|
||||
TIMEINFO*
|
||||
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
|
||||
|
|
|
@ -442,9 +442,8 @@ VOID TuiDrawStatusText(PCSTR StatusText)
|
|||
|
||||
VOID TuiUpdateDateTime(VOID)
|
||||
{
|
||||
ULONG Year, Month, Day;
|
||||
ULONG Hour, Minute, Second;
|
||||
CHAR DateString[40];
|
||||
TIMEINFO* TimeInfo;
|
||||
char DateString[40];
|
||||
CHAR TimeString[40];
|
||||
CHAR TempString[20];
|
||||
BOOLEAN PMHour = FALSE;
|
||||
|
@ -452,27 +451,31 @@ VOID TuiUpdateDateTime(VOID)
|
|||
/* Don't draw the time if this has been disabled */
|
||||
if (!UiDrawTime) return;
|
||||
|
||||
MachRTCGetCurrentDateTime(&Year, &Month, &Day, &Hour, &Minute, &Second);
|
||||
if (Year < 1 || 9999 < Year || Month < 1 || 12 < Month || Day < 1 ||
|
||||
31 < Day || 23 < Hour || 59 < Minute || 59 < Second)
|
||||
TimeInfo = ArcGetTime();
|
||||
if (TimeInfo->Year < 1 || 9999 < TimeInfo->Year ||
|
||||
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 */
|
||||
return;
|
||||
}
|
||||
// Get the month name
|
||||
strcpy(DateString, UiMonthNames[Month - 1]);
|
||||
strcpy(DateString, UiMonthNames[TimeInfo->Month - 1]);
|
||||
// Get the day
|
||||
_itoa(Day, TempString, 10);
|
||||
_itoa(TimeInfo->Day, TempString, 10);
|
||||
// Get the day postfix
|
||||
if (1 == Day || 21 == Day || 31 == Day)
|
||||
if (1 == TimeInfo->Day || 21 == TimeInfo->Day || 31 == TimeInfo->Day)
|
||||
{
|
||||
strcat(TempString, "st");
|
||||
}
|
||||
else if (2 == Day || 22 == Day)
|
||||
else if (2 == TimeInfo->Day || 22 == TimeInfo->Day)
|
||||
{
|
||||
strcat(TempString, "nd");
|
||||
}
|
||||
else if (3 == Day || 23 == Day)
|
||||
else if (3 == TimeInfo->Day || 23 == TimeInfo->Day)
|
||||
{
|
||||
strcat(TempString, "rd");
|
||||
}
|
||||
|
@ -486,35 +489,35 @@ VOID TuiUpdateDateTime(VOID)
|
|||
strcat(DateString, " ");
|
||||
|
||||
// Get the year and add it to the date
|
||||
_itoa(Year, TempString, 10);
|
||||
_itoa(TimeInfo->Year, TempString, 10);
|
||||
strcat(DateString, TempString);
|
||||
|
||||
// Draw the date
|
||||
TuiDrawText(UiScreenWidth-strlen(DateString)-2, 1, DateString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
|
||||
|
||||
// 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;
|
||||
}
|
||||
if (Hour == 0)
|
||||
if (TimeInfo->Hour == 0)
|
||||
{
|
||||
Hour = 12;
|
||||
TimeInfo->Hour = 12;
|
||||
}
|
||||
_itoa(Hour, TempString, 10);
|
||||
_itoa(TimeInfo->Hour, TempString, 10);
|
||||
strcpy(TimeString, " ");
|
||||
strcat(TimeString, TempString);
|
||||
strcat(TimeString, ":");
|
||||
_itoa(Minute, TempString, 10);
|
||||
if (Minute < 10)
|
||||
_itoa(TimeInfo->Minute, TempString, 10);
|
||||
if (TimeInfo->Minute < 10)
|
||||
{
|
||||
strcat(TimeString, "0");
|
||||
}
|
||||
strcat(TimeString, TempString);
|
||||
strcat(TimeString, ":");
|
||||
_itoa(Second, TempString, 10);
|
||||
if (Second < 10)
|
||||
_itoa(TimeInfo->Second, TempString, 10);
|
||||
if (TimeInfo->Second < 10)
|
||||
{
|
||||
strcat(TimeString, "0");
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
|
|||
UiMenuKeyPressFilterCallback KeyPressFilter)
|
||||
{
|
||||
UI_MENU_INFO MenuInformation;
|
||||
ULONG InitialClockSecond;
|
||||
ULONG LastClockSecond;
|
||||
ULONG CurrentClockSecond;
|
||||
ULONG KeyPress;
|
||||
|
@ -59,7 +60,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
|
|||
//
|
||||
// Get the current second of time
|
||||
//
|
||||
MachRTCGetCurrentDateTime(NULL, NULL, NULL, NULL, NULL, &LastClockSecond);
|
||||
InitialClockSecond = LastClockSecond = ArcGetRelativeTime();
|
||||
|
||||
//
|
||||
// Process keys
|
||||
|
@ -87,17 +88,12 @@ TuiDisplayMenu(PCSTR MenuItemList[],
|
|||
//
|
||||
// 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,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&CurrentClockSecond);
|
||||
CurrentClockSecond = ArcGetRelativeTime();
|
||||
|
||||
//
|
||||
// Check if more then a second has now elapsed
|
||||
|
@ -108,7 +104,10 @@ TuiDisplayMenu(PCSTR MenuItemList[],
|
|||
// Update the time information
|
||||
//
|
||||
LastClockSecond = CurrentClockSecond;
|
||||
MenuInformation.MenuTimeRemaining--;
|
||||
MenuInformation.MenuTimeRemaining =
|
||||
InitialClockSecond + MenuTimeOut - LastClockSecond;
|
||||
if (MenuInformation.MenuTimeRemaining < 0)
|
||||
MenuInformation.MenuTimeRemaining = 0;
|
||||
|
||||
//
|
||||
// Update the menu
|
||||
|
@ -117,7 +116,7 @@ TuiDisplayMenu(PCSTR MenuItemList[],
|
|||
VideoCopyOffScreenBufferToVRAM();
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (MenuInformation.MenuTimeRemaining == 0)
|
||||
{
|
||||
//
|
||||
// A time out occurred, exit this loop and return default OS
|
||||
|
|
|
@ -121,6 +121,16 @@ typedef enum _MEMORY_TYPE
|
|||
MemoryMaximum
|
||||
} MEMORY_TYPE;
|
||||
|
||||
typedef struct _TIMEINFO
|
||||
{
|
||||
USHORT Year;
|
||||
USHORT Month;
|
||||
USHORT Day;
|
||||
USHORT Hour;
|
||||
USHORT Minute;
|
||||
USHORT Second;
|
||||
} TIMEINFO;
|
||||
|
||||
typedef struct _MEMORY_DESCRIPTOR
|
||||
{
|
||||
MEMORY_TYPE MemoryType;
|
||||
|
|
Loading…
Reference in a new issue