summaryrefslogtreecommitdiff
path: root/bootloader
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader')
-rw-r--r--bootloader/SOURCES1
-rw-r--r--bootloader/x1000.c42
-rw-r--r--bootloader/x1000/boot.c70
-rw-r--r--bootloader/x1000/x1000bootloader.h8
4 files changed, 79 insertions, 42 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index 0aa5985ef5..e818fab916 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -89,6 +89,7 @@ sansaconnect.c
89show_logo.c 89show_logo.c
90#elif defined(FIIO_M3K) || defined(SHANLING_Q1) || defined(EROS_QN) 90#elif defined(FIIO_M3K) || defined(SHANLING_Q1) || defined(EROS_QN)
91x1000.c 91x1000.c
92x1000/boot.c
92x1000/gui.c 93x1000/gui.c
93x1000/install.c 94x1000/install.c
94#endif 95#endif
diff --git a/bootloader/x1000.c b/bootloader/x1000.c
index 72a02188c3..c57ddfff4e 100644
--- a/bootloader/x1000.c
+++ b/bootloader/x1000.c
@@ -73,10 +73,7 @@ int init_disk(void);
73 73
74void recovery_menu(void) __attribute__((noreturn)); 74void recovery_menu(void) __attribute__((noreturn));
75 75
76void boot_rockbox(void);
77void usb_mode(void); 76void usb_mode(void);
78void shutdown(void);
79void reboot(void);
80 77
81/* Defines the recovery menu contents */ 78/* Defines the recovery menu contents */
82const struct menuitem recovery_items[] = { 79const struct menuitem recovery_items[] = {
@@ -212,31 +209,6 @@ void recovery_menu(void)
212 } 209 }
213} 210}
214 211
215void boot_rockbox(void)
216{
217 if(init_disk() != 0)
218 return;
219
220 size_t max_size = 0;
221 int handle = core_alloc_maximum("rockbox", &max_size, &buflib_ops_locked);
222 if(handle < 0) {
223 splash(5*HZ, "Out of memory");
224 return;
225 }
226
227 unsigned char* loadbuffer = core_get_data(handle);
228 int rc = load_firmware(loadbuffer, BOOTFILE, max_size);
229 if(rc <= 0) {
230 core_free(handle);
231 splash2(5*HZ, "Error loading Rockbox", loader_strerror(rc));
232 return;
233 }
234
235 gui_shutdown();
236
237 x1000_boot_rockbox(loadbuffer, rc);
238}
239
240void usb_mode(void) 212void usb_mode(void)
241{ 213{
242 init_usb(); 214 init_usb();
@@ -257,20 +229,6 @@ void usb_mode(void)
257 splash(3*HZ, "USB disconnected"); 229 splash(3*HZ, "USB disconnected");
258} 230}
259 231
260void shutdown(void)
261{
262 splash(HZ, "Shutting down");
263 power_off();
264 while(1);
265}
266
267void reboot(void)
268{
269 splash(HZ, "Rebooting");
270 system_reboot();
271 while(1);
272}
273
274void main(void) 232void main(void)
275{ 233{
276 system_init(); 234 system_init();
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
31extern int init_disk(void);
32
33void 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
58void shutdown(void)
59{
60 splash(HZ, "Shutting down");
61 power_off();
62 while(1);
63}
64
65void reboot(void)
66{
67 splash(HZ, "Rebooting");
68 system_reboot();
69 while(1);
70}
diff --git a/bootloader/x1000/x1000bootloader.h b/bootloader/x1000/x1000bootloader.h
index fb7aa80e7f..47f340532d 100644
--- a/bootloader/x1000/x1000bootloader.h
+++ b/bootloader/x1000/x1000bootloader.h
@@ -84,4 +84,12 @@ void bootloader_install(void);
84void bootloader_backup(void); 84void bootloader_backup(void);
85void bootloader_restore(void); 85void bootloader_restore(void);
86 86
87/*
88 * Boot code
89 */
90
91void boot_rockbox(void);
92void shutdown(void);
93void reboot(void);
94
87#endif /* __X1000BOOTLOADER_H__ */ 95#endif /* __X1000BOOTLOADER_H__ */