mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Magical Backup
This commit is contained in:
46
bootloader/interface/menus/upsilon_recovery.cpp
Normal file
46
bootloader/interface/menus/upsilon_recovery.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "upsilon_recovery.h"
|
||||
#include <bootloader/slots/slot.h>
|
||||
#include <bootloader/usb_data.h>
|
||||
#include <ion/src/device/shared/drivers/board.h>
|
||||
#include <ion.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" void jump_to_firmware(const uint32_t* stackPtr, const void(*startPtr)(void));
|
||||
|
||||
Bootloader::UpsilonRecoveryMenu::UpsilonRecoveryMenu() : Menu(KDColorBlack, KDColorWhite, Messages::upsilonRecoveryTitle, Messages::mainTitle) {
|
||||
setup();
|
||||
}
|
||||
|
||||
void Bootloader::UpsilonRecoveryMenu::setup() {
|
||||
m_defaultColumns[0] = Column(Messages::upsilonRecoveryMessage1, k_small_font, 0, true);
|
||||
m_defaultColumns[1] = Column(Messages::upsilonRecoveryMessage2, k_small_font, 0, true);
|
||||
m_defaultColumns[2] = Column(Messages::upsilonRecoveryMessage3, k_small_font, 0, true);
|
||||
m_defaultColumns[3] = Column(Messages::upsilonRecoveryMessage4, k_small_font, 0, true);
|
||||
m_defaultColumns[4] = Column(Messages::upsilonRecoveryMessage5, k_small_font, 0, true);
|
||||
|
||||
m_columns[0] = ColumnBinder(&m_defaultColumns[0]);
|
||||
m_columns[1] = ColumnBinder(&m_defaultColumns[1]);
|
||||
m_columns[2] = ColumnBinder(&m_defaultColumns[2]);
|
||||
m_columns[3] = ColumnBinder(&m_defaultColumns[3]);
|
||||
m_columns[4] = ColumnBinder(&m_defaultColumns[4]);
|
||||
}
|
||||
|
||||
void Bootloader::UpsilonRecoveryMenu::postOpen() {
|
||||
// We override the open method
|
||||
for (;;) {
|
||||
uint64_t scan = Ion::Keyboard::scan();
|
||||
if (scan == Ion::Keyboard::State(Ion::Keyboard::Key::Back)) {
|
||||
while (Ion::Keyboard::scan() == Ion::Keyboard::State(Ion::Keyboard::Key::Back));
|
||||
forceExit();
|
||||
return;
|
||||
} else if (scan == Ion::Keyboard::State(Ion::Keyboard::Key::OnOff)) {
|
||||
Ion::Power::standby();
|
||||
return;
|
||||
} else if (scan == Ion::Keyboard::State(Ion::Keyboard::Key::OK)) {
|
||||
Slot slot = Slot::Upsilon();
|
||||
Ion::Device::Board::bootloaderMPU();
|
||||
jump_to_firmware(slot.kernelHeader()->stackPointer(), slot.userlandHeader()->upsilonRecoveryBootFunction());
|
||||
for(;;);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
bootloader/interface/menus/upsilon_recovery.h
Normal file
15
bootloader/interface/menus/upsilon_recovery.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef _BOOTLOADER_INTERFACE_MENUS_UPSILON_RECOVERY_H_
|
||||
#define _BOOTLOADER_INTERFACE_MENUS_UPSILON_RECOVERY_H_
|
||||
|
||||
#include <bootloader/interface/src/menu.h>
|
||||
|
||||
namespace Bootloader {
|
||||
class UpsilonRecoveryMenu : public Menu {
|
||||
public:
|
||||
UpsilonRecoveryMenu();
|
||||
void setup() override;
|
||||
void postOpen() override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -9,10 +9,10 @@ namespace Bootloader {
|
||||
class Menu {
|
||||
public:
|
||||
Menu() : Menu(KDColorBlack, KDColorWhite, Messages::mainTitle) { };
|
||||
Menu(KDColor foreground, KDColor background, const char * title) : Menu(foreground, background, title, nullptr) {};
|
||||
Menu(KDColor foreground, KDColor background, const char * title, const char * bottom) : Menu(foreground, background, title, bottom, false) {};
|
||||
Menu(KDColor foreground, KDColor background, const char * title, const char * bottom, bool centerY) : Menu(foreground, background, title, bottom, centerY, k_columns_margin) {};
|
||||
Menu(KDColor foreground, KDColor background, const char * title, const char * bottom, bool centerY, int margin) : m_columns(), m_defaultColumns(), m_slotColumns(), m_background(background), m_title(title), m_foreground(foreground), m_bottom(bottom), m_centerY(centerY), m_forced_exit(false), m_margin(margin) {
|
||||
Menu(KDColor forground, KDColor background, const char * title) : Menu(forground, background, title, nullptr) {};
|
||||
Menu(KDColor forground, KDColor background, const char * title, const char * bottom) : Menu(forground, background, title, bottom, false) {};
|
||||
Menu(KDColor forground, KDColor background, const char * title, const char * bottom, bool centerY) : Menu(forground, background, title, bottom, centerY, k_columns_margin) {};
|
||||
Menu(KDColor forground, KDColor background, const char * title, const char * bottom, bool centerY, int margin) : m_columns(), m_defaultColumns(), m_slotColumns(), m_background(background), m_title(title), m_foreground(forground), m_bottom(bottom), m_centerY(centerY), m_forced_exit(false), m_margin(margin) {
|
||||
setup();
|
||||
}
|
||||
static const int k_columns_margin = 5;
|
||||
|
||||
@@ -53,6 +53,15 @@ public:
|
||||
constexpr static const char * recoveryMessage4 = "Press Back to continue.";
|
||||
constexpr static const char * recoveryMessage5 = "(you will not be able to recover your data !)";
|
||||
|
||||
// Upsilon Recovery menu
|
||||
constexpr static const char * upsilonRecoveryTitle = "Upsilon Recovery";
|
||||
|
||||
constexpr static const char * upsilonRecoveryMessage1 = "The bootloader has detected a crash.";
|
||||
constexpr static const char * upsilonRecoveryMessage2 = "Because you also have an Upsilon slot,";
|
||||
constexpr static const char * upsilonRecoveryMessage3 = "you can recover your data by booting";
|
||||
constexpr static const char * upsilonRecoveryMessage4 = "the Upsilon slot.";
|
||||
constexpr static const char * upsilonRecoveryMessage5 = "Press OK to continue, BACK to cancel";
|
||||
|
||||
// Warning menu
|
||||
constexpr static const char * epsilonWarningTitle = "Epsilon Slot";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user