[Concept,07/11] bootm: Update FPDT boot times before handing off to OS

Message ID 20251023094308.3406453-8-sjg@u-boot.org
State New
Headers
Series Bootstage and script enhancements |

Commit Message

Simon Glass Oct. 23, 2025, 9:42 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

Update the FPDT boot performance record's ebs_entry and ebs_exit
fields in bootm_final() to record the time when we're about to
hand off to the operating system.

The timing is recorded just before we start the kernel, after all
device cleanup and before interrupts are disabled, which corresponds
to the ExitBootServices phase in UEFI.

If EFI is used to boot, a further update could be made, but that is
left for later.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

 boot/bootm_final.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
  

Patch

diff --git a/boot/bootm_final.c b/boot/bootm_final.c
index 881d737ce67..870c16b7853 100644
--- a/boot/bootm_final.c
+++ b/boot/bootm_final.c
@@ -5,9 +5,11 @@ 
  * Copyright 2025 Simon Glass <sjg@chromium.org>
  */
 
+#include <acpi/acpi_table.h>
 #include <bootm.h>
 #include <bootstage.h>
 #include <event.h>
+#include <timer.h>
 #include <usb.h>
 #include <dm/root.h>
 
@@ -25,6 +27,21 @@  void bootm_final(enum bootm_final_t flags)
 
 	bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
 
+	/* Update FPDT boot performance record if it exists */
+	if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) {
+		struct acpi_fpdt_boot *fpdt;
+
+		fpdt = acpi_get_fpdt_boot();
+		if (fpdt) {
+			u64 time;
+
+			time = timer_get_boot_us();
+			fpdt->ebs_entry = time;
+			fpdt->ebs_exit = time;
+			acpi_fix_fpdt_checksum();
+		}
+	}
+
 	if (IS_ENABLED(CONFIG_BOOTSTAGE_FDT) && IS_ENABLED(CONFIG_CMD_FDT))
 		bootstage_fdt_add_report();
 	if (IS_ENABLED(CONFIG_BOOTSTAGE_REPORT))