[PATCH] [33/66] x86_64: Handle years beyond 2100
- Subject: [PATCH] [33/66] x86_64: Handle years beyond 2100
- From: "Andi Kleen" <ak@xxxxxxx>
- Date: Thu, 23 Mar 2006 21:29:58 +0100
- Cc: linux-x86_64@xxxxxxxxxxxxxxx
- User-agent: nail 10.6 11/15/03
ACPIv2 has an official but optional way to get a date >2100. Use it. But all the
hardware I tested didn't seem to support it. But anyways x86-64 will be ready now.
Signed-off-by: Andi Kleen <ak@xxxxxxx>
---
arch/x86_64/kernel/time.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
Index: linux/arch/x86_64/kernel/time.c
===================================================================
--- linux.orig/arch/x86_64/kernel/time.c
+++ linux/arch/x86_64/kernel/time.c
@@ -517,6 +517,7 @@ static unsigned long get_cmos_time(void)
unsigned int timeout = 1000000, year, mon, day, hour, min, sec;
unsigned char uip = 0, this = 0;
unsigned long flags;
+ unsigned extyear = 0;
/*
* The Linux interpretation of the CMOS clock register contents: When the
@@ -545,6 +546,11 @@ static unsigned long get_cmos_time(void)
mon = CMOS_READ(RTC_MONTH);
year = CMOS_READ(RTC_YEAR);
+#ifdef CONFIG_ACPI
+ if (acpi_fadt.revision >= FADT2_REVISION_ID && acpi_fadt.century)
+ extyear = CMOS_READ(acpi_fadt.century);
+#endif
+
spin_unlock_irqrestore(&rtc_lock, flags);
/*
@@ -559,11 +565,17 @@ static unsigned long get_cmos_time(void)
BCD_TO_BIN(mon);
BCD_TO_BIN(year);
- /*
- * x86-64 systems only exists since 2002.
- * This will work up to Dec 31, 2100
- */
- year += 2000;
+ if (extyear) {
+ BCD_TO_BIN(extyear);
+ year += extyear;
+ printk(KERN_INFO "Extended CMOS year: %d\n", extyear);
+ } else {
+ /*
+ * x86-64 systems only exists since 2002.
+ * This will work up to Dec 31, 2100
+ */
+ year += 2000;
+ }
return mktime(year, mon, day, hour, min, sec);
}
-
: send the line "unsubscribe linux-x86_64" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux ia64]
[Linux MIPS Home]
[Linux Kernel]
[DCCP]
[Linux ARM]
[Linux]
[Photo]
[Yosemite News]
[Linux SCSI]
[Linux Hams]