From patchwork Tue Aug 19 18:58:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 10 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755630045; bh=XIhlcYMk9yB5gIiaUL1xKIokMZcYuBPKCA1IFhcauVI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Pd+TfWwnbzEtNwLuIQ7QMxN6ehP1AoCharAa6Q/oDkWA+VFsOoSwTs1A2Osw9e2D7 DBmHtPVRnkO0ij/NFnUWasgGJKB1ljACMGi8KLwHD1xUHy/rTVRDjTmIaIRsFFONLZ w4ybMUFMMMt0CbsnnIlt/wxDlT1hhrCeluW80NPevo1TECGFCAlqjzyboNqEQ0hzQl uChGGcxPntVVvoNUNAgEd8IdXd+ZXXkIANab/tNTCwJfgMHScqhXJdJaUvRfwhyEHm qSccksI8uHTsiLsuZf406aCw2ZaxHjFG883KTxIvgHkHsLWOHw5swgs7hgBh19Zfpy yVJCkkUs9H7PA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 494FB67607 for ; Tue, 19 Aug 2025 13:00:45 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id NVTTzsNM2i4A for ; Tue, 19 Aug 2025 13:00:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755630045; bh=XIhlcYMk9yB5gIiaUL1xKIokMZcYuBPKCA1IFhcauVI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Pd+TfWwnbzEtNwLuIQ7QMxN6ehP1AoCharAa6Q/oDkWA+VFsOoSwTs1A2Osw9e2D7 DBmHtPVRnkO0ij/NFnUWasgGJKB1ljACMGi8KLwHD1xUHy/rTVRDjTmIaIRsFFONLZ w4ybMUFMMMt0CbsnnIlt/wxDlT1hhrCeluW80NPevo1TECGFCAlqjzyboNqEQ0hzQl uChGGcxPntVVvoNUNAgEd8IdXd+ZXXkIANab/tNTCwJfgMHScqhXJdJaUvRfwhyEHm qSccksI8uHTsiLsuZf406aCw2ZaxHjFG883KTxIvgHkHsLWOHw5swgs7hgBh19Zfpy yVJCkkUs9H7PA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3970267600 for ; Tue, 19 Aug 2025 13:00:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755630042; bh=QsQdaNjTpS0gyLoYAk0zGENvGv86wIPmT/XADfbVG+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KIKSlmDqqPwHXemeZQQkGW/Htb976bgMoNHDv9GrPpRWqouv7wwVPEYCtvFkPj+RR IluypQd8su1NSUueoisj2S/a+vVZSM7H9figJzhsB9SB3u0Yc520GObbOi0dVeZRYt FglDIj2ZXDRpIkIEIIzVoLdIG9b+tIiUYkje3oy1NCOd9I1unqypBzzsMZLZGATzbK b1KtyGHtn4/5sWOyV4FdPQUqSXiEi600fjCANgAiBsNe3PAcsxSxvzuAKnFUi7ncMh eVQi9KUa3sKtAuMZjo1PCMN9vxCo6YGeYwclGBYNWWegYBbdKk7nMqbvvnxe/T5pmY F2RqNKptEypVg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9B163675F8; Tue, 19 Aug 2025 13:00:42 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id yxeXIYKLlb5x; Tue, 19 Aug 2025 13:00:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755630041; bh=ZQdkrbAu0jsSdh07pXNlJF6jjtJ/4w9Dz8Qq7G5M1Hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=br2rq27YE2wP19D15G0SPpGeKPElJwe+juMOH+YGM2+kBsTfDnz4+/SgXSC6wR6eo A3qWLyAO8hnqnikPJsJ5dmp0DhqX5kdGXICRUf/Fx3+fxLhw53NhLldTkwizdwcDE8 WygV1IwWE6bYSMy2FTau243FLk6BkeMjkmUAqZEfK60oXluOg30E1WPE73ERkuF8Mt 4oThlk2r3QxzRKSin12ymV338A4tlGtfjdr2zAezh0BzVnGb6OkoCKjeAyGr9SCNeD kgnEi+B7iN5642QHEJzrVrLGCs1TkeYkWePMID0EYKuwn4huBtgZTkUAV8PSO+LWg0 ZznYTJl8Nv//w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CF921675DE; Tue, 19 Aug 2025 13:00:40 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 19 Aug 2025 12:58:39 -0600 Message-ID: <20250819185900.835939-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250819185900.835939-1-sjg@u-boot.org> References: <20250819185900.835939-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YUR27PHJYMIYPMOE5OS26TEYFFUFBBDU X-Message-ID-Hash: YUR27PHJYMIYPMOE5OS26TEYFFUFBBDU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 08/22] boot: Pass flags to the bootm_final event List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 --- (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 diff --git a/boot/bootm_final.c b/boot/bootm_final.c index 7594880399e..881d737ce67 100644 --- a/boot/bootm_final.c +++ b/boot/bootm_final.c @@ -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(); + } } diff --git a/include/bootm.h b/include/bootm.h index b026e1dd80d..392825841e9 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -7,6 +7,7 @@ #ifndef _BOOTM_H #define _BOOTM_H +#include #include 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 * diff --git a/include/event.h b/include/event.h index a68be9fc1e8..5fecaa66e80 100644 --- a/include/event.h +++ b/include/event.h @@ -12,6 +12,7 @@ #include #include +#include /** * 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; }; /** diff --git a/include/event_decl.h b/include/event_decl.h new file mode 100644 index 00000000000..483ae687e5a --- /dev/null +++ b/include/event_decl.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Declarations needed by events + * + * Copyright 2025 Simon Glass + */ + +#ifndef __event_decl_h +#define __event_decl_h + +#include + +/** + * 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