From 7554a49309fe31e69747c64caa28b4303270481b Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 5 Mar 2022 09:38:13 +0000 Subject: x1000: bootloader: refactor init_disk Add check_disk() to query the disk insertion status and prompt the user if necessary. Use this in place of init_disk(). Perform an unconditional disk_mount_all() from the main function. Change-Id: I9a8cc42266edf99cd15ece3aee8fa25835df04ae --- bootloader/x1000.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'bootloader/x1000.c') diff --git a/bootloader/x1000.c b/bootloader/x1000.c index 8b1dae3050..1c9f3cd2fa 100644 --- a/bootloader/x1000.c +++ b/bootloader/x1000.c @@ -56,15 +56,8 @@ #include #include -void init_lcd(void); -void init_usb(void); -int init_disk(void); - -void usb_mode(void); - /* Flags to indicate if hardware was already initialized */ bool usb_inited = false; -bool disk_inited = false; /* Set to true if a SYS_USB_CONNECTED event is seen * Set to false if a SYS_USB_DISCONNECTED event is seen */ @@ -80,26 +73,6 @@ void init_usb(void) usb_inited = true; } -int init_disk(void) -{ - if(disk_inited) - return 0; - - while(!storage_present(IF_MD(0))) { - splash2(0, "Insert SD card", "Press " BL_QUIT_NAME " for recovery"); - if(get_button(HZ/4) == BL_QUIT) - return -1; - } - - if(disk_mount_all() <= 0) { - splash(5*HZ, "Cannot mount disk"); - return -1; - } - - disk_inited = true; - return 0; -} - void usb_mode(void) { init_usb(); @@ -137,6 +110,11 @@ void main(void) filesystem_init(); + /* It's OK if this doesn't mount anything. Any disk access should + * be guarded by a call to check_disk() to see if the disk is really + * present, blocking with an "insert SD card" prompt if appropriate. */ + disk_mount_all(); + /* If USB booting, the user probably needs to enter recovery mode; * let's not force them to hold down the recovery key. */ bool recovery_mode = get_boot_flag(BOOT_FLAG_USB_BOOT); -- cgit v1.2.3