2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: ReadBattClock() function.
8 #include "battclock_intern.h"
21 inline unsigned char read_port(unsigned char port
);
22 inline int bcd_to_dec(int x
);
24 /*****************************************************************************
27 #include <proto/battclock.h>
28 #include <proto/utility.h>
29 #include <utility/date.h>
31 AROS_LH0(ULONG
, ReadBattClock
,
37 struct BattClockBase
*, BattClockBase
, 2, Battclock
)
40 Return the value stored in the battery back up clock. This value
41 is the number of seconds that have elapsed since midnight on the
42 1st of January 1978 (00:00:00 1.1.1978).
44 If the value of the battery clock is invalid, then the clock will
50 The number of seconds since 1.1.1978 00:00:00
59 WriteBattClock, ResetBattClock
64 27-11-96 digulla automatically created from
65 battclock_lib.fd and clib/battclock_protos.h
67 *****************************************************************************/
71 struct ClockData date
;
76 date
.sec
= read_port(SEC
);
77 date
.min
= read_port(MIN
);
78 date
.hour
= read_port(HOUR
);
79 date
.mday
= read_port(MDAY
);
80 date
.month
= read_port(MONTH
);
81 date
.year
= read_port(YEAR
);
82 century
= read_port(CENTURY
);
83 status_b
= read_port(STATUS_B
);
85 if ((status_b
& 0x04) == 0) {
86 date
.sec
= bcd_to_dec(date
.sec
);
87 date
.min
= bcd_to_dec(date
.min
);
88 date
.hour
= bcd_to_dec(date
.hour
);
89 date
.mday
= bcd_to_dec(date
.mday
);
90 date
.month
= bcd_to_dec(date
.month
);
91 date
.year
= bcd_to_dec(date
.year
);
92 century
= bcd_to_dec(century
);
95 date
.year
= century
* 100 + date
.year
;
97 secs
=Date2Amiga(&date
);
102 } /* ReadBattClock */
105 unsigned char read_port(unsigned char port
)
110 "outb %1,$0x70 \n\t" \
118 inline int bcd_to_dec(int x
)
120 return ( (x
>> 4) * 10 + (x
& 0x0f) );