[freeldr] Move custom.c, drivemap.c/h, miscboot.c/h to i386 directories
[reactos.git] / reactos / boot / freeldr / freeldr / arch / i386 / pcrtc.c
index c6823d0..1141753 100644 (file)
  *  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.
+ *  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.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "freeldr.h"
-#include "arch.h"
-#include "machine.h"
-#include "machpc.h"
+#include <freeldr.h>
 
 #define BCD_INT(bcd) (((bcd & 0xf0) >> 4) * 10 + (bcd &0x0f))
 
-VOID
-PcRTCGetCurrentDateTime(PU32 Year, PU32 Month, PU32 Day, PU32 Hour, PU32 Minute, PU32 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. */
+    __writeeflags(__readeflags() & ~EFLAGS_CF);
 
-      /* 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.cl) + BCD_INT(Regs.b.ch);
-        }
-      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. */
+    __writeeflags(__readeflags() & ~EFLAGS_CF);
 
-      /* 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 */