bootstage: Implement core microsecond boot time measurement

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>
This commit is contained in:
Simon Glass
2012-02-13 13:51:19 +00:00
committed by Wolfgang Denk
parent 770605e4f9
commit 3a608ca01d
4 changed files with 227 additions and 0 deletions

View File

@@ -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,6 +174,33 @@ 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,
};
/*
@@ -189,6 +221,11 @@ 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(),
@@ -207,6 +244,12 @@ static inline ulong bootstage_error(enum bootstage_id id)
return 0;
}
static inline ulong bootstage_mark_name(enum bootstage_id id, const char *name)
{
return 0;
}
#endif /* CONFIG_BOOTSTAGE */
#endif