diff options
Diffstat (limited to 'bootloader/x1000/utils.c')
-rw-r--r-- | bootloader/x1000/utils.c | 28 |
1 files changed, 28 insertions, 0 deletions
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 | } | ||