summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-04-25 23:11:02 +0000
committerJordan Crouse <jordan.crouse@amd.com>2008-04-25 23:11:02 +0000
commite2271430c53d24976ec3b0869dd8993cfba6d768 (patch)
tree4a5cf4555b8b535377e0f457b51c70c13ae08609 /payloads/libpayload/include
parentd772e1e7feb3d782564fe7f46374d4ae8a5f4c36 (diff)
downloadcoreboot-e2271430c53d24976ec3b0869dd8993cfba6d768.tar.xz
libpayload: Add gettimeofday() and friends
Add a gettimeofday() implementation - it works pretty well, but it drifts a little bit so its not very suitable for keeping time. It works best to track changes in time over small periods of time. Signed-off-by: Jordan Crouse <jordan.crouse@amd.com> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3272 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/include')
-rw-r--r--payloads/libpayload/include/arch/rdtsc.h4
-rw-r--r--payloads/libpayload/include/arch/types.h3
-rw-r--r--payloads/libpayload/include/libpayload.h25
3 files changed, 30 insertions, 2 deletions
diff --git a/payloads/libpayload/include/arch/rdtsc.h b/payloads/libpayload/include/arch/rdtsc.h
index da7949d808..52f8c9c83c 100644
--- a/payloads/libpayload/include/arch/rdtsc.h
+++ b/payloads/libpayload/include/arch/rdtsc.h
@@ -30,9 +30,9 @@
#ifndef _ARCH_RDTSC_H
#define _ARCH_RDTSC_H
-static inline unsigned long long rdtsc(void)
+static u64 rdtsc(void)
{
- unsigned long long val;
+ u64 val;
__asm__ __volatile__ ("rdtsc" : "=A" (val));
return val;
}
diff --git a/payloads/libpayload/include/arch/types.h b/payloads/libpayload/include/arch/types.h
index 641fb0aef8..1bd815bb44 100644
--- a/payloads/libpayload/include/arch/types.h
+++ b/payloads/libpayload/include/arch/types.h
@@ -50,6 +50,9 @@ typedef unsigned long long u64;
typedef signed long long int64_t;
typedef signed long long s64;
+typedef long time_t;
+typedef long suseconds_t;
+
#ifndef NULL
#define NULL ((void *)0)
#endif
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index d557eeff69..5bafb305ef 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -61,10 +61,26 @@
#define NVRAM_RTC_DAY 7
#define NVRAM_RTC_MONTH 8
#define NVRAM_RTC_YEAR 9
+#define NVRAM_RTC_FREQ_SELECT 10
+#define NVRAM_RTC_UIP 0x80
+
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+};
/* drivers/nvram.c */
u8 nvram_read(u8 addr);
void nvram_write(u8 val, u8 addr);
+int nvram_updating(void);
+void rtc_read_clock(struct tm *tm);
/* drivers/keyboard.c */
void keyboard_init(void);
@@ -182,6 +198,15 @@ char *strchr(const char *s, int c);
char *strdup(const char *s);
char *strstr(const char *h, const char *n);
+/* libc/time.c */
+
+struct timeval {
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
+
+int gettimeofday(struct timeval *tv, void *tz);
+
/* i386/coreboot.c */
int get_coreboot_info(struct sysinfo_t *info);