Skip to content

Commit

Permalink
tpm: convert tpm_crb.c to use trace-events
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanberger committed Mar 6, 2018
1 parent 8cb340c commit ec42749
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions Makefile.objs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ trace-events-subdirs += hw/alpha
trace-events-subdirs += hw/hppa
trace-events-subdirs += hw/xen
trace-events-subdirs += hw/ide
trace-events-subdirs += hw/tpm
trace-events-subdirs += ui
trace-events-subdirs += audio
trace-events-subdirs += net
Expand Down
17 changes: 5 additions & 12 deletions hw/tpm/tpm_crb.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "sysemu/reset.h"
#include "tpm_int.h"
#include "tpm_util.h"
#include "trace.h"

typedef struct CRBState {
DeviceState parent_obj;
Expand All @@ -44,14 +45,6 @@ typedef struct CRBState {

#define CRB(obj) OBJECT_CHECK(CRBState, (obj), TYPE_TPM_CRB)

#define DEBUG_CRB 0

#define DPRINTF(fmt, ...) do { \
if (DEBUG_CRB) { \
printf(fmt, ## __VA_ARGS__); \
} \
} while (0)

#define CRB_INTF_TYPE_CRB_ACTIVE 0b1
#define CRB_INTF_VERSION_CRB 0b1
#define CRB_INTF_CAP_LOCALITY_0_ONLY 0b0
Expand Down Expand Up @@ -91,17 +84,17 @@ static uint64_t tpm_crb_mmio_read(void *opaque, hwaddr addr,
unsigned offset = addr & 3;
uint32_t val = *(uint32_t *)regs >> (8 * offset);

DPRINTF("CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32 "\n",
addr, size, val);
trace_tpm_crb_mmio_read(addr, size, val);

return val;
}

static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
CRBState *s = CRB(opaque);
DPRINTF("CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx64 "\n",
addr, size, val);

trace_tpm_crb_mmio_write(addr, size, val);

switch (addr) {
case A_CRB_CTRL_REQ:
Expand Down
5 changes: 5 additions & 0 deletions hw/tpm/trace-events
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# See docs/devel/tracing.txt for syntax documentation.

# hw/tpm/tpm_crb.c
tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32
tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x" TARGET_FMT_plx " len:%u val: 0x%" PRIx32

0 comments on commit ec42749

Please sign in to comment.