Skip to content

Commit

Permalink
software/bios: add target hooks
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Andrew Dennison committed Jul 28, 2024
1 parent 93a7cc2 commit 2228482
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions litex/soc/software/bios/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions litex/soc/software/bios/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
6 changes: 6 additions & 0 deletions litex/soc/software/bios/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2228482

Please sign in to comment.