Lines Matching +full:init +full:- +full:delay
2 * (C) Copyright 2011-2013 Pali Rohár <pali.rohar@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0+
35 int delay; /* delay for autoboot */ member
62 int reverse = (entry->menu->active == entry->num); in bootmenu_print_entry()
65 * Move cursor to line where the entry will be drown (entry->num) in bootmenu_print_entry()
68 printf(ANSI_CURSOR_POSITION, entry->num + 4, 1); in bootmenu_print_entry()
75 puts(entry->title); in bootmenu_print_entry()
86 if (menu->delay > 0) { in bootmenu_autoboot_loop()
87 printf(ANSI_CURSOR_POSITION, menu->count + 5, 1); in bootmenu_autoboot_loop()
88 printf(" Hit any key to stop autoboot: %2d ", menu->delay); in bootmenu_autoboot_loop()
91 while (menu->delay > 0) { in bootmenu_autoboot_loop()
99 menu->delay = -1; in bootmenu_autoboot_loop()
118 if (menu->delay < 0) in bootmenu_autoboot_loop()
121 --menu->delay; in bootmenu_autoboot_loop()
122 printf("\b\b\b%2d ", menu->delay); in bootmenu_autoboot_loop()
125 printf(ANSI_CURSOR_POSITION, menu->count + 5, 1); in bootmenu_autoboot_loop()
128 if (menu->delay == 0) in bootmenu_autoboot_loop()
163 /* Third char of ANSI (number '1') - optional */ in bootmenu_loop()
172 /* ANSI 'A' - key up was pressed */ in bootmenu_loop()
175 /* ANSI 'B' - key down was pressed */ in bootmenu_loop()
199 if (menu->delay >= 0) { in bootmenu_choice_entry()
209 if (menu->active > 0) in bootmenu_choice_entry()
210 --menu->active; in bootmenu_choice_entry()
214 if (menu->active < menu->count - 1) in bootmenu_choice_entry()
215 ++menu->active; in bootmenu_choice_entry()
219 iter = menu->first; in bootmenu_choice_entry()
220 for (i = 0; i < menu->active; ++i) in bootmenu_choice_entry()
221 iter = iter->next; in bootmenu_choice_entry()
222 return iter->key; in bootmenu_choice_entry()
235 struct bootmenu_entry *iter = menu->first; in bootmenu_destroy()
239 next = iter->next; in bootmenu_destroy()
240 free(iter->title); in bootmenu_destroy()
241 free(iter->command); in bootmenu_destroy()
248 static struct bootmenu_data *bootmenu_create(int delay) in bootmenu_create() argument
263 menu->delay = delay; in bootmenu_create()
264 menu->active = 0; in bootmenu_create()
265 menu->first = NULL; in bootmenu_create()
278 len = sep-option; in bootmenu_create()
279 entry->title = malloc(len + 1); in bootmenu_create()
280 if (!entry->title) { in bootmenu_create()
284 memcpy(entry->title, option, len); in bootmenu_create()
285 entry->title[len] = 0; in bootmenu_create()
288 entry->command = malloc(len + 1); in bootmenu_create()
289 if (!entry->command) { in bootmenu_create()
290 free(entry->title); in bootmenu_create()
294 memcpy(entry->command, sep + 1, len); in bootmenu_create()
295 entry->command[len] = 0; in bootmenu_create()
297 sprintf(entry->key, "%d", i); in bootmenu_create()
299 entry->num = i; in bootmenu_create()
300 entry->menu = menu; in bootmenu_create()
301 entry->next = NULL; in bootmenu_create()
304 menu->first = entry; in bootmenu_create()
306 iter->next = entry; in bootmenu_create()
311 if (i == MAX_COUNT - 1) in bootmenu_create()
315 /* Add U-Boot console entry at the end */ in bootmenu_create()
316 if (i <= MAX_COUNT - 1) { in bootmenu_create()
321 entry->title = strdup("U-Boot console"); in bootmenu_create()
322 if (!entry->title) { in bootmenu_create()
327 entry->command = strdup(""); in bootmenu_create()
328 if (!entry->command) { in bootmenu_create()
329 free(entry->title); in bootmenu_create()
334 sprintf(entry->key, "%d", i); in bootmenu_create()
336 entry->num = i; in bootmenu_create()
337 entry->menu = menu; in bootmenu_create()
338 entry->next = NULL; in bootmenu_create()
341 menu->first = entry; in bootmenu_create()
343 iter->next = entry; in bootmenu_create()
349 menu->count = i; in bootmenu_create()
357 static void bootmenu_show(int delay) in bootmenu_show() argument
359 int init = 0; in bootmenu_show() local
368 /* If delay is 0 do not create menu, just run first entry */ in bootmenu_show()
369 if (delay == 0) { in bootmenu_show()
384 bootmenu = bootmenu_create(delay); in bootmenu_show()
388 menu = menu_create(NULL, bootmenu->delay, 1, bootmenu_print_entry, in bootmenu_show()
395 for (iter = bootmenu->first; iter; iter = iter->next) { in bootmenu_show()
396 if (!menu_item_add(menu, iter->key, iter)) in bootmenu_show()
407 init = 1; in bootmenu_show()
411 title = strdup(iter->title); in bootmenu_show()
412 command = strdup(iter->command); in bootmenu_show()
419 if (init) { in bootmenu_show()
445 menu = entry->menu; in menu_display_statusline()
450 puts(" *** U-Boot Boot Menu ***"); in menu_display_statusline()
456 printf(ANSI_CURSOR_POSITION, menu->count + 5, 1); in menu_display_statusline()
458 printf(ANSI_CURSOR_POSITION, menu->count + 6, 1); in menu_display_statusline()
461 printf(ANSI_CURSOR_POSITION, menu->count + 7, 1); in menu_display_statusline()
469 return -1; /* -1 - abort boot and run monitor code */ in menu_show()
476 int delay = 10; in do_bootmenu() local
479 delay = CONFIG_BOOTDELAY; in do_bootmenu()
489 delay = (int)simple_strtol(delay_str, NULL, 10); in do_bootmenu()
491 bootmenu_show(delay); in do_bootmenu()
498 "[delay]\n"
499 " - show ANSI terminal bootmenu with autoboot delay"