[Concept,v2,08/22] boot: Pass flags to the bootm_final event
Commit Message
From: Simon Glass <sjg@chromium.org>
For a fake go, we should tell the event not to actually do anything
irreversable, so pass the flag along.
Move the enum into a separate event_decl.h header file since otherwise
we must include bootm.h which causes a breakage with qemu-ppce500
We also don't want to pull event.h into the tools build, since it uses
types like u8 which are not available outside U-Boot
Signed-off-by: Simon Glass <sjg@chromium.org>
---
(no changes since v1)
boot/bootm_final.c | 13 ++++++++-----
include/bootm.h | 13 +------------
include/event.h | 10 ++++++++++
include/event_decl.h | 27 +++++++++++++++++++++++++++
4 files changed, 46 insertions(+), 17 deletions(-)
create mode 100644 include/event_decl.h
@@ -17,6 +17,7 @@ __weak void board_quiesce_devices(void)
void bootm_final(enum bootm_final_t flags)
{
+ struct event_bootm_final final;
int ret;
printf("\nStarting kernel ...%s\n\n", flags & BOOTM_FINAL_FAKE ?
@@ -43,15 +44,17 @@ void bootm_final(enum bootm_final_t flags)
*/
dm_remove_devices_active();
- ret = event_notify_null(EVT_BOOTM_FINAL);
+ final.flags = flags;
+ ret = event_notify(EVT_BOOTM_FINAL, &final, sizeof(final));
if (ret) {
printf("Event handler failed to finalise (err %dE\n",
ret);
return;
}
+ if (!(flags & BOOTM_FINAL_FAKE)) {
+ bootm_disable_interrupts();
- bootm_disable_interrupts();
-
- if (!(flags & BOOTM_FINAL_NO_CLEANUP))
- cleanup_before_linux();
+ if (!(flags & BOOTM_FINAL_NO_CLEANUP))
+ cleanup_before_linux();
+ }
}
@@ -7,6 +7,7 @@
#ifndef _BOOTM_H
#define _BOOTM_H
+#include <event_decl.h>
#include <image.h>
struct boot_params;
@@ -16,18 +17,6 @@ struct cmd_tbl;
#define BOOTM_ERR_OVERLAP (-2)
#define BOOTM_ERR_UNIMPLEMENTED (-3)
-/**
- * enum bootm_final_t - flags to control bootm_final()
- *
- * @BOOTM_FINAL_FAKE: true to do everything except actually boot; it then
- * returns to the caller
- * @BOOTM_FINAL_NO_CLEANUP: true to skip calling cleanup_before_linux()
- */
-enum bootm_final_t {
- BOOTM_FINAL_FAKE = BIT(0),
- BOOTM_FINAL_NO_CLEANUP = BIT(1),
-};
-
/**
* struct bootm_info() - information used when processing images to boot
*
@@ -12,6 +12,7 @@
#include <dm/ofnode_decl.h>
#include <linux/types.h>
+#include <event_decl.h>
/**
* enum event_t - Types of events supported by U-Boot
@@ -260,6 +261,15 @@ union event_data {
struct event_ft_fixup_f {
oftree tree;
} ft_fixup_f;
+
+ /**
+ * struct event_bootm_final - State information
+ *
+ * @flags: Flags passed to bootm_final()
+ */
+ struct event_bootm_final {
+ enum bootm_final_t flags;
+ } bootm_final;
};
/**
new file mode 100644
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Declarations needed by events
+ *
+ * Copyright 2025 Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __event_decl_h
+#define __event_decl_h
+
+#include <linux/bitops.h>
+
+/**
+ * enum bootm_final_t - flags to control bootm_final()
+ *
+ * Note that this is defined in event.h since it is used by events
+ *
+ * @BOOTM_FINAL_FAKE: true to do everything except actually boot; it then
+ * returns to the caller
+ * @BOOTM_FINAL_NO_CLEANUP: true to skip calling cleanup_before_linux()
+ */
+enum bootm_final_t {
+ BOOTM_FINAL_FAKE = BIT(0),
+ BOOTM_FINAL_NO_CLEANUP = BIT(1),
+};
+
+#endif