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:
Aaron Durbin
2013-04-24 16:28:52 -05:00
committed by Ronald G. Minnich
parent 0a6c20a2a3
commit 4dd87fb2d8
5 changed files with 8 additions and 38 deletions

View File

@ -18,8 +18,8 @@
*/
#include <stdint.h>
#include <bootstate.h>
#include <cbmem.h>
#include <coverage.h>
typedef struct file {
uint32_t magic;
@ -128,7 +128,7 @@ static void setbuf(FILE *stream, char *buf)
gcc_assert(buf == 0);
}
void coverage_init(void)
static void coverage_init(void *unused)
{
extern long __CTOR_LIST__;
typedef void (*func_ptr)(void) ;
@ -142,7 +142,7 @@ void coverage_init(void)
}
void __gcov_flush(void);
void coverage_exit(void)
static void coverage_exit(void *unused)
{
#if CONFIG_DEBUG_COVERAGE
printk(BIOS_DEBUG, "Syncing coverage data.\n");
@ -150,4 +150,8 @@ void coverage_exit(void)
__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),
};