Add EVT_RESERVE_BOARD event for custom memory reservation
Add a new EVT_RESERVE_BOARD event that is triggered immediately after the reserve_board() initcall completes during pre-relocation init. This allows board or application code to reserve additional memory before other reservations (global_data, fdt, etc). The event is placed after EVT_FSP_INIT_F in the event enumeration and is triggered in board_f.c right after the reserve_board initcall. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
@@ -533,6 +533,9 @@ static int reserve_malloc(void)
|
||||
/* (permanently) allocate a Board Info struct */
|
||||
static int reserve_board(void)
|
||||
{
|
||||
struct event_reserve_board reserve;
|
||||
int ret;
|
||||
|
||||
if (!gd->bd) {
|
||||
gd->start_addr_sp = reserve_stack_aligned(sizeof(struct bd_info));
|
||||
gd->bd = (struct bd_info *)map_sysmem(gd->start_addr_sp,
|
||||
@@ -541,6 +544,14 @@ static int reserve_board(void)
|
||||
debug("Reserving %zu Bytes for Board Info at: %08lx\n",
|
||||
sizeof(struct bd_info), gd->start_addr_sp);
|
||||
}
|
||||
|
||||
/* Allow board/app code to reserve additional memory */
|
||||
reserve.start_addr_sp = gd->start_addr_sp;
|
||||
ret = event_notify_resp(EVT_RESERVE_BOARD, &reserve, sizeof(reserve));
|
||||
if (ret)
|
||||
return log_msg_ret("res", ret);
|
||||
gd->start_addr_sp = reserve.start_addr_sp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ const char *const type_name[] = {
|
||||
/* init hooks */
|
||||
"misc_init_f",
|
||||
"fsp_init_r",
|
||||
"reserve_board",
|
||||
"settings_r",
|
||||
"last_stage_init",
|
||||
|
||||
|
||||
@@ -105,6 +105,16 @@ enum event_t {
|
||||
*/
|
||||
EVT_FSP_INIT_F,
|
||||
|
||||
/**
|
||||
* @EVT_RESERVE_BOARD:
|
||||
* This event is triggered immediately after reserve_board() completes
|
||||
* during pre-relocation init. It allows board or application code to
|
||||
* reserve additional memory before other reservations.
|
||||
* A non-zero return code from the event spy causes the boot process
|
||||
* to fail.
|
||||
*/
|
||||
EVT_RESERVE_BOARD,
|
||||
|
||||
/**
|
||||
* @EVT_SETTINGS_R:
|
||||
* This event is triggered post-relocation and before console init.
|
||||
@@ -292,6 +302,18 @@ union event_data {
|
||||
char *bootcmd;
|
||||
int size;
|
||||
} bootcmd;
|
||||
|
||||
/**
|
||||
* struct event_reserve_board - memory reservation event
|
||||
*
|
||||
* This is used for EVT_RESERVE_BOARD
|
||||
*
|
||||
* @start_addr_sp: On entry, current stack pointer for reservations;
|
||||
* on exit, updated stack pointer after any additional reservations
|
||||
*/
|
||||
struct event_reserve_board {
|
||||
ulong start_addr_sp;
|
||||
} reserve_board;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user