1
0
Fork 0
forked from len0rd/rockbox
foxbox/bootloader/x1000/boot.c
Aidan MacDonald 7554a49309 x1000: bootloader: refactor init_disk
Add check_disk() to query the disk insertion status and prompt the
user if necessary. Use this in place of init_disk().

Perform an unconditional disk_mount_all() from the main function.

Change-Id: I9a8cc42266edf99cd15ece3aee8fa25835df04ae
2022-03-12 18:25:10 +00:00

68 lines
1.9 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2021-2022 Aidan MacDonald
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "x1000bootloader.h"
#include "core_alloc.h"
#include "rb-loader.h"
#include "loader_strerror.h"
#include "system.h"
#include "kernel.h"
#include "power.h"
#include "boot-x1000.h"
void boot_rockbox(void)
{
if(check_disk(true) != DISK_PRESENT)
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);
}
void shutdown(void)
{
splash(HZ, "Shutting down");
power_off();
while(1);
}
void reboot(void)
{
splash(HZ, "Rebooting");
system_reboot();
while(1);
}