coverage: use boot state callbacks
Utilize the static boot state callback scheduling to initialize and tear down the coverage infrastructure at the appropriate points. The coverage initialization is performed at BS_PRE_DEVICE which is the earliest point a callback can be called. The tear down occurs at the 2 exit points of ramstage: OS resume and payload boot. Change-Id: Ie5ee51268e1f473f98fa517710a266e38dc01b6d Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/3135 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
parent
0a6c20a2a3
commit
4dd87fb2d8
|
@ -36,7 +36,6 @@
|
||||||
#if CONFIG_COLLECT_TIMESTAMPS
|
#if CONFIG_COLLECT_TIMESTAMPS
|
||||||
#include <timestamp.h>
|
#include <timestamp.h>
|
||||||
#endif
|
#endif
|
||||||
#include <coverage.h>
|
|
||||||
|
|
||||||
/* FIXME: Kconfig doesn't support overridable defaults :-( */
|
/* FIXME: Kconfig doesn't support overridable defaults :-( */
|
||||||
#ifndef CONFIG_HPET_MIN_TICKS
|
#ifndef CONFIG_HPET_MIN_TICKS
|
||||||
|
@ -638,9 +637,6 @@ void acpi_resume(void *wake_vec)
|
||||||
/* Call mainboard resume handler first, if defined. */
|
/* Call mainboard resume handler first, if defined. */
|
||||||
if (mainboard_suspend_resume)
|
if (mainboard_suspend_resume)
|
||||||
mainboard_suspend_resume();
|
mainboard_suspend_resume();
|
||||||
#if CONFIG_COVERAGE
|
|
||||||
coverage_exit();
|
|
||||||
#endif
|
|
||||||
/* Tear down the caching of the ROM. */
|
/* Tear down the caching of the ROM. */
|
||||||
if (disable_cache_rom)
|
if (disable_cache_rom)
|
||||||
disable_cache_rom();
|
disable_cache_rom();
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the coreboot project.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012 Google, Inc.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
void coverage_init(void);
|
|
||||||
void coverage_exit(void);
|
|
|
@ -18,8 +18,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <bootstate.h>
|
||||||
#include <cbmem.h>
|
#include <cbmem.h>
|
||||||
#include <coverage.h>
|
|
||||||
|
|
||||||
typedef struct file {
|
typedef struct file {
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
@ -128,7 +128,7 @@ static void setbuf(FILE *stream, char *buf)
|
||||||
gcc_assert(buf == 0);
|
gcc_assert(buf == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void coverage_init(void)
|
static void coverage_init(void *unused)
|
||||||
{
|
{
|
||||||
extern long __CTOR_LIST__;
|
extern long __CTOR_LIST__;
|
||||||
typedef void (*func_ptr)(void) ;
|
typedef void (*func_ptr)(void) ;
|
||||||
|
@ -142,7 +142,7 @@ void coverage_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gcov_flush(void);
|
void __gcov_flush(void);
|
||||||
void coverage_exit(void)
|
static void coverage_exit(void *unused)
|
||||||
{
|
{
|
||||||
#if CONFIG_DEBUG_COVERAGE
|
#if CONFIG_DEBUG_COVERAGE
|
||||||
printk(BIOS_DEBUG, "Syncing coverage data.\n");
|
printk(BIOS_DEBUG, "Syncing coverage data.\n");
|
||||||
|
@ -150,4 +150,8 @@ void coverage_exit(void)
|
||||||
__gcov_flush();
|
__gcov_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOT_STATE_INIT_ENTRIES(gcov_bscb) = {
|
||||||
|
BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_ENTRY, coverage_init, NULL),
|
||||||
|
BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, coverage_exit, NULL),
|
||||||
|
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, coverage_exit, NULL),
|
||||||
|
};
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include <arch/acpi.h>
|
#include <arch/acpi.h>
|
||||||
#endif
|
#endif
|
||||||
#include <cbmem.h>
|
#include <cbmem.h>
|
||||||
#include <coverage.h>
|
|
||||||
#include <timestamp.h>
|
#include <timestamp.h>
|
||||||
|
|
||||||
#if BOOT_STATE_DEBUG
|
#if BOOT_STATE_DEBUG
|
||||||
|
@ -331,10 +330,6 @@ void hardwaremain(int boot_complete)
|
||||||
timestamp_stash(TS_START_RAMSTAGE);
|
timestamp_stash(TS_START_RAMSTAGE);
|
||||||
post_code(POST_ENTRY_RAMSTAGE);
|
post_code(POST_ENTRY_RAMSTAGE);
|
||||||
|
|
||||||
#if CONFIG_COVERAGE
|
|
||||||
coverage_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* console_init() MUST PRECEDE ALL printk()! */
|
/* console_init() MUST PRECEDE ALL printk()! */
|
||||||
console_init();
|
console_init();
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#if CONFIG_COLLECT_TIMESTAMPS
|
#if CONFIG_COLLECT_TIMESTAMPS
|
||||||
#include <timestamp.h>
|
#include <timestamp.h>
|
||||||
#endif
|
#endif
|
||||||
#include <coverage.h>
|
|
||||||
|
|
||||||
/* Maximum physical address we can use for the coreboot bounce buffer. */
|
/* Maximum physical address we can use for the coreboot bounce buffer. */
|
||||||
#ifndef MAX_ADDR
|
#ifndef MAX_ADDR
|
||||||
|
@ -537,9 +536,6 @@ int selfboot(struct lb_memory *mem, struct cbfs_payload *payload)
|
||||||
#if CONFIG_COLLECT_TIMESTAMPS
|
#if CONFIG_COLLECT_TIMESTAMPS
|
||||||
timestamp_add_now(TS_SELFBOOT_JUMP);
|
timestamp_add_now(TS_SELFBOOT_JUMP);
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_COVERAGE
|
|
||||||
coverage_exit();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Tear down the caching of the ROM. */
|
/* Tear down the caching of the ROM. */
|
||||||
if (disable_cache_rom)
|
if (disable_cache_rom)
|
||||||
|
|
Loading…
Reference in New Issue