diff --git a/fusee/fusee-secondary/src/main.c b/fusee/fusee-secondary/src/main.c index 97983819e..bf2474fc3 100644 --- a/fusee/fusee-secondary/src/main.c +++ b/fusee/fusee-secondary/src/main.c @@ -111,6 +111,9 @@ int main(int argc, void **argv) { print(SCREEN_LOG_LEVEL_MANDATORY, "Now performing nxboot.\n"); uint32_t boot_memaddr = nxboot_main(); + /* Wait for the splash screen to have been displayed as long as it should be. */ + splash_screen_wait_delay(); + /* Finish boot. */ nxboot_finish(boot_memaddr); } else { /* TODO: What else do we want to do in terms of argc/argv? */ diff --git a/fusee/fusee-secondary/src/splash_screen.c b/fusee/fusee-secondary/src/splash_screen.c index 1e21f252c..38908f439 100644 --- a/fusee/fusee-secondary/src/splash_screen.c +++ b/fusee/fusee-secondary/src/splash_screen.c @@ -27,6 +27,8 @@ #undef u8 #undef u32 +static uint32_t g_splash_start_time = 0; + static void render_bmp(const uint32_t *bmp_data, uint32_t *framebuffer, uint32_t bmp_width, uint32_t bmp_height, uint32_t bmp_pos_x, uint32_t bmp_pos_y) { /* Render the BMP. */ for (uint32_t y = bmp_pos_y; y < (bmp_pos_y + bmp_height); y++) { @@ -39,6 +41,11 @@ static void render_bmp(const uint32_t *bmp_data, uint32_t *framebuffer, uint32_t console_display(framebuffer); } +void splash_screen_wait_delay(void) { + /* Ensure the splash screen is displayed for at least three seconds. */ + udelay_absolute(g_splash_start_time, 3000000); +} + void display_splash_screen_bmp(const char *custom_splash_path, void *fb_address) { uint8_t *splash_screen = (uint8_t *)splash_screen_bmp; @@ -84,7 +91,7 @@ void display_splash_screen_bmp(const char *custom_splash_path, void *fb_address) } else { fatal_error("Invalid splash screen format!\n"); } - - /* Display the splash screen for two and a half seconds. */ - udelay(2500000); + + /* Note the time we started displaying the splash. */ + g_splash_start_time = get_time_us(); } diff --git a/fusee/fusee-secondary/src/splash_screen.h b/fusee/fusee-secondary/src/splash_screen.h index 0cca4fe52..7bd665e6d 100644 --- a/fusee/fusee-secondary/src/splash_screen.h +++ b/fusee/fusee-secondary/src/splash_screen.h @@ -26,5 +26,6 @@ #define SPLASH_SCREEN_SIZE_MAX (SPLASH_SCREEN_HEIGHT_MAX * SPLASH_SCREEN_STRIDE * 4) void display_splash_screen_bmp(const char *custom_splash_path, void *fb_address); +void splash_screen_wait_delay(void); #endif diff --git a/fusee/fusee-secondary/src/timers.h b/fusee/fusee-secondary/src/timers.h index 1c2be85d7..547dbe844 100644 --- a/fusee/fusee-secondary/src/timers.h +++ b/fusee/fusee-secondary/src/timers.h @@ -81,6 +81,13 @@ static inline void udelay(uint32_t usecs) { while (get_time_us() - start < usecs); } +/** + * Delays until a number of usecs have passed since an absolute start time. + */ +static inline void udelay_absolute(uint32_t start, uint32_t usecs) { + while (get_time_us() - start < usecs); +} + /** * Delays for a given number of milliseconds. */