[U-Boot] [PATCH v2 5/8] x86: slimbootloader: Set TSC information for timer driver
Park, Aiden
aiden.park at intel.com
Tue Jun 25 23:20:14 UTC 2019
- Get TSC frequency from performance info hob
- Set tsc_base and clock_rate for timer driver
Signed-off-by: Aiden Park <aiden.park at intel.com>
---
arch/x86/cpu/slimbootloader/slimbootloader.c | 31 +++++++++++++++++++
.../asm/arch-slimbootloader/slimbootloader.h | 26 ++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/arch/x86/cpu/slimbootloader/slimbootloader.c b/arch/x86/cpu/slimbootloader/slimbootloader.c
index 9f3a61ec61..e2bab99461 100644
--- a/arch/x86/cpu/slimbootloader/slimbootloader.c
+++ b/arch/x86/cpu/slimbootloader/slimbootloader.c
@@ -4,9 +4,40 @@
*/
#include <common.h>
+#include <asm/arch/slimbootloader.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/**
+ * This sets tsc_base and clock_rate for early_timer and tsc_timer.
+ * The performance info guid hob has all performance timestamp data, but
+ * the only tsc frequency info is used for the timer driver for now.
+ */
+static void tsc_init(void)
+{
+ struct performance_info *data = NULL;
+ const struct efi_guid guid = LOADER_PERFORMANCE_INFO_GUID;
+
+ gd->arch.tsc_base = rdtsc();
+ debug("tsc_base=0x%llx\n", gd->arch.tsc_base);
+
+ data = (struct performance_info *)
+ get_next_guid_hob_data(&guid, gd->arch.hob_list);
+
+ if (!data) {
+ debug("performance info hob not found\n");
+ return;
+ }
+
+ /* frequency is in KHz, so to Hz */
+ gd->arch.clock_rate = data->frequency * 1000;
+ debug("freq=0x%lx\n", gd->arch.clock_rate);
+}
int arch_cpu_init(void)
{
+ tsc_init();
+
return x86_cpu_init_f();
}
diff --git a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
index b05e527148..0b908f7c3e 100644
--- a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
+++ b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h
@@ -22,6 +22,12 @@
{ 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } \
}
+#define LOADER_PERFORMANCE_INFO_GUID \
+ { \
+ 0x868204be, 0x23d0, 0x4ff9, \
+ { 0xac, 0x34, 0xb9, 0x95, 0xac, 0x04, 0xb1, 0xb9 } \
+ }
+
/**
* A single entry of memory map information
*
@@ -81,6 +87,26 @@ struct serial_port_info {
u32 rsvd1;
} __packed;
+/**
+ * This includes timestamp data which has been collected
+ * in Slim Bootloader stages.
+ *
+ * @rev : revision of performance_info structure. currently 1.
+ * @rsvd : padding for alignment
+ * @count : the number of collected timestamp data
+ * @flags : only used in Slim Bootloader
+ * @frequency: tsc frequency in KHz
+ * @timestamp: the array of timestamp data which has 64-bit tsc value
+ */
+struct performance_info {
+ u8 rev;
+ u8 rsvd[3];
+ u16 count;
+ u16 flags;
+ u32 frequency;
+ u64 timestamp[0];
+} __packed;
+
/**
* This returns a pointer to hob data buffer if the given guid hob is found.
*
--
2.20.1
More information about the U-Boot
mailing list