Skip to content

Commit

Permalink
elfloader: Check return code of device init
Browse files Browse the repository at this point in the history
Device initialization returns early if an error is encountered. Handle
this error by printing an Error message and aborting the booting
process.

Signed-off-by: Kent McLeod <[email protected]>
  • Loading branch information
kent-mcleod authored and Indanz committed Feb 19, 2024
1 parent 02f1eee commit 24a7eca
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion elfloader-tool/src/arch-arm/smp_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ void non_boot_main(void)
}

/* Do any driver specific non_boot core init */
initialise_devices_non_boot();
if (initialise_devices_non_boot()) {
printf("ERROR: Did not successfully return from initialise_devices_non_boot()\n");
abort();
}

#ifndef CONFIG_ARM_HYPERVISOR_SUPPORT
if (is_hyp_mode()) {
Expand Down
11 changes: 9 additions & 2 deletions elfloader-tool/src/arch-arm/sys_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ void main(UNUSED void *arg)
void *bootloader_dtb = NULL;

/* initialize platform to a state where we can print to a UART */
initialise_devices();
if (initialise_devices()) {
printf("ERROR: Did not successfully return from initialise_devices()\n");
abort();
}

platform_init();

/* Print welcome message. */
Expand Down Expand Up @@ -175,7 +179,10 @@ void continue_boot(int was_relocated)
* driver model so all its pointers are set up properly.
*/
if (was_relocated) {
initialise_devices();
if (initialise_devices()) {
printf("ERROR: Did not successfully return from initialise_devices()\n");
abort();
}
}

#if (defined(CONFIG_ARCH_ARM_V7A) || defined(CONFIG_ARCH_ARM_V8A)) && !defined(CONFIG_ARM_HYPERVISOR_SUPPORT)
Expand Down
10 changes: 8 additions & 2 deletions elfloader-tool/src/drivers/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ static int init_device(struct elfloader_device *dev)
int ret = table_has_match(dev->compat, drv->match_table);
if (ret >= 0) {
dev->drv = drv;
drv->init(dev, drv->match_table[ret].match_data);
ret = drv->init(dev, drv->match_table[ret].match_data);
if (ret) {
return ret;
}
}
drvp++;
}
Expand Down Expand Up @@ -64,7 +67,10 @@ static int init_device_non_boot(struct elfloader_device *dev)
int ret = table_has_match(dev->compat, drv->match_table);
if (ret >= 0) {
dev->drv = drv;
drv->init_on_secondary_cores(dev, drv->match_table[ret].match_data);
ret = drv->init_on_secondary_cores(dev, drv->match_table[ret].match_data);
if (ret) {
return ret;
}
}
}
drvp++;
Expand Down

0 comments on commit 24a7eca

Please sign in to comment.