summaryrefslogtreecommitdiff
path: root/bootloader/x1000.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-05 09:38:13 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-03-12 18:25:10 +0000
commit7554a49309fe31e69747c64caa28b4303270481b (patch)
tree0712f67d4e7d3b7ae4b33709f4a1f7e426c5210b /bootloader/x1000.c
parent905591215fdad421f9985ad846b082b86a9ed0b7 (diff)
downloadrockbox-7554a49309fe31e69747c64caa28b4303270481b.tar.gz
rockbox-7554a49309fe31e69747c64caa28b4303270481b.zip
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
Diffstat (limited to 'bootloader/x1000.c')
-rw-r--r--bootloader/x1000.c32
1 files changed, 5 insertions, 27 deletions
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 @@
56#include <stdio.h> 56#include <stdio.h>
57#include <stdarg.h> 57#include <stdarg.h>
58 58
59void init_lcd(void);
60void init_usb(void);
61int init_disk(void);
62
63void usb_mode(void);
64
65/* Flags to indicate if hardware was already initialized */ 59/* Flags to indicate if hardware was already initialized */
66bool usb_inited = false; 60bool usb_inited = false;
67bool disk_inited = false;
68 61
69/* Set to true if a SYS_USB_CONNECTED event is seen 62/* Set to true if a SYS_USB_CONNECTED event is seen
70 * Set to false if a SYS_USB_DISCONNECTED event is seen */ 63 * Set to false if a SYS_USB_DISCONNECTED event is seen */
@@ -80,26 +73,6 @@ void init_usb(void)
80 usb_inited = true; 73 usb_inited = true;
81} 74}
82 75
83int init_disk(void)
84{
85 if(disk_inited)
86 return 0;
87
88 while(!storage_present(IF_MD(0))) {
89 splash2(0, "Insert SD card", "Press " BL_QUIT_NAME " for recovery");
90 if(get_button(HZ/4) == BL_QUIT)
91 return -1;
92 }
93
94 if(disk_mount_all() <= 0) {
95 splash(5*HZ, "Cannot mount disk");
96 return -1;
97 }
98
99 disk_inited = true;
100 return 0;
101}
102
103void usb_mode(void) 76void usb_mode(void)
104{ 77{
105 init_usb(); 78 init_usb();
@@ -137,6 +110,11 @@ void main(void)
137 110
138 filesystem_init(); 111 filesystem_init();
139 112
113 /* It's OK if this doesn't mount anything. Any disk access should
114 * be guarded by a call to check_disk() to see if the disk is really
115 * present, blocking with an "insert SD card" prompt if appropriate. */
116 disk_mount_all();
117
140 /* If USB booting, the user probably needs to enter recovery mode; 118 /* If USB booting, the user probably needs to enter recovery mode;
141 * let's not force them to hold down the recovery key. */ 119 * let's not force them to hold down the recovery key. */
142 bool recovery_mode = get_boot_flag(BOOT_FLAG_USB_BOOT); 120 bool recovery_mode = get_boot_flag(BOOT_FLAG_USB_BOOT);