diff options
Diffstat (limited to 'bootloader/x1000.c')
-rw-r--r-- | bootloader/x1000.c | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/bootloader/x1000.c b/bootloader/x1000.c index c57ddfff4e..8b1dae3050 100644 --- a/bootloader/x1000.c +++ b/bootloader/x1000.c | |||
@@ -56,38 +56,12 @@ | |||
56 | #include <stdio.h> | 56 | #include <stdio.h> |
57 | #include <stdarg.h> | 57 | #include <stdarg.h> |
58 | 58 | ||
59 | enum { | ||
60 | MENUITEM_HEADING, | ||
61 | MENUITEM_ACTION, | ||
62 | }; | ||
63 | |||
64 | struct menuitem { | ||
65 | int type; | ||
66 | const char* text; | ||
67 | void(*action)(void); | ||
68 | }; | ||
69 | |||
70 | void init_lcd(void); | 59 | void init_lcd(void); |
71 | void init_usb(void); | 60 | void init_usb(void); |
72 | int init_disk(void); | 61 | int init_disk(void); |
73 | 62 | ||
74 | void recovery_menu(void) __attribute__((noreturn)); | ||
75 | |||
76 | void usb_mode(void); | 63 | void usb_mode(void); |
77 | 64 | ||
78 | /* Defines the recovery menu contents */ | ||
79 | const struct menuitem recovery_items[] = { | ||
80 | {MENUITEM_HEADING, "System", NULL}, | ||
81 | {MENUITEM_ACTION, "Start Rockbox", &boot_rockbox}, | ||
82 | {MENUITEM_ACTION, "USB mode", &usb_mode}, | ||
83 | {MENUITEM_ACTION, "Shutdown", &shutdown}, | ||
84 | {MENUITEM_ACTION, "Reboot", &reboot}, | ||
85 | {MENUITEM_HEADING, "Bootloader", NULL}, | ||
86 | {MENUITEM_ACTION, "Install or update", &bootloader_install}, | ||
87 | {MENUITEM_ACTION, "Backup", &bootloader_backup}, | ||
88 | {MENUITEM_ACTION, "Restore", &bootloader_restore}, | ||
89 | }; | ||
90 | |||
91 | /* Flags to indicate if hardware was already initialized */ | 65 | /* Flags to indicate if hardware was already initialized */ |
92 | bool usb_inited = false; | 66 | bool usb_inited = false; |
93 | bool disk_inited = false; | 67 | bool disk_inited = false; |
@@ -126,89 +100,6 @@ int init_disk(void) | |||
126 | return 0; | 100 | return 0; |
127 | } | 101 | } |
128 | 102 | ||
129 | void put_help_line(int line, const char* str1, const char* str2) | ||
130 | { | ||
131 | int width = LCD_WIDTH / SYSFONT_WIDTH; | ||
132 | lcd_puts(0, line, str1); | ||
133 | lcd_puts(width - strlen(str2), line, str2); | ||
134 | } | ||
135 | |||
136 | void recovery_menu(void) | ||
137 | { | ||
138 | const int n_items = sizeof(recovery_items)/sizeof(struct menuitem); | ||
139 | |||
140 | int selection = 0; | ||
141 | while(recovery_items[selection].type != MENUITEM_ACTION) | ||
142 | ++selection; | ||
143 | |||
144 | while(1) { | ||
145 | clearscreen(); | ||
146 | putcenter_y(0, "Rockbox recovery menu"); | ||
147 | |||
148 | int top_line = 2; | ||
149 | |||
150 | /* draw the menu */ | ||
151 | for(int i = 0; i < n_items; ++i) { | ||
152 | switch(recovery_items[i].type) { | ||
153 | case MENUITEM_HEADING: | ||
154 | lcd_putsf(0, top_line+i, "[%s]", recovery_items[i].text); | ||
155 | break; | ||
156 | |||
157 | case MENUITEM_ACTION: | ||
158 | lcd_puts(3, top_line+i, recovery_items[i].text); | ||
159 | break; | ||
160 | |||
161 | default: | ||
162 | break; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /* draw the selection marker */ | ||
167 | lcd_puts(0, top_line+selection, "=>"); | ||
168 | |||
169 | /* draw the help text */ | ||
170 | int line = (LCD_HEIGHT - SYSFONT_HEIGHT)/SYSFONT_HEIGHT - 3; | ||
171 | put_help_line(line++, BL_DOWN_NAME "/" BL_UP_NAME, "move cursor"); | ||
172 | put_help_line(line++, BL_SELECT_NAME, "select item"); | ||
173 | put_help_line(line++, BL_QUIT_NAME, "power off"); | ||
174 | |||
175 | lcd_update(); | ||
176 | |||
177 | /* handle input */ | ||
178 | switch(get_button(TIMEOUT_BLOCK)) { | ||
179 | case BL_SELECT: { | ||
180 | if(recovery_items[selection].action) | ||
181 | recovery_items[selection].action(); | ||
182 | } break; | ||
183 | |||
184 | case BL_UP: | ||
185 | for(int i = selection-1; i >= 0; --i) { | ||
186 | if(recovery_items[i].action) { | ||
187 | selection = i; | ||
188 | break; | ||
189 | } | ||
190 | } | ||
191 | break; | ||
192 | |||
193 | case BL_DOWN: | ||
194 | for(int i = selection+1; i < n_items; ++i) { | ||
195 | if(recovery_items[i].action) { | ||
196 | selection = i; | ||
197 | break; | ||
198 | } | ||
199 | } | ||
200 | break; | ||
201 | |||
202 | case BL_QUIT: | ||
203 | shutdown(); | ||
204 | break; | ||
205 | |||
206 | default: | ||
207 | break; | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
212 | void usb_mode(void) | 103 | void usb_mode(void) |
213 | { | 104 | { |
214 | init_usb(); | 105 | init_usb(); |