make the linux-ppc packags be in synch with other platforms
[tangerine.git] / arch / x86_64-pc / battclock / readbattclock.c
blob42131d5941dfd70264343ba82b630c472aa62f3f
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id: readbattclock.c 19714 2003-09-09 17:48:30Z hkiel $
5 Desc: ReadBattClock() function.
6 Lang: english
7 */
8 #include "battclock_intern.h"
10 #define ReadRTC(in,out) \
11 asm volatile ( \
12 "outb %%al,$0x70 \n\t" \
13 "inb $0x71,%%al \n\t" \
14 "movl %%eax,%%ebx \n\t" \
15 "andl $0x0f,%%eax \n\t" \
16 "shrl $4,%%ebx \n\t" \
17 "imul $10,%%ebx \n\t" \
18 "addl %%ebx,%%eax" \
19 : "=al"(out) \
20 : "0"(in) \
21 : "%ebx","cc");
23 /*****************************************************************************
25 NAME */
26 #include <proto/battclock.h>
27 #include <proto/utility.h>
28 #include <utility/date.h>
30 AROS_LH0(ULONG, ReadBattClock,
32 /* SYNOPSIS */
33 /* void */
35 /* LOCATION */
36 struct BattClockBase *, BattClockBase, 2, Battclock)
38 /* FUNCTION
39 Return the value stored in the battery back up clock. This value
40 is the number of seconds that have elapsed since midnight on the
41 1st of January 1978 (00:00:00 1.1.1978).
43 If the value of the battery clock is invalid, then the clock will
44 be reset.
46 INPUTS
48 RESULT
49 The number of seconds since 1.1.1978 00:00:00
51 NOTES
53 EXAMPLE
55 BUGS
57 SEE ALSO
58 WriteBattClock, ResetBattClock
60 INTERNALS
62 HISTORY
63 27-11-96 digulla automatically created from
64 battclock_lib.fd and clib/battclock_protos.h
66 *****************************************************************************/
68 AROS_LIBFUNC_INIT
70 struct ClockData date;
71 #warning HACK: asm statements do not work with a single variable
72 struct __myyear { UWORD year; } myyear;
73 // UWORD year;
74 ULONG secs;
76 // ReadRTC(50,year);
77 ReadRTC(50,myyear.year);
78 ReadRTC(9,date.year);
79 ReadRTC(8,date.month);
80 ReadRTC(7,date.mday);
81 ReadRTC(4,date.hour);
82 ReadRTC(2,date.min);
83 ReadRTC(0,date.sec);
84 // date.year+=100*year;
85 date.year+=100*myyear.year;
87 secs=Date2Amiga(&date);
89 return secs;
91 AROS_LIBFUNC_EXIT
92 } /* ReadBattClock */