x1000: use core_alloc in bootloader for loading rockbox
Using the audio buffer directly is a bad idea because this will render core_alloc non-functional if load_firmware() writes into the buffer but then fails, for example on a checksum mismatch. Change-Id: Ib2d17bcea53bdea1c4c5496cec0c4eee5dd66069
This commit is contained in:
parent
376ffbcf9a
commit
38eafb60ff
2 changed files with 10 additions and 8 deletions
|
@ -137,11 +137,6 @@ const struct menuitem recovery_items[] = {
|
|||
{MENUITEM_ACTION, "Restore", &bootloader_restore},
|
||||
};
|
||||
|
||||
/* Temp buffer to contain the binary in memory */
|
||||
extern unsigned char loadbuffer[];
|
||||
extern unsigned char loadbufferend[];
|
||||
#define MAX_LOAD_SIZE (loadbufferend - loadbuffer)
|
||||
|
||||
/* Flags to indicate if hardware was already initialized */
|
||||
bool lcd_inited = false;
|
||||
bool usb_inited = false;
|
||||
|
@ -340,8 +335,17 @@ void boot_rockbox(void)
|
|||
if(init_disk() != 0)
|
||||
return;
|
||||
|
||||
int rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -88,10 +88,8 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
audiobuffer = .;
|
||||
loadbuffer = .;
|
||||
} > DRAM
|
||||
|
||||
loadbufferend = ENDAUDIOADDR;
|
||||
audiobufend = ENDAUDIOADDR;
|
||||
codecbuf = ENDAUDIOADDR;
|
||||
pluginbuf = ENDCODECADDR;
|
||||
|
|
Loading…
Reference in a new issue