From ed897d1359bcf09692746d2b8b31fcbd2da95b58 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 5 Mar 2022 09:40:57 +0000 Subject: x1000: bootloader: move the main function to its own file Now that everything has been refactored into separate files the main routine is the only thing left to move. Put it in main.c. Change-Id: I53aba87ed281b52944fb80d9a62beaec1c87f152 --- bootloader/SOURCES | 2 +- bootloader/x1000.c | 102 ------------------------------------------------ bootloader/x1000/main.c | 79 +++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 103 deletions(-) delete mode 100644 bootloader/x1000.c create mode 100644 bootloader/x1000/main.c (limited to 'bootloader') diff --git a/bootloader/SOURCES b/bootloader/SOURCES index 95836eb016..8a4358ca77 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES @@ -88,10 +88,10 @@ show_logo.c sansaconnect.c show_logo.c #elif defined(FIIO_M3K) || defined(SHANLING_Q1) || defined(EROS_QN) -x1000.c x1000/boot.c x1000/gui.c x1000/install.c +x1000/main.c x1000/recovery.c x1000/utils.c #endif diff --git a/bootloader/x1000.c b/bootloader/x1000.c deleted file mode 100644 index bc56b8f822..0000000000 --- a/bootloader/x1000.c +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2021 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. - * - ****************************************************************************/ - -/* Unified bootloader for all X1000 targets. This is a bit messy. - * - * Features: - * - Text based user interface - * - USB mass storage access - * - Bootloader installation / backup / restore - * - * Possible future improvements: - * - Allow booting original firmware from the UI - */ - -#include "system.h" -#include "core_alloc.h" -#include "kernel/kernel-internal.h" -#include "i2c.h" -#include "power.h" -#include "lcd.h" -#include "font.h" -#include "backlight.h" -#include "backlight-target.h" -#include "button.h" -#include "storage.h" -#include "file_internal.h" -#include "disk.h" -#include "usb.h" -#include "rb-loader.h" -#include "loader_strerror.h" -#include "version.h" -#include "boot-x1000.h" -#include "installer-x1000.h" -#include "x1000/x1000bootloader.h" -#include -#include -#include -#include -#include - -void main(void) -{ - system_init(); - core_allocator_init(); - kernel_init(); - i2c_init(); - power_init(); - button_init(); - enable_irq(); - - if(storage_init() < 0) { - splash(5*HZ, "storage_init() failed"); - power_off(); - } - - filesystem_init(); - - usb_init(); - usb_start_monitoring(); - - /* It's OK if this doesn't mount anything. Any disk access should - * be guarded by a call to check_disk() to see if the disk is really - * present, blocking with an "insert SD card" prompt if appropriate. */ - disk_mount_all(); - - /* If USB booting, the user probably needs to enter recovery mode; - * let's not force them to hold down the recovery key. */ - bool recovery_mode = get_boot_flag(BOOT_FLAG_USB_BOOT); - -#ifdef HAVE_BUTTON_DATA - int bdata; - if(button_read_device(&bdata) & BL_RECOVERY) -#else - if(button_read_device() & BL_RECOVERY) -#endif - recovery_mode = true; - - /* If boot fails, it will return and continue on below */ - if(!recovery_mode) - boot_rockbox(); - - /* This function does not return. */ - recovery_menu(); -} diff --git a/bootloader/x1000/main.c b/bootloader/x1000/main.c new file mode 100644 index 0000000000..c507b1d2c9 --- /dev/null +++ b/bootloader/x1000/main.c @@ -0,0 +1,79 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2021 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 "system.h" +#include "core_alloc.h" +#include "kernel/kernel-internal.h" +#include "power.h" +#include "button.h" +#include "storage.h" +#include "disk.h" +#include "file_internal.h" +#include "usb.h" +#include "i2c-x1000.h" +#include "boot-x1000.h" +#include + +void main(void) +{ + system_init(); + core_allocator_init(); + kernel_init(); + i2c_init(); + power_init(); + button_init(); + enable_irq(); + + if(storage_init() < 0) { + splash(5*HZ, "storage_init() failed"); + power_off(); + } + + filesystem_init(); + + usb_init(); + usb_start_monitoring(); + + /* It's OK if this doesn't mount anything. Any disk access should + * be guarded by a call to check_disk() to see if the disk is really + * present, blocking with an "insert SD card" prompt if appropriate. */ + disk_mount_all(); + + /* If USB booting, the user probably needs to enter recovery mode; + * let's not force them to hold down the recovery key. */ + bool recovery_mode = get_boot_flag(BOOT_FLAG_USB_BOOT); + +#ifdef HAVE_BUTTON_DATA + int bdata; + if(button_read_device(&bdata) & BL_RECOVERY) +#else + if(button_read_device() & BL_RECOVERY) +#endif + recovery_mode = true; + + /* If boot fails, it will return and continue on below */ + if(!recovery_mode) + boot_rockbox(); + + /* This function does not return. */ + recovery_menu(); +} -- cgit v1.2.3