software/bios: add target hooks

This allows the target to supply custom target_init() and target_boot()
functions, eg:

    # add custom target specific library to the bios:
    src="libtarget"
    src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), src))
    builder.add_software_package(src, src_dir)
    builder.add_software_library(src)
This commit is contained in:
Andrew Dennison 2024-02-29 12:41:28 +11:00
parent 93a7cc2523
commit 222848298f
3 changed files with 14 additions and 3 deletions

View File

@ -580,7 +580,7 @@ void netboot(int nb_params, char **params)
/* Flash Boot */
/*-----------------------------------------------------------------------*/
#ifdef FLASH_BOOT_ADDRESS
#if defined(FLASH_BOOT_ADDRESS) || defined(MAIN_RAM_BASE)
static unsigned int check_image_in_flash(unsigned int base_address)
{
@ -603,9 +603,10 @@ static unsigned int check_image_in_flash(unsigned int base_address)
return length;
}
#endif
#if defined(MAIN_RAM_BASE) && defined(FLASH_BOOT_ADDRESS)
static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned long ram_address)
#if defined(MAIN_RAM_BASE)
int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned long ram_address)
{
uint32_t length;
uint32_t offset;
@ -632,6 +633,7 @@ static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned lon
}
#endif
#if defined(FLASH_BOOT_ADDRESS)
void flashboot(void)
{
uint32_t length;

View File

@ -12,5 +12,8 @@ void flashboot(void);
void romboot(void);
void sdcardboot(void);
void sataboot(void);
extern void target_init(void) __attribute__((weak));
extern void target_boot(void) __attribute__((weak));
extern int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned long ram_address);
#endif /* __BOOT_H */

View File

@ -57,6 +57,8 @@ static void boot_sequence(void)
if (serialboot() == 0)
return;
#endif
if (target_boot)
target_boot();
#ifdef FLASH_BOOT_ADDRESS
flashboot();
#endif
@ -297,6 +299,10 @@ __attribute__((__used__)) int main(int i, char **c)
/* Execute initialization functions */
init_dispatcher();
/* Execute any target specific initialisation (if linked) */
if (target_init)
target_init();
/* Execute Boot sequence */
#ifndef CONFIG_BIOS_NO_BOOT
if(sdr_ok) {