summaryrefslogtreecommitdiff
path: root/bootloader/x1000
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-05 09:23:54 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-03-12 18:25:10 +0000
commite2fcbd04ea8a9334b6c961a2f19933d8b9d675d4 (patch)
tree38c1c1b530bfed49263c89dc398f416ea0886982 /bootloader/x1000
parent22cf852db1a37349061a665ea5b7a45bb1b2c2a7 (diff)
downloadrockbox-e2fcbd04ea8a9334b6c961a2f19933d8b9d675d4.tar.gz
rockbox-e2fcbd04ea8a9334b6c961a2f19933d8b9d675d4.zip
x1000: bootloader: split off rockbox boot code
Change-Id: Ie3a097b24ee96551f6c3d08938dcb83f59ba1073
Diffstat (limited to 'bootloader/x1000')
-rw-r--r--bootloader/x1000/boot.c70
-rw-r--r--bootloader/x1000/x1000bootloader.h8
2 files changed, 78 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
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__ */