diff mbox series

[v4,3/5] event: Add a generic way to reserve memory

Message ID 20241011212126.747741-4-sjg@chromium.org
State New
Delegated to: Tom Rini
Headers show
Series Adjust initial EFI memory-allocation to be in the U-Boot region | expand

Commit Message

Simon Glass Oct. 11, 2024, 9:21 p.m. UTC
Add an event which allows memory to be reserved, for use after
relocation. This can be used by subsystems which need their own
memory.

This could be used to clean up reserve_arch() but that is left for a
separate series.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/board_f.c |  1 +
 common/event.c   |  1 +
 include/event.h  | 11 +++++++++++
 3 files changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/common/board_f.c b/common/board_f.c
index 154675d0e40..9f13bc9c374 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -976,6 +976,7 @@  static const init_fnc_t init_sequence_f[] = {
 	reserve_bootstage,
 	reserve_bloblist,
 	reserve_arch,
+	INITCALL_EVENT(EVT_RESERVE),
 	reserve_stacks,
 	dram_init_banksize,
 	show_dram_config,
diff --git a/common/event.c b/common/event.c
index dda569d4478..b7da027094b 100644
--- a/common/event.c
+++ b/common/event.c
@@ -37,6 +37,7 @@  const char *const type_name[] = {
 	/* init hooks */
 	"misc_init_f",
 	"fsp_init_r",
+	"reserve",
 	"settings_r",
 	"last_stage_init",
 
diff --git a/include/event.h b/include/event.h
index 75141a192a4..56c05e8e7a4 100644
--- a/include/event.h
+++ b/include/event.h
@@ -104,6 +104,17 @@  enum event_t {
 	 */
 	EVT_FSP_INIT_F,
 
+	/**
+	 * @EVT_RESERVE:
+	 * This event is trigged after all other reservations are done, just
+	 * before the stack is placed. It can be used to reserve memory for any
+	 * other purpose. The memory thus reserved is available immediately and
+	 * will remain valid after relocation.
+	 *
+	 * To reserve memory, subtract the required amount of bytes from
+	 * gd->start_addr_sp
+	 */
+	EVT_RESERVE,
 	/**
 	 * @EVT_SETTINGS_R:
 	 * This event is triggered post-relocation and before console init.