From 074f516bda136e5464499fc63a854d8469f8e9fb Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 20 Nov 2009 15:23:58 +0100 Subject: Updated timing measurement structure, changed atags and added idle time measurement. Note: idle time measurement does not seem to work reliable at the moment. Verification needed. Signed-off-by: Michael Brandt --- lib_arm/Makefile | 1 + lib_arm/bootm.c | 69 +++++++++++++++++++++++---------------------- lib_arm/boottime.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 34 deletions(-) create mode 100644 lib_arm/boottime.c (limited to 'lib_arm') diff --git a/lib_arm/Makefile b/lib_arm/Makefile index 02933485c..5cfeba985 100644 --- a/lib_arm/Makefile +++ b/lib_arm/Makefile @@ -44,6 +44,7 @@ COBJS-y += cache-cp15.o endif COBJS-y += interrupts.o COBJS-y += reset.o +COBJS-y += boottime.o SRCS := $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \ $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c index ebaf2b3f2..9dc790dee 100644 --- a/lib_arm/bootm.c +++ b/lib_arm/bootm.c @@ -54,16 +54,14 @@ static void setup_end_tag (bd_t *bd); static void setup_videolfb_tag (gd_t *gd); # endif -static struct tag *params; -#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ - #ifdef CONFIG_BOOTTIME -ulong boottime_ticks_uboot_init = 0; -ulong boottime_ticks_load_kernel = 0; -ulong boottime_ticks_uboot_done = 0; static void setup_boottime_tags(void); #endif +static struct tag *params; +#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ + + int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; @@ -91,7 +89,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); - boottime_tag_uboot_done() + boottime_tag("uncompress_ll_init"); #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ @@ -168,33 +166,6 @@ static void setup_start_tag (bd_t *bd) params = tag_next (params); } -#ifdef CONFIG_BOOTTIME -static void setup_boottime_tags(void) -{ - if(!boottime_ticks_uboot_init) - printf("Warning: uboot init time not tracked\n"); - if(!boottime_ticks_load_kernel) - printf("Warning: load kernel time not tracked\n"); - if(!boottime_ticks_uboot_done) - printf("Warning: uboot done time not tracked\n"); - - params->hdr.tag = ATAG_BOOTTIME_UBOOT_INIT; - params->hdr.size = tag_size (tag_boottime); - params->u.boottime.tick = boottime_ticks_uboot_init; - params = tag_next (params); - - params->hdr.tag = ATAG_BOOTTIME_LOAD_KERNEL; - params->hdr.size = tag_size (tag_boottime); - params->u.boottime.tick = boottime_ticks_load_kernel; - params = tag_next (params); - - params->hdr.tag = ATAG_BOOTTIME_UBOOT_DONE; - params->hdr.size = tag_size (tag_boottime); - params->u.boottime.tick = boottime_ticks_uboot_done; - params = tag_next (params); - -} -#endif #ifdef CONFIG_SETUP_MEMORY_TAGS static void setup_memory_tags (bd_t *bd) @@ -213,6 +184,36 @@ static void setup_memory_tags (bd_t *bd) } #endif /* CONFIG_SETUP_MEMORY_TAGS */ +#ifdef CONFIG_BOOTTIME +static void setup_boottime_tags(void) +{ + unsigned int i; + struct boottime_entry *b; + + params->hdr.tag = ATAG_BOOTTIME; + params->hdr.size = tag_size(tag_boottime); + + params->u.boottime.idle = boottime_idle_get(); + params->u.boottime.total = boottime_idle_done(); + + for (i = 0; i < BOOTTIME_MAX; i++) { + b = boottime_get_entry(i); + if (b == NULL) + break; + + params->u.boottime.entry[i].tick = b->tick; + strncpy((char *)params->u.boottime.entry[i].name, + (char *)b->name, BOOTTIME_MAX_NAME_LEN); + params->u.boottime.entry[i].name[BOOTTIME_MAX_NAME_LEN - 1] = '\0'; + + } + + params->u.boottime.num = i; + + params = tag_next(params); + +} +#endif static void setup_commandline_tag (bd_t *bd, char *commandline) { diff --git a/lib_arm/boottime.c b/lib_arm/boottime.c new file mode 100644 index 000000000..3c84bb3e3 --- /dev/null +++ b/lib_arm/boottime.c @@ -0,0 +1,83 @@ +/* + * (C) Copyright 2009 ST-Ericsson AB + * Jonas Aaberg + * + * 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 + * + */ + + +#include +#include +#include +#include + +#ifdef CONFIG_BOOTTIME +ulong get_raw_timer(void); + +static struct tag_boottime boottime; + +int boottime_tag(char *name) +{ + if (boottime.num == BOOTTIME_MAX) { + printf("boottime: out of entries!\n"); + return -1; + } + + strncpy((char *)boottime.entry[boottime.num].name, + name, + BOOTTIME_MAX_NAME_LEN); + boottime.entry[boottime.num].name[BOOTTIME_MAX_NAME_LEN - 1] = '\0'; + boottime.entry[boottime.num].tick = get_raw_timer(); + + boottime.num++; + return 0; +} + + +struct boottime_entry *boottime_get_entry(unsigned int i) +{ + if (i >= boottime.num) + return NULL; + else + return &boottime.entry[i]; +} + + +void boottime_idle_add(ulong i) +{ + boottime.idle += i; +} + +ulong boottime_idle_done(void) +{ + return get_raw_timer(); +} + +ulong boottime_idle_get(void) +{ + return boottime.idle; +} + +void boottime_remove_last(void) +{ + if (boottime.num > 0) + boottime.num--; +} +#endif + + + + -- cgit v1.2.3