boot: Pass flags to the bootm_final event

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>
This commit is contained in:
Simon Glass
2025-08-15 13:45:10 -06:00
parent cc6a9fe314
commit ddb78711fd
4 changed files with 46 additions and 17 deletions

View File

@@ -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();
}
}

View File

@@ -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
*

View File

@@ -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;
};
/**

27
include/event_decl.h Normal file
View File

@@ -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