[U-Boot] [PATCH v3 04/15] bootstage: Convert progress numbers 1-9 into enums

Simon Glass sjg at chromium.org
Sun Jan 15 02:24:47 CET 2012


Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v3:
- Set BOOTSTAGE_ID_START to 0 explicitly

 board/bf533-stamp/bf533-stamp.c        |   18 +++++++-------
 board/hermes/hermes.c                  |    2 +-
 board/ivm/ivm.c                        |    2 +-
 board/matrix_vision/common/mv_common.c |    2 +-
 board/matrix_vision/mvbc_p/mvbc_p.c    |    2 +-
 board/pcs440ep/pcs440ep.c              |   22 ++++++++--------
 common/cmd_bootm.c                     |   41 +++++++++++++++----------------
 common/image.c                         |    2 +-
 include/bootstage.h                    |   14 +++++++++++
 9 files changed, 59 insertions(+), 46 deletions(-)

diff --git a/board/bf533-stamp/bf533-stamp.c b/board/bf533-stamp/bf533-stamp.c
index b1134e9..07a988a 100644
--- a/board/bf533-stamp/bf533-stamp.c
+++ b/board/bf533-stamp/bf533-stamp.c
@@ -91,27 +91,27 @@ static void stamp_led_set(int LED1, int LED2, int LED3)
 void show_boot_progress(int status)
 {
 	switch (status) {
-	case 1:
+	case BOOTSTAGE_ID_CHECK_MAGIC:
 		stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
 		break;
-	case 2:
+	case BOOTSTAGE_ID_CHECK_HEADER:
 		stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
 		break;
-	case 3:
+	case BOOTSTAGE_ID_CHECK_CHECKSUM:
 		stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
 		break;
-	case 4:
+	case BOOTSTAGE_ID_CHECK_ARCH:
 		stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
 		break;
-	case 5:
-	case 6:
+	case BOOTSTAGE_ID_CHECK_IMAGETYPE:
+	case BOOTSTAGE_ID_DECOMP_IMAGE:
 		stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
 		break;
-	case 7:
-	case 8:
+	case BOOTSTAGE_ID_KERNEL_LOADED:
+	case BOOTSTAGE_ID_CHECK_BOOT_OS:
 		stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
 		break;
-	case 9:
+	case BOOTSTAGE_ID_BOOT_OS_RETURNED:
 	case 10:
 	case 11:
 	case 12:
diff --git a/board/hermes/hermes.c b/board/hermes/hermes.c
index acf364e..1b40ae8 100644
--- a/board/hermes/hermes.c
+++ b/board/hermes/hermes.c
@@ -370,7 +370,7 @@ static ulong board_init (void)
 			immr->im_ioport.iop_pcdat |= PC_REP_RES;
 		}
 	}
-	SHOW_BOOT_PROGRESS (0x00);
+	SHOW_BOOT_PROGRESS(BOOTSTAGE_ID_CHECK_MAGIC);
 
 	return ((revision << 16) | (speed & 0xFFFF));
 }
diff --git a/board/ivm/ivm.c b/board/ivm/ivm.c
index 9bec198..71d64d4 100644
--- a/board/ivm/ivm.c
+++ b/board/ivm/ivm.c
@@ -322,7 +322,7 @@ void show_boot_progress (int status)
 			(status < 0) ? STATUS_LED_ON : STATUS_LED_OFF);
 # endif	/* STATUS_LED_YELLOW */
 # if defined(STATUS_LED_BOOT)
-	if (status == 6)
+	if (status == BOOTSTAGE_ID_DECOMP_IMAGE)
 		status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
 # endif	/* STATUS_LED_BOOT */
 #endif /* CONFIG_STATUS_LED */
diff --git a/board/matrix_vision/common/mv_common.c b/board/matrix_vision/common/mv_common.c
index acb72c5..7fde4ac 100644
--- a/board/matrix_vision/common/mv_common.c
+++ b/board/matrix_vision/common/mv_common.c
@@ -95,7 +95,7 @@ int mv_load_fpga(void)
 
 	result = fpga_load(0, fpga_data, data_size);
 	if (!result)
-		show_boot_progress(0);
+		show_boot_progress(BOOTSTAGE_ID_START);
 
 	return result;
 }
diff --git a/board/matrix_vision/mvbc_p/mvbc_p.c b/board/matrix_vision/mvbc_p/mvbc_p.c
index 9dffedc..a5dc2f0 100644
--- a/board/matrix_vision/mvbc_p/mvbc_p.c
+++ b/board/matrix_vision/mvbc_p/mvbc_p.c
@@ -241,7 +241,7 @@ void show_boot_progress(int val)
 	struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio*)MPC5XXX_GPIO;
 
 	switch(val) {
-	case 0: /* FPGA ok */
+	case BOOTSTAGE_ID_START: /* FPGA ok */
 		setbits_be32(&gpio->simple_dvo, LED_G0);
 		break;
 	case 65:
diff --git a/board/pcs440ep/pcs440ep.c b/board/pcs440ep/pcs440ep.c
index 36994b5..118d81c 100644
--- a/board/pcs440ep/pcs440ep.c
+++ b/board/pcs440ep/pcs440ep.c
@@ -104,17 +104,17 @@ void show_boot_progress (int val)
 		return;
 	}
 	switch (val) {
-		case 1:
-			/* validating Image */
-			status_led_set (0, STATUS_LED_OFF);
-			status_led_set (1, STATUS_LED_ON);
-			status_led_set (2, STATUS_LED_ON);
-			break;
-		case BOOTSTAGE_ID_RUN_OS:
-			status_led_set (0, STATUS_LED_ON);
-			status_led_set (1, STATUS_LED_ON);
-			status_led_set (2, STATUS_LED_ON);
-			break;
+	case BOOTSTAGE_ID_CHECK_MAGIC:
+		/* validating Image */
+		status_led_set(0, STATUS_LED_OFF);
+		status_led_set(1, STATUS_LED_ON);
+		status_led_set(2, STATUS_LED_ON);
+		break;
+	case BOOTSTAGE_ID_RUN_OS:
+		status_led_set(0, STATUS_LED_ON);
+		status_led_set(1, STATUS_LED_ON);
+		status_led_set(2, STATUS_LED_ON);
+		break;
 #if 0
 		case 64:
 			/* starting Ethernet configuration */
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 450fa5c..9ab1c61 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -348,7 +348,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
 			puts("GUNZIP: uncompress, out-of-mem or overwrite "
 				"error - must RESET board to recover\n");
 			if (boot_progress)
-				show_boot_error(6);
+				show_boot_error(BOOTSTAGE_ID_DECOMP_IMAGE);
 			return BOOTM_ERR_RESET;
 		}
 
@@ -370,7 +370,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
 			printf("BUNZIP2: uncompress or overwrite error %d "
 				"- must RESET board to recover\n", i);
 			if (boot_progress)
-				show_boot_error(6);
+				show_boot_error(BOOTSTAGE_ID_DECOMP_IMAGE);
 			return BOOTM_ERR_RESET;
 		}
 
@@ -389,7 +389,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
 		if (ret != SZ_OK) {
 			printf("LZMA: uncompress or overwrite error %d "
 				"- must RESET board to recover\n", ret);
-			show_boot_error(6);
+			show_boot_error(BOOTSTAGE_ID_DECOMP_IMAGE);
 			return BOOTM_ERR_RESET;
 		}
 		*load_end = load + unc_len;
@@ -407,7 +407,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
 			printf("LZO: uncompress or overwrite error %d "
 			      "- must RESET board to recover\n", ret);
 			if (boot_progress)
-				show_boot_error(6);
+				show_boot_error(BOOTSTAGE_ID_DECOMP_IMAGE);
 			return BOOTM_ERR_RESET;
 		}
 
@@ -423,8 +423,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
 
 	puts("OK\n");
 	debug("   kernel loaded at 0x%08lx, end = 0x%08lx\n", load, *load_end);
-	if (boot_progress)
-		show_boot_progress(7);
+	show_boot_progress(BOOTSTAGE_ID_KERNEL_LOADED);
 
 	if (!no_overlap && (load < blob_end) && (*load_end > blob_start)) {
 		debug("images.os.start = 0x%lX, images.os.end = 0x%lx\n",
@@ -656,7 +655,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if (ret == BOOTM_ERR_UNIMPLEMENTED) {
 			if (iflag)
 				enable_interrupts();
-			show_boot_error(7);
+			show_boot_error(BOOTSTAGE_ID_DECOMP_UNIMPL);
 			return 1;
 		}
 	}
@@ -671,7 +670,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 0;
 	}
 
-	show_boot_progress(8);
+	show_boot_progress(BOOTSTAGE_ID_CHECK_BOOT_OS);
 
 #ifdef CONFIG_SILENT_CONSOLE
 	if (images.os.os == IH_OS_LINUX)
@@ -685,7 +684,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			enable_interrupts();
 		printf("ERROR: booting os '%s' (%d) is not supported\n",
 			genimg_get_os_name(images.os.os), images.os.os);
-		show_boot_error(8);
+		show_boot_error(BOOTSTAGE_ID_CHECK_BOOT_OS);
 		return 1;
 	}
 
@@ -693,7 +692,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	boot_fn(0, argc, argv, &images);
 
-	show_boot_error(9);
+	show_boot_error(BOOTSTAGE_ID_BOOT_OS_RETURNED);
 #ifdef DEBUG
 	puts("\n## Control returned to monitor - resetting...\n");
 #endif
@@ -735,34 +734,34 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify)
 
 	if (!image_check_magic(hdr)) {
 		puts("Bad Magic Number\n");
-		show_boot_error(1);
+		show_boot_error(BOOTSTAGE_ID_CHECK_MAGIC);
 		return NULL;
 	}
-	show_boot_progress(2);
+	show_boot_progress(BOOTSTAGE_ID_CHECK_HEADER);
 
 	if (!image_check_hcrc(hdr)) {
 		puts("Bad Header Checksum\n");
-		show_boot_error(2);
+		show_boot_error(BOOTSTAGE_ID_CHECK_HEADER);
 		return NULL;
 	}
 
-	show_boot_progress(3);
+	show_boot_progress(BOOTSTAGE_ID_CHECK_CHECKSUM);
 	image_print_contents(hdr);
 
 	if (verify) {
 		puts("   Verifying Checksum ... ");
 		if (!image_check_dcrc(hdr)) {
 			printf("Bad Data CRC\n");
-			show_boot_error(3);
+			show_boot_error(BOOTSTAGE_ID_CHECK_CHECKSUM);
 			return NULL;
 		}
 		puts("OK\n");
 	}
-	show_boot_progress(4);
+	show_boot_progress(BOOTSTAGE_ID_CHECK_ARCH);
 
 	if (!image_check_target_arch(hdr)) {
 		printf("Unsupported Architecture 0x%x\n", image_get_arch(hdr));
-		show_boot_error(4);
+		show_boot_error(BOOTSTAGE_ID_CHECK_ARCH);
 		return NULL;
 	}
 	return hdr;
@@ -864,7 +863,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 		debug("*  kernel: cmdline image address = 0x%08lx\n", img_addr);
 	}
 
-	show_boot_progress(1);
+	show_boot_progress(BOOTSTAGE_ID_CHECK_MAGIC);
 
 	/* copy from dataflash if needed */
 	img_addr = genimg_get_image(img_addr);
@@ -878,7 +877,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 		hdr = image_get_kernel(img_addr, images->verify);
 		if (!hdr)
 			return NULL;
-		show_boot_progress(5);
+		show_boot_progress(BOOTSTAGE_ID_CHECK_IMAGETYPE);
 
 		/* get os_data and os_len */
 		switch (image_get_type(hdr)) {
@@ -897,7 +896,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 		default:
 			printf("Wrong Image Type for %s command\n",
 				cmdtp->name);
-			show_boot_error(5);
+			show_boot_error(BOOTSTAGE_ID_CHECK_IMAGETYPE);
 			return NULL;
 		}
 
@@ -912,7 +911,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 		images->legacy_hdr_os = hdr;
 
 		images->legacy_hdr_valid = 1;
-		show_boot_progress(6);
+		show_boot_progress(BOOTSTAGE_ID_DECOMP_IMAGE);
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
diff --git a/common/image.c b/common/image.c
index 22644d2..6c69c2b 100644
--- a/common/image.c
+++ b/common/image.c
@@ -895,7 +895,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 			printf("## Loading init Ramdisk from Legacy "
 					"Image at %08lx ...\n", rd_addr);
 
-			show_boot_progress(9);
+			show_boot_progress(BOOTSTAGE_ID_LOAD_RAMDISK);
 			rd_hdr = image_get_ramdisk(rd_addr, arch,
 							images->verify);
 
diff --git a/include/bootstage.h b/include/bootstage.h
index 63a6435..408356c 100644
--- a/include/bootstage.h
+++ b/include/bootstage.h
@@ -44,6 +44,20 @@
  * error on action3
  */
 enum bootstage_id {
+	BOOTSTAGE_ID_START = 0,
+	BOOTSTAGE_ID_CHECK_MAGIC,	/* Checking image magic */
+	BOOTSTAGE_ID_CHECK_HEADER,	/* Checking image header */
+	BOOTSTAGE_ID_CHECK_CHECKSUM,	/* Checking image checksum */
+	BOOTSTAGE_ID_CHECK_ARCH,	/* Checking architecture */
+
+	BOOTSTAGE_ID_CHECK_IMAGETYPE = 5,/* Checking image type */
+	BOOTSTAGE_ID_DECOMP_IMAGE,	/* Decompressing image */
+	BOOTSTAGE_ID_KERNEL_LOADED,	/* Kernel has been loaded */
+	BOOTSTAGE_ID_DECOMP_UNIMPL = 7,	/* Odd decompression algorithm */
+	BOOTSTAGE_ID_CHECK_BOOT_OS,	/* Calling OS-specific boot function */
+	BOOTSTAGE_ID_BOOT_OS_RETURNED,	/* Tried to boot OS, but it returned */
+	BOOTSTAGE_ID_CHECK_RAMDISK = 9,	/* Checking ram disk */
+
 	BOOTSTAGE_ID_RUN_OS	= 15,	/* Exiting U-Boot, entering OS */
 };
 
-- 
1.7.7.3



More information about the U-Boot mailing list