summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Held <felix-coreboot@felixheld.de>2020-11-24 20:37:15 +0100
committerFelix Held <felix-coreboot@felixheld.de>2020-11-30 16:28:56 +0000
commitcd50715e0334fb16006788506e3815e489d337a9 (patch)
treedf59c4d5d44081a31bd07d0a1b75ddcd083fe034
parent9900c4f0b041cb0ac1c958500453a803beda3c8c (diff)
soc/amd: move vboot-on-PSP-related functions to common/vboot
Change-Id: I4f07d3ab12116229a13d2e8c02b2deb06e51a1af Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/47976 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
-rw-r--r--src/soc/amd/common/vboot/vboot_bootblock.c50
-rw-r--r--src/soc/amd/picasso/bootblock/bootblock.c50
-rw-r--r--src/soc/amd/picasso/include/soc/psp_transfer.h2
3 files changed, 52 insertions, 50 deletions
diff --git a/src/soc/amd/common/vboot/vboot_bootblock.c b/src/soc/amd/common/vboot/vboot_bootblock.c
index 3fbc4ef608..45ad9de03e 100644
--- a/src/soc/amd/common/vboot/vboot_bootblock.c
+++ b/src/soc/amd/common/vboot/vboot_bootblock.c
@@ -2,13 +2,23 @@
#include <amdblocks/reset.h>
#include <bl_uapp/bl_syscall_public.h>
+#include <bootblock_common.h>
#include <console/console.h>
#include <pc80/mc146818rtc.h>
#include <security/vboot/vbnv.h>
#include <security/vboot/symbols.h>
#include <soc/psp_transfer.h>
+#include <timestamp.h>
#include <2struct.h>
+static int transfer_buffer_valid(const struct transfer_info_struct *ptr)
+{
+ if (ptr->magic_val == TRANSFER_MAGIC_VAL)
+ return 1;
+ else
+ return 0;
+}
+
void verify_psp_transfer_buf(void)
{
if (*(uint32_t *)_vboot2_work == VB2_SHARED_DATA_MAGIC) {
@@ -51,3 +61,43 @@ void show_psp_transfer_info(void)
"Production" : "Pre-Production");
}
}
+
+void boot_with_psp_timestamp(uint64_t base_timestamp)
+{
+ const struct transfer_info_struct *info = (const struct transfer_info_struct *)
+ (void *)(uintptr_t)_transfer_buffer;
+
+ if (!transfer_buffer_valid(info) || info->timestamp == 0)
+ return;
+
+ /*
+ * info->timestamp is PSP's timestamp (in microseconds)
+ * when x86 processor is released.
+ */
+ uint64_t psp_last_ts = info->timestamp;
+
+ int i;
+ struct timestamp_table *psp_ts_table =
+ (struct timestamp_table *)(void *)
+ ((uintptr_t)_transfer_buffer + info->timestamp_offset);
+ /* new base_timestamp will be offset for all PSP timestamps. */
+ base_timestamp -= psp_last_ts;
+
+ for (i = 0; i < psp_ts_table->num_entries; i++) {
+ struct timestamp_entry *tse = &psp_ts_table->entries[i];
+ /*
+ * We ignore the time between x86 processor release and bootblock.
+ * Since timestamp_add subtracts base_time, we first add old base_time
+ * to make it absolute then add base_timestamp again since
+ * it'll be a new base_time.
+ *
+ * We don't need to convert unit since both PSP and coreboot
+ * will use 1us granularity.
+ *
+ */
+ tse->entry_stamp += psp_ts_table->base_time + base_timestamp;
+ }
+
+ bootblock_main_with_timestamp(base_timestamp, psp_ts_table->entries,
+ psp_ts_table->num_entries);
+}
diff --git a/src/soc/amd/picasso/bootblock/bootblock.c b/src/soc/amd/picasso/bootblock/bootblock.c
index 4bff042a91..0b52a17307 100644
--- a/src/soc/amd/picasso/bootblock/bootblock.c
+++ b/src/soc/amd/picasso/bootblock/bootblock.c
@@ -3,7 +3,6 @@
#include <stdint.h>
#include <symbols.h>
#include <amdblocks/reset.h>
-#include <timestamp.h>
#include <bootblock_common.h>
#include <console/console.h>
#include <cpu/x86/cache.h>
@@ -18,7 +17,6 @@
#include <soc/i2c.h>
#include <amdblocks/amd_pci_mmconf.h>
#include <acpi/acpi.h>
-#include <security/vboot/vbnv.h>
asmlinkage void bootblock_resume_entry(void);
@@ -110,54 +108,6 @@ static void write_resume_eip(void)
wrmsr(S3_RESUME_EIP_MSR, s3_resume_entry);
}
-static int transfer_buffer_valid(const struct transfer_info_struct *ptr)
-{
- if (ptr->magic_val == TRANSFER_MAGIC_VAL)
- return 1;
- else
- return 0;
-}
-
-static void boot_with_psp_timestamp(uint64_t base_timestamp)
-{
- const struct transfer_info_struct *info = (const struct transfer_info_struct *)
- (void *)(uintptr_t)_transfer_buffer;
-
- if (!transfer_buffer_valid(info) || info->timestamp == 0)
- return;
-
- /*
- * info->timestamp is PSP's timestamp (in microseconds)
- * when x86 processor is released.
- */
- uint64_t psp_last_ts = info->timestamp;
-
- int i;
- struct timestamp_table *psp_ts_table =
- (struct timestamp_table *)(void *)
- ((uintptr_t)_transfer_buffer + info->timestamp_offset);
- /* new base_timestamp will be offset for all PSP timestamps. */
- base_timestamp -= psp_last_ts;
-
- for (i = 0; i < psp_ts_table->num_entries; i++) {
- struct timestamp_entry *tse = &psp_ts_table->entries[i];
- /*
- * We ignore the time between x86 processor release and bootblock.
- * Since timestamp_add subtracts base_time, we first add old base_time
- * to make it absolute then add base_timestamp again since
- * it'll be a new base_time.
- *
- * We don't need to convert unit since both PSP and coreboot
- * will use 1us granularity.
- *
- */
- tse->entry_stamp += psp_ts_table->base_time + base_timestamp;
- }
-
- bootblock_main_with_timestamp(base_timestamp, psp_ts_table->entries,
- psp_ts_table->num_entries);
-}
-
asmlinkage void bootblock_c_entry(uint64_t base_timestamp)
{
set_caching();
diff --git a/src/soc/amd/picasso/include/soc/psp_transfer.h b/src/soc/amd/picasso/include/soc/psp_transfer.h
index ce197c11e2..8c78496cea 100644
--- a/src/soc/amd/picasso/include/soc/psp_transfer.h
+++ b/src/soc/amd/picasso/include/soc/psp_transfer.h
@@ -46,6 +46,8 @@ _Static_assert(sizeof(struct transfer_info_struct) == TRANSFER_INFO_SIZE, \
void verify_psp_transfer_buf(void);
/* Display the transfer block's PSP_info data */
void show_psp_transfer_info(void);
+/* Called by bootblock_c_entry in the VBOOT_STARTS_BEFORE_BOOTBLOCK case */
+void boot_with_psp_timestamp(uint64_t base_timestamp);
#endif