mirror of
				https://xff.cz/git/u-boot/
				synced 2025-10-31 02:15:45 +01:00 
			
		
		
		
	The patch introduces the CRITICAL feature of POST tests. If the test marked as POST_CRITICAL fails then the alternative, post_critical, boot-command is used. If this command is not defined then U-Boot enters into interactive mode.
Signed-off-by: Dmitry Rakhchev <rda@emcraft.com> Signed-off-by: Yuri Tikhonov <yur@emcraft.com>
This commit is contained in:
		
				
					committed by
					
						 Wolfgang Denk
						Wolfgang Denk
					
				
			
			
				
	
			
			
			
						parent
						
							8f15d4addd
						
					
				
				
					commit
					b428f6a8c6
				
			| @@ -40,7 +40,7 @@ | |||||||
|  |  | ||||||
| #include <post.h> | #include <post.h> | ||||||
|  |  | ||||||
| #ifdef CONFIG_SILENT_CONSOLE | #if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST) | ||||||
| DECLARE_GLOBAL_DATA_PTR; | DECLARE_GLOBAL_DATA_PTR; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -369,6 +369,12 @@ void main_loop (void) | |||||||
| 	init_cmd_timeout (); | 	init_cmd_timeout (); | ||||||
| # endif	/* CONFIG_BOOT_RETRY_TIME */ | # endif	/* CONFIG_BOOT_RETRY_TIME */ | ||||||
|  |  | ||||||
|  | #ifdef CONFIG_POST | ||||||
|  | 	if (gd->flags & GD_FLG_POSTFAIL) { | ||||||
|  | 		s = getenv("failbootcmd"); | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | #endif /* CONFIG_POST */ | ||||||
| #ifdef CONFIG_BOOTCOUNT_LIMIT | #ifdef CONFIG_BOOTCOUNT_LIMIT | ||||||
| 	if (bootlimit && (bootcount > bootlimit)) { | 	if (bootlimit && (bootcount > bootlimit)) { | ||||||
| 		printf ("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n", | 		printf ("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n", | ||||||
|   | |||||||
| @@ -60,6 +60,7 @@ typedef	struct	global_data { | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed		*/ | ||||||
|  |  | ||||||
| #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r8") | #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r8") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -51,6 +51,7 @@ typedef	struct	global_data { | |||||||
| #define GD_FLG_RELOC	0x00001		/* Code was relocated to RAM	 */ | #define GD_FLG_RELOC	0x00001		/* Code was relocated to RAM	 */ | ||||||
| #define GD_FLG_DEVINIT	0x00002		/* Devices have been initialized */ | #define GD_FLG_DEVINIT	0x00002		/* Devices have been initialized */ | ||||||
| #define GD_FLG_SILENT	0x00004		/* Silent mode			 */ | #define GD_FLG_SILENT	0x00004		/* Silent mode			 */ | ||||||
|  | #define GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed	 */ | ||||||
|  |  | ||||||
| #define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm("r5") | #define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm("r5") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -61,6 +61,7 @@ typedef struct global_data { | |||||||
| #define	GD_FLG_RELOC	0x00001	/* Code was relocated to RAM     */ | #define	GD_FLG_RELOC	0x00001	/* Code was relocated to RAM     */ | ||||||
| #define	GD_FLG_DEVINIT	0x00002	/* Devices have been initialized */ | #define	GD_FLG_DEVINIT	0x00002	/* Devices have been initialized */ | ||||||
| #define	GD_FLG_SILENT	0x00004	/* Silent mode                   */ | #define	GD_FLG_SILENT	0x00004	/* Silent mode                   */ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008	/* Critical POST test failed     */ | ||||||
|  |  | ||||||
| #define DECLARE_GLOBAL_DATA_PTR     register gd_t * volatile gd asm ("P5") | #define DECLARE_GLOBAL_DATA_PTR     register gd_t * volatile gd asm ("P5") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -54,6 +54,7 @@ typedef	struct { | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed		*/ | ||||||
|  |  | ||||||
| extern gd_t *global_data; | extern gd_t *global_data; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -68,6 +68,7 @@ typedef	struct	global_data { | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed		*/ | ||||||
|  |  | ||||||
| #if 0 | #if 0 | ||||||
| extern gd_t *global_data; | extern gd_t *global_data; | ||||||
|   | |||||||
| @@ -52,6 +52,7 @@ typedef	struct	global_data { | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed		*/ | ||||||
|  |  | ||||||
| #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r31") | #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r31") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -54,6 +54,7 @@ typedef	struct	global_data { | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM     */ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM     */ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized */ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized */ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode			 */ | #define	GD_FLG_SILENT	0x00004		/* Silent mode			 */ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed	 */ | ||||||
|  |  | ||||||
| #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("k0") | #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("k0") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -45,6 +45,7 @@ typedef	struct	global_data { | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed		*/ | ||||||
|  |  | ||||||
| #define DECLARE_GLOBAL_DATA_PTR     register gd_t *gd asm ("%g7") | #define DECLARE_GLOBAL_DATA_PTR     register gd_t *gd asm ("%g7") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -44,6 +44,7 @@ typedef	struct	global_data { | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed		*/ | ||||||
|  |  | ||||||
| #define DECLARE_GLOBAL_DATA_PTR     register gd_t *gd asm ("r15") | #define DECLARE_GLOBAL_DATA_PTR     register gd_t *gd asm ("r15") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -164,6 +164,7 @@ typedef	struct	global_data { | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed		*/ | ||||||
|  |  | ||||||
| #if 1 | #if 1 | ||||||
| #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r2") | #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r2") | ||||||
|   | |||||||
| @@ -44,6 +44,7 @@ typedef	struct global_data | |||||||
| #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | #define	GD_FLG_RELOC	0x00001		/* Code was relocated to RAM		*/ | ||||||
| #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | #define	GD_FLG_DEVINIT	0x00002		/* Devices have been initialized	*/ | ||||||
| #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | #define	GD_FLG_SILENT	0x00004		/* Silent mode				*/ | ||||||
|  | #define	GD_FLG_POSTFAIL	0x00008		/* Critical POST test failed		*/ | ||||||
|  |  | ||||||
| #define DECLARE_GLOBAL_DATA_PTR	register gd_t *gd asm ("r13") | #define DECLARE_GLOBAL_DATA_PTR	register gd_t *gd asm ("r13") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -42,12 +42,16 @@ | |||||||
| #define POST_REBOOT		0x0800	/* test may cause rebooting */ | #define POST_REBOOT		0x0800	/* test may cause rebooting */ | ||||||
| #define POST_PREREL             0x1000  /* test runs before relocation */ | #define POST_PREREL             0x1000  /* test runs before relocation */ | ||||||
|  |  | ||||||
|  | #define POST_CRITICAL		0x2000	/* Use failbootcmd if test failed */ | ||||||
|  |  | ||||||
| #define POST_MEM		(POST_RAM | POST_ROM) | #define POST_MEM		(POST_RAM | POST_ROM) | ||||||
| #define POST_ALWAYS		(POST_NORMAL	| \ | #define POST_ALWAYS		(POST_NORMAL	| \ | ||||||
| 				 POST_SLOWTEST	| \ | 				 POST_SLOWTEST	| \ | ||||||
| 				 POST_MANUAL	| \ | 				 POST_MANUAL	| \ | ||||||
| 				 POST_POWERON	) | 				 POST_POWERON	) | ||||||
|  |  | ||||||
|  | #define POST_FAIL_SAVE		0x80 | ||||||
|  |  | ||||||
| #ifndef	__ASSEMBLY__ | #ifndef	__ASSEMBLY__ | ||||||
|  |  | ||||||
| struct post_test { | struct post_test { | ||||||
|   | |||||||
							
								
								
									
										18
									
								
								post/post.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								post/post.c
									
									
									
									
									
								
							| @@ -157,8 +157,10 @@ static void post_bootmode_test_off (void) | |||||||
|  |  | ||||||
| static void post_get_flags (int *test_flags) | static void post_get_flags (int *test_flags) | ||||||
| { | { | ||||||
| 	int  flag[] = {  POST_POWERON,   POST_NORMAL,   POST_SLOWTEST }; | 	int  flag[] = {  POST_POWERON,   POST_NORMAL,   POST_SLOWTEST, | ||||||
| 	char *var[] = { "post_poweron", "post_normal", "post_slowtest" }; | 			 POST_CRITICAL }; | ||||||
|  | 	char *var[] = { "post_poweron", "post_normal", "post_slowtest", | ||||||
|  | 			"post_critical" }; | ||||||
| 	int varnum = sizeof (var) / sizeof (var[0]); | 	int varnum = sizeof (var) / sizeof (var[0]); | ||||||
| 	char list[128];			/* long enough for POST list */ | 	char list[128];			/* long enough for POST list */ | ||||||
| 	char *name; | 	char *name; | ||||||
| @@ -224,7 +226,9 @@ static int post_run_single (struct post_test *test, | |||||||
|  |  | ||||||
| 		if (!(flags & POST_REBOOT)) { | 		if (!(flags & POST_REBOOT)) { | ||||||
| 			if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) { | 			if ((test_flags & POST_REBOOT) && !(flags & POST_MANUAL)) { | ||||||
| 				post_bootmode_test_on (i); | 				post_bootmode_test_on ( | ||||||
|  | 					(gd->flags & GD_FLG_POSTFAIL) ? | ||||||
|  | 						POST_FAIL_SAVE | i : i); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if (test_flags & POST_PREREL) | 			if (test_flags & POST_PREREL) | ||||||
| @@ -236,10 +240,14 @@ static int post_run_single (struct post_test *test, | |||||||
| 		if (test_flags & POST_PREREL) { | 		if (test_flags & POST_PREREL) { | ||||||
| 			if ((*test->test) (flags) == 0) | 			if ((*test->test) (flags) == 0) | ||||||
| 				post_log_mark_succ ( test->testid ); | 				post_log_mark_succ ( test->testid ); | ||||||
|  | 			else if (test_flags & POST_CRITICAL) | ||||||
|  | 				gd->flags |= GD_FLG_POSTFAIL; | ||||||
| 		} else { | 		} else { | ||||||
| 		if ((*test->test) (flags) != 0) { | 		if ((*test->test) (flags) != 0) { | ||||||
| 			post_log ("FAILED\n"); | 			post_log ("FAILED\n"); | ||||||
| 			show_boot_progress (-32); | 			show_boot_progress (-32); | ||||||
|  | 			if (test_flags & POST_CRITICAL) | ||||||
|  | 				gd->flags |= GD_FLG_POSTFAIL; | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 			post_log ("PASSED\n"); | 			post_log ("PASSED\n"); | ||||||
| @@ -266,6 +274,10 @@ int post_run (char *name, int flags) | |||||||
| 		unsigned int last; | 		unsigned int last; | ||||||
|  |  | ||||||
| 		if (post_bootmode_get (&last) & POST_POWERTEST) { | 		if (post_bootmode_get (&last) & POST_POWERTEST) { | ||||||
|  | 			if (last & POST_FAIL_SAVE) { | ||||||
|  | 				last &= ~POST_FAIL_SAVE; | ||||||
|  | 				gd->flags |= GD_FLG_POSTFAIL; | ||||||
|  | 			} | ||||||
| 			if (last < post_list_size && | 			if (last < post_list_size && | ||||||
| 				(flags & test_flags[last] & POST_ALWAYS) && | 				(flags & test_flags[last] & POST_ALWAYS) && | ||||||
| 				(flags & test_flags[last] & POST_MEM)) { | 				(flags & test_flags[last] & POST_MEM)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user