2011-03-25 08:09:23 +03:00
|
|
|
#include <system.h>
|
|
|
|
|
|
|
|
#define from_bcd(val) ((val / 16) * 10 + (val & 0xf))
|
|
|
|
|
2011-04-05 03:51:55 +04:00
|
|
|
void
|
|
|
|
get_date(
|
|
|
|
uint16_t * month,
|
|
|
|
uint16_t * day
|
|
|
|
) {
|
|
|
|
uint16_t values[128];
|
|
|
|
uint16_t index;
|
|
|
|
__asm__ __volatile__ ("cli");
|
|
|
|
for (index = 0; index < 128; ++index) {
|
|
|
|
outportb(0x70, index);
|
|
|
|
values[index] = inportb(0x71);
|
|
|
|
}
|
|
|
|
__asm__ __volatile__ ("sti");
|
|
|
|
*month = from_bcd(values[8]);
|
|
|
|
*day = from_bcd(values[7]);
|
|
|
|
}
|
|
|
|
|
2011-03-25 08:09:23 +03:00
|
|
|
void
|
|
|
|
get_time(
|
|
|
|
uint16_t * hours,
|
|
|
|
uint16_t * minutes,
|
|
|
|
uint16_t * seconds
|
|
|
|
) {
|
|
|
|
uint16_t values[128];
|
|
|
|
uint16_t index;
|
|
|
|
__asm__ __volatile__ ("cli");
|
|
|
|
for (index = 0; index < 128; ++index) {
|
|
|
|
outportb(0x70, index);
|
|
|
|
values[index] = inportb(0x71);
|
|
|
|
}
|
|
|
|
__asm__ __volatile__ ("sti");
|
|
|
|
|
|
|
|
*hours = from_bcd(values[4]);
|
|
|
|
*minutes = from_bcd(values[2]);
|
|
|
|
*seconds = from_bcd(values[0]);
|
|
|
|
}
|