mirror of
				https://github.com/smaeul/u-boot.git
				synced 2025-10-31 20:18:18 +00:00 
			
		
		
		
	This command is being introduced with the goal of allowing user-friendly
"generic use case" U-Boot builds to pause until user input under some
situations.
The main use case would be when a boot failure happens, to pause until
the user has had time to acknowledge the current state.
Tested using:
    make && ./u-boot -v -T -c 'ut lib lib_test_hush_pause'
Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
Cc: Simon Glass <sjg@chromium.org>
		
	
			
		
			
				
	
	
		
			33 lines
		
	
	
		
			716 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			716 B
		
	
	
	
		
			C
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0+
 | |
| /*
 | |
|  * (C) Copyright 2021
 | |
|  * Samuel Dionne-Riel <samuel@dionne-riel.com>
 | |
|  */
 | |
| 
 | |
| #include <command.h>
 | |
| #include <stdio.h>
 | |
| 
 | |
| static int do_pause(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 | |
| {
 | |
| 	char *message = "Press any key to continue...";
 | |
| 
 | |
| 	if (argc == 2)
 | |
| 		message = argv[1];
 | |
| 
 | |
| 	/* No newline, so it sticks to the bottom of the screen */
 | |
| 	printf("%s", message);
 | |
| 
 | |
| 	/* Wait on "any" key... */
 | |
| 	(void) getchar();
 | |
| 
 | |
| 	/* Since there was no newline, we need it now */
 | |
| 	printf("\n");
 | |
| 
 | |
| 	return CMD_RET_SUCCESS;
 | |
| }
 | |
| 
 | |
| U_BOOT_CMD(pause, 2, 1, do_pause,
 | |
| 	"delay until user input",
 | |
| 	"[prompt] - Wait until users presses any key. [prompt] can be used to customize the message.\n"
 | |
| );
 |