forked from len0rd/rockbox
x1000: bootloader: refactor rockbox boot
Separate loading out into its own routine with a file name parameter in preparation for multiboot support. Change-Id: Ic651e9fa7738ea97789e4a9669834c4e3ef22d66
This commit is contained in:
parent
ed897d1359
commit
b87f2ed851
3 changed files with 35 additions and 20 deletions
|
@ -21,8 +21,6 @@
|
|||
|
||||
#include "x1000bootloader.h"
|
||||
#include "core_alloc.h"
|
||||
#include "rb-loader.h"
|
||||
#include "loader_strerror.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "power.h"
|
||||
|
@ -30,27 +28,13 @@
|
|||
|
||||
void boot_rockbox(void)
|
||||
{
|
||||
if(check_disk(true) != DISK_PRESENT)
|
||||
size_t length;
|
||||
int handle = load_rockbox(BOOTFILE, &length);
|
||||
if(handle < 0)
|
||||
return;
|
||||
|
||||
size_t max_size = 0;
|
||||
int handle = core_alloc_maximum("rockbox", &max_size, &buflib_ops_locked);
|
||||
if(handle < 0) {
|
||||
splash(5*HZ, "Out of memory");
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char* loadbuffer = core_get_data(handle);
|
||||
int rc = load_firmware(loadbuffer, BOOTFILE, max_size);
|
||||
if(rc <= 0) {
|
||||
core_free(handle);
|
||||
splash2(5*HZ, "Error loading Rockbox", loader_strerror(rc));
|
||||
return;
|
||||
}
|
||||
|
||||
gui_shutdown();
|
||||
|
||||
x1000_boot_rockbox(loadbuffer, rc);
|
||||
x1000_boot_rockbox(core_get_data(handle), length);
|
||||
}
|
||||
|
||||
void shutdown(void)
|
||||
|
|
|
@ -20,10 +20,13 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "x1000bootloader.h"
|
||||
#include "core_alloc.h"
|
||||
#include "storage.h"
|
||||
#include "button.h"
|
||||
#include "kernel.h"
|
||||
#include "usb.h"
|
||||
#include "rb-loader.h"
|
||||
#include "loader_strerror.h"
|
||||
|
||||
/* Set to true if a SYS_USB_CONNECTED event is seen
|
||||
* Set to false if a SYS_USB_DISCONNECTED event is seen
|
||||
|
@ -68,3 +71,28 @@ void usb_mode(void)
|
|||
|
||||
splash(3*HZ, "USB disconnected");
|
||||
}
|
||||
|
||||
int load_rockbox(const char* filename, size_t* sizep)
|
||||
{
|
||||
if(check_disk(true) != DISK_PRESENT)
|
||||
return -1;
|
||||
|
||||
int handle = core_alloc_maximum("rockbox", sizep, &buflib_ops_locked);
|
||||
if(handle < 0) {
|
||||
splash(5*HZ, "Out of memory");
|
||||
return -2;
|
||||
}
|
||||
|
||||
unsigned char* loadbuffer = core_get_data(handle);
|
||||
int rc = load_firmware(loadbuffer, filename, *sizep);
|
||||
if(rc <= 0) {
|
||||
core_free(handle);
|
||||
splash2(5*HZ, "Error loading Rockbox", loader_strerror(rc));
|
||||
return -3;
|
||||
}
|
||||
|
||||
core_shrink(handle, loadbuffer, rc);
|
||||
*sizep = rc;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#define __X1000BOOTLOADER_H__
|
||||
|
||||
#include "config.h"
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if defined(FIIO_M3K)
|
||||
|
@ -106,6 +107,8 @@ enum {
|
|||
int check_disk(bool wait);
|
||||
void usb_mode(void);
|
||||
|
||||
int load_rockbox(const char* filename, size_t* sizep);
|
||||
|
||||
void recovery_menu(void) __attribute__((noreturn));
|
||||
|
||||
#endif /* __X1000BOOTLOADER_H__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue