]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: sandbox: Add os_localtime() to obtain the system time
authorSimon Glass <sjg@chromium.org>
Mon, 20 Apr 2015 18:37:22 +0000 (12:37 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 6 May 2015 02:58:20 +0000 (20:58 -0600)
Add a function to read the system time into U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/os.c
include/os.h

index 4d5f8057533e89f2ed6edd0298ac4c69038360eb..e6dd17e9efc7c62777bc6e4210c367abb2471435 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/sections.h>
 #include <asm/state.h>
 #include <os.h>
+#include <rtc_def.h>
 
 /* Operating System Interface */
 
@@ -537,3 +538,20 @@ int os_jump_to_image(const void *dest, int size)
 
        return unlink(fname);
 }
+
+void os_localtime(struct rtc_time *rt)
+{
+       time_t t = time(NULL);
+       struct tm *tm;
+
+       tm = localtime(&t);
+       rt->tm_sec = tm->tm_sec;
+       rt->tm_min = tm->tm_min;
+       rt->tm_hour = tm->tm_hour;
+       rt->tm_mday = tm->tm_mday;
+       rt->tm_mon = tm->tm_mon + 1;
+       rt->tm_year = tm->tm_year + 1900;
+       rt->tm_wday = tm->tm_wday;
+       rt->tm_yday = tm->tm_yday;
+       rt->tm_isdst = tm->tm_isdst;
+}
index a758f099aab622f4aba9696de3213bbdc67a9843..ffbdce84643e0f593f8d6d684753b1b32af13447 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/types.h>
 
+struct rtc_time;
 struct sandbox_state;
 
 /**
@@ -277,4 +278,14 @@ int os_read_ram_buf(const char *fname);
  */
 int os_jump_to_image(const void *dest, int size);
 
+/**
+ * Read the current system time
+ *
+ * This reads the current Local Time and places it into the provided
+ * structure.
+ *
+ * @param rt           Place to put system time
+ */
+void os_localtime(struct rtc_time *rt);
+
 #endif