[coreboot-gerrit] Patch set updated for filo: Use libpayload timer API

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Sat Apr 16 00:29:43 CEST 2016


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14373

-gerrit

commit 19f6a10605bfc163c6880f7f55a01b82cd077505
Author: Stefan Reinauer <stefan.reinauer at coreboot.org>
Date:   Thu Apr 14 18:02:10 2016 -0700

    Use libpayload timer API
    
    Instead of implementing our own, platform specific timer API, use
    libpayload's code.
    
    Change-Id: I29634fdaba8a6b2f644736f29d8aa66380f4c797
    Signed-off-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
---
 include/timer.h          | 32 ++++++++++++++++++++++++++++++++
 main/Makefile.inc        |  1 +
 main/elfload.c           |  8 ++++----
 main/filo.c              |  2 +-
 main/grub/builtins.c     |  2 +-
 main/grub/grub.c         |  2 +-
 main/timer.c             | 36 ++++++++++++++++++++++++++++++++++++
 x86/Makefile.inc         |  2 +-
 x86/include/arch/timer.h | 32 --------------------------------
 x86/timer.c              | 38 --------------------------------------
 10 files changed, 77 insertions(+), 78 deletions(-)

diff --git a/include/timer.h b/include/timer.h
new file mode 100644
index 0000000..4723b1e
--- /dev/null
+++ b/include/timer.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of FILO.
+ *
+ * (C) 2004-2008 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef	TIMER_H
+#define TIMER_H
+
+#include <libpayload.h>
+
+u64 currticks(void);
+int getrtsecs (void);
+
+#define TICKS_PER_SEC timer_hz()
+#define TICKS_PER_USEC (cpu_khz / 1000)
+
+
+#endif	/* TIMER_H */
diff --git a/main/Makefile.inc b/main/Makefile.inc
index fc7c851..1d4029d 100644
--- a/main/Makefile.inc
+++ b/main/Makefile.inc
@@ -20,5 +20,6 @@ include main/grub/Makefile.inc
 
 TARGETS-y += main/filo.o main/strtox.o
 TARGETS-y += main/elfload.o main/ipchecksum.o 
+TARGETS-y += main/timer.o
 TARGETS-$(CONFIG_SUPPORT_SOUND) += main/sound.o
 TARGETS-$(CONFIG_MULTIBOOT_IMAGE) += main/mb_hdr.o
diff --git a/main/elfload.c b/main/elfload.c
index 3eb03c2..7aa8a2e 100644
--- a/main/elfload.c
+++ b/main/elfload.c
@@ -22,7 +22,7 @@
 
 #include <libpayload.h>
 #include <config.h>
-#include <arch/timer.h>
+#include <timer.h>
 #include <sys_info.h>
 #include <elf.h>
 #include <arch/elf.h>
@@ -139,7 +139,7 @@ static int load_segments(Elf_phdr *phdr, int phnum,
 
     bytes = 0;
 #if defined(DEBUG) && (DEBUG == 1)
-    u64 start_time = currticks();
+    u64 start_time = timer_raw_value();
 #endif
     for (i = 0; i < phnum; i++) {
 	if (phdr[i].p_type != PT_LOAD)
@@ -167,8 +167,8 @@ static int load_segments(Elf_phdr *phdr, int phnum,
 
     }
 #if defined(DEBUG) && (DEBUG == 1)
-    u64 time = currticks() - start_time;
-    debug("Loaded %lu bytes in %ums (%luKB/s)\n", bytes, time,
+    u64 time = (timer_raw_value() - start_time) / (timer_hz() * 1000);
+    debug("Loaded %lu bytes in %lldms (%luKB/s)\n", bytes, time,
 	    time? bytes/time : 0);
 #endif
     return 1;
diff --git a/main/filo.c b/main/filo.c
index 9d69386..1855f08 100644
--- a/main/filo.c
+++ b/main/filo.c
@@ -23,7 +23,7 @@
 #include <fs.h>
 #include <sys_info.h>
 #include <sound.h>
-#include <arch/timer.h>
+#include <timer.h>
 #include <debug.h>
 
 PAYLOAD_INFO(name, PROGRAM_NAME " " PROGRAM_VERSION);
diff --git a/main/grub/builtins.c b/main/grub/builtins.c
index 3f6daf2..58d6855 100644
--- a/main/grub/builtins.c
+++ b/main/grub/builtins.c
@@ -26,7 +26,7 @@
 #include <fs.h>
 #include <lib.h>
 #include <grub/shared.h>
-#include <arch/timer.h>
+#include <timer.h>
 #ifdef CONFIG_USE_MD5_PASSWORDS
 #include <grub/md5.h>
 #endif
diff --git a/main/grub/grub.c b/main/grub/grub.c
index c7b7765..2c8595b 100644
--- a/main/grub/grub.c
+++ b/main/grub/grub.c
@@ -25,7 +25,7 @@
 #include <grub/shared.h>
 #include <fs.h>
 #include <lib.h>
-#include <arch/timer.h>
+#include <timer.h>
 
 extern char config_file[];
 extern int reload_configfile;
diff --git a/main/timer.c b/main/timer.c
new file mode 100644
index 0000000..6f76e09
--- /dev/null
+++ b/main/timer.c
@@ -0,0 +1,36 @@
+/*
+ * This file is part of FILO.
+ *
+ * (C) 2004-2008 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <libpayload.h>
+#include <timer.h>
+
+u64 currticks(void)
+{
+	return timer_raw_value();
+}
+
+int getrtsecs (void)
+{
+	u64 t;
+	t=timer_raw_value();
+	t=t / timer_hz();
+	return (int)t;
+}
+
+
diff --git a/x86/Makefile.inc b/x86/Makefile.inc
index f01ca72..0d6fc64 100644
--- a/x86/Makefile.inc
+++ b/x86/Makefile.inc
@@ -17,7 +17,7 @@
 #
 
 TARGETS-$(CONFIG_TARGET_I386) += x86/context.o x86/switch.S.o x86/segment.o
-TARGETS-$(CONFIG_TARGET_I386) += x86/timer.o x86/sys_info.o
+TARGETS-$(CONFIG_TARGET_I386) += x86/sys_info.o
 TARGETS-$(CONFIG_LINUX_LOADER) += x86/linux_load.o
 TARGETS-$(CONFIG_WINCE_LOADER) += x86/wince_load.o
 TARGETS-$(CONFIG_ARTEC_BOOT) += x86/artecboot.o
diff --git a/x86/include/arch/timer.h b/x86/include/arch/timer.h
deleted file mode 100644
index 3cdd9b4..0000000
--- a/x86/include/arch/timer.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * This file is part of FILO.
- *
- * (C) 2004-2008 coresystems GmbH
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#ifndef	TIMER_H
-#define TIMER_H
-
-extern u32 cpu_khz;
-
-u64 currticks(void);
-int getrtsecs (void);
-
-#define TICKS_PER_SEC (cpu_khz * 1000)
-#define TICKS_PER_USEC (cpu_khz / 1000)
-
-
-#endif	/* TIMER_H */
diff --git a/x86/timer.c b/x86/timer.c
deleted file mode 100644
index 739c9ed..0000000
--- a/x86/timer.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of FILO.
- *
- * (C) 2004-2008 coresystems GmbH
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#include <libpayload.h>
-#include <arch/rdtsc.h>
-#include <arch/timer.h>
-
-u64 currticks(void)
-{
-	/* Read the Time Stamp Counter */
-	return  rdtsc();
-}
-
-int getrtsecs (void)
-{
-	u64 t;
-	t=currticks();
-	t=t/(TICKS_PER_SEC);
-	return (int)t;
-}
-
-



More information about the coreboot-gerrit mailing list