[U-Boot] [PATCH v3 0/15] bootstage: record and publish boot progress timing

This series creates a simple boot progress timing feature in U-Boot.
Previous discussion on this is here:
http://lists.denx.de/pipermail/u-boot/2011-May/thread.html#92584
A request was made to unify this with show_boot_progress(). As discussed in the v1 RFC patch, this series addresses this the following way:
1. Create bootstage.h with the intent of replacing integers with enums. This will allow the values to be easily changed or rationalised later as required. It also makes it more explicit that (for example) 15 means we are about to run an OS.
2. Change show_boot_progress() to use these enums. This first patch just shows doing this with one (commonly used) integer value.
3. Create bootstage.c file which permits recording of bootstage timestamps.
4. Change the existing show_boot_progress() handlers within board files to use a provided bootstage progress handler instead. This is easy enough as there are few users.
5. Change show_boot_progress() to call into bootstage, which in turns calls the board-provided progress handler, if defined, after recording a timestamp. The function signature will stay the same for now.
Ultimately I would like boot timing available from before U-Boot to user space in Linux. See RFC patch for Linux here:
http://lwn.net/Articles/460432/
and discussion here:
http://comments.gmane.org/gmane.linux.kernel/1194861
Still to do: change the microsecond time printout to use the Linux seconds.microseconds format.
Changes in v2: - Unify show_boot_progress() into this series
Changes in v3: - Adjust show_boot_progress() comment - Fix 'progres' typo - Fix code style in bootstage_mark_name() - Make main bootstage commit title more explicit - Move file comment above copyright message - Rename timer patch to remove bootstage: tag - Set BOOTSTAGE_ID_START to 0 explicitly - Update commit message to clarify the purpose of CONFIG_BOOTSTAGE_REPORT
Simon Glass (15): bootstage: Create an initial header for boot progress integers bootstage: Make use of BOOTSTAGE_ID_RUN_OS in show_boot_progress() bootstage: Use show_boot_error() for -ve progress numbers bootstage: Convert progress numbers 1-9 into enums bootstage: Convert progress numbers 10-19 to enums bootstage: Convert progress numbers 20-41 to enums bootstage: Convert IDE progress numbers to enums bootstage: Convert NAND progress numbers to enums bootstage: Convert net progress numbers to enums bootstage: Convert FIT progress numbers to enums timer: add microsecond boot func bootstage: Replace show_boot_progress/error() with bootstage_...() bootstage: Implement core microsecond boot time measurement bootstage: Plumb in bootstage calls for basic operations bootstage: arm: Add bootstage calls in board and bootm
README | 25 +++ arch/arm/lib/board.c | 3 + arch/arm/lib/bootm.c | 6 +- arch/avr32/lib/bootm.c | 2 +- arch/m68k/lib/bootm.c | 2 +- arch/microblaze/lib/bootm.c | 2 +- arch/mips/lib/bootm.c | 2 +- arch/mips/lib/bootm_qemu_mips.c | 2 +- arch/nds32/lib/bootm.c | 2 +- arch/powerpc/lib/board.c | 2 +- arch/powerpc/lib/bootm.c | 2 +- arch/sparc/lib/board.c | 2 +- arch/x86/lib/board.c | 19 +-- board/Seagate/dockstar/dockstar.c | 4 +- board/a4m072/a4m072.c | 2 +- board/bf533-stamp/bf533-stamp.c | 30 ++-- board/hermes/hermes.c | 8 +- board/ivm/ivm.c | 2 +- board/matrix_vision/common/mv_common.c | 2 +- board/matrix_vision/mvbc_p/mvbc_p.c | 8 +- board/pcs440ep/pcs440ep.c | 50 +++--- board/scb9328/scb9328.c | 6 - board/sixnet/sixnet.c | 2 +- board/ti/beagle/beagle.c | 2 +- common/Makefile | 1 + common/bootstage.c | 160 ++++++++++++++++++++ common/cmd_bootm.c | 95 ++++++------ common/cmd_ide.c | 46 +++--- common/cmd_nand.c | 34 ++-- common/cmd_net.c | 23 ++- common/cmd_usb.c | 1 + common/env_common.c | 2 +- common/image.c | 56 ++++---- include/bootstage.h | 259 ++++++++++++++++++++++++++++++++ include/common.h | 13 +- lib/time.c | 17 ++ net/bootp.c | 4 + net/eth.c | 6 +- net/net.c | 1 + post/post.c | 4 +- 40 files changed, 697 insertions(+), 212 deletions(-) create mode 100644 common/bootstage.c create mode 100644 include/bootstage.h

At present boot_stage_progress() is called with various magic numbers. The new bootstage.h header will be used to turn these into symbolic names throughout the code.
The intent is not that these numbers are passed to Linux. In fact by using an enum to track them we should eventually be able to remove the explict numbers and just have the stages count up from 0.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v3: - Adjust show_boot_progress() comment - Fix 'progres' typo - Move file comment above copyright message
include/bootstage.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/common.h | 6 +--- 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 include/bootstage.h
diff --git a/include/bootstage.h b/include/bootstage.h new file mode 100644 index 0000000..ddfb07a --- /dev/null +++ b/include/bootstage.h @@ -0,0 +1,58 @@ +/* + * This file implements recording of each stage of the boot process. It is + * intended to implement timing of each stage, reporting this information + * to the user and passing it to the OS for logging / further analysis. + * + * Copyright (c) 2011 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef _BOOTSTAGE_H +#define _BOOTSTAGE_H + +/* + * A list of boot stages that we know about. Each of these indicates the + * state that we are at, and the action that we are about to perform. For + * errors, we issue an error for an item when it fails. Therefore the + * normal sequence is: + * + * progress action1 + * progress action2 + * progress action3 + * + * and an error condition where action 3 failed would be: + * + * progress action1 + * progress action2 + * progress action3 + * error on action3 + */ +enum bootstage_id { + BOOTSTAGE_ID_RUN_OS = 15, /* Exiting U-Boot, entering OS */ +}; + +/* + * Board code can implement show_boot_progress() if needed. + * + * @param val Progress state (enum bootstage_id), or -id if an error + * has occurred. + */ +void show_boot_progress(int val); + +#endif diff --git a/include/common.h b/include/common.h index 3df1def..ae38784 100644 --- a/include/common.h +++ b/include/common.h @@ -799,10 +799,8 @@ int pcmcia_init (void); #ifdef CONFIG_STATUS_LED # include <status_led.h> #endif -/* - * Board-specific Platform code can reimplement show_boot_progress () if needed - */ -void show_boot_progress(int val); + +#include <bootstage.h>
/* Multicore arch functions */ #ifdef CONFIG_MP

Dear Simon Glass,
In message 1326590698-7767-2-git-send-email-sjg@chromium.org you wrote:
At present boot_stage_progress() is called with various magic numbers. The new bootstage.h header will be used to turn these into symbolic names throughout the code.
The intent is not that these numbers are passed to Linux. In fact by using an enum to track them we should eventually be able to remove the explict numbers and just have the stages count up from 0.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v3:
- Adjust show_boot_progress() comment
- Fix 'progres' typo
- Move file comment above copyright message
include/bootstage.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/common.h | 6 +--- 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 include/bootstage.h
Applied, thanks.
Best regards,
Wolfgang Denk

This changes the number 15 as used in boot_stage_progress() to use the new name provided for it. This is a separate patch because it touches so many files.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Mike Frysinger vapier@gentoo.org ---
arch/arm/lib/bootm.c | 2 +- arch/avr32/lib/bootm.c | 2 +- arch/m68k/lib/bootm.c | 2 +- arch/microblaze/lib/bootm.c | 2 +- arch/mips/lib/bootm.c | 2 +- arch/mips/lib/bootm_qemu_mips.c | 2 +- arch/nds32/lib/bootm.c | 2 +- arch/powerpc/lib/bootm.c | 2 +- board/Seagate/dockstar/dockstar.c | 2 +- board/a4m072/a4m072.c | 2 +- board/bf533-stamp/bf533-stamp.c | 2 +- board/matrix_vision/mvbc_p/mvbc_p.c | 2 +- board/pcs440ep/pcs440ep.c | 3 +-- board/sixnet/sixnet.c | 2 +- board/ti/beagle/beagle.c | 2 +- common/cmd_bootm.c | 8 ++++---- 16 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index afa0093..249ac1b 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -113,7 +113,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) printf ("Using machid 0x%x from environment\n", machid); }
- show_boot_progress (15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
#ifdef CONFIG_OF_LIBFDT if (images->ft_len) diff --git a/arch/avr32/lib/bootm.c b/arch/avr32/lib/bootm.c index c9a55ff..f180737 100644 --- a/arch/avr32/lib/bootm.c +++ b/arch/avr32/lib/bootm.c @@ -192,7 +192,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima
theKernel = (void *)images->ep;
- show_boot_progress (15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
params = params_start = (struct tag *)gd->bd->bi_boot_params; params = setup_start_tag(params); diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c index 1229ac7..233782b 100644 --- a/arch/m68k/lib/bootm.c +++ b/arch/m68k/lib/bootm.c @@ -104,7 +104,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel);
- show_boot_progress (15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
/* * Linux Kernel Parameters (passing board info data): diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c index 9f6d6d6..24b9e09 100644 --- a/arch/microblaze/lib/bootm.c +++ b/arch/microblaze/lib/bootm.c @@ -59,7 +59,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima if (ret) return 1;
- show_boot_progress (15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
if (!of_flat_tree && argc > 3) of_flat_tree = (char *)simple_strtoul(argv[3], NULL, 16); diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 40a5647..5b7e74f 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -56,7 +56,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima /* find kernel entry point */ theKernel = (void (*)(int, char **, char **, int *))images->ep;
- show_boot_progress (15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
#ifdef DEBUG printf ("## Transferring control to Linux (at address %08lx) ...\n", diff --git a/arch/mips/lib/bootm_qemu_mips.c b/arch/mips/lib/bootm_qemu_mips.c index f1906c6..47f5310 100644 --- a/arch/mips/lib/bootm_qemu_mips.c +++ b/arch/mips/lib/bootm_qemu_mips.c @@ -39,7 +39,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima /* find kernel entry point */ theKernel = (void (*)(int, char **, char **, int *))images->ep;
- show_boot_progress (15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); diff --git a/arch/nds32/lib/bootm.c b/arch/nds32/lib/bootm.c index b0a5a0d..5ae90fb 100644 --- a/arch/nds32/lib/bootm.c +++ b/arch/nds32/lib/bootm.c @@ -69,7 +69,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) printf("Using machid 0x%x from environment\n", machid); }
- show_boot_progress(15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong)theKernel); diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c index efcfe84..37f162a 100644 --- a/arch/powerpc/lib/bootm.c +++ b/arch/powerpc/lib/bootm.c @@ -69,7 +69,7 @@ static void boot_jump_linux(bootm_headers_t *images) debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong)kernel);
- show_boot_progress (15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
#if defined(CONFIG_SYS_INIT_RAM_LOCK) && !defined(CONFIG_E500) unlock_ram_in_cache(); diff --git a/board/Seagate/dockstar/dockstar.c b/board/Seagate/dockstar/dockstar.c index a1de0dc..8cbfb02 100644 --- a/board/Seagate/dockstar/dockstar.c +++ b/board/Seagate/dockstar/dockstar.c @@ -169,7 +169,7 @@ static void set_leds(u32 leds, u32 blinking) void show_boot_progress(int val) { switch (val) { - case 15: /* booting Linux */ + case BOOTSTAGE_ID_RUN_OS: /* booting Linux */ set_leds(BOTH_LEDS, NEITHER_LED); break; case 64: /* Ethernet initialization */ diff --git a/board/a4m072/a4m072.c b/board/a4m072/a4m072.c index 09a5a51..9485cfb 100644 --- a/board/a4m072/a4m072.c +++ b/board/a4m072/a4m072.c @@ -484,7 +484,7 @@ void show_boot_progress(int status) display_out_pos = 0; /* reset output position */
/* we want to flush status 15 now */ - if (status == 15) + if (status == BOOTSTAGE_ID_RUN_OS) display_flush(); } #endif diff --git a/board/bf533-stamp/bf533-stamp.c b/board/bf533-stamp/bf533-stamp.c index 935aad2..b1134e9 100644 --- a/board/bf533-stamp/bf533-stamp.c +++ b/board/bf533-stamp/bf533-stamp.c @@ -117,7 +117,7 @@ void show_boot_progress(int status) case 12: case 13: case 14: - case 15: + case BOOTSTAGE_ID_RUN_OS: stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF); break; default: diff --git a/board/matrix_vision/mvbc_p/mvbc_p.c b/board/matrix_vision/mvbc_p/mvbc_p.c index 4392176..9dffedc 100644 --- a/board/matrix_vision/mvbc_p/mvbc_p.c +++ b/board/matrix_vision/mvbc_p/mvbc_p.c @@ -250,7 +250,7 @@ void show_boot_progress(int val) case 12: setbits_be32(&gpio->simple_dvo, LED_Y); break; - case 15: + case BOOTSTAGE_ID_RUN_OS: setbits_be32(&gpio->simple_dvo, LED_R); break; default: diff --git a/board/pcs440ep/pcs440ep.c b/board/pcs440ep/pcs440ep.c index 5a3ec58..36994b5 100644 --- a/board/pcs440ep/pcs440ep.c +++ b/board/pcs440ep/pcs440ep.c @@ -110,8 +110,7 @@ void show_boot_progress (int val) status_led_set (1, STATUS_LED_ON); status_led_set (2, STATUS_LED_ON); break; - case 15: - /* booting */ + 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); diff --git a/board/sixnet/sixnet.c b/board/sixnet/sixnet.c index edb5d13..a13c72d 100644 --- a/board/sixnet/sixnet.c +++ b/board/sixnet/sixnet.c @@ -46,7 +46,7 @@ void show_boot_progress (int status) { #if defined(CONFIG_STATUS_LED) # if defined(STATUS_LED_BOOT) - if (status == 15) { + if (status == BOOTSTAGE_ID_RUN_OS) { /* ready to transfer to kernel, make sure LED is proper state */ status_led_set(STATUS_LED_BOOT, CONFIG_BOOT_LED_STATE); } diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c index 6a457cb..4ea0fac 100644 --- a/board/ti/beagle/beagle.c +++ b/board/ti/beagle/beagle.c @@ -462,7 +462,7 @@ int ehci_hcd_stop(void) /* Call usb_stop() before starting the kernel */ void show_boot_progress(int val) { - if(val == 15) + if (val == BOOTSTAGE_ID_RUN_OS) usb_stop(); }
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index d5745b1..6edee3f 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -1340,7 +1340,7 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[], "(at address %08lx) ...\n", (ulong)loader);
- show_boot_progress(15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
/* * NetBSD Stage-2 Loader Parameters: @@ -1398,7 +1398,7 @@ static int do_bootm_rtems(int flag, int argc, char * const argv[], printf("## Transferring control to RTEMS (at address %08lx) ...\n", (ulong)entry_point);
- show_boot_progress(15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
/* * RTEMS Parameters: @@ -1431,7 +1431,7 @@ static int do_bootm_ose(int flag, int argc, char * const argv[], printf("## Transferring control to OSE (at address %08lx) ...\n", (ulong)entry_point);
- show_boot_progress(15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
/* * OSE Parameters: @@ -1512,7 +1512,7 @@ static int do_bootm_integrity(int flag, int argc, char * const argv[], printf("## Transferring control to INTEGRITY (at address %08lx) ...\n", (ulong)entry_point);
- show_boot_progress(15); + show_boot_progress(BOOTSTAGE_ID_RUN_OS);
/* * INTEGRITY Parameters:

Dear Simon Glass,
In message 1326590698-7767-3-git-send-email-sjg@chromium.org you wrote:
This changes the number 15 as used in boot_stage_progress() to use the new name provided for it. This is a separate patch because it touches so many files.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Mike Frysinger vapier@gentoo.org
arch/arm/lib/bootm.c | 2 +- arch/avr32/lib/bootm.c | 2 +- arch/m68k/lib/bootm.c | 2 +- arch/microblaze/lib/bootm.c | 2 +- arch/mips/lib/bootm.c | 2 +- arch/mips/lib/bootm_qemu_mips.c | 2 +- arch/nds32/lib/bootm.c | 2 +- arch/powerpc/lib/bootm.c | 2 +- board/Seagate/dockstar/dockstar.c | 2 +- board/a4m072/a4m072.c | 2 +- board/bf533-stamp/bf533-stamp.c | 2 +- board/matrix_vision/mvbc_p/mvbc_p.c | 2 +- board/pcs440ep/pcs440ep.c | 3 +-- board/sixnet/sixnet.c | 2 +- board/ti/beagle/beagle.c | 2 +- common/cmd_bootm.c | 8 ++++---- 16 files changed, 19 insertions(+), 20 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Rather than the caller negating our progress numbers to indicate an error has occurred, which seems hacky, add a function to indicate this.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Mike Frysinger vapier@gentoo.org ---
arch/powerpc/lib/board.c | 2 +- arch/sparc/lib/board.c | 2 +- common/cmd_bootm.c | 50 +++++++++++++++++++++++----------------------- common/cmd_ide.c | 22 ++++++++++---------- common/cmd_nand.c | 16 +++++++------- common/cmd_net.c | 8 +++--- common/env_common.c | 2 +- common/image.c | 22 ++++++++++---------- include/bootstage.h | 4 +++ net/eth.c | 2 +- post/post.c | 4 +- 11 files changed, 69 insertions(+), 65 deletions(-)
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index ff5888e..b11ec8c 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -1065,7 +1065,7 @@ void board_init_r(gd_t *id, ulong dest_addr) void hang(void) { puts("### ERROR ### Please RESET the board ###\n"); - show_boot_progress(-30); + show_boot_error(30); for (;;) ; } diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c index 519a4fb..fcbc666 100644 --- a/arch/sparc/lib/board.c +++ b/arch/sparc/lib/board.c @@ -426,7 +426,7 @@ void hang(void) { puts("### ERROR ### Please RESET the board ###\n"); #ifdef CONFIG_SHOW_BOOT_PROGRESS - show_boot_progress(-30); + show_boot_error(30); #endif for (;;) ; } diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 6edee3f..450fa5c 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -222,21 +222,21 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] if (fit_image_get_type(images.fit_hdr_os, images.fit_noffset_os, &images.os.type)) { puts("Can't get image type!\n"); - show_boot_progress(-109); + show_boot_error(109); return 1; }
if (fit_image_get_comp(images.fit_hdr_os, images.fit_noffset_os, &images.os.comp)) { puts("Can't get image compression!\n"); - show_boot_progress(-110); + show_boot_error(110); return 1; }
if (fit_image_get_os(images.fit_hdr_os, images.fit_noffset_os, &images.os.os)) { puts("Can't get image OS!\n"); - show_boot_progress(-111); + show_boot_error(111); return 1; }
@@ -245,7 +245,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] if (fit_image_get_load(images.fit_hdr_os, images.fit_noffset_os, &images.os.load)) { puts("Can't get image load address!\n"); - show_boot_progress(-112); + show_boot_error(112); return 1; } break; @@ -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_progress(-6); + show_boot_error(6); 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_progress(-6); + show_boot_error(6); 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_progress(-6); + show_boot_error(6); 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_progress(-6); + show_boot_error(6); return BOOTM_ERR_RESET; }
@@ -649,14 +649,14 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else { puts("ERROR: new format image overwritten - " "must RESET the board to recover\n"); - show_boot_progress(-113); + show_boot_error(113); do_reset(cmdtp, flag, argc, argv); } } if (ret == BOOTM_ERR_UNIMPLEMENTED) { if (iflag) enable_interrupts(); - show_boot_progress(-7); + show_boot_error(7); return 1; } } @@ -685,7 +685,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_progress(-8); + show_boot_error(8); return 1; }
@@ -693,7 +693,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
boot_fn(0, argc, argv, &images);
- show_boot_progress(-9); + show_boot_error(9); #ifdef DEBUG puts("\n## Control returned to monitor - resetting...\n"); #endif @@ -735,14 +735,14 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify)
if (!image_check_magic(hdr)) { puts("Bad Magic Number\n"); - show_boot_progress(-1); + show_boot_error(1); return NULL; } show_boot_progress(2);
if (!image_check_hcrc(hdr)) { puts("Bad Header Checksum\n"); - show_boot_progress(-2); + show_boot_error(2); return NULL; }
@@ -753,7 +753,7 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify) puts(" Verifying Checksum ... "); if (!image_check_dcrc(hdr)) { printf("Bad Data CRC\n"); - show_boot_progress(-3); + show_boot_error(3); return NULL; } puts("OK\n"); @@ -762,7 +762,7 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify)
if (!image_check_target_arch(hdr)) { printf("Unsupported Architecture 0x%x\n", image_get_arch(hdr)); - show_boot_progress(-4); + show_boot_error(4); return NULL; } return hdr; @@ -790,7 +790,7 @@ static int fit_check_kernel(const void *fit, int os_noffset, int verify) puts(" Verifying Hash Integrity ... "); if (!fit_image_check_hashes(fit, os_noffset)) { puts("Bad Data Hash\n"); - show_boot_progress(-104); + show_boot_error(104); return 0; } puts("OK\n"); @@ -799,7 +799,7 @@ static int fit_check_kernel(const void *fit, int os_noffset, int verify)
if (!fit_image_check_target_arch(fit, os_noffset)) { puts("Unsupported Architecture\n"); - show_boot_progress(-105); + show_boot_error(105); return 0; }
@@ -807,7 +807,7 @@ static int fit_check_kernel(const void *fit, int os_noffset, int verify) if (!fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL) && !fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL_NOLOAD)) { puts("Not a kernel image\n"); - show_boot_progress(-106); + show_boot_error(106); return 0; }
@@ -897,7 +897,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_progress(-5); + show_boot_error(5); return NULL; }
@@ -922,7 +922,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
if (!fit_check_format(fit_hdr)) { puts("Bad FIT kernel image format!\n"); - show_boot_progress(-100); + show_boot_error(100); return NULL; } show_boot_progress(100); @@ -938,7 +938,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, cfg_noffset = fit_conf_get_node(fit_hdr, fit_uname_config); if (cfg_noffset < 0) { - show_boot_progress(-101); + show_boot_error(101); return NULL; } /* save configuration uname provided in the first @@ -962,7 +962,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, fit_uname_kernel); } if (os_noffset < 0) { - show_boot_progress(-103); + show_boot_error(103); return NULL; }
@@ -975,7 +975,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, /* get kernel image data address and length */ if (fit_image_get_data(fit_hdr, os_noffset, &data, &len)) { puts("Could not find kernel subimage data!\n"); - show_boot_progress(-107); + show_boot_error(107); return NULL; } show_boot_progress(108); @@ -989,7 +989,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, #endif default: printf("Wrong Image Format for %s command\n", cmdtp->name); - show_boot_progress(-108); + show_boot_error(108); return NULL; }
diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 305c602..bdfa8db 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -360,14 +360,14 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) boot_device = argv[2]; break; default: - show_boot_progress(-42); + show_boot_error(42); return cmd_usage(cmdtp); } show_boot_progress(42);
if (!boot_device) { puts("\n** No boot device **\n"); - show_boot_progress(-43); + show_boot_error(43); return 1; } show_boot_progress(43); @@ -376,7 +376,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN) { printf("\n** Device %d not available\n", dev); - show_boot_progress(-44); + show_boot_error(44); return 1; } show_boot_progress(44); @@ -384,14 +384,14 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (*ep) { if (*ep != ':') { puts("\n** Invalid boot device, use `dev[:part]' **\n"); - show_boot_progress(-45); + show_boot_error(45); return 1; } part = simple_strtoul(++ep, NULL, 16); } show_boot_progress(45); if (get_partition_info(&ide_dev_desc[dev], part, &info)) { - show_boot_progress(-46); + show_boot_error(46); return 1; } show_boot_progress(46); @@ -402,7 +402,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) printf("\n** Invalid partition type "%.32s"" " (expect "" BOOT_PART_TYPE "")\n", info.type); - show_boot_progress(-47); + show_boot_error(47); return 1; } show_boot_progress(47); @@ -416,7 +416,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (ide_dev_desc[dev]. block_read(dev, info.start, 1, (ulong *) addr) != 1) { printf("** Read error on %d:%d\n", dev, part); - show_boot_progress(-48); + show_boot_error(48); return 1; } show_boot_progress(48); @@ -429,7 +429,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (!image_check_hcrc(hdr)) { puts("\n** Bad Header Checksum **\n"); - show_boot_progress(-50); + show_boot_error(50); return 1; } show_boot_progress(50); @@ -447,7 +447,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) break; #endif default: - show_boot_progress(-49); + show_boot_error(49); puts("** Unknown image type\n"); return 1; } @@ -459,7 +459,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (ide_dev_desc[dev].block_read(dev, info.start + 1, cnt, (ulong *)(addr + info.blksz)) != cnt) { printf("** Read error on %d:%d\n", dev, part); - show_boot_progress(-51); + show_boot_error(51); return 1; } show_boot_progress(51); @@ -468,7 +468,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) /* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format((void *) addr) == IMAGE_FORMAT_FIT) { if (!fit_check_format(fit_hdr)) { - show_boot_progress(-140); + show_boot_error(140); puts("** Bad FIT image format\n"); return 1; } diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 3e2edb8..e294b3e 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -787,7 +787,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, if (s != NULL && (strcmp(s, ".jffs2") && strcmp(s, ".e") && strcmp(s, ".i"))) { printf("Unknown nand load suffix '%s'\n", s); - show_boot_progress(-53); + show_boot_error(53); return 1; }
@@ -797,7 +797,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr); if (r) { puts("** Read error\n"); - show_boot_progress (-56); + show_boot_error(56); return 1; } show_boot_progress (56); @@ -820,7 +820,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, break; #endif default: - show_boot_progress (-57); + show_boot_error(57); puts ("** Unknown image type\n"); return 1; } @@ -829,7 +829,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr); if (r) { puts("** Read error\n"); - show_boot_progress (-58); + show_boot_error(58); return 1; } show_boot_progress (58); @@ -838,7 +838,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, /* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) { if (!fit_check_format (fit_hdr)) { - show_boot_progress (-150); + show_boot_error(150); puts ("** Bad FIT image format\n"); return 1; } @@ -907,14 +907,14 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_MTDPARTS) usage: #endif - show_boot_progress(-53); + show_boot_error(53); return cmd_usage(cmdtp); }
show_boot_progress(53); if (!boot_device) { puts("\n** No boot device **\n"); - show_boot_progress(-54); + show_boot_error(54); return 1; } show_boot_progress(54); @@ -923,7 +923,7 @@ usage:
if (idx < 0 || idx >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[idx].name) { printf("\n** Device %d not available\n", idx); - show_boot_progress(-55); + show_boot_error(55); return 1; } show_boot_progress(55); diff --git a/common/cmd_net.c b/common/cmd_net.c index 89519fa..efaddf5 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -230,13 +230,13 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc, break; #endif default: - show_boot_progress (-80); + show_boot_error(80); return cmd_usage(cmdtp); }
show_boot_progress (80); if ((size = NetLoop(proto)) < 0) { - show_boot_progress (-81); + show_boot_error(81); return 1; }
@@ -246,7 +246,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
/* done if no file was loaded (no errors though) */ if (size == 0) { - show_boot_progress (-82); + show_boot_error(82); return 0; }
@@ -257,7 +257,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc, rcode = bootm_maybe_autostart(cmdtp, argv[0]);
if (rcode < 0) - show_boot_progress (-83); + show_boot_error(83); else show_boot_progress (84); return rcode; diff --git a/common/env_common.c b/common/env_common.c index 71811c4..49b55f1 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -228,7 +228,7 @@ void env_relocate(void) #if defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */ set_default_env(NULL); #else - show_boot_progress(-60); + show_boot_error(60); set_default_env("!bad CRC"); #endif } else { diff --git a/common/image.c b/common/image.c index 202c8a1..22644d2 100644 --- a/common/image.c +++ b/common/image.c @@ -373,13 +373,13 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
if (!image_check_magic(rd_hdr)) { puts("Bad Magic Number\n"); - show_boot_progress(-10); + show_boot_error(10); return NULL; }
if (!image_check_hcrc(rd_hdr)) { puts("Bad Header Checksum\n"); - show_boot_progress(-11); + show_boot_error(11); return NULL; }
@@ -390,7 +390,7 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch, puts(" Verifying Checksum ... "); if (!image_check_dcrc(rd_hdr)) { puts("Bad Data CRC\n"); - show_boot_progress(-12); + show_boot_error(12); return NULL; } puts("OK\n"); @@ -403,7 +403,7 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch, !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) { printf("No Linux %s Ramdisk Image\n", genimg_get_arch_name(arch)); - show_boot_progress(-13); + show_boot_error(13); return NULL; }
@@ -915,7 +915,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, show_boot_progress(120); if (!fit_check_format(fit_hdr)) { puts("Bad FIT ramdisk image format!\n"); - show_boot_progress(-120); + show_boot_error(120); return 1; } show_boot_progress(121); @@ -932,7 +932,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, if (cfg_noffset < 0) { puts("Could not find configuration " "node\n"); - show_boot_progress(-122); + show_boot_error(122); return 1; } fit_uname_config = fdt_get_name(fit_hdr, @@ -952,7 +952,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, } if (rd_noffset < 0) { puts("Could not find subimage node\n"); - show_boot_progress(-124); + show_boot_error(124); return 1; }
@@ -968,7 +968,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, if (fit_image_get_data(fit_hdr, rd_noffset, &data, &size)) { puts("Could not find ramdisk subimage data!\n"); - show_boot_progress(-127); + show_boot_error(127); return 1; } show_boot_progress(128); @@ -979,7 +979,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, if (fit_image_get_load(fit_hdr, rd_noffset, &rd_load)) { puts("Can't get ramdisk subimage load " "address!\n"); - show_boot_progress(-129); + show_boot_error(129); return 1; } show_boot_progress(129); @@ -3171,7 +3171,7 @@ static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch, puts(" Verifying Hash Integrity ... "); if (!fit_image_check_hashes(fit, rd_noffset)) { puts("Bad Data Hash\n"); - show_boot_progress(-125); + show_boot_error(125); return 0; } puts("OK\n"); @@ -3183,7 +3183,7 @@ static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch, !fit_image_check_type(fit, rd_noffset, IH_TYPE_RAMDISK)) { printf("No Linux %s Ramdisk Image\n", genimg_get_arch_name(arch)); - show_boot_progress(-126); + show_boot_error(126); return 0; }
diff --git a/include/bootstage.h b/include/bootstage.h index ddfb07a..63a6435 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -54,5 +54,9 @@ enum bootstage_id { * has occurred. */ void show_boot_progress(int val); +static inline void show_boot_error(int val) +{ + show_boot_progress(-val); +}
#endif diff --git a/net/eth.c b/net/eth.c index b4b9b43..b55f327 100644 --- a/net/eth.c +++ b/net/eth.c @@ -260,7 +260,7 @@ int eth_initialize(bd_t *bis) #endif if (!eth_devices) { puts ("No ethernet found.\n"); - show_boot_progress (-64); + show_boot_error(64); } else { struct eth_device *dev = eth_devices; char *ethprime = getenv ("ethprime"); diff --git a/post/post.c b/post/post.c index d62f10a..25d9586 100644 --- a/post/post.c +++ b/post/post.c @@ -158,7 +158,7 @@ void post_output_backlog(void) post_log("PASSED\n"); else { post_log("FAILED\n"); - show_boot_progress(-31); + show_boot_error(31); } } } @@ -295,7 +295,7 @@ static int post_run_single(struct post_test *test, } else { if ((*test->test)(flags) != 0) { post_log("FAILED\n"); - show_boot_progress(-32); + show_boot_error(32); show_post_progress(i, POST_AFTER, POST_FAILED); if (test_flags & POST_CRITICAL) gd->flags |= GD_FLG_POSTFAIL;

Dear Simon Glass,
In message 1326590698-7767-4-git-send-email-sjg@chromium.org you wrote:
Rather than the caller negating our progress numbers to indicate an error has occurred, which seems hacky, add a function to indicate this.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Mike Frysinger vapier@gentoo.org
arch/powerpc/lib/board.c | 2 +- arch/sparc/lib/board.c | 2 +- common/cmd_bootm.c | 50 +++++++++++++++++++++++----------------------- common/cmd_ide.c | 22 ++++++++++---------- common/cmd_nand.c | 16 +++++++------- common/cmd_net.c | 8 +++--- common/env_common.c | 2 +- common/image.c | 22 ++++++++++---------- include/bootstage.h | 4 +++ net/eth.c | 2 +- post/post.c | 4 +- 11 files changed, 69 insertions(+), 65 deletions(-)
Applied (fixing a few merge conflicts), thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Simon Glass sjg@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 */ };

Dear Simon Glass,
In message 1326590698-7767-5-git-send-email-sjg@chromium.org you wrote:
Signed-off-by: Simon Glass sjg@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(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Mike Frysinger vapier@gentoo.org ---
board/bf533-stamp/bf533-stamp.c | 10 +++++----- board/matrix_vision/mvbc_p/mvbc_p.c | 2 +- common/image.c | 20 ++++++++++---------- include/bootstage.h | 7 +++++++ 4 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/board/bf533-stamp/bf533-stamp.c b/board/bf533-stamp/bf533-stamp.c index 07a988a..4d36160 100644 --- a/board/bf533-stamp/bf533-stamp.c +++ b/board/bf533-stamp/bf533-stamp.c @@ -112,11 +112,11 @@ void show_boot_progress(int status) stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF); break; case BOOTSTAGE_ID_BOOT_OS_RETURNED: - case 10: - case 11: - case 12: - case 13: - case 14: + case BOOTSTAGE_ID_RD_MAGIC: + case BOOTSTAGE_ID_RD_HDR_CHECKSUM: + case BOOTSTAGE_ID_RD_CHECKSUM: + case BOOTSTAGE_ID_RAMDISK: + case BOOTSTAGE_ID_NO_RAMDISK: case BOOTSTAGE_ID_RUN_OS: stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF); break; diff --git a/board/matrix_vision/mvbc_p/mvbc_p.c b/board/matrix_vision/mvbc_p/mvbc_p.c index a5dc2f0..7e06d6c 100644 --- a/board/matrix_vision/mvbc_p/mvbc_p.c +++ b/board/matrix_vision/mvbc_p/mvbc_p.c @@ -247,7 +247,7 @@ void show_boot_progress(int val) case 65: setbits_be32(&gpio->simple_dvo, LED_G1); break; - case 12: + case BOOTSTAGE_ID_COPY_RAMDISK: setbits_be32(&gpio->simple_dvo, LED_Y); break; case BOOTSTAGE_ID_RUN_OS: diff --git a/common/image.c b/common/image.c index 6c69c2b..af228cc 100644 --- a/common/image.c +++ b/common/image.c @@ -373,37 +373,37 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
if (!image_check_magic(rd_hdr)) { puts("Bad Magic Number\n"); - show_boot_error(10); + show_boot_error(BOOTSTAGE_ID_RD_MAGIC); return NULL; }
if (!image_check_hcrc(rd_hdr)) { puts("Bad Header Checksum\n"); - show_boot_error(11); + show_boot_error(BOOTSTAGE_ID_RD_HDR_CHECKSUM); return NULL; }
- show_boot_progress(10); + show_boot_progress(BOOTSTAGE_ID_RD_MAGIC); image_print_contents(rd_hdr);
if (verify) { puts(" Verifying Checksum ... "); if (!image_check_dcrc(rd_hdr)) { puts("Bad Data CRC\n"); - show_boot_error(12); + show_boot_error(BOOTSTAGE_ID_RD_CHECKSUM); return NULL; } puts("OK\n"); }
- show_boot_progress(11); + show_boot_progress(BOOTSTAGE_ID_RD_HDR_CHECKSUM);
if (!image_check_os(rd_hdr, IH_OS_LINUX) || !image_check_arch(rd_hdr, arch) || !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) { printf("No Linux %s Ramdisk Image\n", genimg_get_arch_name(arch)); - show_boot_error(13); + show_boot_error(BOOTSTAGE_ID_RAMDISK); return NULL; }
@@ -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(BOOTSTAGE_ID_LOAD_RAMDISK); + show_boot_progress(BOOTSTAGE_ID_CHECK_RAMDISK); rd_hdr = image_get_ramdisk(rd_addr, arch, images->verify);
@@ -1002,7 +1002,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, * Now check if we have a legacy mult-component image, * get second entry data start address and len. */ - show_boot_progress(13); + show_boot_progress(BOOTSTAGE_ID_RAMDISK); printf("## Loading init Ramdisk from multi component " "Legacy Image at %08lx ...\n", (ulong)images->legacy_hdr_os); @@ -1012,7 +1012,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, /* * no initrd image */ - show_boot_progress(14); + show_boot_progress(BOOTSTAGE_ID_NO_RAMDISK); rd_len = rd_data = 0; }
@@ -1096,7 +1096,7 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len, puts("ramdisk - allocation error\n"); goto error; } - show_boot_progress(12); + show_boot_progress(BOOTSTAGE_ID_COPY_RAMDISK);
*initrd_end = *initrd_start + rd_len; printf(" Loading Ramdisk to %08lx, end %08lx ... ", diff --git a/include/bootstage.h b/include/bootstage.h index 408356c..29082eb 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -58,6 +58,13 @@ enum bootstage_id { BOOTSTAGE_ID_BOOT_OS_RETURNED, /* Tried to boot OS, but it returned */ BOOTSTAGE_ID_CHECK_RAMDISK = 9, /* Checking ram disk */
+ BOOTSTAGE_ID_RD_MAGIC, /* Checking ram disk magic */ + BOOTSTAGE_ID_RD_HDR_CHECKSUM, /* Checking ram disk heder checksum */ + BOOTSTAGE_ID_RD_CHECKSUM, /* Checking ram disk checksum */ + BOOTSTAGE_ID_COPY_RAMDISK = 12, /* Copying ram disk into place */ + BOOTSTAGE_ID_RAMDISK, /* Checking for valid ramdisk */ + BOOTSTAGE_ID_NO_RAMDISK, /* No ram disk found (not an error) */ + BOOTSTAGE_ID_RUN_OS = 15, /* Exiting U-Boot, entering OS */ };

Dear Simon Glass,
In message 1326590698-7767-6-git-send-email-sjg@chromium.org you wrote:
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Mike Frysinger vapier@gentoo.org
board/bf533-stamp/bf533-stamp.c | 10 +++++----- board/matrix_vision/mvbc_p/mvbc_p.c | 2 +- common/image.c | 20 ++++++++++---------- include/bootstage.h | 7 +++++++ 4 files changed, 23 insertions(+), 16 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Signed-off-by: Simon Glass sjg@chromium.org ---
arch/powerpc/lib/board.c | 2 +- arch/sparc/lib/board.c | 2 +- arch/x86/lib/board.c | 18 +++++++++--------- board/hermes/hermes.c | 4 +++- board/pcs440ep/pcs440ep.c | 3 ++- include/bootstage.h | 25 +++++++++++++++++++++++++ post/post.c | 4 ++-- 7 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index b11ec8c..837c82d 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -1065,7 +1065,7 @@ void board_init_r(gd_t *id, ulong dest_addr) void hang(void) { puts("### ERROR ### Please RESET the board ###\n"); - show_boot_error(30); + show_boot_error(BOOTSTAGE_ID_NEED_RESET); for (;;) ; } diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c index fcbc666..770136b 100644 --- a/arch/sparc/lib/board.c +++ b/arch/sparc/lib/board.c @@ -426,7 +426,7 @@ void hang(void) { puts("### ERROR ### Please RESET the board ###\n"); #ifdef CONFIG_SHOW_BOOT_PROGRESS - show_boot_error(30); + show_boot_error(BOOTSTAGE_ID_NEED_RESET); #endif for (;;) ; } diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index d742fec..1f677cc 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -280,7 +280,7 @@ void board_init_r(gd_t *id, ulong dest_addr) static gd_t gd_data; init_fnc_t **init_fnc_ptr;
- show_boot_progress(0x21); + show_boot_progress(BOOTSTAGE_ID_BOARD_INIT_R);
/* Global data pointer is now writable */ gd = &gd_data; @@ -291,7 +291,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
gd->bd = &bd_data; memset(gd->bd, 0, sizeof(bd_t)); - show_boot_progress(0x22); + show_boot_progress(BOOTSTAGE_ID_BOARD_GLOBAL_DATA);
gd->baudrate = CONFIG_BAUDRATE;
@@ -302,7 +302,7 @@ void board_init_r(gd_t *id, ulong dest_addr) if ((*init_fnc_ptr)() != 0) hang(); } - show_boot_progress(0x23); + show_boot_progress(BOOTSTAGE_ID_BOARD_INIT_SEQ);
#ifdef CONFIG_SERIAL_MULTI serial_initialize(); @@ -312,14 +312,14 @@ void board_init_r(gd_t *id, ulong dest_addr) /* configure available FLASH banks */ size = flash_init(); display_flash_config(size); - show_boot_progress(0x24); + show_boot_progress(BOOTSTAGE_ID_BOARD_FLASH); #endif
- show_boot_progress(0x25); + show_boot_progress(BOOTSTAGE_ID_BOARD_FLASH_37);
/* initialize environment */ env_relocate(); - show_boot_progress(0x26); + show_boot_progress(BOOTSTAGE_ID_BOARD_ENV);
#ifdef CONFIG_CMD_NET @@ -334,7 +334,7 @@ void board_init_r(gd_t *id, ulong dest_addr) pci_init(); #endif
- show_boot_progress(0x27); + show_boot_progress(BOOTSTAGE_ID_BOARD_PCI);
stdio_init(); @@ -363,7 +363,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* enable exceptions */ enable_interrupts(); - show_boot_progress(0x28); + show_boot_progress(BOOTSTAGE_ID_BOARD_INTERRUPTS);
#ifdef CONFIG_STATUS_LED status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); @@ -432,7 +432,7 @@ void board_init_r(gd_t *id, ulong dest_addr) post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif
- show_boot_progress(0x29); + show_boot_progress(BOOTSTAGE_ID_BOARD_DONE);
/* main_loop() can return to retry autoboot, if so just run it again. */ for (;;) diff --git a/board/hermes/hermes.c b/board/hermes/hermes.c index 1b40ae8..38bab03 100644 --- a/board/hermes/hermes.c +++ b/board/hermes/hermes.c @@ -595,7 +595,9 @@ void show_boot_progress (int status) { volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
- if (status < -32) status = -1; /* let things compatible */ + /* let things compatible */ + if (status < -BOOTSTAGE_ID_POST_FAIL_R) + status = -1; status ^= 0x0F; status = (status & 0x0F) << 14; immr->im_cpm.cp_pbdat = (immr->im_cpm.cp_pbdat & ~PB_LED_ALL) | status; diff --git a/board/pcs440ep/pcs440ep.c b/board/pcs440ep/pcs440ep.c index 118d81c..f67eedd 100644 --- a/board/pcs440ep/pcs440ep.c +++ b/board/pcs440ep/pcs440ep.c @@ -97,7 +97,8 @@ static void status_led_blink (void) void show_boot_progress (int val) { /* find all valid Codes for val in README */ - if (val == -30) return; + if (val == -BOOTSTAGE_ID_NEED_RESET) + return; if (val < 0) { /* smthing goes wrong */ status_led_blink (); diff --git a/include/bootstage.h b/include/bootstage.h index 29082eb..a828f5c 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -66,6 +66,31 @@ enum bootstage_id { BOOTSTAGE_ID_NO_RAMDISK, /* No ram disk found (not an error) */
BOOTSTAGE_ID_RUN_OS = 15, /* Exiting U-Boot, entering OS */ + + BOOTSTAGE_ID_NEED_RESET = 30, + BOOTSTAGE_ID_POST_FAIL, /* Post failure */ + BOOTSTAGE_ID_POST_FAIL_R, /* Post failure reported after reloc */ + + /* + * This set is reported ony by x86, and the meaning is different. In + * this case we are reporting completion of a particular stage. + * This should probably change in he x86 code (which doesn't report + * errors in any case), but discussion this can perhaps wait until we + * have a generic board implementation. + */ + BOOTSTAGE_ID_BOARD_INIT_R, /* We have relocated */ + BOOTSTAGE_ID_BOARD_GLOBAL_DATA, /* Global data is set up */ + + BOOTSTAGE_ID_BOARD_INIT_SEQ, /* We completed the init sequence */ + BOOTSTAGE_ID_BOARD_FLASH, /* We have configured flash banks */ + BOOTSTAGE_ID_BOARD_FLASH_37, /* In case you didn't hear... */ + BOOTSTAGE_ID_BOARD_ENV, /* Environment is relocated & ready */ + BOOTSTAGE_ID_BOARD_PCI, /* PCI is up */ + + BOOTSTAGE_ID_BOARD_INTERRUPTS, /* Exceptions / interrupts ready */ + BOOTSTAGE_ID_BOARD_DONE, /* Board init done, off to main loop */ + /* ^^^ here ends the x86 sequence */ + };
/* diff --git a/post/post.c b/post/post.c index 25d9586..9764e1d 100644 --- a/post/post.c +++ b/post/post.c @@ -158,7 +158,7 @@ void post_output_backlog(void) post_log("PASSED\n"); else { post_log("FAILED\n"); - show_boot_error(31); + show_boot_error(BOOTSTAGE_ID_POST_FAIL_R); } } } @@ -295,7 +295,7 @@ static int post_run_single(struct post_test *test, } else { if ((*test->test)(flags) != 0) { post_log("FAILED\n"); - show_boot_error(32); + show_boot_error(BOOTSTAGE_ID_POST_FAIL_R); show_post_progress(i, POST_AFTER, POST_FAILED); if (test_flags & POST_CRITICAL) gd->flags |= GD_FLG_POSTFAIL;

Dear Simon Glass,
In message 1326590698-7767-7-git-send-email-sjg@chromium.org you wrote:
Signed-off-by: Simon Glass sjg@chromium.org
arch/powerpc/lib/board.c | 2 +- arch/sparc/lib/board.c | 2 +- arch/x86/lib/board.c | 18 +++++++++--------- board/hermes/hermes.c | 4 +++- board/pcs440ep/pcs440ep.c | 3 ++- include/bootstage.h | 25 +++++++++++++++++++++++++ post/post.c | 4 ++-- 7 files changed, 43 insertions(+), 15 deletions(-)
Applied, thanks.
Note: this patch did not apply at all to arch/x86/lib/board.c ; this is due to commit d47ab0e "x86: Split init functions out of board.c".
Graeme: it seems that with this patch you removed all boot progress support from the x86 code; that's a pity, and it will make unifying the code woth other architectures even more painful.
At the moment there was nothing I could do, so I simply ignored this file.
Best regards,
Wolfgang Denk

This changes over the IDE progress numbers to use enums from bootstage.h.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/cmd_ide.c | 46 +++++++++++++++++++++++----------------------- include/bootstage.h | 14 ++++++++++++++ 2 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/common/cmd_ide.c b/common/cmd_ide.c index bdfa8db..46fa7d4 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -345,7 +345,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) const void *fit_hdr = NULL; #endif
- show_boot_progress(41); + show_boot_progress(BOOTSTAGE_ID_IDE_START); switch (argc) { case 1: addr = CONFIG_SYS_LOAD_ADDR; @@ -360,41 +360,41 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) boot_device = argv[2]; break; default: - show_boot_error(42); + show_boot_error(BOOTSTAGE_ID_IDE_ADDR); return cmd_usage(cmdtp); } - show_boot_progress(42); + show_boot_progress(BOOTSTAGE_ID_IDE_ADDR);
if (!boot_device) { puts("\n** No boot device **\n"); - show_boot_error(43); + show_boot_error(BOOTSTAGE_ID_IDE_BOOT_DEVICE); return 1; } - show_boot_progress(43); + show_boot_progress(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
dev = simple_strtoul(boot_device, &ep, 16);
if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN) { printf("\n** Device %d not available\n", dev); - show_boot_error(44); + show_boot_error(BOOTSTAGE_ID_IDE_TYPE); return 1; } - show_boot_progress(44); + show_boot_progress(BOOTSTAGE_ID_IDE_TYPE);
if (*ep) { if (*ep != ':') { puts("\n** Invalid boot device, use `dev[:part]' **\n"); - show_boot_error(45); + show_boot_error(BOOTSTAGE_ID_IDE_PART); return 1; } part = simple_strtoul(++ep, NULL, 16); } - show_boot_progress(45); + show_boot_progress(BOOTSTAGE_ID_IDE_PART); if (get_partition_info(&ide_dev_desc[dev], part, &info)) { - show_boot_error(46); + show_boot_error(BOOTSTAGE_ID_IDE_PART_INFO); return 1; } - show_boot_progress(46); + show_boot_progress(BOOTSTAGE_ID_IDE_PART_INFO); if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) && (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0) @@ -402,10 +402,10 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) printf("\n** Invalid partition type "%.32s"" " (expect "" BOOT_PART_TYPE "")\n", info.type); - show_boot_error(47); + show_boot_error(BOOTSTAGE_ID_IDE_PART_TYPE); return 1; } - show_boot_progress(47); + show_boot_progress(BOOTSTAGE_ID_IDE_PART_TYPE);
printf("\nLoading from IDE device %d, partition %d: " "Name: %.32s Type: %.32s\n", dev, part, info.name, info.type); @@ -416,23 +416,23 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (ide_dev_desc[dev]. block_read(dev, info.start, 1, (ulong *) addr) != 1) { printf("** Read error on %d:%d\n", dev, part); - show_boot_error(48); + show_boot_error(BOOTSTAGE_ID_IDE_PART_READ); return 1; } - show_boot_progress(48); + show_boot_progress(BOOTSTAGE_ID_IDE_PART_READ);
switch (genimg_get_format((void *) addr)) { case IMAGE_FORMAT_LEGACY: hdr = (image_header_t *) addr;
- show_boot_progress(49); + show_boot_progress(BOOTSTAGE_ID_IDE_FORMAT);
if (!image_check_hcrc(hdr)) { puts("\n** Bad Header Checksum **\n"); - show_boot_error(50); + show_boot_error(BOOTSTAGE_ID_IDE_CHECKSUM); return 1; } - show_boot_progress(50); + show_boot_progress(BOOTSTAGE_ID_IDE_CHECKSUM);
image_print_contents(hdr);
@@ -447,7 +447,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) break; #endif default: - show_boot_error(49); + show_boot_error(BOOTSTAGE_ID_IDE_FORMAT); puts("** Unknown image type\n"); return 1; } @@ -459,20 +459,20 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (ide_dev_desc[dev].block_read(dev, info.start + 1, cnt, (ulong *)(addr + info.blksz)) != cnt) { printf("** Read error on %d:%d\n", dev, part); - show_boot_error(51); + show_boot_error(BOOTSTAGE_ID_IDE_READ); return 1; } - show_boot_progress(51); + show_boot_progress(BOOTSTAGE_ID_IDE_READ);
#if defined(CONFIG_FIT) /* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format((void *) addr) == IMAGE_FORMAT_FIT) { if (!fit_check_format(fit_hdr)) { - show_boot_error(140); + show_boot_error(BOOTSTAGE_ID_IDE_FIT_READ); puts("** Bad FIT image format\n"); return 1; } - show_boot_progress(141); + show_boot_progress(BOOTSTAGE_ID_IDE_FIT_READ_OK); fit_print_contents(fit_hdr); } #endif diff --git a/include/bootstage.h b/include/bootstage.h index a828f5c..fec3c3c 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -91,6 +91,20 @@ enum bootstage_id { BOOTSTAGE_ID_BOARD_DONE, /* Board init done, off to main loop */ /* ^^^ here ends the x86 sequence */
+ /* Boot stages related to loading a kernel from an IDE device */ + BOOTSTAGE_ID_IDE_START = 41, + BOOTSTAGE_ID_IDE_ADDR, + BOOTSTAGE_ID_IDE_BOOT_DEVICE, + BOOTSTAGE_ID_IDE_TYPE, + + BOOTSTAGE_ID_IDE_PART, + BOOTSTAGE_ID_IDE_PART_INFO, + BOOTSTAGE_ID_IDE_PART_TYPE, + BOOTSTAGE_ID_IDE_PART_READ, + BOOTSTAGE_ID_IDE_FORMAT, + + BOOTSTAGE_ID_IDE_CHECKSUM, /* 50 */ + BOOTSTAGE_ID_IDE_READ, };
/*

Dear Simon Glass,
In message 1326590698-7767-8-git-send-email-sjg@chromium.org you wrote:
This changes over the IDE progress numbers to use enums from bootstage.h.
Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_ide.c | 46 +++++++++++++++++++++++----------------------- include/bootstage.h | 14 ++++++++++++++ 2 files changed, 37 insertions(+), 23 deletions(-)
Applied, after fixing some more merge conflicts. thanks.
Best regards,
Wolfgang Denk

This changes over the NAND progress numbers to use enums from bootstage.h.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/cmd_nand.c | 34 +++++++++++++++++----------------- include/bootstage.h | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/common/cmd_nand.c b/common/cmd_nand.c index e294b3e..1cfa247 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -787,7 +787,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, if (s != NULL && (strcmp(s, ".jffs2") && strcmp(s, ".e") && strcmp(s, ".i"))) { printf("Unknown nand load suffix '%s'\n", s); - show_boot_error(53); + show_boot_error(BOOTSTAGE_ID_NAND_SUFFIX); return 1; }
@@ -797,16 +797,16 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr); if (r) { puts("** Read error\n"); - show_boot_error(56); + show_boot_error(BOOTSTAGE_ID_NAND_HDR_READ); return 1; } - show_boot_progress (56); + show_boot_progress(BOOTSTAGE_ID_NAND_HDR_READ);
switch (genimg_get_format ((void *)addr)) { case IMAGE_FORMAT_LEGACY: hdr = (image_header_t *)addr;
- show_boot_progress (57); + show_boot_progress(BOOTSTAGE_ID_NAND_TYPE); image_print_contents (hdr);
cnt = image_get_image_size (hdr); @@ -820,29 +820,29 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, break; #endif default: - show_boot_error(57); + show_boot_error(BOOTSTAGE_ID_NAND_TYPE); puts ("** Unknown image type\n"); return 1; } - show_boot_progress (57); + show_boot_progress(BOOTSTAGE_ID_NAND_TYPE);
r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr); if (r) { puts("** Read error\n"); - show_boot_error(58); + show_boot_error(BOOTSTAGE_ID_NAND_READ); return 1; } - show_boot_progress (58); + show_boot_progress(BOOTSTAGE_ID_NAND_READ);
#if defined(CONFIG_FIT) /* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) { if (!fit_check_format (fit_hdr)) { - show_boot_error(150); + show_boot_error(BOOTSTAGE_ID_NAND_FIT_READ); puts ("** Bad FIT image format\n"); return 1; } - show_boot_progress (151); + show_boot_progress(BOOTSTAGE_ID_NAND_FIT_READ_OK); fit_print_contents (fit_hdr); } #endif @@ -884,7 +884,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } #endif
- show_boot_progress(52); + show_boot_progress(BOOTSTAGE_ID_NAND_PART); switch (argc) { case 1: addr = CONFIG_SYS_LOAD_ADDR; @@ -907,26 +907,26 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_MTDPARTS) usage: #endif - show_boot_error(53); + show_boot_error(BOOTSTAGE_ID_NAND_SUFFIX); return cmd_usage(cmdtp); }
- show_boot_progress(53); + show_boot_progress(BOOTSTAGE_ID_NAND_SUFFIX); if (!boot_device) { puts("\n** No boot device **\n"); - show_boot_error(54); + show_boot_error(BOOTSTAGE_ID_NAND_BOOT_DEVICE); return 1; } - show_boot_progress(54); + show_boot_progress(BOOTSTAGE_ID_NAND_BOOT_DEVICE);
idx = simple_strtoul(boot_device, NULL, 16);
if (idx < 0 || idx >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[idx].name) { printf("\n** Device %d not available\n", idx); - show_boot_error(55); + show_boot_error(BOOTSTAGE_ID_NAND_AVAILABLE); return 1; } - show_boot_progress(55); + show_boot_progress(BOOTSTAGE_ID_NAND_AVAILABLE);
return nand_load_image(cmdtp, &nand_info[idx], offset, addr, argv[0]); } diff --git a/include/bootstage.h b/include/bootstage.h index fec3c3c..d58c46b 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -105,6 +105,21 @@ enum bootstage_id {
BOOTSTAGE_ID_IDE_CHECKSUM, /* 50 */ BOOTSTAGE_ID_IDE_READ, + + /* Boot stages related to loading a kernel from an NAND device */ + BOOTSTAGE_ID_NAND_PART, + BOOTSTAGE_ID_NAND_SUFFIX, + BOOTSTAGE_ID_NAND_BOOT_DEVICE, + BOOTSTAGE_ID_NAND_HDR_READ = 55, + BOOTSTAGE_ID_NAND_AVAILABLE = 55, + BOOTSTAGE_ID_NAND_TYPE = 57, + BOOTSTAGE_ID_NAND_READ, + + BOOTSTAGE_ID_IDE_FIT_READ = 140, + BOOTSTAGE_ID_IDE_FIT_READ_OK, + + BOOTSTAGE_ID_NAND_FIT_READ = 150, + BOOTSTAGE_ID_NAND_FIT_READ_OK, };
/*

Dear Simon Glass,
In message 1326590698-7767-9-git-send-email-sjg@chromium.org you wrote:
This changes over the NAND progress numbers to use enums from bootstage.h.
Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_nand.c | 34 +++++++++++++++++----------------- include/bootstage.h | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 17 deletions(-)
Applied (with merge conflicts fixed), thanks.
Best regards,
Wolfgang Denk

This changes over the network-related progress numbers to use enums from bootstage.h.
Signed-off-by: Simon Glass sjg@chromium.org ---
board/Seagate/dockstar/dockstar.c | 2 +- board/matrix_vision/mvbc_p/mvbc_p.c | 2 +- board/pcs440ep/pcs440ep.c | 24 ++++++++++++------------ common/cmd_net.c | 16 ++++++++-------- common/env_common.c | 2 +- include/bootstage.h | 11 +++++++++++ net/eth.c | 6 +++--- 7 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/board/Seagate/dockstar/dockstar.c b/board/Seagate/dockstar/dockstar.c index 8cbfb02..38473e5 100644 --- a/board/Seagate/dockstar/dockstar.c +++ b/board/Seagate/dockstar/dockstar.c @@ -172,7 +172,7 @@ void show_boot_progress(int val) case BOOTSTAGE_ID_RUN_OS: /* booting Linux */ set_leds(BOTH_LEDS, NEITHER_LED); break; - case 64: /* Ethernet initialization */ + case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */ set_leds(GREEN_LED, GREEN_LED); break; default: diff --git a/board/matrix_vision/mvbc_p/mvbc_p.c b/board/matrix_vision/mvbc_p/mvbc_p.c index 7e06d6c..4b48a3c 100644 --- a/board/matrix_vision/mvbc_p/mvbc_p.c +++ b/board/matrix_vision/mvbc_p/mvbc_p.c @@ -244,7 +244,7 @@ void show_boot_progress(int val) case BOOTSTAGE_ID_START: /* FPGA ok */ setbits_be32(&gpio->simple_dvo, LED_G0); break; - case 65: + case BOOTSTAGE_ID_NET_ETH_INIT: setbits_be32(&gpio->simple_dvo, LED_G1); break; case BOOTSTAGE_ID_COPY_RAMDISK: diff --git a/board/pcs440ep/pcs440ep.c b/board/pcs440ep/pcs440ep.c index f67eedd..746a54c 100644 --- a/board/pcs440ep/pcs440ep.c +++ b/board/pcs440ep/pcs440ep.c @@ -117,19 +117,19 @@ void show_boot_progress (int val) status_led_set(2, STATUS_LED_ON); break; #if 0 - case 64: - /* starting Ethernet configuration */ - status_led_set (0, STATUS_LED_OFF); - status_led_set (1, STATUS_LED_OFF); - status_led_set (2, STATUS_LED_ON); - break; + case BOOTSTAGE_ID_NET_ETH_START: + /* starting Ethernet configuration */ + status_led_set(0, STATUS_LED_OFF); + status_led_set(1, STATUS_LED_OFF); + status_led_set(2, STATUS_LED_ON); + break; #endif - case 80: - /* loading Image */ - status_led_set (0, STATUS_LED_ON); - status_led_set (1, STATUS_LED_OFF); - status_led_set (2, STATUS_LED_ON); - break; + case BOOTSTAGE_ID_NET_START: + /* loading Image */ + status_led_set(0, STATUS_LED_ON); + status_led_set(1, STATUS_LED_OFF); + status_led_set(2, STATUS_LED_ON); + break; } } #endif diff --git a/common/cmd_net.c b/common/cmd_net.c index efaddf5..ea3df8f 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -230,36 +230,36 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc, break; #endif default: - show_boot_error(80); + show_boot_error(BOOTSTAGE_ID_NET_START); return cmd_usage(cmdtp); }
- show_boot_progress (80); + show_boot_progress(BOOTSTAGE_ID_NET_START); if ((size = NetLoop(proto)) < 0) { - show_boot_error(81); + show_boot_error(BOOTSTAGE_ID_NET_NETLOOP_OK); return 1; }
- show_boot_progress (81); + show_boot_progress(BOOTSTAGE_ID_NET_NETLOOP_OK); /* NetLoop ok, update environment */ netboot_update_env();
/* done if no file was loaded (no errors though) */ if (size == 0) { - show_boot_error(82); + show_boot_error(BOOTSTAGE_ID_NET_LOADED); return 0; }
/* flush cache */ flush_cache(load_addr, size);
- show_boot_progress(82); + show_boot_progress(BOOTSTAGE_ID_NET_LOADED); rcode = bootm_maybe_autostart(cmdtp, argv[0]);
if (rcode < 0) - show_boot_error(83); + show_boot_error(BOOTSTAGE_ID_NET_DONE_ERR); else - show_boot_progress (84); + show_boot_progress(BOOTSTAGE_ID_NET_DONE); return rcode; }
diff --git a/common/env_common.c b/common/env_common.c index 49b55f1..41e2f26 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -228,7 +228,7 @@ void env_relocate(void) #if defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */ set_default_env(NULL); #else - show_boot_error(60); + show_boot_error(BOOTSTAGE_ID_NET_CHECKSUM); set_default_env("!bad CRC"); #endif } else { diff --git a/include/bootstage.h b/include/bootstage.h index d58c46b..35e11b8 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -115,6 +115,17 @@ enum bootstage_id { BOOTSTAGE_ID_NAND_TYPE = 57, BOOTSTAGE_ID_NAND_READ,
+ /* Boot stages related to loading a kernel from an network device */ + BOOTSTAGE_ID_NET_CHECKSUM = 60, + BOOTSTAGE_ID_NET_ETH_START = 64, + BOOTSTAGE_ID_NET_ETH_INIT, + + BOOTSTAGE_ID_NET_START = 80, + BOOTSTAGE_ID_NET_NETLOOP_OK, + BOOTSTAGE_ID_NET_LOADED, + BOOTSTAGE_ID_NET_DONE_ERR, + BOOTSTAGE_ID_NET_DONE, + BOOTSTAGE_ID_IDE_FIT_READ = 140, BOOTSTAGE_ID_IDE_FIT_READ_OK,
diff --git a/net/eth.c b/net/eth.c index b55f327..8fc84bc 100644 --- a/net/eth.c +++ b/net/eth.c @@ -230,7 +230,7 @@ int eth_initialize(bd_t *bis) eth_devices = NULL; eth_current = NULL;
- show_boot_progress (64); + show_boot_progress(BOOTSTAGE_ID_NET_ETH_START); #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) miiphy_init(); #endif @@ -260,12 +260,12 @@ int eth_initialize(bd_t *bis) #endif if (!eth_devices) { puts ("No ethernet found.\n"); - show_boot_error(64); + show_boot_error(BOOTSTAGE_ID_NET_ETH_START); } else { struct eth_device *dev = eth_devices; char *ethprime = getenv ("ethprime");
- show_boot_progress (65); + show_boot_progress(BOOTSTAGE_ID_NET_ETH_INIT); do { if (dev->index) puts (", ");

Dear Simon Glass,
In message 1326590698-7767-10-git-send-email-sjg@chromium.org you wrote:
This changes over the network-related progress numbers to use enums from bootstage.h.
Signed-off-by: Simon Glass sjg@chromium.org
board/Seagate/dockstar/dockstar.c | 2 +- board/matrix_vision/mvbc_p/mvbc_p.c | 2 +- board/pcs440ep/pcs440ep.c | 24 ++++++++++++------------ common/cmd_net.c | 16 ++++++++-------- common/env_common.c | 2 +- include/bootstage.h | 11 +++++++++++ net/eth.c | 6 +++--- 7 files changed, 37 insertions(+), 26 deletions(-)
Applied (with fixes), thanks.
Best regards,
Wolfgang Denk

This changes over all the FIT image progress numbers to use enums from bootstage.h.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/cmd_bootm.c | 44 ++++++++++++++++++++++---------------------- common/image.c | 36 ++++++++++++++++++++---------------- include/bootstage.h | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 38 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 9ab1c61..44a9ded 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -222,21 +222,21 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] if (fit_image_get_type(images.fit_hdr_os, images.fit_noffset_os, &images.os.type)) { puts("Can't get image type!\n"); - show_boot_error(109); + show_boot_error(BOOTSTAGE_ID_FIT_TYPE); return 1; }
if (fit_image_get_comp(images.fit_hdr_os, images.fit_noffset_os, &images.os.comp)) { puts("Can't get image compression!\n"); - show_boot_error(110); + show_boot_error(BOOTSTAGE_ID_FIT_COMPRESSION); return 1; }
if (fit_image_get_os(images.fit_hdr_os, images.fit_noffset_os, &images.os.os)) { puts("Can't get image OS!\n"); - show_boot_error(111); + show_boot_error(BOOTSTAGE_ID_FIT_OS); return 1; }
@@ -245,7 +245,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] if (fit_image_get_load(images.fit_hdr_os, images.fit_noffset_os, &images.os.load)) { puts("Can't get image load address!\n"); - show_boot_error(112); + show_boot_error(BOOTSTAGE_ID_FIT_LOADADDR); return 1; } break; @@ -648,7 +648,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else { puts("ERROR: new format image overwritten - " "must RESET the board to recover\n"); - show_boot_error(113); + show_boot_error(BOOTSTAGE_ID_OVERWRITTEN); do_reset(cmdtp, flag, argc, argv); } } @@ -789,28 +789,28 @@ static int fit_check_kernel(const void *fit, int os_noffset, int verify) puts(" Verifying Hash Integrity ... "); if (!fit_image_check_hashes(fit, os_noffset)) { puts("Bad Data Hash\n"); - show_boot_error(104); + show_boot_error(BOOTSTAGE_ID_FIT_CHECK_HASH); return 0; } puts("OK\n"); } - show_boot_progress(105); + show_boot_progress(BOOTSTAGE_ID_FIT_CHECK_ARCH);
if (!fit_image_check_target_arch(fit, os_noffset)) { puts("Unsupported Architecture\n"); - show_boot_error(105); + show_boot_error(BOOTSTAGE_ID_FIT_CHECK_ARCH); return 0; }
- show_boot_progress(106); + show_boot_progress(BOOTSTAGE_ID_FIT_CHECK_KERNEL); if (!fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL) && !fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL_NOLOAD)) { puts("Not a kernel image\n"); - show_boot_error(106); + show_boot_error(BOOTSTAGE_ID_FIT_CHECK_KERNEL); return 0; }
- show_boot_progress(107); + show_boot_progress(BOOTSTAGE_ID_FIT_CHECKED); return 1; } #endif /* CONFIG_FIT */ @@ -921,10 +921,10 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
if (!fit_check_format(fit_hdr)) { puts("Bad FIT kernel image format!\n"); - show_boot_error(100); + show_boot_error(BOOTSTAGE_ID_FIT_FORMAT); return NULL; } - show_boot_progress(100); + show_boot_progress(BOOTSTAGE_ID_FIT_FORMAT);
if (!fit_uname_kernel) { /* @@ -933,11 +933,11 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, * fit_conf_get_node() will try to find default config * node */ - show_boot_progress(101); + show_boot_progress(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); cfg_noffset = fit_conf_get_node(fit_hdr, fit_uname_config); if (cfg_noffset < 0) { - show_boot_error(101); + show_boot_error(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); return NULL; } /* save configuration uname provided in the first @@ -948,7 +948,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, NULL); printf(" Using '%s' configuration\n", images->fit_uname_cfg); - show_boot_progress(103); + show_boot_progress(BOOTSTAGE_ID_FIT_CONFIG);
os_noffset = fit_conf_get_kernel_node(fit_hdr, cfg_noffset); @@ -956,28 +956,28 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, NULL); } else { /* get kernel component image node offset */ - show_boot_progress(102); + show_boot_progress(BOOTSTAGE_ID_FIT_UNIT_NAME); os_noffset = fit_image_get_node(fit_hdr, fit_uname_kernel); } if (os_noffset < 0) { - show_boot_error(103); + show_boot_error(BOOTSTAGE_ID_FIT_CONFIG); return NULL; }
printf(" Trying '%s' kernel subimage\n", fit_uname_kernel);
- show_boot_progress(104); + show_boot_progress(BOOTSTAGE_ID_FIT_CHECK_SUBIMAGE); if (!fit_check_kernel(fit_hdr, os_noffset, images->verify)) return NULL;
/* get kernel image data address and length */ if (fit_image_get_data(fit_hdr, os_noffset, &data, &len)) { puts("Could not find kernel subimage data!\n"); - show_boot_error(107); + show_boot_error(BOOTSTAGE_ID_FIT_KERNEL_INFO_ERR); return NULL; } - show_boot_progress(108); + show_boot_progress(BOOTSTAGE_ID_FIT_KERNEL_INFO);
*os_len = len; *os_data = (ulong)data; @@ -988,7 +988,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, #endif default: printf("Wrong Image Format for %s command\n", cmdtp->name); - show_boot_error(108); + show_boot_error(BOOTSTAGE_ID_FIT_KERNEL_INFO); return NULL; }
diff --git a/common/image.c b/common/image.c index af228cc..8b097bf 100644 --- a/common/image.c +++ b/common/image.c @@ -912,13 +912,14 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, printf("## Loading init Ramdisk from FIT " "Image at %08lx ...\n", rd_addr);
- show_boot_progress(120); + show_boot_progress(BOOTSTAGE_ID_FIT_RD_FORMAT); if (!fit_check_format(fit_hdr)) { puts("Bad FIT ramdisk image format!\n"); - show_boot_error(120); + show_boot_error( + BOOTSTAGE_ID_FIT_RD_FORMAT); return 1; } - show_boot_progress(121); + show_boot_progress(BOOTSTAGE_ID_FIT_RD_FORMAT_OK);
if (!fit_uname_ramdisk) { /* @@ -926,13 +927,15 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, * node first. If config unit node name is NULL * fit_conf_get_node() will try to find default config node */ - show_boot_progress(122); + show_boot_progress( + BOOTSTAGE_ID_FIT_RD_NO_UNIT_NAME); cfg_noffset = fit_conf_get_node(fit_hdr, fit_uname_config); if (cfg_noffset < 0) { puts("Could not find configuration " "node\n"); - show_boot_error(122); + show_boot_error( + BOOTSTAGE_ID_FIT_RD_NO_UNIT_NAME); return 1; } fit_uname_config = fdt_get_name(fit_hdr, @@ -946,20 +949,21 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, rd_noffset, NULL); } else { /* get ramdisk component image node offset */ - show_boot_progress(123); + show_boot_progress( + BOOTSTAGE_ID_FIT_RD_UNIT_NAME); rd_noffset = fit_image_get_node(fit_hdr, fit_uname_ramdisk); } if (rd_noffset < 0) { puts("Could not find subimage node\n"); - show_boot_error(124); + show_boot_error(BOOTSTAGE_ID_FIT_RD_SUBNODE); return 1; }
printf(" Trying '%s' ramdisk subimage\n", fit_uname_ramdisk);
- show_boot_progress(125); + show_boot_progress(BOOTSTAGE_ID_FIT_RD_CHECK); if (!fit_check_ramdisk(fit_hdr, rd_noffset, arch, images->verify)) return 1; @@ -968,10 +972,10 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, if (fit_image_get_data(fit_hdr, rd_noffset, &data, &size)) { puts("Could not find ramdisk subimage data!\n"); - show_boot_error(127); + show_boot_error(BOOTSTAGE_ID_FIT_RD_GET_DATA); return 1; } - show_boot_progress(128); + show_boot_progress(BOOTSTAGE_ID_FIT_RD_GET_DATA_OK);
rd_data = (ulong)data; rd_len = size; @@ -979,10 +983,10 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, if (fit_image_get_load(fit_hdr, rd_noffset, &rd_load)) { puts("Can't get ramdisk subimage load " "address!\n"); - show_boot_error(129); + show_boot_error(BOOTSTAGE_ID_FIT_RD_LOAD); return 1; } - show_boot_progress(129); + show_boot_progress(BOOTSTAGE_ID_FIT_RD_LOAD);
images->fit_hdr_rd = fit_hdr; images->fit_uname_rd = fit_uname_ramdisk; @@ -3171,23 +3175,23 @@ static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch, puts(" Verifying Hash Integrity ... "); if (!fit_image_check_hashes(fit, rd_noffset)) { puts("Bad Data Hash\n"); - show_boot_error(125); + show_boot_error(BOOTSTAGE_ID_FIT_RD_HASH); return 0; } puts("OK\n"); }
- show_boot_progress(126); + show_boot_progress(BOOTSTAGE_ID_FIT_RD_CHECK_ALL); if (!fit_image_check_os(fit, rd_noffset, IH_OS_LINUX) || !fit_image_check_arch(fit, rd_noffset, arch) || !fit_image_check_type(fit, rd_noffset, IH_TYPE_RAMDISK)) { printf("No Linux %s Ramdisk Image\n", genimg_get_arch_name(arch)); - show_boot_error(126); + show_boot_error(BOOTSTAGE_ID_FIT_RD_CHECK_ALL); return 0; }
- show_boot_progress(127); + show_boot_progress(BOOTSTAGE_ID_FIT_RD_CHECK_ALL_OK); return 1; } #endif /* USE_HOSTCC */ diff --git a/include/bootstage.h b/include/bootstage.h index 35e11b8..8f7fcd7 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -126,6 +126,44 @@ enum bootstage_id { BOOTSTAGE_ID_NET_DONE_ERR, BOOTSTAGE_ID_NET_DONE,
+ /* + * Boot stages related to loading a FIT image. Some of these are a + * bit wonky. + */ + BOOTSTAGE_ID_FIT_FORMAT = 100, + BOOTSTAGE_ID_FIT_NO_UNIT_NAME, + BOOTSTAGE_ID_FIT_UNIT_NAME, + BOOTSTAGE_ID_FIT_CONFIG, + BOOTSTAGE_ID_FIT_CHECK_SUBIMAGE, + BOOTSTAGE_ID_FIT_CHECK_HASH = 104, + + BOOTSTAGE_ID_FIT_CHECK_ARCH, + BOOTSTAGE_ID_FIT_CHECK_KERNEL, + BOOTSTAGE_ID_FIT_CHECKED, + + BOOTSTAGE_ID_FIT_KERNEL_INFO_ERR = 107, + BOOTSTAGE_ID_FIT_KERNEL_INFO, + BOOTSTAGE_ID_FIT_TYPE, + + BOOTSTAGE_ID_FIT_COMPRESSION, + BOOTSTAGE_ID_FIT_OS, + BOOTSTAGE_ID_FIT_LOADADDR, + BOOTSTAGE_ID_OVERWRITTEN, + + BOOTSTAGE_ID_FIT_RD_FORMAT = 120, + BOOTSTAGE_ID_FIT_RD_FORMAT_OK, + BOOTSTAGE_ID_FIT_RD_NO_UNIT_NAME, + BOOTSTAGE_ID_FIT_RD_UNIT_NAME, + BOOTSTAGE_ID_FIT_RD_SUBNODE, + + BOOTSTAGE_ID_FIT_RD_CHECK, + BOOTSTAGE_ID_FIT_RD_HASH = 125, + BOOTSTAGE_ID_FIT_RD_CHECK_ALL, + BOOTSTAGE_ID_FIT_RD_GET_DATA, + BOOTSTAGE_ID_FIT_RD_CHECK_ALL_OK = 127, + BOOTSTAGE_ID_FIT_RD_GET_DATA_OK, + BOOTSTAGE_ID_FIT_RD_LOAD, + BOOTSTAGE_ID_IDE_FIT_READ = 140, BOOTSTAGE_ID_IDE_FIT_READ_OK,

Dear Simon Glass,
In message 1326590698-7767-11-git-send-email-sjg@chromium.org you wrote:
This changes over all the FIT image progress numbers to use enums from bootstage.h.
Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_bootm.c | 44 ++++++++++++++++++++++---------------------- common/image.c | 36 ++++++++++++++++++++---------------- include/bootstage.h | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 38 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Define timer_get_boot_us() which returns the number of microseconds since boot. If undefined then we use get_timer() * 1000.
We can fit this in a 32-bit register which keeps everyone happy on the efficiency side. It will wrap around after about an hour. If we are still looking at it after an hour then we had better not be timing the boot.
There is some scope to join bootstage and post, but for now they are separate things with separate CONFIGs, and you don't have to enable one to get the other.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v3: - Rename timer patch to remove bootstage: tag
include/common.h | 7 +++++++ lib/time.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/include/common.h b/include/common.h index ae38784..c23087a 100644 --- a/include/common.h +++ b/include/common.h @@ -207,6 +207,13 @@ typedef void (interrupt_handler_t)(void *); #endif /* CONFIG_SERIAL_MULTI */
/* + * Return the time since boot in microseconds, This is needed for bootstage + * and should be defined in CPU- or board-specific code. If undefined then + * millisecond resolution will be used (the standard get_timer()). + */ +ulong timer_get_boot_us(void); + +/* * General Purpose Utilities */ #define min(X, Y) \ diff --git a/lib/time.c b/lib/time.c index 6e2937b..69edc3d 100644 --- a/lib/time.c +++ b/lib/time.c @@ -47,3 +47,20 @@ void mdelay(unsigned long msec) while (msec--) udelay(1000); } + +ulong __timer_get_boot_us(void) +{ + static ulong base_time; + + /* + * We can't implement this properly. Return 0 on the first call and + * larger values after that. + */ + if (base_time) + return get_timer(base_time) * 1000; + base_time = get_timer(0); + return 0; +} + +ulong timer_get_boot_us(void) + __attribute__((weak, alias("__timer_get_boot_us")));

Dear Simon Glass,
In message 1326590698-7767-12-git-send-email-sjg@chromium.org you wrote:
Define timer_get_boot_us() which returns the number of microseconds since boot. If undefined then we use get_timer() * 1000.
We can fit this in a 32-bit register which keeps everyone happy on the efficiency side. It will wrap around after about an hour. If we are still looking at it after an hour then we had better not be timing the boot.
There is some scope to join bootstage and post, but for now they are separate things with separate CONFIGs, and you don't have to enable one to get the other.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v3:
- Rename timer patch to remove bootstage: tag
include/common.h | 7 +++++++ lib/time.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

These calls should not be made directly any more, since bootstage will call the show_boot_...() functions as needed.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/arm/lib/bootm.c | 2 +- arch/avr32/lib/bootm.c | 2 +- arch/m68k/lib/bootm.c | 2 +- arch/microblaze/lib/bootm.c | 2 +- arch/mips/lib/bootm.c | 2 +- arch/mips/lib/bootm_qemu_mips.c | 2 +- arch/nds32/lib/bootm.c | 2 +- arch/powerpc/lib/board.c | 2 +- arch/powerpc/lib/bootm.c | 2 +- arch/sparc/lib/board.c | 2 +- arch/x86/lib/board.c | 19 +++---- board/hermes/hermes.c | 2 +- board/matrix_vision/common/mv_common.c | 2 +- board/scb9328/scb9328.c | 6 -- common/cmd_bootm.c | 92 ++++++++++++++++---------------- common/cmd_ide.c | 46 ++++++++-------- common/cmd_nand.c | 34 ++++++------ common/cmd_net.c | 16 +++--- common/env_common.c | 2 +- common/image.c | 52 +++++++++--------- net/eth.c | 6 +- post/post.c | 4 +- 22 files changed, 147 insertions(+), 154 deletions(-)
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 249ac1b..f114cd6 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -113,7 +113,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) printf ("Using machid 0x%x from environment\n", machid); }
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
#ifdef CONFIG_OF_LIBFDT if (images->ft_len) diff --git a/arch/avr32/lib/bootm.c b/arch/avr32/lib/bootm.c index f180737..74ebeca 100644 --- a/arch/avr32/lib/bootm.c +++ b/arch/avr32/lib/bootm.c @@ -192,7 +192,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima
theKernel = (void *)images->ep;
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
params = params_start = (struct tag *)gd->bd->bi_boot_params; params = setup_start_tag(params); diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c index 233782b..d506d0c 100644 --- a/arch/m68k/lib/bootm.c +++ b/arch/m68k/lib/bootm.c @@ -104,7 +104,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel);
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
/* * Linux Kernel Parameters (passing board info data): diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c index 24b9e09..95cee50 100644 --- a/arch/microblaze/lib/bootm.c +++ b/arch/microblaze/lib/bootm.c @@ -59,7 +59,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima if (ret) return 1;
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
if (!of_flat_tree && argc > 3) of_flat_tree = (char *)simple_strtoul(argv[3], NULL, 16); diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 5b7e74f..9930abf 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -56,7 +56,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima /* find kernel entry point */ theKernel = (void (*)(int, char **, char **, int *))images->ep;
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
#ifdef DEBUG printf ("## Transferring control to Linux (at address %08lx) ...\n", diff --git a/arch/mips/lib/bootm_qemu_mips.c b/arch/mips/lib/bootm_qemu_mips.c index 47f5310..bb6442a 100644 --- a/arch/mips/lib/bootm_qemu_mips.c +++ b/arch/mips/lib/bootm_qemu_mips.c @@ -39,7 +39,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima /* find kernel entry point */ theKernel = (void (*)(int, char **, char **, int *))images->ep;
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); diff --git a/arch/nds32/lib/bootm.c b/arch/nds32/lib/bootm.c index 5ae90fb..03f58bf 100644 --- a/arch/nds32/lib/bootm.c +++ b/arch/nds32/lib/bootm.c @@ -69,7 +69,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) printf("Using machid 0x%x from environment\n", machid); }
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong)theKernel); diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index 837c82d..fc63b2c 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -1065,7 +1065,7 @@ void board_init_r(gd_t *id, ulong dest_addr) void hang(void) { puts("### ERROR ### Please RESET the board ###\n"); - show_boot_error(BOOTSTAGE_ID_NEED_RESET); + bootstage_error(BOOTSTAGE_ID_NEED_RESET); for (;;) ; } diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c index 37f162a..53dc4df 100644 --- a/arch/powerpc/lib/bootm.c +++ b/arch/powerpc/lib/bootm.c @@ -69,7 +69,7 @@ static void boot_jump_linux(bootm_headers_t *images) debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong)kernel);
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
#if defined(CONFIG_SYS_INIT_RAM_LOCK) && !defined(CONFIG_E500) unlock_ram_in_cache(); diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c index 770136b..c0d2608 100644 --- a/arch/sparc/lib/board.c +++ b/arch/sparc/lib/board.c @@ -426,7 +426,7 @@ void hang(void) { puts("### ERROR ### Please RESET the board ###\n"); #ifdef CONFIG_SHOW_BOOT_PROGRESS - show_boot_error(BOOTSTAGE_ID_NEED_RESET); + bootstage_error(BOOTSTAGE_ID_NEED_RESET); #endif for (;;) ; } diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 1f677cc..4c117a3 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -280,7 +280,7 @@ void board_init_r(gd_t *id, ulong dest_addr) static gd_t gd_data; init_fnc_t **init_fnc_ptr;
- show_boot_progress(BOOTSTAGE_ID_BOARD_INIT_R); + bootstage_mark(BOOTSTAGE_ID_BOARD_INIT_R);
/* Global data pointer is now writable */ gd = &gd_data; @@ -291,7 +291,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
gd->bd = &bd_data; memset(gd->bd, 0, sizeof(bd_t)); - show_boot_progress(BOOTSTAGE_ID_BOARD_GLOBAL_DATA); + bootstage_mark(BOOTSTAGE_ID_BOARD_GLOBAL_DATA);
gd->baudrate = CONFIG_BAUDRATE;
@@ -302,7 +302,7 @@ void board_init_r(gd_t *id, ulong dest_addr) if ((*init_fnc_ptr)() != 0) hang(); } - show_boot_progress(BOOTSTAGE_ID_BOARD_INIT_SEQ); + bootstage_mark(BOOTSTAGE_ID_BOARD_INIT_SEQ);
#ifdef CONFIG_SERIAL_MULTI serial_initialize(); @@ -312,15 +312,14 @@ void board_init_r(gd_t *id, ulong dest_addr) /* configure available FLASH banks */ size = flash_init(); display_flash_config(size); - show_boot_progress(BOOTSTAGE_ID_BOARD_FLASH); + bootstage_mark(BOOTSTAGE_ID_BOARD_FLASH); #endif
- show_boot_progress(BOOTSTAGE_ID_BOARD_FLASH_37); + bootstage_mark(BOOTSTAGE_ID_BOARD_FLASH_37);
/* initialize environment */ env_relocate(); - show_boot_progress(BOOTSTAGE_ID_BOARD_ENV); - + bootstage_mark(BOOTSTAGE_ID_BOARD_ENV);
#ifdef CONFIG_CMD_NET /* IP Address */ @@ -334,7 +333,7 @@ void board_init_r(gd_t *id, ulong dest_addr) pci_init(); #endif
- show_boot_progress(BOOTSTAGE_ID_BOARD_PCI); + bootstage_mark(BOOTSTAGE_ID_BOARD_PCI);
stdio_init(); @@ -363,7 +362,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* enable exceptions */ enable_interrupts(); - show_boot_progress(BOOTSTAGE_ID_BOARD_INTERRUPTS); + bootstage_mark(BOOTSTAGE_ID_BOARD_INTERRUPTS);
#ifdef CONFIG_STATUS_LED status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); @@ -432,7 +431,7 @@ void board_init_r(gd_t *id, ulong dest_addr) post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif
- show_boot_progress(BOOTSTAGE_ID_BOARD_DONE); + bootstage_mark(BOOTSTAGE_ID_BOARD_DONE);
/* main_loop() can return to retry autoboot, if so just run it again. */ for (;;) diff --git a/board/hermes/hermes.c b/board/hermes/hermes.c index 38bab03..a3bf4bb 100644 --- a/board/hermes/hermes.c +++ b/board/hermes/hermes.c @@ -27,7 +27,7 @@
#ifdef CONFIG_SHOW_BOOT_PROGRESS # include <status_led.h> -# define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg) +# define SHOW_BOOT_PROGRESS(arg) bootstage_mark(arg) #else # define SHOW_BOOT_PROGRESS(arg) #endif diff --git a/board/matrix_vision/common/mv_common.c b/board/matrix_vision/common/mv_common.c index 7fde4ac..b9330f9 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(BOOTSTAGE_ID_START); + bootstage_mark(BOOTSTAGE_ID_START);
return result; } diff --git a/board/scb9328/scb9328.c b/board/scb9328/scb9328.c index 076c046..1ec2044 100644 --- a/board/scb9328/scb9328.c +++ b/board/scb9328/scb9328.c @@ -23,12 +23,6 @@
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_SHOW_BOOT_PROGRESS -# define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg) -#else -# define SHOW_BOOT_PROGRESS(arg) -#endif - int board_init (void) { gd->bd->bi_arch_number = MACH_TYPE_SCB9328; diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 44a9ded..7e780fb 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -222,21 +222,21 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] if (fit_image_get_type(images.fit_hdr_os, images.fit_noffset_os, &images.os.type)) { puts("Can't get image type!\n"); - show_boot_error(BOOTSTAGE_ID_FIT_TYPE); + bootstage_error(BOOTSTAGE_ID_FIT_TYPE); return 1; }
if (fit_image_get_comp(images.fit_hdr_os, images.fit_noffset_os, &images.os.comp)) { puts("Can't get image compression!\n"); - show_boot_error(BOOTSTAGE_ID_FIT_COMPRESSION); + bootstage_error(BOOTSTAGE_ID_FIT_COMPRESSION); return 1; }
if (fit_image_get_os(images.fit_hdr_os, images.fit_noffset_os, &images.os.os)) { puts("Can't get image OS!\n"); - show_boot_error(BOOTSTAGE_ID_FIT_OS); + bootstage_error(BOOTSTAGE_ID_FIT_OS); return 1; }
@@ -245,7 +245,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] if (fit_image_get_load(images.fit_hdr_os, images.fit_noffset_os, &images.os.load)) { puts("Can't get image load address!\n"); - show_boot_error(BOOTSTAGE_ID_FIT_LOADADDR); + bootstage_error(BOOTSTAGE_ID_FIT_LOADADDR); return 1; } break; @@ -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(BOOTSTAGE_ID_DECOMP_IMAGE); + bootstage_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(BOOTSTAGE_ID_DECOMP_IMAGE); + bootstage_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(BOOTSTAGE_ID_DECOMP_IMAGE); + bootstage_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(BOOTSTAGE_ID_DECOMP_IMAGE); + bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE); return BOOTM_ERR_RESET; }
@@ -423,7 +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); - show_boot_progress(BOOTSTAGE_ID_KERNEL_LOADED); + bootstage_mark(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", @@ -648,14 +648,14 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else { puts("ERROR: new format image overwritten - " "must RESET the board to recover\n"); - show_boot_error(BOOTSTAGE_ID_OVERWRITTEN); + bootstage_error(BOOTSTAGE_ID_OVERWRITTEN); do_reset(cmdtp, flag, argc, argv); } } if (ret == BOOTM_ERR_UNIMPLEMENTED) { if (iflag) enable_interrupts(); - show_boot_error(BOOTSTAGE_ID_DECOMP_UNIMPL); + bootstage_error(BOOTSTAGE_ID_DECOMP_UNIMPL); return 1; } } @@ -670,7 +670,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; }
- show_boot_progress(BOOTSTAGE_ID_CHECK_BOOT_OS); + bootstage_mark(BOOTSTAGE_ID_CHECK_BOOT_OS);
#ifdef CONFIG_SILENT_CONSOLE if (images.os.os == IH_OS_LINUX) @@ -684,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(BOOTSTAGE_ID_CHECK_BOOT_OS); + bootstage_error(BOOTSTAGE_ID_CHECK_BOOT_OS); return 1; }
@@ -692,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(BOOTSTAGE_ID_BOOT_OS_RETURNED); + bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED); #ifdef DEBUG puts("\n## Control returned to monitor - resetting...\n"); #endif @@ -734,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(BOOTSTAGE_ID_CHECK_MAGIC); + bootstage_error(BOOTSTAGE_ID_CHECK_MAGIC); return NULL; } - show_boot_progress(BOOTSTAGE_ID_CHECK_HEADER); + bootstage_mark(BOOTSTAGE_ID_CHECK_HEADER);
if (!image_check_hcrc(hdr)) { puts("Bad Header Checksum\n"); - show_boot_error(BOOTSTAGE_ID_CHECK_HEADER); + bootstage_error(BOOTSTAGE_ID_CHECK_HEADER); return NULL; }
- show_boot_progress(BOOTSTAGE_ID_CHECK_CHECKSUM); + bootstage_mark(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(BOOTSTAGE_ID_CHECK_CHECKSUM); + bootstage_error(BOOTSTAGE_ID_CHECK_CHECKSUM); return NULL; } puts("OK\n"); } - show_boot_progress(BOOTSTAGE_ID_CHECK_ARCH); + bootstage_mark(BOOTSTAGE_ID_CHECK_ARCH);
if (!image_check_target_arch(hdr)) { printf("Unsupported Architecture 0x%x\n", image_get_arch(hdr)); - show_boot_error(BOOTSTAGE_ID_CHECK_ARCH); + bootstage_error(BOOTSTAGE_ID_CHECK_ARCH); return NULL; } return hdr; @@ -789,28 +789,28 @@ static int fit_check_kernel(const void *fit, int os_noffset, int verify) puts(" Verifying Hash Integrity ... "); if (!fit_image_check_hashes(fit, os_noffset)) { puts("Bad Data Hash\n"); - show_boot_error(BOOTSTAGE_ID_FIT_CHECK_HASH); + bootstage_error(BOOTSTAGE_ID_FIT_CHECK_HASH); return 0; } puts("OK\n"); } - show_boot_progress(BOOTSTAGE_ID_FIT_CHECK_ARCH); + bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_ARCH);
if (!fit_image_check_target_arch(fit, os_noffset)) { puts("Unsupported Architecture\n"); - show_boot_error(BOOTSTAGE_ID_FIT_CHECK_ARCH); + bootstage_error(BOOTSTAGE_ID_FIT_CHECK_ARCH); return 0; }
- show_boot_progress(BOOTSTAGE_ID_FIT_CHECK_KERNEL); + bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_KERNEL); if (!fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL) && !fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL_NOLOAD)) { puts("Not a kernel image\n"); - show_boot_error(BOOTSTAGE_ID_FIT_CHECK_KERNEL); + bootstage_error(BOOTSTAGE_ID_FIT_CHECK_KERNEL); return 0; }
- show_boot_progress(BOOTSTAGE_ID_FIT_CHECKED); + bootstage_mark(BOOTSTAGE_ID_FIT_CHECKED); return 1; } #endif /* CONFIG_FIT */ @@ -863,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(BOOTSTAGE_ID_CHECK_MAGIC); + bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC);
/* copy from dataflash if needed */ img_addr = genimg_get_image(img_addr); @@ -877,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(BOOTSTAGE_ID_CHECK_IMAGETYPE); + bootstage_mark(BOOTSTAGE_ID_CHECK_IMAGETYPE);
/* get os_data and os_len */ switch (image_get_type(hdr)) { @@ -896,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(BOOTSTAGE_ID_CHECK_IMAGETYPE); + bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE); return NULL; }
@@ -911,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(BOOTSTAGE_ID_DECOMP_IMAGE); + bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE); break; #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: @@ -921,10 +921,10 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
if (!fit_check_format(fit_hdr)) { puts("Bad FIT kernel image format!\n"); - show_boot_error(BOOTSTAGE_ID_FIT_FORMAT); + bootstage_error(BOOTSTAGE_ID_FIT_FORMAT); return NULL; } - show_boot_progress(BOOTSTAGE_ID_FIT_FORMAT); + bootstage_mark(BOOTSTAGE_ID_FIT_FORMAT);
if (!fit_uname_kernel) { /* @@ -933,11 +933,11 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, * fit_conf_get_node() will try to find default config * node */ - show_boot_progress(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); + bootstage_mark(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); cfg_noffset = fit_conf_get_node(fit_hdr, fit_uname_config); if (cfg_noffset < 0) { - show_boot_error(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); + bootstage_error(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); return NULL; } /* save configuration uname provided in the first @@ -948,7 +948,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, NULL); printf(" Using '%s' configuration\n", images->fit_uname_cfg); - show_boot_progress(BOOTSTAGE_ID_FIT_CONFIG); + bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG);
os_noffset = fit_conf_get_kernel_node(fit_hdr, cfg_noffset); @@ -956,28 +956,28 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, NULL); } else { /* get kernel component image node offset */ - show_boot_progress(BOOTSTAGE_ID_FIT_UNIT_NAME); + bootstage_mark(BOOTSTAGE_ID_FIT_UNIT_NAME); os_noffset = fit_image_get_node(fit_hdr, fit_uname_kernel); } if (os_noffset < 0) { - show_boot_error(BOOTSTAGE_ID_FIT_CONFIG); + bootstage_error(BOOTSTAGE_ID_FIT_CONFIG); return NULL; }
printf(" Trying '%s' kernel subimage\n", fit_uname_kernel);
- show_boot_progress(BOOTSTAGE_ID_FIT_CHECK_SUBIMAGE); + bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_SUBIMAGE); if (!fit_check_kernel(fit_hdr, os_noffset, images->verify)) return NULL;
/* get kernel image data address and length */ if (fit_image_get_data(fit_hdr, os_noffset, &data, &len)) { puts("Could not find kernel subimage data!\n"); - show_boot_error(BOOTSTAGE_ID_FIT_KERNEL_INFO_ERR); + bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO_ERR); return NULL; } - show_boot_progress(BOOTSTAGE_ID_FIT_KERNEL_INFO); + bootstage_mark(BOOTSTAGE_ID_FIT_KERNEL_INFO);
*os_len = len; *os_data = (ulong)data; @@ -988,7 +988,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, #endif default: printf("Wrong Image Format for %s command\n", cmdtp->name); - show_boot_error(BOOTSTAGE_ID_FIT_KERNEL_INFO); + bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO); return NULL; }
@@ -1339,7 +1339,7 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[], "(at address %08lx) ...\n", (ulong)loader);
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
/* * NetBSD Stage-2 Loader Parameters: @@ -1397,7 +1397,7 @@ static int do_bootm_rtems(int flag, int argc, char * const argv[], printf("## Transferring control to RTEMS (at address %08lx) ...\n", (ulong)entry_point);
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
/* * RTEMS Parameters: @@ -1430,7 +1430,7 @@ static int do_bootm_ose(int flag, int argc, char * const argv[], printf("## Transferring control to OSE (at address %08lx) ...\n", (ulong)entry_point);
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
/* * OSE Parameters: @@ -1511,7 +1511,7 @@ static int do_bootm_integrity(int flag, int argc, char * const argv[], printf("## Transferring control to INTEGRITY (at address %08lx) ...\n", (ulong)entry_point);
- show_boot_progress(BOOTSTAGE_ID_RUN_OS); + bootstage_mark(BOOTSTAGE_ID_RUN_OS);
/* * INTEGRITY Parameters: diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 46fa7d4..b1aa50f 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -345,7 +345,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) const void *fit_hdr = NULL; #endif
- show_boot_progress(BOOTSTAGE_ID_IDE_START); + bootstage_mark(BOOTSTAGE_ID_IDE_START); switch (argc) { case 1: addr = CONFIG_SYS_LOAD_ADDR; @@ -360,41 +360,41 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) boot_device = argv[2]; break; default: - show_boot_error(BOOTSTAGE_ID_IDE_ADDR); + bootstage_error(BOOTSTAGE_ID_IDE_ADDR); return cmd_usage(cmdtp); } - show_boot_progress(BOOTSTAGE_ID_IDE_ADDR); + bootstage_mark(BOOTSTAGE_ID_IDE_ADDR);
if (!boot_device) { puts("\n** No boot device **\n"); - show_boot_error(BOOTSTAGE_ID_IDE_BOOT_DEVICE); + bootstage_error(BOOTSTAGE_ID_IDE_BOOT_DEVICE); return 1; } - show_boot_progress(BOOTSTAGE_ID_IDE_BOOT_DEVICE); + bootstage_mark(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
dev = simple_strtoul(boot_device, &ep, 16);
if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN) { printf("\n** Device %d not available\n", dev); - show_boot_error(BOOTSTAGE_ID_IDE_TYPE); + bootstage_error(BOOTSTAGE_ID_IDE_TYPE); return 1; } - show_boot_progress(BOOTSTAGE_ID_IDE_TYPE); + bootstage_mark(BOOTSTAGE_ID_IDE_TYPE);
if (*ep) { if (*ep != ':') { puts("\n** Invalid boot device, use `dev[:part]' **\n"); - show_boot_error(BOOTSTAGE_ID_IDE_PART); + bootstage_error(BOOTSTAGE_ID_IDE_PART); return 1; } part = simple_strtoul(++ep, NULL, 16); } - show_boot_progress(BOOTSTAGE_ID_IDE_PART); + bootstage_mark(BOOTSTAGE_ID_IDE_PART); if (get_partition_info(&ide_dev_desc[dev], part, &info)) { - show_boot_error(BOOTSTAGE_ID_IDE_PART_INFO); + bootstage_error(BOOTSTAGE_ID_IDE_PART_INFO); return 1; } - show_boot_progress(BOOTSTAGE_ID_IDE_PART_INFO); + bootstage_mark(BOOTSTAGE_ID_IDE_PART_INFO); if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) && (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0) @@ -402,10 +402,10 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) printf("\n** Invalid partition type "%.32s"" " (expect "" BOOT_PART_TYPE "")\n", info.type); - show_boot_error(BOOTSTAGE_ID_IDE_PART_TYPE); + bootstage_error(BOOTSTAGE_ID_IDE_PART_TYPE); return 1; } - show_boot_progress(BOOTSTAGE_ID_IDE_PART_TYPE); + bootstage_mark(BOOTSTAGE_ID_IDE_PART_TYPE);
printf("\nLoading from IDE device %d, partition %d: " "Name: %.32s Type: %.32s\n", dev, part, info.name, info.type); @@ -416,23 +416,23 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (ide_dev_desc[dev]. block_read(dev, info.start, 1, (ulong *) addr) != 1) { printf("** Read error on %d:%d\n", dev, part); - show_boot_error(BOOTSTAGE_ID_IDE_PART_READ); + bootstage_error(BOOTSTAGE_ID_IDE_PART_READ); return 1; } - show_boot_progress(BOOTSTAGE_ID_IDE_PART_READ); + bootstage_mark(BOOTSTAGE_ID_IDE_PART_READ);
switch (genimg_get_format((void *) addr)) { case IMAGE_FORMAT_LEGACY: hdr = (image_header_t *) addr;
- show_boot_progress(BOOTSTAGE_ID_IDE_FORMAT); + bootstage_mark(BOOTSTAGE_ID_IDE_FORMAT);
if (!image_check_hcrc(hdr)) { puts("\n** Bad Header Checksum **\n"); - show_boot_error(BOOTSTAGE_ID_IDE_CHECKSUM); + bootstage_error(BOOTSTAGE_ID_IDE_CHECKSUM); return 1; } - show_boot_progress(BOOTSTAGE_ID_IDE_CHECKSUM); + bootstage_mark(BOOTSTAGE_ID_IDE_CHECKSUM);
image_print_contents(hdr);
@@ -447,7 +447,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) break; #endif default: - show_boot_error(BOOTSTAGE_ID_IDE_FORMAT); + bootstage_error(BOOTSTAGE_ID_IDE_FORMAT); puts("** Unknown image type\n"); return 1; } @@ -459,20 +459,20 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (ide_dev_desc[dev].block_read(dev, info.start + 1, cnt, (ulong *)(addr + info.blksz)) != cnt) { printf("** Read error on %d:%d\n", dev, part); - show_boot_error(BOOTSTAGE_ID_IDE_READ); + bootstage_error(BOOTSTAGE_ID_IDE_READ); return 1; } - show_boot_progress(BOOTSTAGE_ID_IDE_READ); + bootstage_mark(BOOTSTAGE_ID_IDE_READ);
#if defined(CONFIG_FIT) /* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format((void *) addr) == IMAGE_FORMAT_FIT) { if (!fit_check_format(fit_hdr)) { - show_boot_error(BOOTSTAGE_ID_IDE_FIT_READ); + bootstage_error(BOOTSTAGE_ID_IDE_FIT_READ); puts("** Bad FIT image format\n"); return 1; } - show_boot_progress(BOOTSTAGE_ID_IDE_FIT_READ_OK); + bootstage_mark(BOOTSTAGE_ID_IDE_FIT_READ_OK); fit_print_contents(fit_hdr); } #endif diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 1cfa247..52d721e 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -787,7 +787,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, if (s != NULL && (strcmp(s, ".jffs2") && strcmp(s, ".e") && strcmp(s, ".i"))) { printf("Unknown nand load suffix '%s'\n", s); - show_boot_error(BOOTSTAGE_ID_NAND_SUFFIX); + bootstage_error(BOOTSTAGE_ID_NAND_SUFFIX); return 1; }
@@ -797,16 +797,16 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr); if (r) { puts("** Read error\n"); - show_boot_error(BOOTSTAGE_ID_NAND_HDR_READ); + bootstage_error(BOOTSTAGE_ID_NAND_HDR_READ); return 1; } - show_boot_progress(BOOTSTAGE_ID_NAND_HDR_READ); + bootstage_mark(BOOTSTAGE_ID_NAND_HDR_READ);
switch (genimg_get_format ((void *)addr)) { case IMAGE_FORMAT_LEGACY: hdr = (image_header_t *)addr;
- show_boot_progress(BOOTSTAGE_ID_NAND_TYPE); + bootstage_mark(BOOTSTAGE_ID_NAND_TYPE); image_print_contents (hdr);
cnt = image_get_image_size (hdr); @@ -820,29 +820,29 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, break; #endif default: - show_boot_error(BOOTSTAGE_ID_NAND_TYPE); + bootstage_error(BOOTSTAGE_ID_NAND_TYPE); puts ("** Unknown image type\n"); return 1; } - show_boot_progress(BOOTSTAGE_ID_NAND_TYPE); + bootstage_mark(BOOTSTAGE_ID_NAND_TYPE);
r = nand_read_skip_bad(nand, offset, &cnt, (u_char *) addr); if (r) { puts("** Read error\n"); - show_boot_error(BOOTSTAGE_ID_NAND_READ); + bootstage_error(BOOTSTAGE_ID_NAND_READ); return 1; } - show_boot_progress(BOOTSTAGE_ID_NAND_READ); + bootstage_mark(BOOTSTAGE_ID_NAND_READ);
#if defined(CONFIG_FIT) /* This cannot be done earlier, we need complete FIT image in RAM first */ if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) { if (!fit_check_format (fit_hdr)) { - show_boot_error(BOOTSTAGE_ID_NAND_FIT_READ); + bootstage_error(BOOTSTAGE_ID_NAND_FIT_READ); puts ("** Bad FIT image format\n"); return 1; } - show_boot_progress(BOOTSTAGE_ID_NAND_FIT_READ_OK); + bootstage_mark(BOOTSTAGE_ID_NAND_FIT_READ_OK); fit_print_contents (fit_hdr); } #endif @@ -884,7 +884,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } #endif
- show_boot_progress(BOOTSTAGE_ID_NAND_PART); + bootstage_mark(BOOTSTAGE_ID_NAND_PART); switch (argc) { case 1: addr = CONFIG_SYS_LOAD_ADDR; @@ -907,26 +907,26 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_CMD_MTDPARTS) usage: #endif - show_boot_error(BOOTSTAGE_ID_NAND_SUFFIX); + bootstage_error(BOOTSTAGE_ID_NAND_SUFFIX); return cmd_usage(cmdtp); }
- show_boot_progress(BOOTSTAGE_ID_NAND_SUFFIX); + bootstage_mark(BOOTSTAGE_ID_NAND_SUFFIX); if (!boot_device) { puts("\n** No boot device **\n"); - show_boot_error(BOOTSTAGE_ID_NAND_BOOT_DEVICE); + bootstage_error(BOOTSTAGE_ID_NAND_BOOT_DEVICE); return 1; } - show_boot_progress(BOOTSTAGE_ID_NAND_BOOT_DEVICE); + bootstage_mark(BOOTSTAGE_ID_NAND_BOOT_DEVICE);
idx = simple_strtoul(boot_device, NULL, 16);
if (idx < 0 || idx >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[idx].name) { printf("\n** Device %d not available\n", idx); - show_boot_error(BOOTSTAGE_ID_NAND_AVAILABLE); + bootstage_error(BOOTSTAGE_ID_NAND_AVAILABLE); return 1; } - show_boot_progress(BOOTSTAGE_ID_NAND_AVAILABLE); + bootstage_mark(BOOTSTAGE_ID_NAND_AVAILABLE);
return nand_load_image(cmdtp, &nand_info[idx], offset, addr, argv[0]); } diff --git a/common/cmd_net.c b/common/cmd_net.c index ea3df8f..78b7113 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -230,36 +230,36 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc, break; #endif default: - show_boot_error(BOOTSTAGE_ID_NET_START); + bootstage_error(BOOTSTAGE_ID_NET_START); return cmd_usage(cmdtp); }
- show_boot_progress(BOOTSTAGE_ID_NET_START); + bootstage_mark(BOOTSTAGE_ID_NET_START); if ((size = NetLoop(proto)) < 0) { - show_boot_error(BOOTSTAGE_ID_NET_NETLOOP_OK); + bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); return 1; }
- show_boot_progress(BOOTSTAGE_ID_NET_NETLOOP_OK); + bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK); /* NetLoop ok, update environment */ netboot_update_env();
/* done if no file was loaded (no errors though) */ if (size == 0) { - show_boot_error(BOOTSTAGE_ID_NET_LOADED); + bootstage_error(BOOTSTAGE_ID_NET_LOADED); return 0; }
/* flush cache */ flush_cache(load_addr, size);
- show_boot_progress(BOOTSTAGE_ID_NET_LOADED); + bootstage_mark(BOOTSTAGE_ID_NET_LOADED); rcode = bootm_maybe_autostart(cmdtp, argv[0]);
if (rcode < 0) - show_boot_error(BOOTSTAGE_ID_NET_DONE_ERR); + bootstage_error(BOOTSTAGE_ID_NET_DONE_ERR); else - show_boot_progress(BOOTSTAGE_ID_NET_DONE); + bootstage_mark(BOOTSTAGE_ID_NET_DONE); return rcode; }
diff --git a/common/env_common.c b/common/env_common.c index 41e2f26..c33d22d 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -228,7 +228,7 @@ void env_relocate(void) #if defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */ set_default_env(NULL); #else - show_boot_error(BOOTSTAGE_ID_NET_CHECKSUM); + bootstage_error(BOOTSTAGE_ID_NET_CHECKSUM); set_default_env("!bad CRC"); #endif } else { diff --git a/common/image.c b/common/image.c index 8b097bf..ff2bb68 100644 --- a/common/image.c +++ b/common/image.c @@ -373,37 +373,37 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
if (!image_check_magic(rd_hdr)) { puts("Bad Magic Number\n"); - show_boot_error(BOOTSTAGE_ID_RD_MAGIC); + bootstage_error(BOOTSTAGE_ID_RD_MAGIC); return NULL; }
if (!image_check_hcrc(rd_hdr)) { puts("Bad Header Checksum\n"); - show_boot_error(BOOTSTAGE_ID_RD_HDR_CHECKSUM); + bootstage_error(BOOTSTAGE_ID_RD_HDR_CHECKSUM); return NULL; }
- show_boot_progress(BOOTSTAGE_ID_RD_MAGIC); + bootstage_mark(BOOTSTAGE_ID_RD_MAGIC); image_print_contents(rd_hdr);
if (verify) { puts(" Verifying Checksum ... "); if (!image_check_dcrc(rd_hdr)) { puts("Bad Data CRC\n"); - show_boot_error(BOOTSTAGE_ID_RD_CHECKSUM); + bootstage_error(BOOTSTAGE_ID_RD_CHECKSUM); return NULL; } puts("OK\n"); }
- show_boot_progress(BOOTSTAGE_ID_RD_HDR_CHECKSUM); + bootstage_mark(BOOTSTAGE_ID_RD_HDR_CHECKSUM);
if (!image_check_os(rd_hdr, IH_OS_LINUX) || !image_check_arch(rd_hdr, arch) || !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) { printf("No Linux %s Ramdisk Image\n", genimg_get_arch_name(arch)); - show_boot_error(BOOTSTAGE_ID_RAMDISK); + bootstage_error(BOOTSTAGE_ID_RAMDISK); return NULL; }
@@ -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(BOOTSTAGE_ID_CHECK_RAMDISK); + bootstage_mark(BOOTSTAGE_ID_CHECK_RAMDISK); rd_hdr = image_get_ramdisk(rd_addr, arch, images->verify);
@@ -912,14 +912,14 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, printf("## Loading init Ramdisk from FIT " "Image at %08lx ...\n", rd_addr);
- show_boot_progress(BOOTSTAGE_ID_FIT_RD_FORMAT); + bootstage_mark(BOOTSTAGE_ID_FIT_RD_FORMAT); if (!fit_check_format(fit_hdr)) { puts("Bad FIT ramdisk image format!\n"); - show_boot_error( + bootstage_error( BOOTSTAGE_ID_FIT_RD_FORMAT); return 1; } - show_boot_progress(BOOTSTAGE_ID_FIT_RD_FORMAT_OK); + bootstage_mark(BOOTSTAGE_ID_FIT_RD_FORMAT_OK);
if (!fit_uname_ramdisk) { /* @@ -927,14 +927,14 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, * node first. If config unit node name is NULL * fit_conf_get_node() will try to find default config node */ - show_boot_progress( + bootstage_mark( BOOTSTAGE_ID_FIT_RD_NO_UNIT_NAME); cfg_noffset = fit_conf_get_node(fit_hdr, fit_uname_config); if (cfg_noffset < 0) { puts("Could not find configuration " "node\n"); - show_boot_error( + bootstage_error( BOOTSTAGE_ID_FIT_RD_NO_UNIT_NAME); return 1; } @@ -949,21 +949,21 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, rd_noffset, NULL); } else { /* get ramdisk component image node offset */ - show_boot_progress( + bootstage_mark( BOOTSTAGE_ID_FIT_RD_UNIT_NAME); rd_noffset = fit_image_get_node(fit_hdr, fit_uname_ramdisk); } if (rd_noffset < 0) { puts("Could not find subimage node\n"); - show_boot_error(BOOTSTAGE_ID_FIT_RD_SUBNODE); + bootstage_error(BOOTSTAGE_ID_FIT_RD_SUBNODE); return 1; }
printf(" Trying '%s' ramdisk subimage\n", fit_uname_ramdisk);
- show_boot_progress(BOOTSTAGE_ID_FIT_RD_CHECK); + bootstage_mark(BOOTSTAGE_ID_FIT_RD_CHECK); if (!fit_check_ramdisk(fit_hdr, rd_noffset, arch, images->verify)) return 1; @@ -972,10 +972,10 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, if (fit_image_get_data(fit_hdr, rd_noffset, &data, &size)) { puts("Could not find ramdisk subimage data!\n"); - show_boot_error(BOOTSTAGE_ID_FIT_RD_GET_DATA); + bootstage_error(BOOTSTAGE_ID_FIT_RD_GET_DATA); return 1; } - show_boot_progress(BOOTSTAGE_ID_FIT_RD_GET_DATA_OK); + bootstage_mark(BOOTSTAGE_ID_FIT_RD_GET_DATA_OK);
rd_data = (ulong)data; rd_len = size; @@ -983,10 +983,10 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, if (fit_image_get_load(fit_hdr, rd_noffset, &rd_load)) { puts("Can't get ramdisk subimage load " "address!\n"); - show_boot_error(BOOTSTAGE_ID_FIT_RD_LOAD); + bootstage_error(BOOTSTAGE_ID_FIT_RD_LOAD); return 1; } - show_boot_progress(BOOTSTAGE_ID_FIT_RD_LOAD); + bootstage_mark(BOOTSTAGE_ID_FIT_RD_LOAD);
images->fit_hdr_rd = fit_hdr; images->fit_uname_rd = fit_uname_ramdisk; @@ -1006,7 +1006,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, * Now check if we have a legacy mult-component image, * get second entry data start address and len. */ - show_boot_progress(BOOTSTAGE_ID_RAMDISK); + bootstage_mark(BOOTSTAGE_ID_RAMDISK); printf("## Loading init Ramdisk from multi component " "Legacy Image at %08lx ...\n", (ulong)images->legacy_hdr_os); @@ -1016,7 +1016,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, /* * no initrd image */ - show_boot_progress(BOOTSTAGE_ID_NO_RAMDISK); + bootstage_mark(BOOTSTAGE_ID_NO_RAMDISK); rd_len = rd_data = 0; }
@@ -1100,7 +1100,7 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len, puts("ramdisk - allocation error\n"); goto error; } - show_boot_progress(BOOTSTAGE_ID_COPY_RAMDISK); + bootstage_mark(BOOTSTAGE_ID_COPY_RAMDISK);
*initrd_end = *initrd_start + rd_len; printf(" Loading Ramdisk to %08lx, end %08lx ... ", @@ -3175,23 +3175,23 @@ static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch, puts(" Verifying Hash Integrity ... "); if (!fit_image_check_hashes(fit, rd_noffset)) { puts("Bad Data Hash\n"); - show_boot_error(BOOTSTAGE_ID_FIT_RD_HASH); + bootstage_error(BOOTSTAGE_ID_FIT_RD_HASH); return 0; } puts("OK\n"); }
- show_boot_progress(BOOTSTAGE_ID_FIT_RD_CHECK_ALL); + bootstage_mark(BOOTSTAGE_ID_FIT_RD_CHECK_ALL); if (!fit_image_check_os(fit, rd_noffset, IH_OS_LINUX) || !fit_image_check_arch(fit, rd_noffset, arch) || !fit_image_check_type(fit, rd_noffset, IH_TYPE_RAMDISK)) { printf("No Linux %s Ramdisk Image\n", genimg_get_arch_name(arch)); - show_boot_error(BOOTSTAGE_ID_FIT_RD_CHECK_ALL); + bootstage_error(BOOTSTAGE_ID_FIT_RD_CHECK_ALL); return 0; }
- show_boot_progress(BOOTSTAGE_ID_FIT_RD_CHECK_ALL_OK); + bootstage_mark(BOOTSTAGE_ID_FIT_RD_CHECK_ALL_OK); return 1; } #endif /* USE_HOSTCC */ diff --git a/net/eth.c b/net/eth.c index 8fc84bc..9000fc7 100644 --- a/net/eth.c +++ b/net/eth.c @@ -230,7 +230,7 @@ int eth_initialize(bd_t *bis) eth_devices = NULL; eth_current = NULL;
- show_boot_progress(BOOTSTAGE_ID_NET_ETH_START); + bootstage_mark(BOOTSTAGE_ID_NET_ETH_START); #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) miiphy_init(); #endif @@ -260,12 +260,12 @@ int eth_initialize(bd_t *bis) #endif if (!eth_devices) { puts ("No ethernet found.\n"); - show_boot_error(BOOTSTAGE_ID_NET_ETH_START); + bootstage_error(BOOTSTAGE_ID_NET_ETH_START); } else { struct eth_device *dev = eth_devices; char *ethprime = getenv ("ethprime");
- show_boot_progress(BOOTSTAGE_ID_NET_ETH_INIT); + bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT); do { if (dev->index) puts (", "); diff --git a/post/post.c b/post/post.c index 9764e1d..7100d8b 100644 --- a/post/post.c +++ b/post/post.c @@ -158,7 +158,7 @@ void post_output_backlog(void) post_log("PASSED\n"); else { post_log("FAILED\n"); - show_boot_error(BOOTSTAGE_ID_POST_FAIL_R); + bootstage_error(BOOTSTAGE_ID_POST_FAIL_R); } } } @@ -295,7 +295,7 @@ static int post_run_single(struct post_test *test, } else { if ((*test->test)(flags) != 0) { post_log("FAILED\n"); - show_boot_error(BOOTSTAGE_ID_POST_FAIL_R); + bootstage_error(BOOTSTAGE_ID_POST_FAIL_R); show_post_progress(i, POST_AFTER, POST_FAILED); if (test_flags & POST_CRITICAL) gd->flags |= GD_FLG_POSTFAIL;

This defines the basics of a new boot time measurement feature. This allows logging of very accurate time measurements as the boot proceeds, by using an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file. Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to renumber them all.
Timer summary in microseconds: Mark Elapsed Stage 0 0 reset 205,000 205,000 board_init_f 6,053,000 5,848,000 bootm_start 6,053,000 0 id=1 6,058,000 5,000 id=101 6,058,000 0 id=100 6,061,000 3,000 id=103 6,064,000 3,000 id=104 6,093,000 29,000 id=107 6,093,000 0 id=106 6,093,000 0 id=105 6,093,000 0 id=108 7,089,000 996,000 id=7 7,089,000 0 id=15 7,089,000 0 id=8 7,097,000 8,000 start_kernel
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v3: - Fix code style in bootstage_mark_name() - Make main bootstage commit title more explicit
README | 25 ++++++++ common/Makefile | 1 + common/bootstage.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/bootstage.h | 77 ++++++++++++++++++++++++- 4 files changed, 261 insertions(+), 2 deletions(-) create mode 100644 common/bootstage.c
diff --git a/README b/README index 9d713e8..e757786 100644 --- a/README +++ b/README @@ -2235,6 +2235,31 @@ The following options need to be configured: example, some LED's) on your board. At the moment, the following checkpoints are implemented:
+- Detailed boot stage timing + CONFIG_BOOTSTAGE + Define this option to get detailed timing of each stage + of the boot process. + + CONFIG_BOOTSTAGE_USER_COUNT + This is the number of available user bootstage records. + Each time you call bootstage_mark(BOOTSTAGE_ID_ALLOC, ...) + a new ID will be allocated from this stash. If you exceed + the limit, recording will stop. + + CONFIG_BOOTSTAGE_REPORT + Define this to print a report before boot, similar to this: + + Timer summary in microseconds: + Mark Elapsed Stage + 0 0 reset + 3,575,678 3,575,678 board_init_f start + 3,575,695 17 arch_cpu_init A9 + 3,575,777 82 arch_cpu_init done + 3,659,598 83,821 board_init_r start + 3,910,375 250,777 main_loop + 29,916,167 26,005,792 bootm_start + 30,361,327 445,160 start_kernel + Legacy uImage format:
Arg Where When diff --git a/common/Makefile b/common/Makefile index 2d9ae8c..038baf0 100644 --- a/common/Makefile +++ b/common/Makefile @@ -172,6 +172,7 @@ SPD := y endif COBJS-$(SPD) += ddr_spd.o COBJS-$(CONFIG_HWCONFIG) += hwconfig.o +COBJS-$(CONFIG_BOOTSTAGE) += bootstage.o COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o COBJS-y += flash.o COBJS-$(CONFIG_CMD_KGDB) += kgdb.o kgdb_stubs.o diff --git a/common/bootstage.c b/common/bootstage.c new file mode 100644 index 0000000..358e1ca --- /dev/null +++ b/common/bootstage.c @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2011, Google Inc. All rights reserved. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + + +/* + * This module records the progress of boot and arbitrary commands, and + * permits accurate timestamping of each. + * + * TBD: Pass timings to kernel in the FDT + */ + +#include <common.h> +#include <libfdt.h> + +DECLARE_GLOBAL_DATA_PTR; + +enum bootstage_flags { + BOOTSTAGEF_ERROR = 1 << 0, /* Error record */ + BOOTSTAGEF_ALLOC = 1 << 1, /* Allocate an id */ +}; + +struct bootstage_record { + ulong time_us; + const char *name; + int flags; /* see enum bootstage_flags */ + enum bootstage_id id; +}; + +static struct bootstage_record record[BOOTSTAGE_ID_COUNT] = { {1} }; +static int next_id = BOOTSTAGE_ID_USER; + +ulong bootstage_add_record(enum bootstage_id id, const char *name, + int flags) +{ + struct bootstage_record *rec; + ulong mark = timer_get_boot_us(); + + if (flags & BOOTSTAGEF_ALLOC) + id = next_id++; + + if (id < BOOTSTAGE_ID_COUNT) { + rec = &record[id]; + + /* Only record the first event for each */ + if (!rec->time_us) { + rec->time_us = mark; + rec->name = name; + rec->flags = flags; + rec->id = id; + } + } + + /* Tell the board about this progress */ +#ifdef CONFIG_SHOW_BOOT_PROGRESS + show_boot_progress(flags & BOOTSTAGE_ERROR ? -id : id); +#endif + return mark; +} + + +ulong bootstage_mark(enum bootstage_id id) +{ + return bootstage_add_record(id, NULL, 0); +} + +ulong bootstage_error(enum bootstage_id id) +{ + return bootstage_add_record(id, NULL, BOOTSTAGEF_ERROR); +} + +ulong bootstage_mark_name(enum bootstage_id id, const char *name) +{ + int flags = 0; + + if (id == BOOTSTAGE_ID_ALLOC) + flags = BOOTSTAGEF_ALLOC; + return bootstage_add_record(id, name, flags); +} + +static void print_time(unsigned long us_time) +{ + char str[12], *s; + int grab = 3; + + /* We don't seem to have %'d in U-Boot */ + sprintf(str, "%9ld", us_time); + for (s = str; *s; s += grab) { + if (s != str) + putc(s[-1] != ' ' ? ',' : ' '); + printf("%.*s", grab, s); + grab = 3; + } +} + +static uint32_t print_time_record(enum bootstage_id id, + struct bootstage_record *rec, uint32_t prev) +{ + print_time(rec->time_us); + print_time(rec->time_us - prev); + if (rec->name) + printf(" %s\n", rec->name); + else if (id >= BOOTSTAGE_ID_USER) + printf(" user_%d\n", id - BOOTSTAGE_ID_USER); + else + printf(" id=%d\n", id); + return rec->time_us; +} + +static int h_compare_record(const void *r1, const void *r2) +{ + const struct bootstage_record *rec1 = r1, *rec2 = r2; + + return rec1->time_us - rec2->time_us; +} + +void bootstage_report(void) +{ + struct bootstage_record *rec = record; + int id; + uint32_t prev; + + puts("Timer summary in microseconds:\n"); + printf("%11s%11s %s\n", "Mark", "Elapsed", "Stage"); + + /* Fake the first record - we could get it from early boot */ + rec->name = "reset"; + rec->time_us = 0; + prev = print_time_record(BOOTSTAGE_ID_AWAKE, rec, 0); + + /* Sort records by increasing time */ + qsort(record, ARRAY_SIZE(record), sizeof(*rec), h_compare_record); + + for (id = 0; id < BOOTSTAGE_ID_COUNT; id++, rec++) { + if (rec->time_us != 0) + prev = print_time_record(rec->id, rec, prev); + } + if (next_id > BOOTSTAGE_ID_COUNT) + printf("(Overflowed internal boot id table by %d entries\n" + "- please increase CONFIG_BOOTSTAGE_USER_COUNT\n", + next_id - BOOTSTAGE_ID_COUNT); +} diff --git a/include/bootstage.h b/include/bootstage.h index 8f7fcd7..82a9f1b 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -26,6 +26,11 @@ #ifndef _BOOTSTAGE_H #define _BOOTSTAGE_H
+/* The number of boot stage records available for the user */ +#ifndef CONFIG_BOOTSTAGE_USER_COUNT +#define CONFIG_BOOTSTAGE_USER_COUNT 20 +#endif + /* * A list of boot stages that we know about. Each of these indicates the * state that we are at, and the action that we are about to perform. For @@ -169,8 +174,56 @@ enum bootstage_id {
BOOTSTAGE_ID_NAND_FIT_READ = 150, BOOTSTAGE_ID_NAND_FIT_READ_OK, + + /* + * These boot stages are new, higher level, and not directly related + * to the old boot progress numbers. They are useful for recording + * rough boot timing information. + */ + BOOTSTAGE_ID_AWAKE, + BOOTSTAGE_ID_START_UBOOT_F, + BOOTSTAGE_ID_START_UBOOT_R, + BOOTSTAGE_ID_USB_START, + BOOTSTAGE_ID_ETH_START, + BOOTSTAGE_ID_BOOTP_START, + BOOTSTAGE_ID_BOOTP_STOP, + BOOTSTAGE_ID_BOOTM_START, + BOOTSTAGE_ID_BOOTM_HANDOFF, + BOOTSTAGE_ID_MAIN_LOOP, + BOOTSTAGE_KERNELREAD_START, + BOOTSTAGE_KERNELREAD_STOP, + + BOOTSTAGE_ID_CPU_AWAKE, + BOOTSTAGE_ID_MAIN_CPU_AWAKE, + BOOTSTAGE_ID_MAIN_CPU_READY, + + /* a few spare for the user, from here */ + BOOTSTAGE_ID_USER, + BOOTSTAGE_ID_COUNT = BOOTSTAGE_ID_USER + CONFIG_BOOTSTAGE_USER_COUNT, + BOOTSTAGE_ID_ALLOC, };
+#ifdef CONFIG_BOOTSTAGE +/* This is the full bootstage implementation */ + +/* + * Mark a time stamp for the current boot stage. + */ +ulong bootstage_mark(enum bootstage_id id); + +ulong bootstage_error(enum bootstage_id id); + +ulong bootstage_mark_name(enum bootstage_id id, const char *name); + +/* Print a report about boot time */ +void bootstage_report(void); + +#else +/* + * This is a dummy implementation which just calls show_boot_progress(), + * and won't even do that unless CONFIG_SHOW_BOOT_PROGRESS is defined + */ + /* * Board code can implement show_boot_progress() if needed. * @@ -178,9 +231,29 @@ enum bootstage_id { * has occurred. */ void show_boot_progress(int val); -static inline void show_boot_error(int val) + +static inline ulong bootstage_mark(enum bootstage_id id) +{ +#ifdef CONFIG_SHOW_BOOT_PROGRESS + show_boot_progress(id); +#endif + return 0; +} + +static inline ulong bootstage_error(enum bootstage_id id) { - show_boot_progress(-val); +#ifdef CONFIG_SHOW_BOOT_PROGRESS + show_boot_progress(-id); +#endif + return 0; }
+static inline ulong bootstage_mark_name(enum bootstage_id id, const char *name) +{ + return 0; +} + + +#endif /* CONFIG_BOOTSTAGE */ + #endif

Dear Simon Glass,
In message 1326590698-7767-14-git-send-email-sjg@chromium.org you wrote:
This defines the basics of a new boot time measurement feature. This allows logging of very accurate time measurements as the boot proceeds, by using an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file. Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to renumber them all.
Hm.... I'm not sure what happened.
I am positively sure (and I just checked again in the bash history) that I did apply the correct version of "[PATCH v3 11/15] timer: add microsecond boot func".
However, the repository appears to have an old version instead:
f933e84 2012-03-18 21:43:17 +0100 bootstage: arm: Add bootstage calls in board and bootm 573f14f 2012-03-18 21:42:56 +0100 bootstage: Plumb in bootstage calls for basic operations 3a608ca 2012-03-18 21:42:14 +0100 bootstage: Implement core microsecond boot time measurement 770605e 2012-03-18 21:41:39 +0100 bootstage: Replace show_boot_progress/error() with bootstage_...() ==> 5ff5539 2012-03-18 21:33:53 +0100 bootstage: Define an optional microsecond timer aacc8c1 2012-03-18 21:33:32 +0100 bootstage: Convert FIT progress numbers to enums c8e66db 2012-03-18 21:33:05 +0100 bootstage: Convert net progress numbers to enums cd24a6b 2012-03-18 21:27:20 +0100 bootstage: Convert NAND progress numbers to enums 90e153d 2012-03-18 21:24:21 +0100 bootstage: Convert IDE progress numbers to enums 8ade950 2012-03-18 21:16:22 +0100 bootstage: Convert progress numbers 20-41 to enums 5e41088 2012-03-18 20:59:53 +0100 bootstage: Convert progress numbers 10-19 to enums 5dc8871 2012-03-18 20:57:37 +0100 bootstage: Convert progress numbers 1-9 into enums 5ddb118 2012-03-18 20:56:00 +0100 bootstage: Use show_boot_error() for -ve progress numbers 578ac1e 2012-03-18 20:45:57 +0100 bootstage: Make use of BOOTSTAGE_ID_RUN_OS in show_boot_progress() 097e178 2012-03-18 20:43:38 +0100 bootstage: Create an initial header for boot progress integers
I cannot reproduce it, but it seems patchworked palyed some trick on me (it has also beenx extremely slow last night - eventually some works was going on there?).
Anyway. Fact is, the current mainline code contains a broken patch, which breaks for example the PMC440 board:
Configuring for PMC440 board... /work/wd/tmp-ppc/examples/api/time.o: In function `__timer_get_boot_us': /home/wd/git/u-boot/work/lib/time.c:60: undefined reference to `get_timer' /home/wd/git/u-boot/work/lib/time.c:61: undefined reference to `get_timer' make[1]: *** [/work/wd/tmp-ppc/examples/api/demo] Error 1
Can you please have a look and provide an incremental patch to bring mainline back in sync with your current code base?
Thanks.
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Mon, Mar 19, 2012 at 12:13 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1326590698-7767-14-git-send-email-sjg@chromium.org you wrote:
This defines the basics of a new boot time measurement feature. This allows logging of very accurate time measurements as the boot proceeds, by using an available microsecond counter.
To enable the feature, define CONFIG_BOOTSTAGE in your board config file. Also available is CONFIG_BOOTSTAGE_REPORT which will cause a report to be printed just before handing off to the OS.
Most IDs are not named at this stage. For that I would first like to renumber them all.
Hm.... I'm not sure what happened.
I am positively sure (and I just checked again in the bash history) that I did apply the correct version of "[PATCH v3 11/15] timer: add microsecond boot func".
However, the repository appears to have an old version instead:
f933e84 2012-03-18 21:43:17 +0100 bootstage: arm: Add bootstage calls in board and bootm 573f14f 2012-03-18 21:42:56 +0100 bootstage: Plumb in bootstage calls for basic operations 3a608ca 2012-03-18 21:42:14 +0100 bootstage: Implement core microsecond boot time measurement 770605e 2012-03-18 21:41:39 +0100 bootstage: Replace show_boot_progress/error() with bootstage_...() ==> 5ff5539 2012-03-18 21:33:53 +0100 bootstage: Define an optional microsecond timer aacc8c1 2012-03-18 21:33:32 +0100 bootstage: Convert FIT progress numbers to enums c8e66db 2012-03-18 21:33:05 +0100 bootstage: Convert net progress numbers to enums cd24a6b 2012-03-18 21:27:20 +0100 bootstage: Convert NAND progress numbers to enums 90e153d 2012-03-18 21:24:21 +0100 bootstage: Convert IDE progress numbers to enums 8ade950 2012-03-18 21:16:22 +0100 bootstage: Convert progress numbers 20-41 to enums 5e41088 2012-03-18 20:59:53 +0100 bootstage: Convert progress numbers 10-19 to enums 5dc8871 2012-03-18 20:57:37 +0100 bootstage: Convert progress numbers 1-9 into enums 5ddb118 2012-03-18 20:56:00 +0100 bootstage: Use show_boot_error() for -ve progress numbers 578ac1e 2012-03-18 20:45:57 +0100 bootstage: Make use of BOOTSTAGE_ID_RUN_OS in show_boot_progress() 097e178 2012-03-18 20:43:38 +0100 bootstage: Create an initial header for boot progress integers
I cannot reproduce it, but it seems patchworked palyed some trick on me (it has also beenx extremely slow last night - eventually some works was going on there?).
Anyway. Fact is, the current mainline code contains a broken patch, which breaks for example the PMC440 board:
Configuring for PMC440 board... /work/wd/tmp-ppc/examples/api/time.o: In function `__timer_get_boot_us': /home/wd/git/u-boot/work/lib/time.c:60: undefined reference to `get_timer' /home/wd/git/u-boot/work/lib/time.c:61: undefined reference to `get_timer' make[1]: *** [/work/wd/tmp-ppc/examples/api/demo] Error 1
Can you please have a look and provide an incremental patch to bring mainline back in sync with your current code base?
Yes I will send one though. But this is my mistake, not yours. I did not get around to sending an updated patch - I was in fact going to ask about the best solution for it, as I was thinking of moving the timer function into bootstage.c.
Anyway I will send a patch as is, but if you would rather the function move so we can remove the #ifdef let me know.
Regards, Simon
Thanks.
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Each team building another component has been using the most recent tested version of the integrated system as a test bed for debugging its piece. Their work will be set back by having that test bed change under them. Of course it must. But the changes need to be quantized. Then each user has periods of productive stability, interrupted by bursts of test-bed change. This seems to be much less disruptive than a constant rippling and trembling. - Frederick Brooks Jr., "The Mythical Man Month"

This inserts bootstage calls into tftp, usb start and bootm. We could go further, but this is a reasonable start to illustrate the concept.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/cmd_bootm.c | 2 ++ common/cmd_net.c | 7 ++++++- common/cmd_usb.c | 1 + net/bootp.c | 4 ++++ net/net.c | 1 + 5 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 7e780fb..7536f34 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -199,6 +199,8 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
bootm_start_lmb();
+ bootstage_mark_name(BOOTSTAGE_ID_BOOTM_START, "bootm_start"); + /* get kernel image header, start address and length */ os_hdr = boot_get_kernel(cmdtp, flag, argc, argv, &images, &images.os.image_start, &images.os.image_len); diff --git a/common/cmd_net.c b/common/cmd_net.c index 78b7113..0606096 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -43,7 +43,12 @@ U_BOOT_CMD(
int do_tftpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - return netboot_common(TFTPGET, cmdtp, argc, argv); + int ret; + + bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start"); + ret = netboot_common(TFTPGET, cmdtp, argc, argv); + bootstage_mark_name(BOOTSTAGE_KERNELREAD_STOP, "tftp_done"); + return ret; }
U_BOOT_CMD( diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 320667f..8115f4e 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -513,6 +513,7 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if ((strncmp(argv[1], "reset", 5) == 0) || (strncmp(argv[1], "start", 5) == 0)) { + bootstage_mark_name(BOOTSTAGE_ID_USB_START, "usb_start"); usb_stop(); printf("(Re)start USB...\n"); i = usb_init(); diff --git a/net/bootp.c b/net/bootp.c index 34124b8..9e32476 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -322,6 +322,7 @@ BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, BootpVendorProcess((uchar *)&bp->bp_vend[4], len);
NetSetTimeout(0, (thand_f *)0); + bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, "bootp_stop");
debug("Got good BOOTP\n");
@@ -589,6 +590,7 @@ BootpRequest (void) Bootp_t *bp; int ext_len, pktlen, iplen;
+ bootstage_mark_name(BOOTSTAGE_ID_BOOTP_START, "bootp_start"); #if defined(CONFIG_CMD_DHCP) dhcp_state = INIT; #endif @@ -949,6 +951,8 @@ DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, BootpCopyNetParams(bp); /* Store net params from reply */ dhcp_state = BOUND; printf ("DHCP client bound to address %pI4\n", &NetOurIP); + bootstage_mark_name(BOOTSTAGE_ID_BOOTP_STOP, + "bootp_stop");
net_auto_load(); return; diff --git a/net/net.c b/net/net.c index 045405b..c5acf8f 100644 --- a/net/net.c +++ b/net/net.c @@ -402,6 +402,7 @@ int NetLoop(enum proto_t protocol) NetArpWaitTxPacketSize = 0; }
+ bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start"); eth_halt(); eth_set_current(); if (eth_init(bd) < 0) {

Dear Simon Glass,
In message 1326590698-7767-15-git-send-email-sjg@chromium.org you wrote:
This inserts bootstage calls into tftp, usb start and bootm. We could go further, but this is a reasonable start to illustrate the concept.
Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_bootm.c | 2 ++ common/cmd_net.c | 7 ++++++- common/cmd_usb.c | 1 + net/bootp.c | 4 ++++ net/net.c | 1 + 5 files changed, 14 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Add calls to bootstage before and after relocation, and just before jumping to the OS.
The idea here is you can call bootstage_report() to get a report. Additionally, if you define CONFIG_BOOTSTAGE_REPORT then a report is printed automatically by U-Boot just before jumping to the kernel.
Signed-off-by: Simon Glass sjg@chromium.org --- Changes in v2: - Unify show_boot_progress() into this series
Changes in v3: - Update commit message to clarify the purpose of CONFIG_BOOTSTAGE_REPORT
arch/arm/lib/board.c | 3 +++ arch/arm/lib/bootm.c | 4 ++++ 2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 3d78274..e4b243b 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -266,6 +266,8 @@ void board_init_f(ulong bootflag) ulong reg; #endif
+ bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r"); + /* Pointer is writable since we allocated a register for it */ gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07); /* compiler optimization barrier needed for GCC >= 3.4 */ @@ -455,6 +457,7 @@ void board_init_r(gd_t *id, ulong dest_addr) gd = id;
gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ + bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
monitor_flash_len = _end_ofs;
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index f114cd6..2961ab2 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -83,6 +83,10 @@ void arch_lmb_reserve(struct lmb *lmb) static void announce_and_cleanup(void) { printf("\nStarting kernel ...\n\n"); + bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel"); +#ifdef CONFIG_BOOTSTAGE_REPORT + bootstage_report(); +#endif
#ifdef CONFIG_USB_DEVICE {
participants (2)
-
Simon Glass
-
Wolfgang Denk