summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/include
diff options
context:
space:
mode:
authorMichael Brown2012-03-19 18:08:51 +0100
committerMichael Brown2012-03-19 23:13:32 +0100
commit12002d6955f7423ef02cd6a68946240f6dd592b2 (patch)
tree914e482da5b59b9afbe02f6e54d10dedfdca48be /src/arch/i386/include
parent[time] Define an API for getting the current time (diff)
downloadipxe-12002d6955f7423ef02cd6a68946240f6dd592b2.tar.gz
ipxe-12002d6955f7423ef02cd6a68946240f6dd592b2.tar.xz
ipxe-12002d6955f7423ef02cd6a68946240f6dd592b2.zip
[time] Add RTC-based time source
Add a time source using the CMOS RTC to obtain the current time. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386/include')
-rw-r--r--src/arch/i386/include/bits/time.h2
-rw-r--r--src/arch/i386/include/ipxe/rtc_time.h18
-rw-r--r--src/arch/i386/include/rtc.h83
3 files changed, 103 insertions, 0 deletions
diff --git a/src/arch/i386/include/bits/time.h b/src/arch/i386/include/bits/time.h
index d2baacd88..24dd020e9 100644
--- a/src/arch/i386/include/bits/time.h
+++ b/src/arch/i386/include/bits/time.h
@@ -9,4 +9,6 @@
FILE_LICENCE ( GPL2_OR_LATER );
+#include <ipxe/rtc_time.h>
+
#endif /* _BITS_TIME_H */
diff --git a/src/arch/i386/include/ipxe/rtc_time.h b/src/arch/i386/include/ipxe/rtc_time.h
new file mode 100644
index 000000000..c0dfe3f88
--- /dev/null
+++ b/src/arch/i386/include/ipxe/rtc_time.h
@@ -0,0 +1,18 @@
+#ifndef _IPXE_RTC_TIME_H
+#define _IPXE_RTC_TIME_H
+
+/** @file
+ *
+ * RTC-based time source
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#ifdef TIME_RTC
+#define TIME_PREFIX_rtc
+#else
+#define TIME_PREFIX_rtc __rtc_
+#endif
+
+#endif /* _IPXE_RTC_TIME_H */
diff --git a/src/arch/i386/include/rtc.h b/src/arch/i386/include/rtc.h
new file mode 100644
index 000000000..2a6abbae5
--- /dev/null
+++ b/src/arch/i386/include/rtc.h
@@ -0,0 +1,83 @@
+#ifndef _RTC_H
+#define _RTC_H
+
+/** @file
+ *
+ * CMOS Real-Time Clock (RTC)
+ *
+ * The CMOS/RTC registers are documented (with varying degrees of
+ * accuracy and consistency) at
+ *
+ * http://www.nondot.org/sabre/os/files/MiscHW/RealtimeClockFAQ.txt
+ * http://wiki.osdev.org/RTC
+ * http://wiki.osdev.org/CMOS
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <pic8259.h>
+
+/** RTC IRQ */
+#define RTC_IRQ 8
+
+/** RTC interrupt vector */
+#define RTC_INT IRQ_INT ( RTC_IRQ )
+
+/** CMOS/RTC address (and NMI) register */
+#define CMOS_ADDRESS 0x70
+
+/** NMI disable bit */
+#define CMOS_DISABLE_NMI 0x80
+
+/** CMOS/RTC data register */
+#define CMOS_DATA 0x71
+
+/** RTC seconds */
+#define RTC_SEC 0x00
+
+/** RTC minutes */
+#define RTC_MIN 0x02
+
+/** RTC hours */
+#define RTC_HOUR 0x04
+
+/** RTC weekday */
+#define RTC_WDAY 0x06
+
+/** RTC day of month */
+#define RTC_MDAY 0x07
+
+/** RTC month */
+#define RTC_MON 0x08
+
+/** RTC year */
+#define RTC_YEAR 0x09
+
+/** RTC status register A */
+#define RTC_STATUS_A 0x0a
+
+/** RTC update in progress bit */
+#define RTC_STATUS_A_UPDATE_IN_PROGRESS 0x80
+
+/** RTC status register B */
+#define RTC_STATUS_B 0x0b
+
+/** RTC 24 hour format bit */
+#define RTC_STATUS_B_24_HOUR 0x02
+
+/** RTC binary mode bit */
+#define RTC_STATUS_B_BINARY 0x04
+
+/** RTC Periodic Interrupt Enabled bit */
+#define RTC_STATUS_B_PIE 0x40
+
+/** RTC status register C */
+#define RTC_STATUS_C 0x0c
+
+/** RTC status register D */
+#define RTC_STATUS_D 0x0d
+
+/** CMOS default address */
+#define CMOS_DEFAULT_ADDRESS RTC_STATUS_D
+
+#endif /* _RTC_H */