From d9bbf72b02709a4afdbb53b2b19f00c8308b0b27 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 21 Jun 2025 15:09:27 -0400 Subject: kernel/amd64: mc1468xx: Add year, month and day Signed-off-by: Ian Moffett --- sys/arch/amd64/isa/mc1468.c | 15 +++++++++++++++ sys/include/sys/time.h | 3 +++ 2 files changed, 18 insertions(+) (limited to 'sys') diff --git a/sys/arch/amd64/isa/mc1468.c b/sys/arch/amd64/isa/mc1468.c index f1421a4..531751b 100644 --- a/sys/arch/amd64/isa/mc1468.c +++ b/sys/arch/amd64/isa/mc1468.c @@ -82,6 +82,12 @@ mc1468_updating(void) static bool mc1468_date_synced(struct date *a, struct date *b) { + if (a->year != b->year) + return false; + if (a->month != b->month) + return false; + if (a->day != b->day) + return false; if (a->sec != b->sec) return false; if (a->min != b->min) @@ -100,6 +106,9 @@ mc1468_date_synced(struct date *a, struct date *b) static void mc1468_bcd_conv(struct date *dp) { + dp->year = (dp->year & 0x0F) + ((dp->year / 16) * 10); + dp->month = (dp->month & 0x0F) + ((dp->month / 16) * 10); + dp->day = (dp->day & 0x0F) + ((dp->day / 16) * 10); dp->sec = (dp->sec & 0x0F) + ((dp->sec / 16) * 10); dp->min = (dp->min & 0x0F) + ((dp->min / 16) * 10); dp->hour = (dp->hour & 0x0F) + (((dp->hour & 0x70) / 16) * 10); @@ -117,6 +126,9 @@ mc1468_bcd_conv(struct date *dp) static void __mc1468_get_time(struct date *dp) { + dp->year = mc1468_read(0x09); + dp->month = mc1468_read(0x08); + dp->day = mc1468_read(0x07); dp->sec = mc1468_read(0x00); dp->min = mc1468_read(0x02); dp->hour = mc1468_read(0x04); @@ -144,6 +156,9 @@ mc1468_get_date(struct date *dp) md_pause(); } __mc1468_get_time(&date_last); + date_cur.year = date_last.year; + date_cur.month = date_last.month; + date_cur.day = date_last.day; date_cur.sec = date_last.sec; date_cur.min = date_last.min; date_cur.hour = date_last.hour; diff --git a/sys/include/sys/time.h b/sys/include/sys/time.h index 8563fc7..ce66885 100644 --- a/sys/include/sys/time.h +++ b/sys/include/sys/time.h @@ -46,6 +46,9 @@ struct timespec { }; struct date { + uint16_t year; + uint8_t month; + uint8_t day; uint8_t sec; uint8_t min; uint8_t hour; -- cgit v1.2.3