Setting the Real-Time Clock
Some target devices cannot detect whether the real-time clock is initialized, and therefore cannot determine when to reset it. For example, a computer-based target device that has a clock with a battery backup may be unable to detect real-time clock initialization. You change this behavior by implementing the I/O control code IOCTL_HAL_INIT_RTC in OEMIoControl. The Windows CE–based file system passes IOCTL_HAL_INIT_RTC to KernelIoControl during initialization for a cold boot sequence. The following code example shows the SYSTEMTIME structure that the file system passes.
const SYSTEMTIME st = {2003,1,0,1,12,0,0,0};
DWORD bytesUsed;
KernelIoControl(IOCTL_HAL_INIT_RTC, (UCHAR *)&st, sizeof(SYSTEMTIME), NULL, 0, &bytesUsed);
To set the real-time clock in OAL code
- Validate the clock during the OEM boot process in your OAL code.
- Set the real-time clock to the value stored in SYSTEMTIME, if the boot process did not return a valid time.
- Call OEMSetRealTime in OEMIoControl to set the real-time clock of the target device.
The following code example shows one implementation of setting the real-time clock.
case IOCTL_HAL_INIT_RTC:
// The kernel has detected a cold boot.
// The real-time clock probably needs to be reset.
if( nInBufSize >= sizeof(SYSTEMTIME) )
return OEMSetRealTime( (LPSYSTEMTIME)lpInBuf );
else
return FALSE;
break;
See Also
How to Develop an OEM Adaptation Layer | Implementing the OEMIoControl Function
Last updated on Wednesday, April 13, 2005
© 2005 Microsoft Corporation. All rights reserved.