diff options
Diffstat (limited to 'bootloader/x1000/boot.c')
-rw-r--r-- | bootloader/x1000/boot.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/bootloader/x1000/boot.c b/bootloader/x1000/boot.c new file mode 100644 index 0000000000..f9e04d1223 --- /dev/null +++ b/bootloader/x1000/boot.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2021-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 "core_alloc.h" | ||
24 | #include "rb-loader.h" | ||
25 | #include "loader_strerror.h" | ||
26 | #include "system.h" | ||
27 | #include "kernel.h" | ||
28 | #include "power.h" | ||
29 | #include "boot-x1000.h" | ||
30 | |||
31 | extern int init_disk(void); | ||
32 | |||
33 | void boot_rockbox(void) | ||
34 | { | ||
35 | if(init_disk() != 0) | ||
36 | return; | ||
37 | |||
38 | size_t max_size = 0; | ||
39 | int handle = core_alloc_maximum("rockbox", &max_size, &buflib_ops_locked); | ||
40 | if(handle < 0) { | ||
41 | splash(5*HZ, "Out of memory"); | ||
42 | return; | ||
43 | } | ||
44 | |||
45 | unsigned char* loadbuffer = core_get_data(handle); | ||
46 | int rc = load_firmware(loadbuffer, BOOTFILE, max_size); | ||
47 | if(rc <= 0) { | ||
48 | core_free(handle); | ||
49 | splash2(5*HZ, "Error loading Rockbox", loader_strerror(rc)); | ||
50 | return; | ||
51 | } | ||
52 | |||
53 | gui_shutdown(); | ||
54 | |||
55 | x1000_boot_rockbox(loadbuffer, rc); | ||
56 | } | ||
57 | |||
58 | void shutdown(void) | ||
59 | { | ||
60 | splash(HZ, "Shutting down"); | ||
61 | power_off(); | ||
62 | while(1); | ||
63 | } | ||
64 | |||
65 | void reboot(void) | ||
66 | { | ||
67 | splash(HZ, "Rebooting"); | ||
68 | system_reboot(); | ||
69 | while(1); | ||
70 | } | ||