summaryrefslogtreecommitdiff
path: root/bootloader/x1000/utils.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/utils.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/utils.c')
-rw-r--r--bootloader/x1000/utils.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/bootloader/x1000/utils.c b/bootloader/x1000/utils.c
new file mode 100644
index 0000000000..f4dbac4c5e
--- /dev/null
+++ b/bootloader/x1000/utils.c
@@ -0,0 +1,45 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2022 Aidan MacDonald
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "x1000bootloader.h"
23#include "storage.h"
24#include "button.h"
25#include "kernel.h"
26
27/* this is both incorrect and incredibly racy... */
28int check_disk(bool wait)
29{
30 if(storage_present(IF_MD(0)))
31 return DISK_PRESENT;
32 if(!wait)
33 return DISK_ABSENT;
34
35 while(!storage_present(IF_MD(0))) {
36 splash2(0, "Insert SD card", "Press " BL_QUIT_NAME " to cancel");
37 if(get_button(HZ/4) == BL_QUIT)
38 return DISK_CANCELED;
39 }
40
41 /* a lie intended to give time for mounting the disk in the background */
42 splash(HZ, "Scanning disk");
43
44 return DISK_PRESENT;
45}