diff options
Diffstat (limited to 'bootloader/x1000/utils.c')
-rw-r--r-- | bootloader/x1000/utils.c | 45 |
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... */ | ||
28 | int 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 | } | ||