From 3ec66893e377b088c1284d2d23adb2aeea6d7965 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 27 Feb 2021 22:08:58 +0000 Subject: New port: FiiO M3K on bare metal Change-Id: I7517e7d5459e129dcfc9465c6fbd708619888fbe --- apps/debug_menu.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'apps/debug_menu.c') diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 9bbbfaec99..f7e179b040 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -126,6 +126,10 @@ #include "bootdata.h" #endif +#ifdef FIIO_M3K +#include "installer.h" +#endif + static const char* threads_getname(int selected_item, void *data, char *buffer, size_t buffer_len) { @@ -2491,6 +2495,52 @@ static bool dbg_boot_data(void) } #endif /* defined(HAVE_BOOTDATA) && !defined(SIMULATOR) */ +#ifdef FIIO_M3K +/* Note: this is temporary and should NOT be merged, ensure it is removed */ +static int fiio_debug_menu_action_callback(int action, struct gui_synclist *lists) +{ + if(action == ACTION_REDRAW) { + simplelist_set_line_count(0); + simplelist_addline("Back to menu"); + simplelist_addline("Install bootloader"); + simplelist_addline("Dump bootloader"); + action = ACTION_REDRAW; + } + + if(action == ACTION_STD_OK) { + int sel = gui_synclist_get_sel_pos(lists); + int rc = 0; + switch(sel) { + case 1: + rc = install_bootloader("/boot.install"); + break; + case 2: + rc = dump_bootloader("/boot.dump"); + break; + default: + break; + } + + if(sel == 1 || sel == 2) { + const char* msg = installer_strerror(rc); + splashf(3*HZ, "(%d) %s", rc, msg); + } + + action = ACTION_STD_CANCEL; + } + + return action; +} + +static bool dbg_fiio_menu(void) +{ + struct simplelist_info info; + simplelist_info_init(&info, "FiiO debug menu", 3, NULL); + info.action_callback = fiio_debug_menu_action_callback; + return simplelist_show_list(&info); +} +#endif + /****** The menu *********/ static const struct { unsigned char *desc; /* string or ID */ @@ -2598,6 +2648,9 @@ static const struct { #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) {"Boot data", dbg_boot_data }, #endif +#ifdef FIIO_M3K + {"FiiO debug menu", dbg_fiio_menu}, +#endif }; static int menu_action_callback(int btn, struct gui_synclist *lists) -- cgit v1.2.3