summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/lib/board.c2
-rw-r--r--arch/arm/lib/bootm.c4
-rw-r--r--common/Makefile1
-rw-r--r--common/bootstage.c98
-rw-r--r--common/cmd_bootm.c2
-rw-r--r--common/cmd_net.c7
-rw-r--r--common/cmd_usb.c1
-rw-r--r--include/bootstage.h70
-rw-r--r--include/common.h8
-rw-r--r--include/configs/tegra2-common.h2
-rw-r--r--net/bootp.c3
-rw-r--r--net/net.c1
12 files changed, 198 insertions, 1 deletions
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 1a9fe7eb5b..cd88c7e358 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -271,6 +271,8 @@ void board_init_f (ulong bootflag)
gd_t *id;
ulong addr, addr_sp;
+ bootstage_mark(BOOTSTAGE_START_UBOOT, "start_armboot");
+
/* 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 */
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 802e833a2e..5116e950f8 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(BOOTSTAGE_BOOTM_HANDOFF, "start_kernel");
+#ifdef CONFIG_BOOTSTAGE_REPORT
+ bootstage_report();
+#endif
#ifdef CONFIG_USB_DEVICE
{
diff --git a/common/Makefile b/common/Makefile
index 224b7cc712..fe7497416d 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -173,6 +173,7 @@ COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o
COBJS-$(CONFIG_MODEM_SUPPORT) += modem.o
COBJS-$(CONFIG_UPDATE_TFTP) += update.o
COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
+COBJS-$(CONFIG_BOOTSTAGE) += bootstage.o
COBJS := $(sort $(COBJS-y))
diff --git a/common/bootstage.c b/common/bootstage.c
new file mode 100644
index 0000000000..6fd0083a68
--- /dev/null
+++ b/common/bootstage.c
@@ -0,0 +1,98 @@
+/*
+ * 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. The records can optionally be
+ * passed to kernel in the ATAGs
+ */
+
+#include <common.h>
+
+
+struct bootstage_record {
+ uint32_t time_us;
+ const char *name;
+};
+
+static struct bootstage_record record[BOOTSTAGE_COUNT];
+
+uint32_t bootstage_mark(enum bootstage_id id, const char *name)
+{
+ struct bootstage_record *rec = &record[id];
+
+ /* Only record the first event for each */
+ if (!rec->name) {
+ rec->time_us = (uint32_t)timer_get_us();
+ rec->name = name;
+ }
+ return rec->time_us;
+}
+
+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
+ printf(" id=%d\n", id);
+ return rec->time_us;
+}
+
+void bootstage_report(void)
+{
+ 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 */
+ prev = 0;
+ record[BOOTSTAGE_AWAKE].name = "awake";
+
+ for (id = 0; id < BOOTSTAGE_COUNT; id++) {
+ struct bootstage_record *rec = &record[id];
+
+ if (id == BOOTSTAGE_AWAKE || rec->time_us != 0)
+ prev = print_time_record(id, rec, prev);
+ }
+}
+
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 1966da48ca..212e510395 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -221,6 +221,8 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
bootm_start_lmb();
+ bootstage_mark(BOOTSTAGE_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 75ba1c3cdc..ac06fac1ce 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 (TFTP, cmdtp, argc, argv);
+ int ret;
+
+ bootstage_mark(BOOTSTAGE_KERNELREAD_START, "tftp start");
+ ret = netboot_common(TFTP, cmdtp, argc, argv);
+ bootstage_mark(BOOTSTAGE_KERNELREAD_STOP, "tftp done");
+ return ret;
}
U_BOOT_CMD(
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 3ba6fff4fd..c7b30a032b 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -522,6 +522,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(BOOTSTAGE_USB_START, "usb_start");
usb_stop();
printf("(Re)start USB...\n");
i = usb_init();
diff --git a/include/bootstage.h b/include/bootstage.h
new file mode 100644
index 0000000000..ade5a13999
--- /dev/null
+++ b/include/bootstage.h
@@ -0,0 +1,70 @@
+/*
+ * 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
+ */
+
+#ifndef __BOOTSTAGE_H
+#define __BOOTSTAGE_H
+
+/*
+ * These are the things that can be timestamped. There are some pre-defined
+ * by U-Boot, and some which are user defined.
+ */
+enum bootstage_id {
+ BOOTSTAGE_AWAKE,
+ BOOTSTAGE_START_UBOOT,
+ BOOTSTAGE_USB_START,
+ BOOTSTAGE_ETH_START,
+ BOOTSTAGE_BOOTP_START,
+ BOOTSTAGE_BOOTP_STOP,
+ BOOTSTAGE_KERNELREAD_START,
+ BOOTSTAGE_KERNELREAD_STOP,
+ BOOTSTAGE_BOOTM_START,
+ BOOTSTAGE_BOOTM_HANDOFF,
+
+ /* a few spare for the user, from here */
+ BOOTSTAGE_USER,
+
+ /*
+ * Total number of entries - increase this at the cost of some BSS
+ * and ATAG space.
+ */
+ BOOTSTAGE_COUNT = 10
+};
+
+#ifdef CONFIG_BOOTSTAGE
+
+/*
+ * Mark a time stamp for the current boot stage.
+ */
+uint32_t bootstage_mark(enum bootstage_id id, const char *name);
+
+/* Print a report about boot time */
+void bootstage_report(void);
+
+#else
+
+static inline bootstage_mark(enum bootstage_id id, const char *name)
+{}
+
+#endif
+
+#endif
+
diff --git a/include/common.h b/include/common.h
index 2c8513ae18..43b3892871 100644
--- a/include/common.h
+++ b/include/common.h
@@ -177,6 +177,14 @@ 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.
+ */
+unsigned long timer_get_us(void);
+
+#include <bootstage.h>
+
+/*
* General Purpose Utilities
*/
#define min(X, Y) \
diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h
index cedf0c4d33..c05380a888 100644
--- a/include/configs/tegra2-common.h
+++ b/include/configs/tegra2-common.h
@@ -32,6 +32,8 @@
#define CONFIG_TEGRA2 /* in a NVidia Tegra2 core */
#define CONFIG_MACH_TEGRA_GENERIC /* which is a Tegra generic machine */
#define CONFIG_SYS_NO_L2CACHE /* No L2 cache */
+#define CONFIG_BOOTSTAGE /* Record boot time */
+#define CONFIG_BOOTSTAGE_REPORT /* Print a boot time report */
#define CONFIG_ENABLE_CORTEXA9 /* enable CPU (A9 complex) */
diff --git a/net/bootp.c b/net/bootp.c
index 4db63cbbe6..043f9e0ed4 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -311,6 +311,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(BOOTSTAGE_BOOTP_STOP, "bootp_stop");
debug("Got good BOOTP\n");
@@ -552,6 +553,7 @@ BootpRequest (void)
Bootp_t *bp;
int ext_len, pktlen, iplen;
+ bootstage_mark(BOOTSTAGE_BOOTP_START, "bootp_start");
#if defined(CONFIG_CMD_DHCP)
dhcp_state = INIT;
#endif
@@ -914,6 +916,7 @@ 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(BOOTSTAGE_BOOTP_STOP, "bootp_stop");
/* Obey the 'autoload' setting */
if ((s = getenv("autoload")) != NULL) {
diff --git a/net/net.c b/net/net.c
index 7a6058339c..272fb5bad7 100644
--- a/net/net.c
+++ b/net/net.c
@@ -378,6 +378,7 @@ NetLoop(proto_t protocol)
NetArpWaitTxPacketSize = 0;
}
+ bootstage_mark(BOOTSTAGE_ETH_START, "eth_start");
eth_halt();
#ifdef CONFIG_NET_MULTI
eth_set_current();