Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpcrtc.c
Go to the documentation of this file.
00001 /* $Id: pcrtc.c 48383 2010-07-31 21:00:40Z ilardig $ 00002 * 00003 * FreeLoader 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #include <freeldr.h> 00021 00022 #define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f)) 00023 00024 TIMEINFO* 00025 PcGetTime(VOID) 00026 { 00027 static TIMEINFO TimeInfo; 00028 REGS Regs; 00029 00030 for (;;) 00031 { 00032 /* Some BIOSes, such as the 1998/07/25 system ROM 00033 * in the Compaq Deskpro EP/SB, leave CF unchanged 00034 * if successful, so CF should be cleared before 00035 * calling this function. */ 00036 Regs.x.eflags = 0; 00037 // __writeeflags(__readeflags() & ~EFLAGS_CF); 00038 00039 /* Int 1Ah AH=04h 00040 * TIME - GET REAL-TIME CLOCK DATE (AT,XT286,PS) 00041 * 00042 * AH = 04h 00043 * CF clear to avoid bug 00044 * Return: 00045 * CF clear if successful 00046 * CH = century (BCD) 00047 * CL = year (BCD) 00048 * DH = month (BCD) 00049 * DL = day (BCD) 00050 * CF set on error 00051 */ 00052 Regs.b.ah = 0x04; 00053 Int386(0x1A, &Regs, &Regs); 00054 00055 if (!INT386_SUCCESS(Regs)) continue; 00056 00057 TimeInfo.Year = 100 * BCD_INT(Regs.b.ch) + BCD_INT(Regs.b.cl); 00058 TimeInfo.Month = BCD_INT(Regs.b.dh); 00059 TimeInfo.Day = BCD_INT(Regs.b.dl); 00060 00061 /* Some BIOSes leave CF unchanged if successful, 00062 * so CF should be cleared before calling this function. */ 00063 Regs.x.eflags = 0; 00064 // __writeeflags(__readeflags() & ~EFLAGS_CF); 00065 00066 /* Int 1Ah AH=02h 00067 * TIME - GET REAL-TIME CLOCK TIME (AT,XT286,PS) 00068 * 00069 * AH = 02h 00070 * CF clear to avoid bug 00071 * Return: 00072 * CF clear if successful 00073 * CH = hour (BCD) 00074 * CL = minutes (BCD) 00075 * DH = seconds (BCD) 00076 * DL = daylight savings flag (00h standard time, 01h daylight time) 00077 * CF set on error (i.e. clock not running or in middle of update) 00078 */ 00079 Regs.b.ah = 0x02; 00080 Int386(0x1A, &Regs, &Regs); 00081 00082 if (!INT386_SUCCESS(Regs)) continue; 00083 00084 TimeInfo.Hour = BCD_INT(Regs.b.ch); 00085 TimeInfo.Minute = BCD_INT(Regs.b.cl); 00086 TimeInfo.Second = BCD_INT(Regs.b.dh); 00087 00088 break; 00089 } 00090 return &TimeInfo; 00091 } 00092 00093 /* EOF */ Generated on Fri May 25 2012 04:17:10 for ReactOS by
1.7.6.1
|