Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
2013-07-17 02:47:35 +02:00
|
|
|
* Copyright 2012 Google Inc.
|
2015-09-06 01:07:17 +02:00
|
|
|
* Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
*
|
|
|
|
* 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; version 2 of the License.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2013-05-26 18:17:54 +02:00
|
|
|
#include <inttypes.h>
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2013-01-03 00:43:56 +01:00
|
|
|
#include <unistd.h>
|
2013-04-19 23:22:29 +02:00
|
|
|
#include <inttypes.h>
|
2013-01-03 00:43:56 +01:00
|
|
|
#include <getopt.h>
|
2014-06-17 08:02:03 +02:00
|
|
|
#include <dirent.h>
|
2013-01-03 23:30:33 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
2013-07-17 02:47:35 +02:00
|
|
|
#include <ctype.h>
|
2013-06-20 00:39:09 +02:00
|
|
|
#include <arpa/inet.h>
|
2013-01-03 23:30:33 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/mman.h>
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
#include <libgen.h>
|
|
|
|
#include <assert.h>
|
2017-04-29 01:31:46 +02:00
|
|
|
#include <regex.h>
|
2015-09-08 20:34:43 +02:00
|
|
|
#include <commonlib/cbmem_id.h>
|
|
|
|
#include <commonlib/timestamp_serialized.h>
|
|
|
|
#include <commonlib/coreboot_tables.h>
|
2013-01-03 23:30:33 +01:00
|
|
|
|
2015-07-13 16:53:50 +02:00
|
|
|
#ifdef __OpenBSD__
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#endif
|
|
|
|
|
2013-01-03 23:30:33 +01:00
|
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2014-06-17 08:02:03 +02:00
|
|
|
typedef uint8_t u8;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
typedef uint16_t u16;
|
|
|
|
typedef uint32_t u32;
|
|
|
|
typedef uint64_t u64;
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
/* Return < 0 on error, 0 on success. */
|
|
|
|
static int parse_cbtable(u64 address, size_t table_size);
|
|
|
|
|
|
|
|
struct mapping {
|
|
|
|
void *virt;
|
|
|
|
size_t offset;
|
|
|
|
size_t virt_size;
|
|
|
|
unsigned long long phys;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
2013-07-17 02:47:35 +02:00
|
|
|
#define CBMEM_VERSION "1.1"
|
2013-01-03 00:43:56 +01:00
|
|
|
|
2013-01-03 23:30:33 +01:00
|
|
|
/* verbose output? */
|
|
|
|
static int verbose = 0;
|
|
|
|
#define debug(x...) if(verbose) printf(x)
|
|
|
|
|
|
|
|
/* File handle used to access /dev/mem */
|
2014-06-17 08:02:03 +02:00
|
|
|
static int mem_fd;
|
2017-09-27 00:22:38 +02:00
|
|
|
static struct mapping lbtable_mapping;
|
|
|
|
|
|
|
|
static void die(const char *msg)
|
|
|
|
{
|
|
|
|
if (msg)
|
|
|
|
fputs(msg, stderr);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long long system_page_size(void)
|
|
|
|
{
|
|
|
|
static unsigned long long page_size;
|
|
|
|
|
|
|
|
if (!page_size)
|
|
|
|
page_size = getpagesize();
|
|
|
|
|
|
|
|
return page_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline size_t size_to_mib(size_t sz)
|
|
|
|
{
|
|
|
|
return sz >> 20;
|
|
|
|
}
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
/* Return mapping of physical address requested. */
|
|
|
|
static const void *mapping_virt(const struct mapping *mapping)
|
|
|
|
{
|
|
|
|
const char *v = mapping->virt;
|
|
|
|
|
|
|
|
if (v == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return v + mapping->offset;
|
|
|
|
}
|
|
|
|
|
2017-09-29 01:52:59 +02:00
|
|
|
/* Returns virtual address on success, NULL on error. mapping is filled in. */
|
2017-09-27 00:22:38 +02:00
|
|
|
static const void *map_memory(struct mapping *mapping, unsigned long long phys,
|
|
|
|
size_t sz)
|
|
|
|
{
|
|
|
|
void *v;
|
|
|
|
unsigned long long page_size;
|
|
|
|
|
|
|
|
page_size = system_page_size();
|
|
|
|
|
|
|
|
mapping->virt = NULL;
|
|
|
|
mapping->offset = phys % page_size;
|
|
|
|
mapping->virt_size = sz + mapping->offset;
|
|
|
|
mapping->size = sz;
|
|
|
|
mapping->phys = phys;
|
|
|
|
|
|
|
|
if (size_to_mib(mapping->virt_size) == 0) {
|
|
|
|
debug("Mapping %zuB of physical memory at 0x%llx (requested 0x%llx).\n",
|
|
|
|
mapping->virt_size, phys - mapping->offset, phys);
|
|
|
|
} else {
|
|
|
|
debug("Mapping %zuMB of physical memory at 0x%llx (requested 0x%llx).\n",
|
|
|
|
size_to_mib(mapping->virt_size), phys - mapping->offset,
|
|
|
|
phys);
|
|
|
|
}
|
|
|
|
|
|
|
|
v = mmap(NULL, mapping->virt_size, PROT_READ, MAP_SHARED, mem_fd,
|
|
|
|
phys - mapping->offset);
|
|
|
|
|
|
|
|
if (v == MAP_FAILED) {
|
|
|
|
debug("Mapping failed %zuB of physical memory at 0x%llx.\n",
|
|
|
|
mapping->virt_size, phys - mapping->offset);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mapping->virt = v;
|
|
|
|
|
|
|
|
if (mapping->offset != 0)
|
|
|
|
debug(" ... padding virtual address with 0x%zx bytes.\n",
|
|
|
|
mapping->offset);
|
|
|
|
|
|
|
|
return mapping_virt(mapping);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns 0 on success, < 0 on error. mapping is cleared if successful. */
|
|
|
|
static int unmap_memory(struct mapping *mapping)
|
|
|
|
{
|
|
|
|
if (mapping->virt == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
munmap(mapping->virt, mapping->virt_size);
|
|
|
|
mapping->virt = NULL;
|
|
|
|
mapping->offset = 0;
|
|
|
|
mapping->virt_size = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return size of physical address mapping requested. */
|
|
|
|
static size_t mapping_size(const struct mapping *mapping)
|
|
|
|
{
|
|
|
|
if (mapping->virt == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return mapping->size;
|
|
|
|
}
|
2015-05-16 21:55:54 +02:00
|
|
|
|
2017-02-03 21:50:03 +01:00
|
|
|
/*
|
|
|
|
* Some architectures map /dev/mem memory in a way that doesn't support
|
|
|
|
* unaligned accesses. Most normal libc memcpy()s aren't safe to use in this
|
|
|
|
* case, so build our own which makes sure to never do unaligned accesses on
|
|
|
|
* *src (*dest is fine since we never map /dev/mem for writing).
|
|
|
|
*/
|
|
|
|
static void *aligned_memcpy(void *dest, const void *src, size_t n)
|
|
|
|
{
|
|
|
|
u8 *d = dest;
|
|
|
|
const volatile u8 *s = src; /* volatile to prevent optimization */
|
|
|
|
|
|
|
|
while ((uintptr_t)s & (sizeof(size_t) - 1)) {
|
|
|
|
if (n-- == 0)
|
|
|
|
return dest;
|
|
|
|
*d++ = *s++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (n >= sizeof(size_t)) {
|
|
|
|
*(size_t *)d = *(const volatile size_t *)s;
|
|
|
|
d += sizeof(size_t);
|
|
|
|
s += sizeof(size_t);
|
|
|
|
n -= sizeof(size_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (n-- > 0)
|
|
|
|
*d++ = *s++;
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
/*
|
|
|
|
* calculate ip checksum (16 bit quantities) on a passed in buffer. In case
|
|
|
|
* the buffer length is odd last byte is excluded from the calculation
|
|
|
|
*/
|
|
|
|
static u16 ipchcksum(const void *addr, unsigned size)
|
|
|
|
{
|
|
|
|
const u16 *p = addr;
|
|
|
|
unsigned i, n = size / 2; /* don't expect odd sized blocks */
|
|
|
|
u32 sum = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
sum += p[i];
|
|
|
|
|
|
|
|
sum = (sum >> 16) + (sum & 0xffff);
|
|
|
|
sum += (sum >> 16);
|
|
|
|
sum = ~sum & 0xffff;
|
|
|
|
return (u16) sum;
|
|
|
|
}
|
|
|
|
|
2015-09-30 19:33:01 +02:00
|
|
|
/* Find the first cbmem entry filling in the details. */
|
|
|
|
static int find_cbmem_entry(uint32_t id, uint64_t *addr, size_t *size)
|
|
|
|
{
|
2017-09-27 01:44:28 +02:00
|
|
|
const uint8_t *table;
|
2015-09-30 19:33:01 +02:00
|
|
|
size_t offset;
|
|
|
|
int ret = -1;
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
table = mapping_virt(&lbtable_mapping);
|
2015-09-30 19:33:01 +02:00
|
|
|
|
|
|
|
if (table == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
while (offset < mapping_size(&lbtable_mapping)) {
|
2017-09-27 01:44:28 +02:00
|
|
|
const struct lb_record *lbr;
|
|
|
|
const struct lb_cbmem_entry *lbe;
|
2015-09-30 19:33:01 +02:00
|
|
|
|
2017-09-27 01:44:28 +02:00
|
|
|
lbr = (const void *)(table + offset);
|
2015-09-30 19:33:01 +02:00
|
|
|
offset += lbr->size;
|
|
|
|
|
|
|
|
if (lbr->tag != LB_TAG_CBMEM_ENTRY)
|
|
|
|
continue;
|
|
|
|
|
2017-09-27 01:44:28 +02:00
|
|
|
lbe = (const void *)lbr;
|
2015-09-30 19:33:01 +02:00
|
|
|
if (lbe->id != id)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*addr = lbe->address;
|
|
|
|
*size = lbe->entry_size;
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-01-03 23:30:33 +01:00
|
|
|
* Try finding the timestamp table and coreboot cbmem console starting from the
|
|
|
|
* passed in memory offset. Could be called recursively in case a forwarding
|
|
|
|
* entry is found.
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
*
|
|
|
|
* Returns pointer to a memory buffer containg the timestamp table or zero if
|
|
|
|
* none found.
|
|
|
|
*/
|
2013-01-03 23:30:33 +01:00
|
|
|
|
|
|
|
static struct lb_cbmem_ref timestamps;
|
|
|
|
static struct lb_cbmem_ref console;
|
2013-01-08 01:26:10 +01:00
|
|
|
static struct lb_memory_range cbmem;
|
2013-01-03 23:30:33 +01:00
|
|
|
|
2013-04-19 23:22:29 +02:00
|
|
|
/* This is a work-around for a nasty problem introduced by initially having
|
|
|
|
* pointer sized entries in the lb_cbmem_ref structures. This caused problems
|
|
|
|
* on 64bit x86 systems because coreboot is 32bit on those systems.
|
|
|
|
* When the problem was found, it was corrected, but there are a lot of
|
|
|
|
* systems out there with a firmware that does not produce the right
|
|
|
|
* lb_cbmem_ref structure. Hence we try to autocorrect this issue here.
|
|
|
|
*/
|
2017-09-27 01:44:28 +02:00
|
|
|
static struct lb_cbmem_ref parse_cbmem_ref(const struct lb_cbmem_ref *cbmem_ref)
|
2013-04-19 23:22:29 +02:00
|
|
|
{
|
|
|
|
struct lb_cbmem_ref ret;
|
|
|
|
|
|
|
|
ret = *cbmem_ref;
|
|
|
|
|
|
|
|
if (cbmem_ref->size < sizeof(*cbmem_ref))
|
|
|
|
ret.cbmem_addr = (uint32_t)ret.cbmem_addr;
|
|
|
|
|
2013-07-17 02:47:35 +02:00
|
|
|
debug(" cbmem_addr = %" PRIx64 "\n", ret.cbmem_addr);
|
|
|
|
|
2013-04-19 23:22:29 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
static void parse_memory_tags(const struct lb_memory *mem)
|
|
|
|
{
|
|
|
|
int num_entries;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Peel off the header size and calculate the number of entries. */
|
|
|
|
num_entries = (mem->size - sizeof(*mem)) / sizeof(mem->map[0]);
|
|
|
|
|
|
|
|
for (i = 0; i < num_entries; i++) {
|
|
|
|
if (mem->map[i].type != LB_MEM_TABLE)
|
|
|
|
continue;
|
|
|
|
debug(" LB_MEM_TABLE found.\n");
|
|
|
|
/* The last one found is CBMEM */
|
|
|
|
cbmem = mem->map[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return < 0 on error, 0 on success, 1 if forwarding table entry found. */
|
|
|
|
static int parse_cbtable_entries(const struct mapping *table_mapping)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
const struct lb_record* lbr_p;
|
|
|
|
size_t table_size = mapping_size(table_mapping);
|
|
|
|
const void *lbtable = mapping_virt(table_mapping);
|
|
|
|
int forwarding_table_found = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < table_size; i += lbr_p->size) {
|
|
|
|
lbr_p = lbtable + i;
|
|
|
|
debug(" coreboot table entry 0x%02x\n", lbr_p->tag);
|
|
|
|
switch (lbr_p->tag) {
|
|
|
|
case LB_TAG_MEMORY:
|
|
|
|
debug(" Found memory map.\n");
|
|
|
|
parse_memory_tags(lbtable + i);
|
|
|
|
continue;
|
|
|
|
case LB_TAG_TIMESTAMPS: {
|
|
|
|
debug(" Found timestamp table.\n");
|
|
|
|
timestamps = parse_cbmem_ref((struct lb_cbmem_ref *) lbr_p);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case LB_TAG_CBMEM_CONSOLE: {
|
|
|
|
debug(" Found cbmem console.\n");
|
|
|
|
console = parse_cbmem_ref((struct lb_cbmem_ref *) lbr_p);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
case LB_TAG_FORWARD: {
|
|
|
|
int ret;
|
|
|
|
/*
|
|
|
|
* This is a forwarding entry - repeat the
|
|
|
|
* search at the new address.
|
|
|
|
*/
|
|
|
|
struct lb_forward lbf_p =
|
|
|
|
*(const struct lb_forward *) lbr_p;
|
|
|
|
debug(" Found forwarding entry.\n");
|
|
|
|
ret = parse_cbtable(lbf_p.forward, 0);
|
|
|
|
|
|
|
|
/* Assume the forwarding entry is valid. If this fails
|
|
|
|
* then there's a total failure. */
|
|
|
|
if (ret < 0)
|
|
|
|
return -1;
|
|
|
|
forwarding_table_found = 1;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return forwarding_table_found;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return < 0 on error, 0 on success. */
|
|
|
|
static int parse_cbtable(u64 address, size_t table_size)
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
{
|
2017-09-27 01:44:28 +02:00
|
|
|
const void *buf;
|
2017-09-27 00:22:38 +02:00
|
|
|
struct mapping header_mapping;
|
|
|
|
size_t req_size;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
req_size = table_size;
|
|
|
|
/* Default to 4 KiB search space. */
|
|
|
|
if (req_size == 0)
|
|
|
|
req_size = 4 * 1024;
|
2013-01-03 23:30:33 +01:00
|
|
|
|
2014-10-07 21:56:35 +02:00
|
|
|
debug("Looking for coreboot table at %" PRIx64 " %zd bytes.\n",
|
2017-09-27 00:22:38 +02:00
|
|
|
address, req_size);
|
|
|
|
|
|
|
|
buf = map_memory(&header_mapping, address, req_size);
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
if (!buf)
|
|
|
|
return -1;
|
2013-01-03 23:30:33 +01:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
/* look at every 16 bytes */
|
2017-09-29 01:52:59 +02:00
|
|
|
for (i = 0; i <= req_size - sizeof(struct lb_header); i += 16) {
|
2017-09-27 00:22:38 +02:00
|
|
|
int ret;
|
2017-09-27 01:44:28 +02:00
|
|
|
const struct lb_header *lbh;
|
2017-09-27 00:22:38 +02:00
|
|
|
struct mapping table_mapping;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
lbh = buf + i;
|
2013-01-03 23:30:33 +01:00
|
|
|
if (memcmp(lbh->signature, "LBIO", sizeof(lbh->signature)) ||
|
|
|
|
!lbh->header_bytes ||
|
|
|
|
ipchcksum(lbh, sizeof(*lbh))) {
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
/* Map in the whole table to parse. */
|
|
|
|
if (!map_memory(&table_mapping, address + i + lbh->header_bytes,
|
|
|
|
lbh->table_bytes)) {
|
|
|
|
debug("Couldn't map in table\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ipchcksum(mapping_virt(&table_mapping), lbh->table_bytes) !=
|
2013-01-03 23:30:33 +01:00
|
|
|
lbh->table_checksum) {
|
|
|
|
debug("Signature found, but wrong checksum.\n");
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(&table_mapping);
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-01-03 23:30:33 +01:00
|
|
|
debug("Found!\n");
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
ret = parse_cbtable_entries(&table_mapping);
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
/* Table parsing failed. */
|
|
|
|
if (ret < 0) {
|
|
|
|
unmap_memory(&table_mapping);
|
|
|
|
continue;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
}
|
2017-09-27 00:22:38 +02:00
|
|
|
|
|
|
|
/* Succeeded in parsing the table. Header not needed anymore. */
|
|
|
|
unmap_memory(&header_mapping);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Table parsing succeeded. If forwarding table not found update
|
|
|
|
* coreboot table mapping for future use.
|
|
|
|
*/
|
|
|
|
if (ret == 0)
|
|
|
|
lbtable_mapping = table_mapping;
|
|
|
|
else
|
|
|
|
unmap_memory(&table_mapping);
|
|
|
|
|
|
|
|
return 0;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
}
|
2013-01-03 23:30:33 +01:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(&header_mapping);
|
|
|
|
|
|
|
|
return -1;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
}
|
|
|
|
|
2015-07-13 16:53:50 +02:00
|
|
|
#if defined(linux) && (defined(__i386__) || defined(__x86_64__))
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
/*
|
util/cbmem: Scale time stamp values correctly
Commit c49014e (timestamp: add tick frequency to exported table)
refactors the code, but forgets to correctly scale the frequency to
megahertz, where the value is read from sysfs, so that printing time
stamp information shows milliseconds instead of microseconds, as can be
seen on the output `cbmem -t` for the ASRock E350M1 below.
```
0:1st timestamp 515
10:start of ramstage 515 (0)
30:device enumeration 515 (0)
40:device configuration 610 (94)
50:device enable 614 (4)
60:device initialization 624 (9)
70:device setup done 639 (14)
75:cbmem post 844 (205)
80:write tables 844 (0)
90:load payload 849 (4)
15:starting LZMA decompress (ignore for x86) 849 (0)
16:finished LZMA decompress (ignore for x86) 869 (20)
99:selfboot jump 869 (0)
Total Time: 350
```
So scale the return value correctly to megahertz, by dividing it with
1000.
```
0:1st timestamp 515,655
10:start of ramstage 515,655 (0)
30:device enumeration 515,663 (7)
40:device configuration 610,620 (94,957)
50:device enable 614,680 (4,059)
60:device initialization 624,618 (9,938)
70:device setup done 639,553 (14,934)
75:cbmem post 844,707 (205,154)
80:write tables 844,710 (2)
90:load payload 849,532 (4,821)
15:starting LZMA decompress (ignore for x86) 849,655 (123)
16:finished LZMA decompress (ignore for x86) 869,903 (20,247)
99:selfboot jump 869,922 (19)
Total Time: 354,261
```
Change-Id: Iea032c62487c7946b6194a90268755034c6350df
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-on: https://review.coreboot.org/14086
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
2016-03-12 08:41:34 +01:00
|
|
|
* read CPU frequency from a sysfs file, return an frequency in Megahertz as
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
* an int or exit on any error.
|
|
|
|
*/
|
2015-08-31 04:19:55 +02:00
|
|
|
static unsigned long arch_tick_frequency(void)
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
{
|
|
|
|
FILE *cpuf;
|
|
|
|
char freqs[100];
|
|
|
|
int size;
|
|
|
|
char *endp;
|
|
|
|
u64 rv;
|
|
|
|
|
|
|
|
const char* freq_file =
|
|
|
|
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq";
|
|
|
|
|
|
|
|
cpuf = fopen(freq_file, "r");
|
|
|
|
if (!cpuf) {
|
2013-01-03 23:30:33 +01:00
|
|
|
fprintf(stderr, "Could not open %s: %s\n",
|
|
|
|
freq_file, strerror(errno));
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(freqs, 0, sizeof(freqs));
|
|
|
|
size = fread(freqs, 1, sizeof(freqs), cpuf);
|
|
|
|
if (!size || (size == sizeof(freqs))) {
|
|
|
|
fprintf(stderr, "Wrong number of bytes(%d) read from %s\n",
|
|
|
|
size, freq_file);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
fclose(cpuf);
|
|
|
|
rv = strtoull(freqs, &endp, 10);
|
|
|
|
|
|
|
|
if (*endp == '\0' || *endp == '\n')
|
util/cbmem: Scale time stamp values correctly
Commit c49014e (timestamp: add tick frequency to exported table)
refactors the code, but forgets to correctly scale the frequency to
megahertz, where the value is read from sysfs, so that printing time
stamp information shows milliseconds instead of microseconds, as can be
seen on the output `cbmem -t` for the ASRock E350M1 below.
```
0:1st timestamp 515
10:start of ramstage 515 (0)
30:device enumeration 515 (0)
40:device configuration 610 (94)
50:device enable 614 (4)
60:device initialization 624 (9)
70:device setup done 639 (14)
75:cbmem post 844 (205)
80:write tables 844 (0)
90:load payload 849 (4)
15:starting LZMA decompress (ignore for x86) 849 (0)
16:finished LZMA decompress (ignore for x86) 869 (20)
99:selfboot jump 869 (0)
Total Time: 350
```
So scale the return value correctly to megahertz, by dividing it with
1000.
```
0:1st timestamp 515,655
10:start of ramstage 515,655 (0)
30:device enumeration 515,663 (7)
40:device configuration 610,620 (94,957)
50:device enable 614,680 (4,059)
60:device initialization 624,618 (9,938)
70:device setup done 639,553 (14,934)
75:cbmem post 844,707 (205,154)
80:write tables 844,710 (2)
90:load payload 849,532 (4,821)
15:starting LZMA decompress (ignore for x86) 849,655 (123)
16:finished LZMA decompress (ignore for x86) 869,903 (20,247)
99:selfboot jump 869,922 (19)
Total Time: 354,261
```
Change-Id: Iea032c62487c7946b6194a90268755034c6350df
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-on: https://review.coreboot.org/14086
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
2016-03-12 08:41:34 +01:00
|
|
|
/* cpuinfo_max_freq is in kHz. Convert it to MHz. */
|
|
|
|
return rv / 1000;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
fprintf(stderr, "Wrong formatted value ^%s^ read from %s\n",
|
|
|
|
freqs, freq_file);
|
|
|
|
exit(1);
|
|
|
|
}
|
2015-07-13 16:53:50 +02:00
|
|
|
#elif defined(__OpenBSD__) && (defined(__i386__) || defined(__x86_64__))
|
2015-08-31 04:19:55 +02:00
|
|
|
static unsigned long arch_tick_frequency(void)
|
2015-07-13 16:53:50 +02:00
|
|
|
{
|
|
|
|
int mib[2] = { CTL_HW, HW_CPUSPEED };
|
|
|
|
static int value = 0;
|
|
|
|
size_t value_len = sizeof(value);
|
|
|
|
|
2015-08-31 04:19:55 +02:00
|
|
|
/* Return 1 MHz when sysctl fails. */
|
2015-07-13 16:53:50 +02:00
|
|
|
if ((value == 0) && (sysctl(mib, 2, &value, &value_len, NULL, 0) == -1))
|
2015-08-31 04:19:55 +02:00
|
|
|
return 1;
|
2015-07-13 16:53:50 +02:00
|
|
|
|
2015-08-31 04:19:55 +02:00
|
|
|
return value;
|
2015-07-13 16:53:50 +02:00
|
|
|
}
|
2013-08-01 00:44:37 +02:00
|
|
|
#else
|
2015-08-31 04:19:55 +02:00
|
|
|
static unsigned long arch_tick_frequency(void)
|
|
|
|
{
|
|
|
|
/* 1 MHz = 1us. */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static unsigned long tick_freq_mhz;
|
|
|
|
|
|
|
|
static void timestamp_set_tick_freq(unsigned long table_tick_freq_mhz)
|
|
|
|
{
|
|
|
|
tick_freq_mhz = table_tick_freq_mhz;
|
|
|
|
|
2017-12-11 21:27:56 +01:00
|
|
|
/* Honor table frequency if present. */
|
|
|
|
if (!tick_freq_mhz)
|
|
|
|
tick_freq_mhz = arch_tick_frequency();
|
2015-08-31 04:19:55 +02:00
|
|
|
|
|
|
|
if (!tick_freq_mhz) {
|
|
|
|
fprintf(stderr, "Cannot determine timestamp tick frequency.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2017-12-11 21:27:56 +01:00
|
|
|
|
|
|
|
debug("Timestamp tick frequency: %ld MHz\n", tick_freq_mhz);
|
2015-08-31 04:19:55 +02:00
|
|
|
}
|
2013-08-01 00:44:37 +02:00
|
|
|
|
|
|
|
u64 arch_convert_raw_ts_entry(u64 ts)
|
|
|
|
{
|
2015-08-31 04:19:55 +02:00
|
|
|
return ts / tick_freq_mhz;
|
2013-08-01 00:44:37 +02:00
|
|
|
}
|
|
|
|
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
/*
|
|
|
|
* Print an integer in 'normalized' form - with commas separating every three
|
2014-12-03 05:51:19 +01:00
|
|
|
* decimal orders.
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
*/
|
2014-12-03 05:51:19 +01:00
|
|
|
static void print_norm(u64 v)
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
{
|
2014-12-03 05:51:19 +01:00
|
|
|
if (v >= 1000) {
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
/* print the higher order sections first */
|
2014-12-03 05:51:19 +01:00
|
|
|
print_norm(v / 1000);
|
|
|
|
printf(",%3.3u", (u32)(v % 1000));
|
|
|
|
} else {
|
|
|
|
printf("%u", (u32)(v % 1000));
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-31 05:00:12 +02:00
|
|
|
static const char *timestamp_name(uint32_t id)
|
2013-08-09 20:06:11 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(timestamp_ids); i++) {
|
2015-08-31 05:00:12 +02:00
|
|
|
if (timestamp_ids[i].id == id)
|
|
|
|
return timestamp_ids[i].name;
|
2013-08-09 20:06:11 +02:00
|
|
|
}
|
2015-08-31 05:00:12 +02:00
|
|
|
return "<unknown>";
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t timestamp_print_parseable_entry(uint32_t id, uint64_t stamp,
|
|
|
|
uint64_t prev_stamp)
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
uint64_t step_time;
|
|
|
|
|
|
|
|
name = timestamp_name(id);
|
|
|
|
|
|
|
|
step_time = arch_convert_raw_ts_entry(stamp - prev_stamp);
|
|
|
|
|
|
|
|
/* ID<tab>absolute time<tab>relative time<tab>description */
|
|
|
|
printf("%d\t", id);
|
|
|
|
printf("%llu\t", (long long)arch_convert_raw_ts_entry(stamp));
|
|
|
|
printf("%llu\t", (long long)step_time);
|
|
|
|
printf("%s\n", name);
|
|
|
|
|
|
|
|
return step_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t timestamp_print_entry(uint32_t id, uint64_t stamp, uint64_t prev_stamp)
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
uint64_t step_time;
|
|
|
|
|
|
|
|
name = timestamp_name(id);
|
2013-08-09 20:06:11 +02:00
|
|
|
|
|
|
|
printf("%4d:", id);
|
2014-12-03 05:51:19 +01:00
|
|
|
printf("%-50s", name);
|
|
|
|
print_norm(arch_convert_raw_ts_entry(stamp));
|
2015-08-06 20:52:08 +02:00
|
|
|
step_time = arch_convert_raw_ts_entry(stamp - prev_stamp);
|
2013-08-09 20:06:11 +02:00
|
|
|
if (prev_stamp) {
|
|
|
|
printf(" (");
|
2015-08-06 20:52:08 +02:00
|
|
|
print_norm(step_time);
|
2013-08-09 20:06:11 +02:00
|
|
|
printf(")");
|
|
|
|
}
|
|
|
|
printf("\n");
|
2015-08-06 20:52:08 +02:00
|
|
|
|
|
|
|
return step_time;
|
2013-08-09 20:06:11 +02:00
|
|
|
}
|
|
|
|
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
/* dump the timestamp table */
|
2015-08-31 05:00:12 +02:00
|
|
|
static void dump_timestamps(int mach_readable)
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
{
|
|
|
|
int i;
|
2017-09-27 01:44:28 +02:00
|
|
|
const struct timestamp_table *tst_p;
|
2014-10-07 21:56:35 +02:00
|
|
|
size_t size;
|
2015-07-11 19:44:10 +02:00
|
|
|
uint64_t prev_stamp;
|
2015-08-06 20:52:08 +02:00
|
|
|
uint64_t total_time;
|
2017-09-27 00:22:38 +02:00
|
|
|
struct mapping timestamp_mapping;
|
2013-01-03 23:30:33 +01:00
|
|
|
|
|
|
|
if (timestamps.tag != LB_TAG_TIMESTAMPS) {
|
|
|
|
fprintf(stderr, "No timestamps found in coreboot table.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-07 21:56:35 +02:00
|
|
|
size = sizeof(*tst_p);
|
2017-09-27 00:22:38 +02:00
|
|
|
tst_p = map_memory(×tamp_mapping, timestamps.cbmem_addr, size);
|
|
|
|
if (!tst_p)
|
|
|
|
die("Unable to map timestamp header\n");
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2015-08-31 04:19:55 +02:00
|
|
|
timestamp_set_tick_freq(tst_p->tick_freq_mhz);
|
|
|
|
|
2015-08-31 05:00:12 +02:00
|
|
|
if (!mach_readable)
|
|
|
|
printf("%d entries total:\n\n", tst_p->num_entries);
|
2014-10-07 21:56:35 +02:00
|
|
|
size += tst_p->num_entries * sizeof(tst_p->entries[0]);
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(×tamp_mapping);
|
|
|
|
|
|
|
|
tst_p = map_memory(×tamp_mapping, timestamps.cbmem_addr, size);
|
|
|
|
if (!tst_p)
|
|
|
|
die("Unable to map full timestamp table\n");
|
2014-10-07 21:56:35 +02:00
|
|
|
|
2015-07-11 19:44:10 +02:00
|
|
|
/* Report the base time within the table. */
|
|
|
|
prev_stamp = 0;
|
2015-08-31 05:00:12 +02:00
|
|
|
if (mach_readable)
|
|
|
|
timestamp_print_parseable_entry(0, tst_p->base_time,
|
|
|
|
prev_stamp);
|
|
|
|
else
|
|
|
|
timestamp_print_entry(0, tst_p->base_time, prev_stamp);
|
2015-07-11 19:44:10 +02:00
|
|
|
prev_stamp = tst_p->base_time;
|
|
|
|
|
2015-08-06 20:52:08 +02:00
|
|
|
total_time = 0;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
for (i = 0; i < tst_p->num_entries; i++) {
|
2015-07-11 19:44:10 +02:00
|
|
|
uint64_t stamp;
|
|
|
|
const struct timestamp_entry *tse = &tst_p->entries[i];
|
|
|
|
|
|
|
|
/* Make all timestamps absolute. */
|
|
|
|
stamp = tse->entry_stamp + tst_p->base_time;
|
2015-08-31 05:00:12 +02:00
|
|
|
if (mach_readable)
|
|
|
|
total_time +=
|
|
|
|
timestamp_print_parseable_entry(tse->entry_id,
|
|
|
|
stamp, prev_stamp);
|
|
|
|
else
|
|
|
|
total_time += timestamp_print_entry(tse->entry_id,
|
2015-08-06 20:52:08 +02:00
|
|
|
stamp, prev_stamp);
|
2015-07-11 19:44:10 +02:00
|
|
|
prev_stamp = stamp;
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
}
|
2013-01-03 23:30:33 +01:00
|
|
|
|
2015-08-31 05:00:12 +02:00
|
|
|
if (!mach_readable) {
|
|
|
|
printf("\nTotal Time: ");
|
|
|
|
print_norm(total_time);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2015-08-06 20:52:08 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(×tamp_mapping);
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
}
|
|
|
|
|
2017-02-03 02:32:00 +01:00
|
|
|
struct cbmem_console {
|
|
|
|
u32 size;
|
|
|
|
u32 cursor;
|
|
|
|
u8 body[0];
|
|
|
|
} __attribute__ ((__packed__));
|
|
|
|
|
|
|
|
#define CBMC_CURSOR_MASK ((1 << 28) - 1)
|
|
|
|
#define CBMC_OVERFLOW (1 << 31)
|
|
|
|
|
2013-01-07 22:37:12 +01:00
|
|
|
/* dump the cbmem console */
|
2017-04-29 01:31:46 +02:00
|
|
|
static void dump_console(int one_boot_only)
|
2013-01-07 22:37:12 +01:00
|
|
|
{
|
2017-09-27 01:44:28 +02:00
|
|
|
const struct cbmem_console *console_p;
|
2013-01-07 22:37:12 +01:00
|
|
|
char *console_c;
|
2017-02-03 02:32:00 +01:00
|
|
|
size_t size, cursor;
|
2017-09-27 00:22:38 +02:00
|
|
|
struct mapping console_mapping;
|
2013-01-07 22:37:12 +01:00
|
|
|
|
|
|
|
if (console.tag != LB_TAG_CBMEM_CONSOLE) {
|
|
|
|
fprintf(stderr, "No console found in coreboot table.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-03 02:32:00 +01:00
|
|
|
size = sizeof(*console_p);
|
2017-09-27 00:22:38 +02:00
|
|
|
console_p = map_memory(&console_mapping, console.cbmem_addr, size);
|
|
|
|
if (!console_p)
|
|
|
|
die("Unable to map console object.\n");
|
|
|
|
|
2017-02-03 02:32:00 +01:00
|
|
|
cursor = console_p->cursor & CBMC_CURSOR_MASK;
|
|
|
|
if (!(console_p->cursor & CBMC_OVERFLOW) && cursor < console_p->size)
|
2013-03-30 12:15:12 +01:00
|
|
|
size = cursor;
|
2017-02-03 02:32:00 +01:00
|
|
|
else
|
|
|
|
size = console_p->size;
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(&console_mapping);
|
2017-02-03 02:32:00 +01:00
|
|
|
|
|
|
|
console_c = malloc(size + 1);
|
2013-01-07 22:37:12 +01:00
|
|
|
if (!console_c) {
|
|
|
|
fprintf(stderr, "Not enough memory for console.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2017-02-03 02:32:00 +01:00
|
|
|
console_c[size] = '\0';
|
2013-01-07 22:37:12 +01:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
console_p = map_memory(&console_mapping, console.cbmem_addr,
|
|
|
|
size + sizeof(*console_p));
|
|
|
|
|
|
|
|
if (!console_p)
|
|
|
|
die("Unable to map full console object.\n");
|
|
|
|
|
2017-02-03 02:32:00 +01:00
|
|
|
if (console_p->cursor & CBMC_OVERFLOW) {
|
|
|
|
if (cursor >= size) {
|
|
|
|
printf("cbmem: ERROR: CBMEM console struct is illegal, "
|
|
|
|
"output may be corrupt or out of order!\n\n");
|
|
|
|
cursor = 0;
|
|
|
|
}
|
|
|
|
aligned_memcpy(console_c, console_p->body + cursor,
|
|
|
|
size - cursor);
|
|
|
|
aligned_memcpy(console_c + size - cursor,
|
|
|
|
console_p->body, cursor);
|
|
|
|
} else {
|
|
|
|
aligned_memcpy(console_c, console_p->body, size);
|
|
|
|
}
|
2013-01-07 22:37:12 +01:00
|
|
|
|
2017-02-03 02:32:00 +01:00
|
|
|
/* Slight memory corruption may occur between reboots and give us a few
|
|
|
|
unprintable characters like '\0'. Replace them with '?' on output. */
|
|
|
|
for (cursor = 0; cursor < size; cursor++)
|
|
|
|
if (!isprint(console_c[cursor]) && !isspace(console_c[cursor]))
|
|
|
|
console_c[cursor] = '?';
|
2013-01-07 22:37:12 +01:00
|
|
|
|
2017-04-29 01:31:46 +02:00
|
|
|
/* We detect the last boot by looking for a bootblock, romstage or
|
|
|
|
ramstage banner, in that order (to account for platforms without
|
|
|
|
CONFIG_BOOTBLOCK_CONSOLE and/or CONFIG_EARLY_CONSOLE). Once we find
|
|
|
|
a banner, store the last match for that stage in cursor and stop. */
|
|
|
|
cursor = 0;
|
|
|
|
if (one_boot_only) {
|
|
|
|
#define BANNER_REGEX(stage) "\n\ncoreboot-[^\n]* " stage " starting\\.\\.\\.\n"
|
2017-06-13 02:35:15 +02:00
|
|
|
#define OVERFLOW_REGEX(stage) "\n\\*\\*\\* Pre-CBMEM " stage " console overflow"
|
2017-04-29 01:31:46 +02:00
|
|
|
const char *regex[] = { BANNER_REGEX("bootblock"),
|
2017-05-16 22:54:18 +02:00
|
|
|
OVERFLOW_REGEX("romstage"),
|
2018-02-17 01:12:02 +01:00
|
|
|
BANNER_REGEX("romstage"),
|
|
|
|
OVERFLOW_REGEX("ramstage"),
|
|
|
|
BANNER_REGEX("ramstage") };
|
2017-04-29 01:31:46 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; !cursor && i < ARRAY_SIZE(regex); i++) {
|
|
|
|
regex_t re;
|
|
|
|
regmatch_t match;
|
|
|
|
assert(!regcomp(&re, regex[i], 0));
|
|
|
|
|
|
|
|
/* Keep looking for matches so we find the last one. */
|
|
|
|
while (!regexec(&re, console_c + cursor, 1, &match, 0))
|
|
|
|
cursor += match.rm_so + 1;
|
|
|
|
regfree(&re);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
puts(console_c + cursor);
|
2013-01-07 22:37:12 +01:00
|
|
|
free(console_c);
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(&console_mapping);
|
2013-01-07 22:37:12 +01:00
|
|
|
}
|
|
|
|
|
2013-07-17 02:47:35 +02:00
|
|
|
static void hexdump(unsigned long memory, int length)
|
|
|
|
{
|
|
|
|
int i;
|
2017-09-27 01:44:28 +02:00
|
|
|
const uint8_t *m;
|
2013-07-17 02:47:35 +02:00
|
|
|
int all_zero = 0;
|
2017-09-27 00:22:38 +02:00
|
|
|
struct mapping hexdump_mapping;
|
2013-07-17 02:47:35 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
m = map_memory(&hexdump_mapping, memory, length);
|
|
|
|
if (!m)
|
|
|
|
die("Unable to map hexdump memory.\n");
|
2013-07-17 02:47:35 +02:00
|
|
|
|
|
|
|
for (i = 0; i < length; i += 16) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
all_zero++;
|
|
|
|
for (j = 0; j < 16; j++) {
|
|
|
|
if(m[i+j] != 0) {
|
|
|
|
all_zero = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (all_zero < 2) {
|
|
|
|
printf("%08lx:", memory + i);
|
|
|
|
for (j = 0; j < 16; j++)
|
|
|
|
printf(" %02x", m[i+j]);
|
|
|
|
printf(" ");
|
|
|
|
for (j = 0; j < 16; j++)
|
|
|
|
printf("%c", isprint(m[i+j]) ? m[i+j] : '.');
|
|
|
|
printf("\n");
|
|
|
|
} else if (all_zero == 2) {
|
|
|
|
printf("...\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(&hexdump_mapping);
|
2013-07-17 02:47:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_cbmem_hex(void)
|
|
|
|
{
|
|
|
|
if (cbmem.type != LB_MEM_TABLE) {
|
|
|
|
fprintf(stderr, "No coreboot CBMEM area found!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hexdump(unpack_lb64(cbmem.start), unpack_lb64(cbmem.size));
|
|
|
|
}
|
|
|
|
|
2015-09-03 21:58:44 +02:00
|
|
|
void rawdump(uint64_t base, uint64_t size)
|
|
|
|
{
|
|
|
|
int i;
|
2017-09-27 01:44:28 +02:00
|
|
|
const uint8_t *m;
|
2017-09-27 00:22:38 +02:00
|
|
|
struct mapping dump_mapping;
|
2015-09-03 21:58:44 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
m = map_memory(&dump_mapping, base, size);
|
|
|
|
if (!m)
|
|
|
|
die("Unable to map rawdump memory\n");
|
2015-09-03 21:58:44 +02:00
|
|
|
|
|
|
|
for (i = 0 ; i < size; i++)
|
|
|
|
printf("%c", m[i]);
|
2017-09-27 00:22:38 +02:00
|
|
|
|
|
|
|
unmap_memory(&dump_mapping);
|
2015-09-03 21:58:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_cbmem_raw(unsigned int id)
|
|
|
|
{
|
2017-09-27 01:44:28 +02:00
|
|
|
const uint8_t *table;
|
2015-09-03 21:58:44 +02:00
|
|
|
size_t offset;
|
|
|
|
uint64_t base = 0;
|
|
|
|
uint64_t size = 0;
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
table = mapping_virt(&lbtable_mapping);
|
2015-09-03 21:58:44 +02:00
|
|
|
|
|
|
|
if (table == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
while (offset < mapping_size(&lbtable_mapping)) {
|
2017-09-27 01:44:28 +02:00
|
|
|
const struct lb_record *lbr;
|
|
|
|
const struct lb_cbmem_entry *lbe;
|
2015-09-03 21:58:44 +02:00
|
|
|
|
2017-09-27 01:44:28 +02:00
|
|
|
lbr = (const void *)(table + offset);
|
2015-09-03 21:58:44 +02:00
|
|
|
offset += lbr->size;
|
|
|
|
|
|
|
|
if (lbr->tag != LB_TAG_CBMEM_ENTRY)
|
|
|
|
continue;
|
|
|
|
|
2017-09-27 01:44:28 +02:00
|
|
|
lbe = (const void *)lbr;
|
2015-09-03 21:58:44 +02:00
|
|
|
if (lbe->id == id) {
|
|
|
|
debug("found id for raw dump %0x", lbe->id);
|
|
|
|
base = lbe->address;
|
|
|
|
size = lbe->entry_size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!base)
|
|
|
|
fprintf(stderr, "id %0x not found in cbtable\n", id);
|
|
|
|
else
|
|
|
|
rawdump(base, size);
|
|
|
|
}
|
|
|
|
|
2015-03-06 04:18:33 +01:00
|
|
|
struct cbmem_id_to_name {
|
|
|
|
uint32_t id;
|
|
|
|
const char *name;
|
|
|
|
};
|
2014-05-14 19:12:55 +02:00
|
|
|
static const struct cbmem_id_to_name cbmem_ids[] = { CBMEM_ID_TO_NAME_TABLE };
|
2013-01-08 01:26:10 +01:00
|
|
|
|
2017-09-04 10:10:17 +02:00
|
|
|
#define MAX_STAGEx 10
|
2013-07-17 02:47:35 +02:00
|
|
|
void cbmem_print_entry(int n, uint32_t id, uint64_t base, uint64_t size)
|
2013-01-08 01:26:10 +01:00
|
|
|
{
|
|
|
|
int i;
|
2013-07-17 02:47:35 +02:00
|
|
|
const char *name;
|
2017-09-04 10:10:17 +02:00
|
|
|
char stage_x[20];
|
2013-01-08 01:26:10 +01:00
|
|
|
|
2013-07-17 02:47:35 +02:00
|
|
|
name = NULL;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(cbmem_ids); i++) {
|
|
|
|
if (cbmem_ids[i].id == id) {
|
|
|
|
name = cbmem_ids[i].name;
|
|
|
|
break;
|
|
|
|
}
|
2017-09-04 10:10:17 +02:00
|
|
|
if (id >= CBMEM_ID_STAGEx_META &&
|
|
|
|
id < CBMEM_ID_STAGEx_META + MAX_STAGEx) {
|
|
|
|
snprintf(stage_x, sizeof(stage_x), "STAGE%d META",
|
|
|
|
(id - CBMEM_ID_STAGEx_META));
|
|
|
|
name = stage_x;
|
|
|
|
}
|
|
|
|
if (id >= CBMEM_ID_STAGEx_CACHE &&
|
|
|
|
id < CBMEM_ID_STAGEx_CACHE + MAX_STAGEx) {
|
|
|
|
snprintf(stage_x, sizeof(stage_x), "STAGE%d $ ",
|
|
|
|
(id - CBMEM_ID_STAGEx_CACHE));
|
|
|
|
name = stage_x;
|
|
|
|
}
|
2013-01-08 01:26:10 +01:00
|
|
|
}
|
|
|
|
|
2013-07-17 02:47:35 +02:00
|
|
|
printf("%2d. ", n);
|
|
|
|
if (name == NULL)
|
2017-09-04 10:10:17 +02:00
|
|
|
printf("\t\t%08x", id);
|
2013-07-17 02:47:35 +02:00
|
|
|
else
|
2015-09-03 21:58:44 +02:00
|
|
|
printf("%s\t%08x", name, id);
|
2013-07-17 02:47:35 +02:00
|
|
|
printf(" %08" PRIx64 " ", base);
|
|
|
|
printf(" %08" PRIx64 "\n", size);
|
|
|
|
}
|
2013-01-08 01:26:10 +01:00
|
|
|
|
2015-09-30 19:33:01 +02:00
|
|
|
static void dump_cbmem_toc(void)
|
2013-07-17 02:47:35 +02:00
|
|
|
{
|
|
|
|
int i;
|
2017-09-27 01:44:28 +02:00
|
|
|
const uint8_t *table;
|
2015-09-30 19:33:01 +02:00
|
|
|
size_t offset;
|
2013-01-08 01:26:10 +01:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
table = mapping_virt(&lbtable_mapping);
|
2013-01-08 01:26:10 +01:00
|
|
|
|
2015-09-30 19:33:01 +02:00
|
|
|
if (table == NULL)
|
|
|
|
return;
|
2013-07-17 02:47:35 +02:00
|
|
|
|
|
|
|
printf("CBMEM table of contents:\n");
|
2015-09-03 21:58:44 +02:00
|
|
|
printf(" NAME ID START LENGTH\n");
|
2013-07-17 02:47:35 +02:00
|
|
|
|
2015-09-30 19:33:01 +02:00
|
|
|
i = 0;
|
|
|
|
offset = 0;
|
2013-07-17 02:47:35 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
while (offset < mapping_size(&lbtable_mapping)) {
|
2017-09-27 01:44:28 +02:00
|
|
|
const struct lb_record *lbr;
|
|
|
|
const struct lb_cbmem_entry *lbe;
|
2013-07-17 02:47:35 +02:00
|
|
|
|
2017-09-27 01:44:28 +02:00
|
|
|
lbr = (const void *)(table + offset);
|
2015-09-30 19:33:01 +02:00
|
|
|
offset += lbr->size;
|
2013-07-17 02:47:35 +02:00
|
|
|
|
2015-09-30 19:33:01 +02:00
|
|
|
if (lbr->tag != LB_TAG_CBMEM_ENTRY)
|
|
|
|
continue;
|
2013-07-17 02:47:35 +02:00
|
|
|
|
2017-09-27 01:44:28 +02:00
|
|
|
lbe = (const void *)lbr;
|
2015-09-30 19:33:01 +02:00
|
|
|
cbmem_print_entry(i, lbe->id, lbe->address, lbe->entry_size);
|
|
|
|
i++;
|
2013-01-08 01:26:10 +01:00
|
|
|
}
|
|
|
|
}
|
2013-01-07 22:37:12 +01:00
|
|
|
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
#define COVERAGE_MAGIC 0x584d4153
|
|
|
|
struct file {
|
|
|
|
uint32_t magic;
|
|
|
|
uint32_t next;
|
|
|
|
uint32_t filename;
|
|
|
|
uint32_t data;
|
|
|
|
int offset;
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int mkpath(char *path, mode_t mode)
|
|
|
|
{
|
|
|
|
assert (path && *path);
|
|
|
|
char *p;
|
|
|
|
for (p = strchr(path+1, '/'); p; p = strchr(p + 1, '/')) {
|
|
|
|
*p = '\0';
|
|
|
|
if (mkdir(path, mode) == -1) {
|
|
|
|
if (errno != EEXIST) {
|
|
|
|
*p = '/';
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*p = '/';
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_coverage(void)
|
|
|
|
{
|
|
|
|
uint64_t start;
|
2015-09-30 19:33:01 +02:00
|
|
|
size_t size;
|
2017-09-27 01:44:28 +02:00
|
|
|
const void *coverage;
|
2017-09-27 00:22:38 +02:00
|
|
|
struct mapping coverage_mapping;
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
unsigned long phys_offset;
|
|
|
|
#define phys_to_virt(x) ((void *)(unsigned long)(x) + phys_offset)
|
|
|
|
|
2015-09-30 19:33:01 +02:00
|
|
|
if (find_cbmem_entry(CBMEM_ID_COVERAGE, &start, &size)) {
|
|
|
|
fprintf(stderr, "No coverage information found\n");
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Map coverage area */
|
2017-09-27 00:22:38 +02:00
|
|
|
coverage = map_memory(&coverage_mapping, start, size);
|
|
|
|
if (!coverage)
|
|
|
|
die("Unable to map coverage area.\n");
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
phys_offset = (unsigned long)coverage - (unsigned long)start;
|
|
|
|
|
|
|
|
printf("Dumping coverage data...\n");
|
|
|
|
|
|
|
|
struct file *file = (struct file *)coverage;
|
|
|
|
while (file && file->magic == COVERAGE_MAGIC) {
|
|
|
|
FILE *f;
|
|
|
|
char *filename;
|
|
|
|
|
|
|
|
debug(" -> %s\n", (char *)phys_to_virt(file->filename));
|
|
|
|
filename = strdup((char *)phys_to_virt(file->filename));
|
|
|
|
if (mkpath(filename, 0755) == -1) {
|
|
|
|
perror("Directory for coverage data could "
|
|
|
|
"not be created");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
f = fopen(filename, "wb");
|
|
|
|
if (!f) {
|
|
|
|
printf("Could not open %s: %s\n",
|
|
|
|
filename, strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (fwrite((void *)phys_to_virt(file->data),
|
|
|
|
file->len, 1, f) != 1) {
|
|
|
|
printf("Could not write to %s: %s\n",
|
|
|
|
filename, strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
free(filename);
|
|
|
|
|
|
|
|
if (file->next)
|
|
|
|
file = (struct file *)phys_to_virt(file->next);
|
|
|
|
else
|
|
|
|
file = NULL;
|
|
|
|
}
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(&coverage_mapping);
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void print_version(void)
|
2013-01-03 00:43:56 +01:00
|
|
|
{
|
|
|
|
printf("cbmem v%s -- ", CBMEM_VERSION);
|
|
|
|
printf("Copyright (C) 2012 The ChromiumOS Authors. All rights reserved.\n\n");
|
|
|
|
printf(
|
|
|
|
"This program is free software: you can redistribute it and/or modify\n"
|
|
|
|
"it under the terms of the GNU General Public License as published by\n"
|
|
|
|
"the Free Software Foundation, version 2 of the License.\n\n"
|
|
|
|
"This program is distributed in the hope that it will be useful,\n"
|
|
|
|
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
|
|
|
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
2016-01-12 21:30:50 +01:00
|
|
|
"GNU General Public License for more details.\n\n");
|
2013-01-03 00:43:56 +01:00
|
|
|
}
|
|
|
|
|
2016-09-11 23:43:22 +02:00
|
|
|
static void print_usage(const char *name, int exit_code)
|
2013-01-03 00:43:56 +01:00
|
|
|
{
|
2015-08-31 05:00:12 +02:00
|
|
|
printf("usage: %s [-cCltTxVvh?]\n", name);
|
2013-01-03 00:43:56 +01:00
|
|
|
printf("\n"
|
2013-01-07 22:37:12 +01:00
|
|
|
" -c | --console: print cbmem console\n"
|
2017-04-29 01:31:46 +02:00
|
|
|
" -1 | --oneboot: print cbmem console for last boot only\n"
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
" -C | --coverage: dump coverage information\n"
|
2013-01-08 01:26:10 +01:00
|
|
|
" -l | --list: print cbmem table of contents\n"
|
2013-07-17 02:47:35 +02:00
|
|
|
" -x | --hexdump: print hexdump of cbmem area\n"
|
2015-09-03 21:58:44 +02:00
|
|
|
" -r | --rawdump ID: print rawdump of specific ID (in hex) of cbtable\n"
|
2013-01-07 22:37:12 +01:00
|
|
|
" -t | --timestamps: print timestamp information\n"
|
2015-08-31 05:00:12 +02:00
|
|
|
" -T | --parseable-timestamps: print parseable timestamps\n"
|
2013-01-07 22:37:12 +01:00
|
|
|
" -V | --verbose: verbose (debugging) output\n"
|
2013-01-03 00:43:56 +01:00
|
|
|
" -v | --version: print the version\n"
|
|
|
|
" -h | --help: print this help\n"
|
|
|
|
"\n");
|
2016-09-11 23:43:22 +02:00
|
|
|
exit(exit_code);
|
2013-01-03 00:43:56 +01:00
|
|
|
}
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2014-06-17 08:02:03 +02:00
|
|
|
#ifdef __arm__
|
|
|
|
static void dt_update_cells(const char *name, int *addr_cells_ptr,
|
|
|
|
int *size_cells_ptr)
|
|
|
|
{
|
|
|
|
if (*addr_cells_ptr >= 0 && *size_cells_ptr >= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int buffer;
|
|
|
|
size_t nlen = strlen(name);
|
|
|
|
char *prop = alloca(nlen + sizeof("/#address-cells"));
|
|
|
|
strcpy(prop, name);
|
|
|
|
|
|
|
|
if (*addr_cells_ptr < 0) {
|
|
|
|
strcpy(prop + nlen, "/#address-cells");
|
|
|
|
int fd = open(prop, O_RDONLY);
|
|
|
|
if (fd < 0 && errno != ENOENT) {
|
|
|
|
perror(prop);
|
|
|
|
} else if (fd >= 0) {
|
|
|
|
if (read(fd, &buffer, sizeof(int)) < 0)
|
|
|
|
perror(prop);
|
|
|
|
else
|
|
|
|
*addr_cells_ptr = ntohl(buffer);
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size_cells_ptr < 0) {
|
|
|
|
strcpy(prop + nlen, "/#size-cells");
|
|
|
|
int fd = open(prop, O_RDONLY);
|
|
|
|
if (fd < 0 && errno != ENOENT) {
|
|
|
|
perror(prop);
|
|
|
|
} else if (fd >= 0) {
|
|
|
|
if (read(fd, &buffer, sizeof(int)) < 0)
|
|
|
|
perror(prop);
|
|
|
|
else
|
|
|
|
*size_cells_ptr = ntohl(buffer);
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *dt_find_compat(const char *parent, const char *compat,
|
|
|
|
int *addr_cells_ptr, int *size_cells_ptr)
|
|
|
|
{
|
|
|
|
char *ret = NULL;
|
|
|
|
struct dirent *entry;
|
|
|
|
DIR *dir;
|
|
|
|
|
|
|
|
if (!(dir = opendir(parent))) {
|
|
|
|
perror(parent);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Loop through all files in the directory (DT node). */
|
|
|
|
while ((entry = readdir(dir))) {
|
|
|
|
/* We only care about compatible props or subnodes. */
|
|
|
|
if (entry->d_name[0] == '.' || !((entry->d_type & DT_DIR) ||
|
|
|
|
!strcmp(entry->d_name, "compatible")))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Assemble the file name (on the stack, for speed). */
|
|
|
|
size_t plen = strlen(parent);
|
|
|
|
char *name = alloca(plen + strlen(entry->d_name) + 2);
|
|
|
|
|
|
|
|
strcpy(name, parent);
|
|
|
|
name[plen] = '/';
|
|
|
|
strcpy(name + plen + 1, entry->d_name);
|
|
|
|
|
|
|
|
/* If it's a subnode, recurse. */
|
|
|
|
if (entry->d_type & DT_DIR) {
|
|
|
|
ret = dt_find_compat(name, compat, addr_cells_ptr,
|
|
|
|
size_cells_ptr);
|
|
|
|
|
|
|
|
/* There is only one matching node to find, abort. */
|
|
|
|
if (ret) {
|
|
|
|
/* Gather cells values on the way up. */
|
|
|
|
dt_update_cells(parent, addr_cells_ptr,
|
|
|
|
size_cells_ptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If it's a compatible string, see if it's the right one. */
|
|
|
|
int fd = open(name, O_RDONLY);
|
|
|
|
int clen = strlen(compat);
|
|
|
|
char *buffer = alloca(clen + 1);
|
|
|
|
|
|
|
|
if (fd < 0) {
|
|
|
|
perror(name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (read(fd, buffer, clen + 1) < 0) {
|
|
|
|
perror(name);
|
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
if (!strcmp(compat, buffer)) {
|
|
|
|
/* Initialize these to "unset" for the way up. */
|
|
|
|
*addr_cells_ptr = *size_cells_ptr = -1;
|
|
|
|
|
|
|
|
/* Can't leave string on the stack or we'll lose it! */
|
|
|
|
ret = strdup(parent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(dir);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif /* __arm__ */
|
|
|
|
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2013-01-07 22:37:12 +01:00
|
|
|
int print_defaults = 1;
|
|
|
|
int print_console = 0;
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
int print_coverage = 0;
|
2013-01-08 01:26:10 +01:00
|
|
|
int print_list = 0;
|
2013-07-17 02:47:35 +02:00
|
|
|
int print_hexdump = 0;
|
2015-09-03 21:58:44 +02:00
|
|
|
int print_rawdump = 0;
|
2013-01-07 22:37:12 +01:00
|
|
|
int print_timestamps = 0;
|
2015-08-31 05:00:12 +02:00
|
|
|
int machine_readable_timestamps = 0;
|
2017-04-29 01:31:46 +02:00
|
|
|
int one_boot_only = 0;
|
2015-09-03 21:58:44 +02:00
|
|
|
unsigned int rawdump_id = 0;
|
2013-01-03 23:30:33 +01:00
|
|
|
|
2013-01-03 00:43:56 +01:00
|
|
|
int opt, option_index = 0;
|
|
|
|
static struct option long_options[] = {
|
2013-01-07 22:37:12 +01:00
|
|
|
{"console", 0, 0, 'c'},
|
2017-04-29 01:31:46 +02:00
|
|
|
{"oneboot", 0, 0, '1'},
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
{"coverage", 0, 0, 'C'},
|
2013-01-08 01:26:10 +01:00
|
|
|
{"list", 0, 0, 'l'},
|
2013-01-07 22:37:12 +01:00
|
|
|
{"timestamps", 0, 0, 't'},
|
2015-08-31 05:00:12 +02:00
|
|
|
{"parseable-timestamps", 0, 0, 'T'},
|
2013-07-17 02:47:35 +02:00
|
|
|
{"hexdump", 0, 0, 'x'},
|
2015-09-03 21:58:44 +02:00
|
|
|
{"rawdump", required_argument, 0, 'r'},
|
2013-01-03 23:30:33 +01:00
|
|
|
{"verbose", 0, 0, 'V'},
|
2013-01-03 00:43:56 +01:00
|
|
|
{"version", 0, 0, 'v'},
|
|
|
|
{"help", 0, 0, 'h'},
|
|
|
|
{0, 0, 0, 0}
|
|
|
|
};
|
2017-04-29 01:31:46 +02:00
|
|
|
while ((opt = getopt_long(argc, argv, "c1CltTxVvh?r:",
|
2013-01-03 00:43:56 +01:00
|
|
|
long_options, &option_index)) != EOF) {
|
|
|
|
switch (opt) {
|
2013-01-07 22:37:12 +01:00
|
|
|
case 'c':
|
|
|
|
print_console = 1;
|
|
|
|
print_defaults = 0;
|
|
|
|
break;
|
2017-04-29 01:31:46 +02:00
|
|
|
case '1':
|
|
|
|
print_console = 1;
|
|
|
|
one_boot_only = 1;
|
|
|
|
print_defaults = 0;
|
|
|
|
break;
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
case 'C':
|
|
|
|
print_coverage = 1;
|
|
|
|
print_defaults = 0;
|
|
|
|
break;
|
2013-01-08 01:26:10 +01:00
|
|
|
case 'l':
|
|
|
|
print_list = 1;
|
|
|
|
print_defaults = 0;
|
|
|
|
break;
|
2013-07-17 02:47:35 +02:00
|
|
|
case 'x':
|
|
|
|
print_hexdump = 1;
|
|
|
|
print_defaults = 0;
|
|
|
|
break;
|
2015-09-03 21:58:44 +02:00
|
|
|
case 'r':
|
|
|
|
print_rawdump = 1;
|
|
|
|
print_defaults = 0;
|
|
|
|
rawdump_id = strtoul(optarg, NULL, 16);
|
|
|
|
break;
|
2013-01-07 22:37:12 +01:00
|
|
|
case 't':
|
|
|
|
print_timestamps = 1;
|
|
|
|
print_defaults = 0;
|
|
|
|
break;
|
2015-08-31 05:00:12 +02:00
|
|
|
case 'T':
|
|
|
|
print_timestamps = 1;
|
|
|
|
machine_readable_timestamps = 1;
|
|
|
|
print_defaults = 0;
|
|
|
|
break;
|
2013-01-03 23:30:33 +01:00
|
|
|
case 'V':
|
|
|
|
verbose = 1;
|
|
|
|
break;
|
2013-01-03 00:43:56 +01:00
|
|
|
case 'v':
|
|
|
|
print_version();
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
case 'h':
|
2016-09-11 23:43:22 +02:00
|
|
|
print_usage(argv[0], 0);
|
|
|
|
break;
|
2013-01-03 00:43:56 +01:00
|
|
|
case '?':
|
|
|
|
default:
|
2016-09-11 23:43:22 +02:00
|
|
|
print_usage(argv[0], 1);
|
2013-01-03 00:43:56 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2014-06-17 08:02:03 +02:00
|
|
|
mem_fd = open("/dev/mem", O_RDONLY, 0);
|
|
|
|
if (mem_fd < 0) {
|
2013-01-03 23:30:33 +01:00
|
|
|
fprintf(stderr, "Failed to gain memory access: %s\n",
|
|
|
|
strerror(errno));
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-06-20 00:39:09 +02:00
|
|
|
#ifdef __arm__
|
2014-06-17 08:02:03 +02:00
|
|
|
int addr_cells, size_cells;
|
|
|
|
char *coreboot_node = dt_find_compat("/proc/device-tree", "coreboot",
|
|
|
|
&addr_cells, &size_cells);
|
2013-06-20 00:39:09 +02:00
|
|
|
|
2014-06-17 08:02:03 +02:00
|
|
|
if (!coreboot_node) {
|
|
|
|
fprintf(stderr, "Could not find 'coreboot' compatible node!\n");
|
2013-06-20 00:39:09 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-17 08:02:03 +02:00
|
|
|
if (addr_cells < 0) {
|
|
|
|
fprintf(stderr, "Warning: no #address-cells node in tree!\n");
|
|
|
|
addr_cells = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nlen = strlen(coreboot_node);
|
|
|
|
char *reg = alloca(nlen + sizeof("/reg"));
|
|
|
|
|
|
|
|
strcpy(reg, coreboot_node);
|
|
|
|
strcpy(reg + nlen, "/reg");
|
|
|
|
free(coreboot_node);
|
|
|
|
|
|
|
|
int fd = open(reg, O_RDONLY);
|
|
|
|
if (fd < 0) {
|
|
|
|
perror(reg);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i;
|
2014-10-07 21:56:35 +02:00
|
|
|
size_t size_to_read = addr_cells * 4 + size_cells * 4;
|
|
|
|
u8 *dtbuffer = alloca(size_to_read);
|
|
|
|
if (read(fd, dtbuffer, size_to_read) < 0) {
|
2014-06-17 08:02:03 +02:00
|
|
|
perror(reg);
|
2013-06-20 00:39:09 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2014-06-17 08:02:03 +02:00
|
|
|
close(fd);
|
2013-06-20 00:39:09 +02:00
|
|
|
|
2014-06-17 08:02:03 +02:00
|
|
|
/* No variable-length byte swap function anywhere in C... how sad. */
|
|
|
|
u64 baseaddr = 0;
|
|
|
|
for (i = 0; i < addr_cells * 4; i++) {
|
|
|
|
baseaddr <<= 8;
|
2014-10-07 21:56:35 +02:00
|
|
|
baseaddr |= *dtbuffer;
|
|
|
|
dtbuffer++;
|
|
|
|
}
|
|
|
|
u64 cb_table_size = 0;
|
|
|
|
for (i = 0; i < size_cells * 4; i++) {
|
|
|
|
cb_table_size <<= 8;
|
|
|
|
cb_table_size |= *dtbuffer;
|
|
|
|
dtbuffer++;
|
2014-06-17 08:02:03 +02:00
|
|
|
}
|
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
parse_cbtable(baseaddr, cb_table_size);
|
2013-06-20 00:39:09 +02:00
|
|
|
#else
|
|
|
|
int j;
|
2017-09-27 00:22:38 +02:00
|
|
|
unsigned long long possible_base_addresses[] = { 0, 0xf0000 };
|
2013-06-20 00:39:09 +02:00
|
|
|
|
2013-01-03 23:30:33 +01:00
|
|
|
/* Find and parse coreboot table */
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
for (j = 0; j < ARRAY_SIZE(possible_base_addresses); j++) {
|
2017-09-27 00:22:38 +02:00
|
|
|
if (!parse_cbtable(possible_base_addresses[j], 0))
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
break;
|
|
|
|
}
|
2013-06-20 00:39:09 +02:00
|
|
|
#endif
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
if (mapping_virt(&lbtable_mapping) == NULL)
|
|
|
|
die("Table not found.\n");
|
|
|
|
|
2013-01-07 22:37:12 +01:00
|
|
|
if (print_console)
|
2017-04-29 01:31:46 +02:00
|
|
|
dump_console(one_boot_only);
|
2013-01-07 22:37:12 +01:00
|
|
|
|
Implement GCC code coverage analysis
In order to provide some insight on what code is executed during
coreboot's run time and how well our test scenarios work, this
adds code coverage support to coreboot's ram stage. This should
be easily adaptable for payloads, and maybe even romstage.
See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for
more information.
To instrument coreboot, select CONFIG_COVERAGE ("Code coverage
support") in Kconfig, and recompile coreboot. coreboot will then
store its code coverage information into CBMEM, if possible.
Then, run "cbmem -CV" as root on the target system running the
instrumented coreboot binary. This will create a whole bunch of
.gcda files that contain coverage information. Tar them up, copy
them to your build system machine, and untar them. Then you can
use your favorite coverage utility (gcov, lcov, ...) to visualize
code coverage.
For a sneak peak of what will expect you, please take a look
at http://www.coreboot.org/~stepan/coreboot-coverage/
Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/2052
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Martin Roth <martin@se-eng.com>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-12-19 01:23:28 +01:00
|
|
|
if (print_coverage)
|
|
|
|
dump_coverage();
|
|
|
|
|
2013-01-08 01:26:10 +01:00
|
|
|
if (print_list)
|
|
|
|
dump_cbmem_toc();
|
|
|
|
|
2013-07-17 02:47:35 +02:00
|
|
|
if (print_hexdump)
|
|
|
|
dump_cbmem_hex();
|
|
|
|
|
2015-09-03 21:58:44 +02:00
|
|
|
if (print_rawdump)
|
|
|
|
dump_cbmem_raw(rawdump_id);
|
|
|
|
|
2013-01-07 22:37:12 +01:00
|
|
|
if (print_defaults || print_timestamps)
|
2015-08-31 05:00:12 +02:00
|
|
|
dump_timestamps(machine_readable_timestamps);
|
2013-01-03 23:30:33 +01:00
|
|
|
|
2017-09-27 00:22:38 +02:00
|
|
|
unmap_memory(&lbtable_mapping);
|
|
|
|
|
2014-06-17 08:02:03 +02:00
|
|
|
close(mem_fd);
|
Utility to dump boot timing table
Coreboot and u-boot create a table of timestamps which allows to see
the boot process performance. The util/cbmem/cbmem.py script allows to
access the table after ChromeOS boots up and display its contents on
the console. The problem is that shipping images do not include Python
interpreter, so there is no way to access the table on a production
machine.
This change introduces a utility which is a Linux app displaying the
timestamp table. Conceivably the output of this utility might be
included in one of the ChromeOS :/system sections, so it was attempted
to write this procedure 'fail safe', namely reporting errors and not
continuing processing if something goes wrong.
Including of coreboot/src .h files will allow to keep the firmware
timestamp implementation and this utility in sync in the future.
Test:
. build the utility (run 'make' while in chroot in util/cbmem)
. copy `cbmem' and 'cbmem.py' to the target
. run both utilities (limiting cbmem.py output to 25 lines or so)
. observe that the generated tables are identical (modulo rounding
up of int division, resulting in 1 ns discrepancies in some
cases)
localhost var # ./cbmem
18 entries total:
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
localhost var # ./cbmem.py | head -25
time base 4249800, total entries 18
1:62,080
2:64,569 (2,489)
3:82,520 (17,951)
4:82,695 (174)
8:84,384 (1,688)
9:131,731 (47,347)
10:131,821 (89)
30:131,849 (27)
40:132,618 (769)
50:134,594 (1,975)
60:134,729 (134)
70:363,440 (228,710)
75:363,453 (13)
80:368,165 (4,711)
90:370,018 (1,852)
99:488,217 (118,199)
1000:491,324 (3,107)
1100:760,475 (269,150)
Change-Id: I013e594d4afe323106d88e7938dd40b17760621c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: http://review.coreboot.org/1759
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2012-09-28 04:24:07 +02:00
|
|
|
return 0;
|
|
|
|
}
|