diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-03-05 09:40:57 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-03-12 18:25:10 +0000 |
commit | ed897d1359bcf09692746d2b8b31fcbd2da95b58 (patch) | |
tree | 573f89a49576426596bad8a96e9644521c79d3ac /bootloader/x1000 | |
parent | 5bdb2fccdb9846e75e499593c6183346eca3e660 (diff) | |
download | rockbox-ed897d1359bcf09692746d2b8b31fcbd2da95b58.tar.gz rockbox-ed897d1359bcf09692746d2b8b31fcbd2da95b58.zip |
x1000: bootloader: move the main function to its own file
Now that everything has been refactored into separate files the
main routine is the only thing left to move. Put it in main.c.
Change-Id: I53aba87ed281b52944fb80d9a62beaec1c87f152
Diffstat (limited to 'bootloader/x1000')
-rw-r--r-- | bootloader/x1000/main.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/bootloader/x1000/main.c b/bootloader/x1000/main.c new file mode 100644 index 0000000000..c507b1d2c9 --- /dev/null +++ b/bootloader/x1000/main.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2021 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 "system.h" | ||
24 | #include "core_alloc.h" | ||
25 | #include "kernel/kernel-internal.h" | ||
26 | #include "power.h" | ||
27 | #include "button.h" | ||
28 | #include "storage.h" | ||
29 | #include "disk.h" | ||
30 | #include "file_internal.h" | ||
31 | #include "usb.h" | ||
32 | #include "i2c-x1000.h" | ||
33 | #include "boot-x1000.h" | ||
34 | #include <stdbool.h> | ||
35 | |||
36 | void main(void) | ||
37 | { | ||
38 | system_init(); | ||
39 | core_allocator_init(); | ||
40 | kernel_init(); | ||
41 | i2c_init(); | ||
42 | power_init(); | ||
43 | button_init(); | ||
44 | enable_irq(); | ||
45 | |||
46 | if(storage_init() < 0) { | ||
47 | splash(5*HZ, "storage_init() failed"); | ||
48 | power_off(); | ||
49 | } | ||
50 | |||
51 | filesystem_init(); | ||
52 | |||
53 | usb_init(); | ||
54 | usb_start_monitoring(); | ||
55 | |||
56 | /* It's OK if this doesn't mount anything. Any disk access should | ||
57 | * be guarded by a call to check_disk() to see if the disk is really | ||
58 | * present, blocking with an "insert SD card" prompt if appropriate. */ | ||
59 | disk_mount_all(); | ||
60 | |||
61 | /* If USB booting, the user probably needs to enter recovery mode; | ||
62 | * let's not force them to hold down the recovery key. */ | ||
63 | bool recovery_mode = get_boot_flag(BOOT_FLAG_USB_BOOT); | ||
64 | |||
65 | #ifdef HAVE_BUTTON_DATA | ||
66 | int bdata; | ||
67 | if(button_read_device(&bdata) & BL_RECOVERY) | ||
68 | #else | ||
69 | if(button_read_device() & BL_RECOVERY) | ||
70 | #endif | ||
71 | recovery_mode = true; | ||
72 | |||
73 | /* If boot fails, it will return and continue on below */ | ||
74 | if(!recovery_mode) | ||
75 | boot_rockbox(); | ||
76 | |||
77 | /* This function does not return. */ | ||
78 | recovery_menu(); | ||
79 | } | ||