Merge branch '2023-08-31-replace-more-init-hooks-with-events' into next

To quote the author:
This series replaces some more of the init hooks in board_f.c and
board_r.c with events. Notably it converts last_state_init() over.

It also provides a 'simple' event spy, which takes no arguments. It
turns out that this is quite a common case, so it is worth optimising
for this, to reduce code size, before events become too commonly used.

Finally, it introduces a way of emitting an event in an initcall,
instead of calling a function. This is likely to be used at least as
often as the functions, as we convert more of these initcalls.

As part of this, the initcall code is brought back into a C file. Somehow
the compiler has changed or something else, so that this does not confer
any benefits now.

For boards with EVENT enabled, this unfortunately results in small
growth, e.g. for firefly:

   aarch64: (for 1/1 boards) all +114.0 data +16.0 rodata +22.0 text +76.0
       arm: (for 1/1 boards) all +82.0 rodata +18.0 text +64.0

For boards without EVENT enabled the growth is smaller, e.g. nokia_rx51:

       arm: (for 1/1 boards) all +32.0 data +8.0 rodata -8.0 text +32.0

I cannot find a good way to avoid the latter, other than macro magic
with an embedded comma (to completely remove an event entry), which
seems nasty.
This commit is contained in:
Tom Rini
2023-08-31 15:10:42 -04:00
89 changed files with 430 additions and 260 deletions
+1
View File
@@ -252,6 +252,7 @@ config X86
imply DM_SPI
imply DM_SPI_FLASH
imply DM_USB
imply LAST_STAGE_INIT
imply VIDEO
imply SYSRESET
imply SPL_SYSRESET
+5
View File
@@ -78,6 +78,11 @@ void tzpc_init(void)
#endif
}
__weak int init_func_vid(void)
{
return 0;
}
void board_init_f(ulong dummy)
{
int ret;
+2 -2
View File
@@ -69,7 +69,7 @@ int arch_cpu_init(void)
return 0;
}
static int imx8_init_mu(void *ctx, struct event *event)
static int imx8_init_mu(void)
{
struct udevice *devp;
int node, ret;
@@ -91,7 +91,7 @@ static int imx8_init_mu(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, imx8_init_mu);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, imx8_init_mu);
#if defined(CONFIG_ARCH_MISC_INIT)
int arch_misc_init(void)
+2 -2
View File
@@ -532,7 +532,7 @@ static void imx_set_wdog_powerdown(bool enable)
writew(enable, &wdog3->wmcr);
}
static int imx8m_check_clock(void *ctx, struct event *event)
static int imx8m_check_clock(void)
{
struct udevice *dev;
int ret;
@@ -549,7 +549,7 @@ static int imx8m_check_clock(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, imx8m_check_clock);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, imx8m_check_clock);
static void imx8m_setup_snvs(void)
{
+1 -6
View File
@@ -803,12 +803,7 @@ int imx8ulp_dm_post_init(void)
return 0;
}
static int imx8ulp_evt_dm_post_init(void *ctx, struct event *event)
{
return imx8ulp_dm_post_init();
}
EVENT_SPY(EVT_DM_POST_INIT_F, imx8ulp_evt_dm_post_init);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, imx8ulp_dm_post_init);
#if defined(CONFIG_SPL_BUILD)
__weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
+2 -2
View File
@@ -552,7 +552,7 @@ int arch_cpu_init(void)
return 0;
}
int imx9_probe_mu(void *ctx, struct event *event)
int imx9_probe_mu(void)
{
struct udevice *devp;
int node, ret;
@@ -576,7 +576,7 @@ int imx9_probe_mu(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, imx9_probe_mu);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, imx9_probe_mu);
int timer_init(void)
{
+2 -2
View File
@@ -527,7 +527,7 @@ void board_init_f(ulong dummy)
#endif
static int am33xx_dm_post_init(void *ctx, struct event *event)
static int am33xx_dm_post_init(void)
{
hw_data_init();
#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
@@ -535,4 +535,4 @@ static int am33xx_dm_post_init(void *ctx, struct event *event)
#endif
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, am33xx_dm_post_init);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, am33xx_dm_post_init);
+4 -8
View File
@@ -174,7 +174,7 @@ void __weak init_package_revision(void)
* done in each of these cases
* This function is called with SRAM stack.
*/
void early_system_init(void)
int early_system_init(void)
{
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_MULTI_DTB_FIT)
int ret;
@@ -225,6 +225,8 @@ void early_system_init(void)
debug_uart_init();
#endif
prcm_init();
return 0;
}
#ifdef CONFIG_SPL_BUILD
@@ -240,13 +242,7 @@ void board_init_f(ulong dummy)
}
#endif
static int omap2_system_init(void *ctx, struct event *event)
{
early_system_init();
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, omap2_system_init);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, early_system_init);
/*
* Routine: wait_for_command_complete
+5 -1
View File
@@ -4,6 +4,7 @@
*/
#include <common.h>
#include <event.h>
#include <init.h>
#include <malloc.h>
#include <asm/addrspace.h>
@@ -21,7 +22,8 @@ int dram_init(void)
return 0;
}
int last_stage_init(void)
#ifndef CONFIG_SPL_BUILD
static int last_stage_init(void)
{
void *src, *dst;
@@ -46,3 +48,5 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
#endif
+4 -8
View File
@@ -57,7 +57,7 @@ static ulong clk_get_cpu_rate(void)
}
/* initialize prefetch module related to cpu_clk */
static void prefetch_init(void)
static int prefetch_init(void)
{
struct pic32_reg_atomic *regs;
const void __iomem *base;
@@ -93,16 +93,12 @@ static void prefetch_init(void)
/* Enable prefetch for all */
writel(0x30, &regs->set);
iounmap(regs);
}
/* arch specific CPU init after DM */
static int pic32_flash_prefetch(void *ctx, struct event *event)
{
/* flash prefetch */
prefetch_init();
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, pic32_flash_prefetch);
/* arch-specific CPU init after DM: flash prefetch */
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, prefetch_init);
/* Un-gate DDR2 modules (gated by default) */
static void ddr2_pmd_ungate(void)
+2 -2
View File
@@ -64,7 +64,7 @@ static void copy_exception_trampoline(void)
}
#endif
static int nios_cpu_setup(void *ctx, struct event *event)
static int nios_cpu_setup(void)
{
struct udevice *dev;
int ret;
@@ -80,7 +80,7 @@ static int nios_cpu_setup(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, nios_cpu_setup);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, nios_cpu_setup);
static int altera_nios2_get_desc(const struct udevice *dev, char *buf,
int size)
+2 -2
View File
@@ -91,7 +91,7 @@ static void dummy_pending_ipi_clear(ulong hart, ulong arg0, ulong arg1)
}
#endif
int riscv_cpu_setup(void *ctx, struct event *event)
int riscv_cpu_setup(void)
{
int ret;
@@ -145,7 +145,7 @@ int riscv_cpu_setup(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, riscv_cpu_setup);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, riscv_cpu_setup);
int arch_early_init_r(void)
{
+1 -1
View File
@@ -26,6 +26,6 @@ struct event;
} while (0)
/* Hook to set up the CPU (called from SPL too) */
int riscv_cpu_setup(void *ctx, struct event *event);
int riscv_cpu_setup(void);
#endif /* __ASM_RISCV_SYSTEM_H */
+1 -1
View File
@@ -28,7 +28,7 @@ __weak void board_init_f(ulong dummy)
if (ret)
panic("spl_early_init() failed: %d\n", ret);
riscv_cpu_setup(NULL, NULL);
riscv_cpu_setup();
preloader_console_init();
+1 -6
View File
@@ -119,12 +119,7 @@ int sandbox_early_getopt_check(void)
os_exit(0);
}
static int sandbox_misc_init_f(void *ctx, struct event *event)
{
return sandbox_early_getopt_check();
}
EVENT_SPY(EVT_MISC_INIT_F, sandbox_misc_init_f);
EVENT_SPY_SIMPLE(EVT_MISC_INIT_F, sandbox_early_getopt_check);
static int sandbox_cmdline_cb_help(struct sandbox_state *state, const char *arg)
{
+2 -2
View File
@@ -45,7 +45,7 @@ static void hsuart_clock_set(void *base)
* Configure the internal clock of both SIO HS-UARTs, if they are enabled
* via FSP
*/
static int baytrail_uart_init(void *ctx, struct event *event)
static int baytrail_uart_init(void)
{
struct udevice *dev;
void *base;
@@ -64,7 +64,7 @@ static int baytrail_uart_init(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, baytrail_uart_init);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, baytrail_uart_init);
static void set_max_freq(void)
{
+2 -2
View File
@@ -25,7 +25,7 @@
#include <asm/arch/pch.h>
#include <asm/arch/rcb.h>
static int broadwell_init_cpu(void *ctx, struct event *event)
static int broadwell_init_cpu(void)
{
struct udevice *dev;
int ret;
@@ -40,7 +40,7 @@ static int broadwell_init_cpu(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, broadwell_init_cpu);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, broadwell_init_cpu);
void set_max_freq(void)
{
+6 -1
View File
@@ -7,6 +7,7 @@
#include <common.h>
#include <cpu_func.h>
#include <event.h>
#include <fdtdec.h>
#include <init.h>
#include <usb.h>
@@ -74,8 +75,11 @@ static void board_final_init(void)
}
}
int last_stage_init(void)
static int last_stage_init(void)
{
if (IS_ENABLED(CONFIG_SPL_BUILD))
return 0;
/* start usb so that usb keyboard can be used as input device */
if (IS_ENABLED(CONFIG_USB_KEYBOARD))
usb_init();
@@ -84,3 +88,4 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
+7 -3
View File
@@ -26,6 +26,7 @@
#include <cpu_func.h>
#include <dm.h>
#include <errno.h>
#include <event.h>
#include <init.h>
#include <irq.h>
#include <log.h>
@@ -185,7 +186,8 @@ void show_boot_progress(int val)
}
#endif
#if !defined(CONFIG_SYS_COREBOOT) && !defined(CONFIG_EFI_STUB)
#if !defined(CONFIG_SYS_COREBOOT) && !defined(CONFIG_EFI_STUB) && \
!defined(CONFIG_SPL_BUILD)
/*
* Implement a weak default function for boards that need to do some final init
* before the system is ready.
@@ -202,7 +204,7 @@ __weak void board_final_cleanup(void)
{
}
int last_stage_init(void)
static int last_stage_init(void)
{
struct acpi_fadt __maybe_unused *fadt;
int ret;
@@ -245,7 +247,9 @@ int last_stage_init(void)
return 0;
}
#endif
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
#endif /* !SYS_COREBOOT && !EFI_STUB && !SPL_BUILD */
static int x86_init_cpus(void)
{
+3 -1
View File
@@ -9,6 +9,7 @@
#include <efi.h>
#include <efi_api.h>
#include <errno.h>
#include <event.h>
#include <init.h>
#include <log.h>
#include <usb.h>
@@ -168,7 +169,7 @@ int reserve_arch(void)
return 0;
}
int last_stage_init(void)
static int last_stage_init(void)
{
/* start usb so that usb keyboard can be used as input device */
if (IS_ENABLED(CONFIG_USB_KEYBOARD))
@@ -176,6 +177,7 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
unsigned int install_e820_map(unsigned int max_entries,
struct e820_entry *entries)
+2 -2
View File
@@ -54,7 +54,7 @@ int arch_cpu_init(void)
return x86_cpu_init_f();
}
static int ivybridge_cpu_init(void *ctx, struct event *ev)
static int ivybridge_cpu_init(void)
{
struct pci_controller *hose;
struct udevice *bus, *dev;
@@ -86,7 +86,7 @@ static int ivybridge_cpu_init(void *ctx, struct event *ev)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, ivybridge_cpu_init);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, ivybridge_cpu_init);
#define PCH_EHCI0_TEMP_BAR0 0xe8000000
#define PCH_EHCI1_TEMP_BAR0 0xe8000400
+13 -17
View File
@@ -107,7 +107,7 @@ static void quark_setup_bars(void)
CONFIG_PCIE_ECAM_BASE | MEM_BAR_EN);
}
static void quark_pcie_early_init(void)
static int quark_pcie_early_init(void)
{
/*
* Step1: Assert PCIe signal PERST#
@@ -146,6 +146,8 @@ static void quark_pcie_early_init(void)
/* Mixer Load Lane 1 */
msg_port_io_clrbits(MSG_PORT_PCIE_AFE, PCIE_RXPICTRL0_L1,
(1 << 6) | (1 << 7));
return 0;
}
static void quark_usb_early_init(void)
@@ -248,22 +250,16 @@ int arch_cpu_init(void)
return 0;
}
static int quark_init_pcie(void *ctx, struct event *event)
{
/*
* Initialize PCIe controller
*
* Quark SoC holds the PCIe controller in reset following a power on.
* U-Boot needs to release the PCIe controller from reset. The PCIe
* controller (D23:F0/F1) will not be visible in PCI configuration
* space and any access to its PCI configuration registers will cause
* system hang while it is held in reset.
*/
quark_pcie_early_init();
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, quark_init_pcie);
/*
* Initialize PCIe controller
*
* Quark SoC holds the PCIe controller in reset following a power on.
* U-Boot needs to release the PCIe controller from reset. The PCIe
* controller (D23:F0/F1) will not be visible in PCI configuration
* space and any access to its PCI configuration registers will cause
* system hang while it is held in reset.
*/
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, quark_pcie_early_init);
int checkcpu(void)
{
+1
View File
@@ -101,3 +101,4 @@ int arch_fsp_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_FSP_INIT_F, arch_fsp_init);
-5
View File
@@ -8,11 +8,6 @@
#include <init.h>
#include <asm/fsp/fsp_support.h>
int arch_fsp_init(void)
{
return 0;
}
void board_final_cleanup(void)
{
u32 status;
+2 -2
View File
@@ -19,7 +19,7 @@
#include <dm/uclass-internal.h>
#include <asm/fsp2/fsp_internal.h>
int fsp_setup_pinctrl(void *ctx, struct event *event)
int fsp_setup_pinctrl(void)
{
struct udevice *dev;
ofnode node;
@@ -42,7 +42,7 @@ int fsp_setup_pinctrl(void *ctx, struct event *event)
return ret;
}
EVENT_SPY(EVT_DM_POST_INIT_F, fsp_setup_pinctrl);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, fsp_setup_pinctrl);
#if !defined(CONFIG_TPL_BUILD)
binman_sym_declare(ulong, intel_fsp_m, image_pos);
+3 -1
View File
@@ -15,6 +15,7 @@
#include <dm.h>
#include <dm/of_extra.h>
#include <env.h>
#include <event.h>
#include <fdt_support.h>
#include <init.h>
#include <led.h>
@@ -667,7 +668,7 @@ err:
return NULL;
}
int last_stage_init(void)
static int last_stage_init(void)
{
struct gpio_desc reset_gpio = {};
@@ -712,6 +713,7 @@ handle_reset_btn:
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
#if defined(CONFIG_OF_BOARD_SETUP)
+4 -1
View File
@@ -8,6 +8,7 @@
#include <dm/device-internal.h>
#include <env.h>
#include <env_internal.h>
#include <event.h>
#include <i2c.h>
#include <init.h>
#include <mmc.h>
@@ -301,7 +302,7 @@ static int mii_multi_chip_mode_write(struct udevice *bus, int dev_smi_addr,
}
/* Bring-up board-specific network stuff */
int last_stage_init(void)
static int last_stage_init(void)
{
struct udevice *bus;
ofnode node;
@@ -356,6 +357,8 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
#endif
#ifdef CONFIG_OF_BOARD_SETUP
+3 -1
View File
@@ -5,6 +5,7 @@
#include <cyclic.h>
#include <dm.h>
#include <event.h>
#include <ram.h>
#include <time.h>
#include <asm/gpio.h>
@@ -364,7 +365,7 @@ int board_late_init(void)
return 0;
}
int last_stage_init(void)
static int last_stage_init(void)
{
struct gpio_desc gpio = {};
ofnode node;
@@ -386,3 +387,4 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
+3 -1
View File
@@ -12,6 +12,7 @@
#include <asm/global_data.h>
#include <dm/uclass-internal.h>
#include <env.h>
#include <event.h>
#include <init.h>
#include <malloc.h>
#include <net.h>
@@ -213,11 +214,12 @@ void board_acquire_flash_arb(bool acquire)
}
}
int last_stage_init(void)
static int last_stage_init(void)
{
(void)smc_flsf_fw_booted();
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
static int do_go_uboot(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
+3 -1
View File
@@ -4,6 +4,7 @@
*
*/
#include <common.h>
#include <event.h>
#include <init.h>
#include <malloc.h>
#include <errno.h>
@@ -121,7 +122,7 @@ void reset_cpu(void)
}
#ifdef CONFIG_LAST_STAGE_INIT
int last_stage_init(void)
static int last_stage_init(void)
{
u32 val;
@@ -134,4 +135,5 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
#endif
+3 -1
View File
@@ -9,6 +9,7 @@
#include <cpu_func.h>
#include <dm.h>
#include <env.h>
#include <event.h>
#include <init.h>
#include <log.h>
#include <net.h>
@@ -184,7 +185,7 @@ int misc_init_r(void)
return 0;
}
int last_stage_init(void)
static int last_stage_init(void)
{
void *fdt = get_fdt_virt();
int len = 0;
@@ -204,6 +205,7 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
static uint64_t get_linear_ram_size(void)
{
+2 -1
View File
@@ -181,13 +181,14 @@ unsigned long long get_qixis_addr(void)
#endif
#if defined(CONFIG_VID)
int init_func_vid(void)
static int setup_core_voltage(void)
{
if (adjust_vdd(0) < 0)
printf("core voltage not adjusted\n");
return 0;
}
EVENT_SPY_SIMPLE(EVT_MISC_INIT_F, setup_core_voltage);
u16 soc_get_fuse_vid(int vid_index)
{
+2
View File
@@ -13,6 +13,7 @@
#include <i2c.h>
#include <malloc.h>
#include <errno.h>
#include <event.h>
#include <netdev.h>
#include <fsl_ddr.h>
#include <asm/io.h>
@@ -242,6 +243,7 @@ int init_func_vid(void)
return 0;
}
#endif
EVENT_SPY_SIMPLE(EVT_MISC_INIT_F, init_func_vid);
int checkboard(void)
{
+14 -17
View File
@@ -7,6 +7,7 @@
#include <common.h>
#include <command.h>
#include <dm.h>
#include <event.h>
#include <init.h>
#include <miiphy.h>
#include <net.h>
@@ -35,19 +36,6 @@ DECLARE_GLOBAL_DATA_PTR;
#define DB_GP_88F68XX_GPP_POL_LOW 0x0
#define DB_GP_88F68XX_GPP_POL_MID 0x0
static int get_tpm(struct udevice **devp)
{
int rc;
rc = uclass_first_device_err(UCLASS_TPM, devp);
if (rc) {
printf("Could not find TPM (ret=%d)\n", rc);
return CMD_RET_FAILURE;
}
return 0;
}
/*
* Define the DDR layout / topology here in the board file. This will
* be used by the DDR3 init code in the SPL U-Boot version to configure
@@ -284,15 +272,22 @@ int board_fix_fdt(void *rw_fdt_blob)
return 0;
}
int last_stage_init(void)
#ifndef CONFIG_SPL_BUILD
static int last_stage_init(void)
{
struct udevice *tpm;
int ret;
#ifndef CONFIG_SPL_BUILD
if (IS_ENABLED(CONFIG_SPL_BUILD))
return 0;
ccdc_eth_init();
#endif
ret = get_tpm(&tpm);
ret = uclass_first_device_err(UCLASS_TPM, &tpm);
if (ret) {
printf("Could not find TPM (ret=%d)\n", ret);
return ret;
}
if (ret || tpm_init(tpm) || tpm1_startup(tpm, TPM_ST_CLEAR) ||
tpm1_continue_self_test(tpm)) {
return 1;
@@ -305,3 +300,5 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
#endif
+3 -1
View File
@@ -9,6 +9,7 @@
#include <command.h>
#include <dm.h>
#include <env.h>
#include <event.h>
#include <fdt_support.h>
#include <fsl_esdhc.h>
#include <init.h>
@@ -124,7 +125,7 @@ static void display_osd_info(struct udevice *osd,
osd_info->width, osd_info->height);
}
int last_stage_init(void)
static int last_stage_init(void)
{
int fpga_hw_rev = 0;
int i;
@@ -179,6 +180,7 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
#if defined(CONFIG_OF_BOARD_SETUP)
int ft_board_setup(void *blob, struct bd_info *bd)
+3 -1
View File
@@ -5,6 +5,7 @@
* Copyright 2012 Freescale Semiconductor, Inc.
*/
#include <event.h>
#include <image.h>
#include <init.h>
#include <asm/arch/clock.h>
@@ -531,7 +532,7 @@ static void remove_ethaddr_env_var(int index)
env_set(env_var_name, NULL);
}
int last_stage_init(void)
static int last_stage_init(void)
{
int i;
@@ -544,6 +545,7 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
int checkboard(void)
{
+2 -2
View File
@@ -33,7 +33,7 @@ struct cros_gpio_info {
int flags;
};
static int coral_check_ll_boot(void *ctx, struct event *event)
static int coral_check_ll_boot(void)
{
if (!ll_boot_init()) {
printf("Running as secondary loader");
@@ -57,7 +57,7 @@ static int coral_check_ll_boot(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_MISC_INIT_F, coral_check_ll_boot);
EVENT_SPY_SIMPLE(EVT_MISC_INIT_F, coral_check_ll_boot);
int arch_misc_init(void)
{
+3 -1
View File
@@ -15,6 +15,7 @@
#include <common.h>
#include <env.h>
#include <event.h>
#include <fdt_support.h>
#include <init.h>
#include <ioports.h>
@@ -184,7 +185,7 @@ int misc_init_r(void)
return 0;
}
int last_stage_init(void)
static int last_stage_init(void)
{
#if defined(CONFIG_TARGET_KMCOGE5NE)
/*
@@ -202,6 +203,7 @@ int last_stage_init(void)
set_km_env();
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
static int fixed_sdram(void)
{
+4 -3
View File
@@ -182,7 +182,7 @@ unsigned long get_serial_clock(unsigned long dummy)
return (gd->bus_clk / 2);
}
static int kmcent2_misc_init_f(void *ctx, struct event *event)
static int kmcent2_misc_init_f(void)
{
/* configure QRIO pis for i2c deblocking */
i2c_deblock_gpio_cfg();
@@ -210,7 +210,7 @@ static int kmcent2_misc_init_f(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_MISC_INIT_F, kmcent2_misc_init_f);
EVENT_SPY_SIMPLE(EVT_MISC_INIT_F, kmcent2_misc_init_f);
#define USED_SRDS_BANK 0
#define EXPECTED_SRDS_RFCK SRDS_PLLCR0_RFCK_SEL_100
@@ -261,7 +261,7 @@ int hush_init_var(void)
return 0;
}
int last_stage_init(void)
static int last_stage_init(void)
{
const char *kmem;
/* DIP switch support on BFTIC */
@@ -287,6 +287,7 @@ int last_stage_init(void)
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
void fdt_fixup_fman_mac_addresses(void *blob)
{
@@ -110,14 +110,14 @@ int board_early_init_f(void)
return 0;
}
static int pg_wcom_misc_init_f(void *ctx, struct event *event)
static int pg_wcom_misc_init_f(void)
{
if (IS_ENABLED(CONFIG_PG_WCOM_UBOOT_UPDATE_SUPPORTED))
check_for_uboot_update();
return 0;
}
EVENT_SPY(EVT_MISC_INIT_F, pg_wcom_misc_init_f);
EVENT_SPY_SIMPLE(EVT_MISC_INIT_F, pg_wcom_misc_init_f);
int board_init(void)
{
@@ -215,8 +215,4 @@ int hush_init_var(void)
return 0;
}
int last_stage_init(void)
{
set_km_env();
return 0;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, set_km_env);
+3 -1
View File
@@ -8,6 +8,7 @@
#include <common.h>
#include <command.h>
#include <cpu_func.h>
#include <event.h>
#include <init.h>
#include <log.h>
#include <asm/armv8/mmu.h>
@@ -99,7 +100,7 @@ int __asm_flush_l3_dcache(void)
return 0;
}
int last_stage_init(void)
static int last_stage_init(void)
{
int ret;
@@ -113,3 +114,4 @@ int last_stage_init(void)
}
return ret;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
+3 -1
View File
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <command.h>
#include <event.h>
#include <init.h>
#include <asm/armv8/mmu.h>
#include <asm/io.h>
@@ -102,7 +103,7 @@ int __asm_flush_l3_dcache(void)
return 0;
}
int last_stage_init(void)
static int last_stage_init(void)
{
int ret;
@@ -116,3 +117,4 @@ int last_stage_init(void)
}
return ret;
}
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
+1 -1
View File
@@ -218,7 +218,7 @@ void board_init_f(ulong dummy)
if (ret)
panic("spl_early_init() failed: %d\n", ret);
riscv_cpu_setup(NULL, NULL);
riscv_cpu_setup();
preloader_console_init();
/* Set the parent clock of cpu_root clock to pll0,
+1 -1
View File
@@ -230,4 +230,4 @@ static int bootmeth_vbe_ft_fixup(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_FT_FIXUP, bootmeth_vbe_ft_fixup);
EVENT_SPY_FULL(EVT_FT_FIXUP, bootmeth_vbe_ft_fixup);
+1 -1
View File
@@ -109,4 +109,4 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_FT_FIXUP, bootmeth_vbe_simple_ft_fixup);
EVENT_SPY_FULL(EVT_FT_FIXUP, bootmeth_vbe_simple_ft_fixup);
+1
View File
@@ -720,6 +720,7 @@ config SYS_FSL_CLK
config LAST_STAGE_INIT
bool "Call board-specific as last setup step"
select EVENT
help
Some boards need to perform initialisation immediately before control
is passed to the command-line interpreter (e.g. for initializations
+2 -19
View File
@@ -280,13 +280,6 @@ static int init_func_i2c(void)
}
#endif
#if defined(CONFIG_VID)
__weak int init_func_vid(void)
{
return 0;
}
#endif
static int setup_mon_len(void)
{
#if defined(__ARM__) || defined(__MICROBLAZE__)
@@ -836,11 +829,6 @@ __weak int clear_bss(void)
return 0;
}
static int misc_init_f(void)
{
return event_notify_null(EVT_MISC_INIT_F);
}
static const init_fnc_t init_sequence_f[] = {
setup_mon_len,
#ifdef CONFIG_OF_CONTROL
@@ -860,9 +848,7 @@ static const init_fnc_t init_sequence_f[] = {
#if defined(CONFIG_CONSOLE_RECORD_INIT_F)
console_record_init,
#endif
#if defined(CONFIG_HAVE_FSP)
arch_fsp_init,
#endif
INITCALL_EVENT(EVT_FSP_INIT_F),
arch_cpu_init, /* basic arch cpu dependent setup */
mach_cpu_init, /* SoC/machine dependent CPU setup */
initf_dm,
@@ -899,13 +885,10 @@ static const init_fnc_t init_sequence_f[] = {
show_board_info,
#endif
INIT_FUNC_WATCHDOG_INIT
misc_init_f,
INITCALL_EVENT(EVT_MISC_INIT_F),
INIT_FUNC_WATCHDOG_RESET
#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
init_func_i2c,
#endif
#if defined(CONFIG_VID) && !defined(CONFIG_SPL)
init_func_vid,
#endif
announce_dram_init,
dram_init, /* configure available RAM banks */
+7 -13
View File
@@ -583,7 +583,10 @@ static int run_main_loop(void)
}
/*
* We hope to remove most of the driver-related init and do it if/when
* Over time we hope to remove these functions with code fragments and
* stub functions, and instead call the relevant function directly.
*
* We also hope to remove most of the driver-related init and do it if/when
* the driver is later used.
*
* TODO: perhaps reset the watchdog in the initcall function after each call?
@@ -770,15 +773,8 @@ static init_fnc_t init_sequence_r[] = {
#ifdef CONFIG_POST
initr_post,
#endif
#ifdef CONFIG_LAST_STAGE_INIT
INIT_FUNC_WATCHDOG_RESET
/*
* Some parts can be only initialized if all others (like
* Interrupts) are up and running (i.e. the PC-style ISA
* keyboard).
*/
last_stage_init,
#endif
INITCALL_EVENT(EVT_LAST_STAGE_INIT),
#if defined(CFG_PRAM)
initr_mem,
#endif
@@ -810,10 +806,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
#endif
gd->flags &= ~GD_FLG_LOG_READY;
if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
for (int i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
MANUAL_RELOC(init_sequence_r[i]);
}
if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC))
initcall_manual_reloc(init_sequence_r);
if (initcall_run_list(init_sequence_r))
hang();
+11 -2
View File
@@ -35,6 +35,8 @@ const char *const type_name[] = {
/* init hooks */
"misc_init_f",
"fsp_init_r",
"last_stage_init",
/* Fpga load hook */
"fpga_load",
@@ -49,7 +51,7 @@ const char *const type_name[] = {
_Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
#endif
static const char *event_type_name(enum event_t type)
const char *event_type_name(enum event_t type)
{
#if CONFIG_IS_ENABLED(EVENT_DEBUG)
return type_name[type];
@@ -71,7 +73,14 @@ static int notify_static(struct event *ev)
log_debug("Sending event %x/%s to spy '%s'\n", ev->type,
event_type_name(ev->type), event_spy_id(spy));
ret = spy->func(NULL, ev);
if (spy->flags & EVSPYF_SIMPLE) {
const struct evspy_info_simple *simple;
simple = (struct evspy_info_simple *)spy;
ret = simple->func();
} else {
ret = spy->func(NULL, ev);
}
/*
* TODO: Handle various return codes to
-1
View File
@@ -25,7 +25,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
-1
View File
@@ -18,7 +18,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
-1
View File
@@ -40,7 +40,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_LOG=y
CONFIG_LOGF_FUNC=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_BLOBLIST=y
# CONFIG_TPL_BLOBLIST is not set
CONFIG_BLOBLIST_ADDR=0x100000
-1
View File
@@ -29,7 +29,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_MISC_INIT_R=y
CONFIG_SPL_NO_BSS_LIMIT=y
CONFIG_SPL_SYS_MALLOC_SIMPLE=y
-1
View File
@@ -25,7 +25,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_MISC_INIT_R=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
-1
View File
@@ -25,7 +25,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_MISC_INIT_R=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
-1
View File
@@ -30,7 +30,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_MISC_INIT_R=y
CONFIG_BLOBLIST=y
CONFIG_BLOBLIST_ADDR=0xff7c0000
-1
View File
@@ -21,7 +21,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_MISC_INIT_R=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
@@ -31,7 +31,6 @@ CONFIG_BOOTCOMMAND="load scsi 0:2 03000000 /boot/vmlinuz-${kernel-ver}-generic;l
CONFIG_USE_PREBOOT=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
@@ -27,7 +27,6 @@ CONFIG_BOOTCOMMAND="load scsi 0:2 03000000 /boot/vmlinuz-${kernel-ver}-generic;l
CONFIG_USE_PREBOOT=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
-1
View File
@@ -19,7 +19,6 @@ CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_PRE_CONSOLE_BUFFER=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_SPL_NO_BSS_LIMIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
-1
View File
@@ -20,7 +20,6 @@ CONFIG_LOG=y
CONFIG_LOGF_LINE=y
CONFIG_LOGF_FUNC=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_PCI_INIT_R=y
CONFIG_CMD_MMC=y
CONFIG_CMD_PART=y
-1
View File
@@ -20,7 +20,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
-1
View File
@@ -21,7 +21,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
-1
View File
@@ -26,7 +26,6 @@ CONFIG_BOOTCOMMAND="load scsi 0:1 03000000 /boot/vmlinuz-${kernel-ver}-generic;l
CONFIG_USE_PREBOOT=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
-1
View File
@@ -13,7 +13,6 @@ CONFIG_TARGET_EDISON=y
CONFIG_SMP=y
CONFIG_SYS_MONITOR_BASE=0x01101000
CONFIG_BOARD_EARLY_INIT_R=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_MAXARGS=128
CONFIG_SYS_CBSIZE=2048
-1
View File
@@ -16,7 +16,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_BOOTZ=y
-1
View File
@@ -17,7 +17,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_BOOTZ=y
-1
View File
@@ -15,7 +15,6 @@ CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_PRE_CONSOLE_BUFFER=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_IDE=y
-1
View File
@@ -15,7 +15,6 @@ CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_PRE_CONSOLE_BUFFER=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_IDE=y
-1
View File
@@ -17,7 +17,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
-1
View File
@@ -30,7 +30,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_MISC_INIT_R=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
+1 -2
View File
@@ -33,7 +33,6 @@ CONFIG_LOG=y
CONFIG_LOGF_FUNC=y
CONFIG_SPL_LOG=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_PCI_INIT_R=y
CONFIG_BLOBLIST=y
CONFIG_BLOBLIST_ADDR=0x10000
@@ -84,11 +83,11 @@ CONFIG_SPL_DM_RTC=y
CONFIG_SYS_NS16550_PORT_MAPPED=y
CONFIG_SPI=y
CONFIG_USB_KEYBOARD=y
CONFIG_SPL_VIDEO=y
CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
CONFIG_FRAMEBUFFER_VESA_MODE_USER=y
CONFIG_FRAMEBUFFER_VESA_MODE=0x144
CONFIG_CONSOLE_SCROLL_LINES=5
CONFIG_SPL_VIDEO=y
# CONFIG_SPL_USE_TINY_PRINTF is not set
CONFIG_GENERATE_ACPI_TABLE=y
# CONFIG_GZIP is not set
-1
View File
@@ -23,7 +23,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_LOG=y
CONFIG_LOGF_FUNC=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_PCI_INIT_R=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
-1
View File
@@ -27,7 +27,6 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
@@ -26,7 +26,6 @@ CONFIG_SHOW_BOOT_PROGRESS=y
CONFIG_USE_PREBOOT=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
@@ -25,7 +25,6 @@ CONFIG_SHOW_BOOT_PROGRESS=y
CONFIG_USE_PREBOOT=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
@@ -24,7 +24,6 @@ CONFIG_SHOW_BOOT_PROGRESS=y
CONFIG_USE_PREBOOT=y
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PBSIZE=532
CONFIG_CMD_CPU=y
+21 -2
View File
@@ -21,16 +21,31 @@ Declaring a spy
To declare a spy, use something like this::
static int snow_setup_cpus(void *ctx, struct event *event)
static int snow_check_temperature(void)
{
/* do something */
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, snow_setup_cpus);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, snow_check_temperature);
This function is called when EVT_DM_POST_INIT_F is emitted, i.e. after the
driver model is initialized (in U-Boot proper before and after relocation).
If you need access to the event data, use `EVENT_SPY_FULL`, like this::
static int snow_setup_cpus(void *ctx, struct event *event)
{
/* do something that uses event->data*/
return 0;
}
EVENT_SPY_FULL(EVT_DM_POST_INIT_F, snow_setup_cpus);
Note that the context is always NULL for a static spy. See below for information
about how to use a dynamic spy.
The return value is handled by the event emitter. If non-zero, then the error
is returned to the function which emitted the event, i.e. the one that called
`event_notify()`.
Debugging
---------
@@ -80,6 +95,10 @@ to be notified when a particular device is probed or removed.
This can be handled by enabling `CONFIG_EVENT_DYNAMIC`. It is then possible to
call `event_register()` to register a new handler for a particular event.
If some context is need for the spy, you can pass a pointer to
`event_register()` to provide that. Note that the context is only passed to
a spy registered with `EVENT_SPY_FULL`.
Dynamic event handlers are called after all the static event spy handlers have
been processed. Of course, since dynamic event handlers are created at runtime
it is not possible to use the `event_dump.py` to see them.
+2 -2
View File
@@ -19,7 +19,7 @@ DECLARE_GLOBAL_DATA_PTR;
ci = tmp; \
}
static int microblaze_cpu_probe_all(void *ctx, struct event *event)
static int microblaze_cpu_probe_all(void)
{
int ret;
@@ -29,7 +29,7 @@ static int microblaze_cpu_probe_all(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_DM_POST_INIT_F, microblaze_cpu_probe_all);
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, microblaze_cpu_probe_all);
static void microblaze_set_cpuinfo_pvr(struct microblaze_cpuinfo *ci)
{
+69 -3
View File
@@ -32,6 +32,27 @@ enum event_t {
/* Init hooks */
EVT_MISC_INIT_F,
/*
* Emitted before relocation to set up Firmware Support Package
*
* Where U-Boot relies on binary blobs to handle part of the system
* init, this event can be used to set up the blobs. This is used on
* some Intel platforms
*/
EVT_FSP_INIT_F,
/*
* Emitted just before jumping to the main loop
*
* Some boards need to perform initialisation immediately before control
* is passed to the command-line interpreter (e.g. for init that depend
* on later phases in the init sequence).
*
* Some parts can be only initialized if all others (like Interrupts)
* are up and running (e.g. the PC-style ISA keyboard).
*/
EVT_LAST_STAGE_INIT,
/* Fpga load hook */
EVT_FPGA_LOAD,
@@ -99,19 +120,48 @@ struct event {
union event_data data;
};
/* Flags for event spy */
enum evspy_flags {
EVSPYF_SIMPLE = 1 << 0,
};
/** Function type for event handlers */
typedef int (*event_handler_t)(void *ctx, struct event *event);
/** Function type for simple event handlers */
typedef int (*event_handler_simple_t)(void);
/**
* struct evspy_info - information about an event spy
*
* @func: Function to call when the event is activated (must be first)
* @type: Event type
* @flag: Flags for this spy
* @id: Event id string
*/
struct evspy_info {
event_handler_t func;
enum event_t type;
u8 type;
u8 flags;
#if CONFIG_IS_ENABLED(EVENT_DEBUG)
const char *id;
#endif
};
/**
* struct evspy_info_simple - information about an event spy
*
* THis is the 'simple' record, the only difference being the handler function
*
* @func: Function to call when the event is activated (must be first)
* @type: Event type
* @flag: Flags for this spy
* @id: Event id string
*/
struct evspy_info_simple {
event_handler_simple_t func;
u8 type;
u8 flags;
#if CONFIG_IS_ENABLED(EVENT_DEBUG)
const char *id;
#endif
@@ -119,9 +169,11 @@ struct evspy_info {
/* Declare a new event spy */
#if CONFIG_IS_ENABLED(EVENT_DEBUG)
#define _ESPY_REC(_type, _func) { _func, _type, #_func, }
#define _ESPY_REC(_type, _func) { _func, _type, 0, #_func, }
#define _ESPY_REC_SIMPLE(_type, _func) { _func, _type, EVSPYF_SIMPLE, #_func, }
#else
#define _ESPY_REC(_type, _func) { _func, _type, }
#define _ESPY_REC_SIMPLE(_type, _func) { _func, _type, EVSPYF_SIMPLE }
#endif
static inline const char *event_spy_id(struct evspy_info *spy)
@@ -164,10 +216,16 @@ static inline const char *event_spy_id(struct evspy_info *spy)
* away the linker-list entry sometimes, e.g. with the EVT_FT_FIXUP entry in
* vbe_simple.c - so for now, make it global.
*/
#define EVENT_SPY(_type, _func) \
#define EVENT_SPY_FULL(_type, _func) \
__used ll_entry_declare(struct evspy_info, _type ## _3_ ## _func, \
evspy_info) = _ESPY_REC(_type, _func)
/* Simple spy with no function arguemnts */
#define EVENT_SPY_SIMPLE(_type, _func) \
__used ll_entry_declare(struct evspy_info_simple, \
_type ## _3_ ## _func, \
evspy_info) = _ESPY_REC_SIMPLE(_type, _func)
/**
* event_register - register a new spy
*
@@ -193,6 +251,14 @@ void event_show_spy_list(void);
*/
int event_manual_reloc(void);
/**
* event_type_name() - Get the name of an event type
*
* @type: Type to check
* Return: Name of event, or "(unknown)" if not known
*/
const char *event_type_name(enum event_t type);
/**
* event_notify() - notify spies about an event
*
-15
View File
@@ -57,17 +57,6 @@ int arch_cpu_init(void);
*/
int mach_cpu_init(void);
/**
* arch_fsp_init() - perform firmware support package init
*
* Where U-Boot relies on binary blobs to handle part of the system init, this
* function can be used to set up the blobs. This is used on some Intel
* platforms.
*
* Return: 0
*/
int arch_fsp_init(void);
/**
* arch_fsp_init() - perform post-relocation firmware support package init
*
@@ -281,15 +270,11 @@ void board_init_r(struct global_data *id, ulong dest_addr)
__attribute__ ((noreturn));
int cpu_init_r(void);
int last_stage_init(void);
int mac_read_from_eeprom(void);
int set_cpu_clk_info(void);
int update_flash_size(int flash_size);
int arch_early_init_r(void);
int misc_init_r(void);
#if defined(CONFIG_VID)
int init_func_vid(void);
#endif
/* common/board_info.c */
int checkboard(void);
+29 -41
View File
@@ -6,52 +6,40 @@
#ifndef __INITCALL_H
#define __INITCALL_H
#include <asm/types.h>
#include <event.h>
_Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits");
/**
* init_fnc_t - Init function
*
* Return: 0 if OK -ve on error
*/
typedef int (*init_fnc_t)(void);
#include <log.h>
#ifdef CONFIG_EFI_APP
#include <efi.h>
#endif
#include <asm/global_data.h>
/* Top bit indicates that the initcall is an event */
#define INITCALL_IS_EVENT GENMASK(BITS_PER_LONG - 1, 8)
#define INITCALL_EVENT_TYPE GENMASK(7, 0)
/*
* To enable debugging. add #define DEBUG at the top of the including file.
#define INITCALL_EVENT(_type) (void *)((_type) | INITCALL_IS_EVENT)
/**
* initcall_run_list() - Run through a list of function calls
*
* To find a symbol, use grep on u-boot.map
* This calls functions one after the other, stopping at the first error, or
* when NULL is obtained.
*
* @init_sequence: NULL-terminated init sequence to run
* Return: 0 if OK, or -ve error code from the first failure
*/
static inline int initcall_run_list(const init_fnc_t init_sequence[])
{
const init_fnc_t *init_fnc_ptr;
int initcall_run_list(const init_fnc_t init_sequence[]);
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
unsigned long reloc_ofs = 0;
int ret;
/*
* Sandbox is relocated by the OS, so symbols always appear at
* the relocated address.
*/
if (IS_ENABLED(CONFIG_SANDBOX) || (gd->flags & GD_FLG_RELOC))
reloc_ofs = gd->reloc_off;
#ifdef CONFIG_EFI_APP
reloc_ofs = (unsigned long)image_base;
#endif
if (reloc_ofs)
debug("initcall: %p (relocated to %p)\n",
(char *)*init_fnc_ptr - reloc_ofs,
(char *)*init_fnc_ptr);
else
debug("initcall: %p\n", (char *)*init_fnc_ptr - reloc_ofs);
ret = (*init_fnc_ptr)();
if (ret) {
printf("initcall sequence %p failed at call %p (err=%d)\n",
init_sequence,
(char *)*init_fnc_ptr - reloc_ofs, ret);
return -1;
}
}
return 0;
}
/**
* initcall_manual_reloc() - Do manual relocation on an initcall sequence
*
* @init_sequence: NULL-terminated init sequence to relocate
*/
void initcall_manual_reloc(init_fnc_t init_sequence[]);
#endif
+1
View File
@@ -44,6 +44,7 @@ obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
obj-$(CONFIG_SMBIOS_PARSER) += smbios-parser.o
obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
obj-y += initcall.o
obj-y += ldiv.o
obj-$(CONFIG_XXHASH) += xxhash.o
obj-y += net_utils.o
+2 -2
View File
@@ -618,7 +618,7 @@ int fwu_trial_state_ctr_start(void)
return ret;
}
static int fwu_boottime_checks(void *ctx, struct event *event)
static int fwu_boottime_checks(void)
{
int ret;
u32 boot_idx, active_idx;
@@ -682,4 +682,4 @@ static int fwu_boottime_checks(void *ctx, struct event *event)
return 0;
}
EVENT_SPY(EVT_MAIN_LOOP, fwu_boottime_checks);
EVENT_SPY_SIMPLE(EVT_MAIN_LOOP, fwu_boottime_checks);
+109
View File
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2013 The Chromium OS Authors.
*/
#include <common.h>
#include <efi.h>
#include <initcall.h>
#include <log.h>
#include <relocate.h>
#include <asm/global_data.h>
DECLARE_GLOBAL_DATA_PTR;
static ulong calc_reloc_ofs(void)
{
#ifdef CONFIG_EFI_APP
return (ulong)image_base;
#endif
/*
* Sandbox is relocated by the OS, so symbols always appear at
* the relocated address.
*/
if (IS_ENABLED(CONFIG_SANDBOX) || (gd->flags & GD_FLG_RELOC))
return gd->reloc_off;
return 0;
}
/**
* initcall_is_event() - Get the event number for an initcall
*
* func: Function pointer to check
* Return: Event number, if this is an event, else 0
*/
static int initcall_is_event(init_fnc_t func)
{
ulong val = (ulong)func;
if ((val & INITCALL_IS_EVENT) == INITCALL_IS_EVENT)
return val & INITCALL_EVENT_TYPE;
return 0;
}
/*
* To enable debugging. add #define DEBUG at the top of the including file.
*
* To find a symbol, use grep on u-boot.map
*/
int initcall_run_list(const init_fnc_t init_sequence[])
{
ulong reloc_ofs = calc_reloc_ofs();
const init_fnc_t *ptr;
enum event_t type;
init_fnc_t func;
int ret = 0;
for (ptr = init_sequence; func = *ptr, !ret && func; ptr++) {
type = initcall_is_event(func);
if (type) {
if (!CONFIG_IS_ENABLED(EVENT))
continue;
debug("initcall: event %d/%s\n", type,
event_type_name(type));
} else if (reloc_ofs) {
debug("initcall: %p (relocated to %p)\n",
(char *)func - reloc_ofs, (char *)func);
} else {
debug("initcall: %p\n", (char *)func - reloc_ofs);
}
ret = type ? event_notify_null(type) : func();
}
if (ret) {
if (CONFIG_IS_ENABLED(EVENT)) {
char buf[60];
/* don't worry about buf size as we are dying here */
if (type) {
sprintf(buf, "event %d/%s", type,
event_type_name(type));
} else {
sprintf(buf, "call %p", func);
}
printf("initcall failed at %s (err=%dE)\n", buf, ret);
} else {
printf("initcall failed at call %p (err=%d)\n",
(char *)func - reloc_ofs, ret);
}
return ret;
}
return 0;
}
void initcall_manual_reloc(init_fnc_t init_sequence[])
{
init_fnc_t *ptr;
for (ptr = init_sequence; *ptr; ptr++) {
if (!initcall_is_event(*ptr))
MANUAL_RELOC(*ptr);
}
}
+8 -4
View File
@@ -19,8 +19,10 @@ from u_boot_pylib import tools
# A typical symbol looks like this:
# _u_boot_list_2_evspy_info_2_EVT_MISC_INIT_F_3_sandbox_misc_init_f
PREFIX = '_u_boot_list_2_evspy_info_2_'
RE_EVTYPE = re.compile('%s(.*)_3_.*' % PREFIX)
PREFIX_FULL = '_u_boot_list_2_evspy_info_2_'
PREFIX_SIMPLE = '_u_boot_list_2_evspy_info_simple_2_'
RE_EVTYPE_FULL = re.compile('%s(.*)_3_.*' % PREFIX_FULL)
RE_EVTYPE_SIMPLE = re.compile('%s(.*)_3_.*' % PREFIX_SIMPLE)
def show_sym(fname, data, endian, evtype, sym):
"""Show information about an evspy entry
@@ -88,12 +90,14 @@ def show_event_spy_list(fname, endian):
fname (str): Filename of ELF file
endian (str): Endianness to use ('little', 'big', 'auto')
"""
syms = elf.GetSymbolFileOffset(fname, [PREFIX])
syms = elf.GetSymbolFileOffset(fname, [PREFIX_FULL, PREFIX_SIMPLE])
data = tools.read_file(fname)
print('%-20s %-30s %s' % ('Event type', 'Id', 'Source location'))
print('%-20s %-30s %s' % ('-' * 20, '-' * 30, '-' * 30))
for name, sym in syms.items():
m_evtype = RE_EVTYPE.search(name)
m_evtype = RE_EVTYPE_FULL.search(name)
if not m_evtype:
m_evtype = RE_EVTYPE_SIMPLE.search(name)
evtype = m_evtype .group(1)
show_sym(fname, data, endian, evtype, sym)
+22
View File
@@ -18,6 +18,8 @@ struct test_state {
int val;
};
static bool called;
static int h_adder(void *ctx, struct event *event)
{
struct event_data_test *data = &event->data.test;
@@ -28,6 +30,14 @@ static int h_adder(void *ctx, struct event *event)
return 0;
}
static int h_adder_simple(void)
{
called = true;
return 0;
}
EVENT_SPY_SIMPLE(EVT_TEST, h_adder_simple);
static int test_event_base(struct unit_test_state *uts)
{
struct test_state state;
@@ -46,6 +56,18 @@ static int test_event_base(struct unit_test_state *uts)
}
COMMON_TEST(test_event_base, 0);
static int test_event_simple(struct unit_test_state *uts)
{
called = false;
/* Check that the handler is called */
ut_assertok(event_notify_null(EVT_TEST));
ut_assert(called);
return 0;
}
COMMON_TEST(test_event_simple, 0);
static int h_probe(void *ctx, struct event *event)
{
struct test_state *test_state = ctx;
+2 -1
View File
@@ -18,5 +18,6 @@ def test_event_dump(u_boot_console):
-------------------- ------------------------------ ------------------------------
EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.*
EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple_os.c:.*
EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:'''
EVT_MISC_INIT_F sandbox_early_getopt_check .*arch/sandbox/cpu/start.c:.*
EVT_TEST h_adder_simple .*test/common/event.c:'''
assert re.match(expect, out, re.MULTILINE) is not None
+6 -5
View File
@@ -175,7 +175,7 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat):
# Then look for this:
# u-boot-1 [000] 282.101375: funcgraph_exit: 0.006 us | }
# Then check for this:
# u-boot-1 [000] 282.101375: funcgraph_entry: 0.000 us | event_init();
# u-boot-1 [000] 282.101375: funcgraph_entry: 0.000 us | initcall_is_event();
expected_indent = None
found_start = False
@@ -197,8 +197,9 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat):
elif found_start and indent == expected_indent and brace == '}':
found_end = True
# The next function after initf_bootstage() exits should be event_init()
assert upto == 'event_init()'
# The next function after initf_bootstage() exits should be
# initcall_is_event()
assert upto == 'initcall_is_event()'
# Now look for initf_dm() and dm_timer_init() so we can check the bootstage
# time
@@ -247,7 +248,7 @@ def check_flamegraph(cons, fname, proftool, map_fname, trace_fg):
# We expect dm_timer_init() to be called twice: once before relocation and
# once after
look1 = 'initf_dm;dm_timer_init 1'
look2 = 'board_init_r;initr_dm_devices;dm_timer_init 1'
look2 = 'board_init_r;initcall_run_list;initr_dm_devices;dm_timer_init 1'
found = 0
with open(trace_fg, 'r') as fd:
for line in fd:
@@ -272,7 +273,7 @@ def check_flamegraph(cons, fname, proftool, map_fname, trace_fg):
total += count
return total
check_flamegraph
@pytest.mark.slow
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('trace')