diff options
Diffstat (limited to 'bootloader/x1000')
-rw-r--r-- | bootloader/x1000/boot.c | 24 | ||||
-rw-r--r-- | bootloader/x1000/utils.c | 28 | ||||
-rw-r--r-- | bootloader/x1000/x1000bootloader.h | 3 |
3 files changed, 35 insertions, 20 deletions
diff --git a/bootloader/x1000/boot.c b/bootloader/x1000/boot.c index bb9528ba3c..6719375151 100644 --- a/bootloader/x1000/boot.c +++ b/bootloader/x1000/boot.c | |||
@@ -21,8 +21,6 @@ | |||
21 | 21 | ||
22 | #include "x1000bootloader.h" | 22 | #include "x1000bootloader.h" |
23 | #include "core_alloc.h" | 23 | #include "core_alloc.h" |
24 | #include "rb-loader.h" | ||
25 | #include "loader_strerror.h" | ||
26 | #include "system.h" | 24 | #include "system.h" |
27 | #include "kernel.h" | 25 | #include "kernel.h" |
28 | #include "power.h" | 26 | #include "power.h" |
@@ -30,27 +28,13 @@ | |||
30 | 28 | ||
31 | void boot_rockbox(void) | 29 | void boot_rockbox(void) |
32 | { | 30 | { |
33 | if(check_disk(true) != DISK_PRESENT) | 31 | size_t length; |
32 | int handle = load_rockbox(BOOTFILE, &length); | ||
33 | if(handle < 0) | ||
34 | return; | 34 | return; |
35 | 35 | ||
36 | size_t max_size = 0; | ||
37 | int handle = core_alloc_maximum("rockbox", &max_size, &buflib_ops_locked); | ||
38 | if(handle < 0) { | ||
39 | splash(5*HZ, "Out of memory"); | ||
40 | return; | ||
41 | } | ||
42 | |||
43 | unsigned char* loadbuffer = core_get_data(handle); | ||
44 | int rc = load_firmware(loadbuffer, BOOTFILE, max_size); | ||
45 | if(rc <= 0) { | ||
46 | core_free(handle); | ||
47 | splash2(5*HZ, "Error loading Rockbox", loader_strerror(rc)); | ||
48 | return; | ||
49 | } | ||
50 | |||
51 | gui_shutdown(); | 36 | gui_shutdown(); |
52 | 37 | x1000_boot_rockbox(core_get_data(handle), length); | |
53 | x1000_boot_rockbox(loadbuffer, rc); | ||
54 | } | 38 | } |
55 | 39 | ||
56 | void shutdown(void) | 40 | void shutdown(void) |
diff --git a/bootloader/x1000/utils.c b/bootloader/x1000/utils.c index 56ac6d1fff..6cb9bb379a 100644 --- a/bootloader/x1000/utils.c +++ b/bootloader/x1000/utils.c | |||
@@ -20,10 +20,13 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "x1000bootloader.h" | 22 | #include "x1000bootloader.h" |
23 | #include "core_alloc.h" | ||
23 | #include "storage.h" | 24 | #include "storage.h" |
24 | #include "button.h" | 25 | #include "button.h" |
25 | #include "kernel.h" | 26 | #include "kernel.h" |
26 | #include "usb.h" | 27 | #include "usb.h" |
28 | #include "rb-loader.h" | ||
29 | #include "loader_strerror.h" | ||
27 | 30 | ||
28 | /* Set to true if a SYS_USB_CONNECTED event is seen | 31 | /* Set to true if a SYS_USB_CONNECTED event is seen |
29 | * Set to false if a SYS_USB_DISCONNECTED event is seen | 32 | * Set to false if a SYS_USB_DISCONNECTED event is seen |
@@ -68,3 +71,28 @@ void usb_mode(void) | |||
68 | 71 | ||
69 | splash(3*HZ, "USB disconnected"); | 72 | splash(3*HZ, "USB disconnected"); |
70 | } | 73 | } |
74 | |||
75 | int load_rockbox(const char* filename, size_t* sizep) | ||
76 | { | ||
77 | if(check_disk(true) != DISK_PRESENT) | ||
78 | return -1; | ||
79 | |||
80 | int handle = core_alloc_maximum("rockbox", sizep, &buflib_ops_locked); | ||
81 | if(handle < 0) { | ||
82 | splash(5*HZ, "Out of memory"); | ||
83 | return -2; | ||
84 | } | ||
85 | |||
86 | unsigned char* loadbuffer = core_get_data(handle); | ||
87 | int rc = load_firmware(loadbuffer, filename, *sizep); | ||
88 | if(rc <= 0) { | ||
89 | core_free(handle); | ||
90 | splash2(5*HZ, "Error loading Rockbox", loader_strerror(rc)); | ||
91 | return -3; | ||
92 | } | ||
93 | |||
94 | core_shrink(handle, loadbuffer, rc); | ||
95 | *sizep = rc; | ||
96 | |||
97 | return handle; | ||
98 | } | ||
diff --git a/bootloader/x1000/x1000bootloader.h b/bootloader/x1000/x1000bootloader.h index 60353e59fd..84feded9b3 100644 --- a/bootloader/x1000/x1000bootloader.h +++ b/bootloader/x1000/x1000bootloader.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #define __X1000BOOTLOADER_H__ | 23 | #define __X1000BOOTLOADER_H__ |
24 | 24 | ||
25 | #include "config.h" | 25 | #include "config.h" |
26 | #include <stddef.h> | ||
26 | #include <stdbool.h> | 27 | #include <stdbool.h> |
27 | 28 | ||
28 | #if defined(FIIO_M3K) | 29 | #if defined(FIIO_M3K) |
@@ -106,6 +107,8 @@ enum { | |||
106 | int check_disk(bool wait); | 107 | int check_disk(bool wait); |
107 | void usb_mode(void); | 108 | void usb_mode(void); |
108 | 109 | ||
110 | int load_rockbox(const char* filename, size_t* sizep); | ||
111 | |||
109 | void recovery_menu(void) __attribute__((noreturn)); | 112 | void recovery_menu(void) __attribute__((noreturn)); |
110 | 113 | ||
111 | #endif /* __X1000BOOTLOADER_H__ */ | 114 | #endif /* __X1000BOOTLOADER_H__ */ |