summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-19 14:08:37 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-03-24 23:40:07 +0000
commitc3562b6df639d6d7c85cdb83d1983e37ed9f889d (patch)
tree0300ad3b14835bd7fa3f4b1e10ebd35a388593c2
parent0d21d80ca8fc5f287eeb12ca67cc070b55ab46fa (diff)
downloadrockbox-c3562b6df639d6d7c85cdb83d1983e37ed9f889d.tar.gz
rockbox-c3562b6df639d6d7c85cdb83d1983e37ed9f889d.zip
x1000: bootloader: add debug tools menu
Add a debug menu to invoke two new actions, dumping the OF kernel and recovery images from flash to the SD card. Change-Id: I3ca943fac22e725a2d56b84d62f4a04821042fed
-rw-r--r--bootloader/x1000/recovery.c59
1 files changed, 44 insertions, 15 deletions
diff --git a/bootloader/x1000/recovery.c b/bootloader/x1000/recovery.c
index de6b3961cd..369244209e 100644
--- a/bootloader/x1000/recovery.c
+++ b/bootloader/x1000/recovery.c
@@ -37,6 +37,9 @@ struct menuitem {
37 void(*action)(void); 37 void(*action)(void);
38}; 38};
39 39
40static void to_main_menu(void);
41static void to_debug_menu(void);
42
40/* Defines the recovery menu contents */ 43/* Defines the recovery menu contents */
41static const struct menuitem recovery_items[] = { 44static const struct menuitem recovery_items[] = {
42 {MENUITEM_HEADING, "Boot select", NULL}, 45 {MENUITEM_HEADING, "Boot select", NULL},
@@ -56,11 +59,41 @@ static const struct menuitem recovery_items[] = {
56 {MENUITEM_ACTION, "Install or update", &bootloader_install}, 59 {MENUITEM_ACTION, "Install or update", &bootloader_install},
57 {MENUITEM_ACTION, "Backup", &bootloader_backup}, 60 {MENUITEM_ACTION, "Backup", &bootloader_backup},
58 {MENUITEM_ACTION, "Restore", &bootloader_restore}, 61 {MENUITEM_ACTION, "Restore", &bootloader_restore},
62 {MENUITEM_HEADING, "Advanced", NULL},
63 {MENUITEM_ACTION, "Debug tools", &to_debug_menu},
59}; 64};
60 65
66static const struct menuitem debug_menu_items[] = {
67 {MENUITEM_HEADING, "Debug tools", NULL},
68#ifdef OF_PLAYER_ADDR
69 {MENUITEM_ACTION, "Dump OF player", &dump_of_player},
70#endif
71#ifdef OF_RECOVERY_ADDR
72 {MENUITEM_ACTION, "Dump OF recovery", &dump_of_recovery},
73#endif
74 {MENUITEM_ACTION, "Main menu", &to_main_menu},
75};
76
77static const struct menuitem* current_menu = NULL;
78static struct bl_list recmenu_list;
79
80static void to_main_menu(void)
81{
82 current_menu = recovery_items;
83 recmenu_list.num_items = ARRAYLEN(recovery_items);
84 recmenu_list.selected_item = 1;
85}
86
87static void to_debug_menu(void)
88{
89 current_menu = debug_menu_items;
90 recmenu_list.num_items = ARRAYLEN(debug_menu_items);
91 recmenu_list.selected_item = 1;
92}
93
61static void recmenu_draw_item(const struct bl_listitem* item) 94static void recmenu_draw_item(const struct bl_listitem* item)
62{ 95{
63 const struct menuitem* mu = &recovery_items[item->index]; 96 const struct menuitem* mu = &current_menu[item->index];
64 const char* fmt; 97 const char* fmt;
65 98
66 switch(mu->type) { 99 switch(mu->type) {
@@ -97,7 +130,7 @@ static void recmenu_scroll(struct bl_list* list, int dir)
97 } 130 }
98 131
99 for(int i = start; i != end; i += step) { 132 for(int i = start; i != end; i += step) {
100 if(recovery_items[i].action) { 133 if(current_menu[i].action) {
101 gui_list_select(list, i); 134 gui_list_select(list, i);
102 135
103 /* always show one item above the selection to ensure 136 /* always show one item above the selection to ensure
@@ -126,11 +159,10 @@ void recovery_menu(void)
126 }; 159 };
127 lcd_init_viewport(&vp); 160 lcd_init_viewport(&vp);
128 161
129 struct bl_list list; 162 struct bl_list* list = &recmenu_list;
130 gui_list_init(&list, &vp); 163 gui_list_init(list, &vp);
131 list.num_items = ARRAYLEN(recovery_items); 164 list->draw_item = recmenu_draw_item;
132 list.selected_item = 1; /* first item is a heading */ 165 to_main_menu();
133 list.draw_item = recmenu_draw_item;
134 166
135 while(1) { 167 while(1) {
136 clearscreen(); 168 clearscreen();
@@ -143,31 +175,28 @@ void recovery_menu(void)
143 put_help_line(ypos, 2, BL_QUIT_NAME, "power off"); 175 put_help_line(ypos, 2, BL_QUIT_NAME, "power off");
144 176
145 /* draw the list */ 177 /* draw the list */
146 gui_list_draw(&list); 178 gui_list_draw(list);
147 179
148 lcd_update(); 180 lcd_update();
149 181
150 /* handle input */ 182 /* handle input */
151 switch(get_button(TIMEOUT_BLOCK)) { 183 switch(get_button(TIMEOUT_BLOCK)) {
152 case BL_SELECT: { 184 case BL_SELECT: {
153 if(recovery_items[list.selected_item].action) 185 if(current_menu[list->selected_item].action)
154 recovery_items[list.selected_item].action(); 186 current_menu[list->selected_item].action();
155 } break; 187 } break;
156 188
157 case BL_UP: 189 case BL_UP:
158 recmenu_scroll(&list, -1); 190 recmenu_scroll(list, -1);
159 break; 191 break;
160 192
161 case BL_DOWN: 193 case BL_DOWN:
162 recmenu_scroll(&list, 1); 194 recmenu_scroll(list, 1);
163 break; 195 break;
164 196
165 case BL_QUIT: 197 case BL_QUIT:
166 shutdown(); 198 shutdown();
167 break; 199 break;
168
169 default:
170 break;
171 } 200 }
172 } 201 }
173} 202}