Skip to content

Commit

Permalink
Add support for storing which time base a USF file uses
Browse files Browse the repository at this point in the history
Store which time base a USF file uses in its header. Old files will
default to 'accesses', which is the typical case. Future applications
may want to store cycles or instructions instead of accesses, enable
that by reserving two bits in the header to represent the time base.
Also, update the usfdump utility to display which time base is used.
  • Loading branch information
andysan committed Apr 27, 2011
1 parent ff6e6d4 commit 40ad678
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/uart/usf.h
Expand Up @@ -71,6 +71,19 @@ typedef uint16_t usf_compression_t;
/** File contains instruction samples */
#define USF_FLAG_INSTRUCTIONS (1 << 3)

/**
* Reserve two bits for the time base, note that these may not be
* contiguous in future releases.
*/
#define USF_FLAG_TIME_MASK ((1 << 4) | (1 << 5))

/** Time in accesses */
#define USF_FLAG_TIME_ACCESSES (0 << 4)
/** Time in instructions */
#define USF_FLAG_TIME_INSTRUCTIONS (1 << 4)
/** Time in cycles */
#define USF_FLAG_TIME_CYCLES (3 << 4)

/* @{ */
/**
* Always set the native endian flag when creating a file. If the
Expand Down
16 changes: 16 additions & 0 deletions tools/usfdump.c
Expand Up @@ -150,6 +150,22 @@ print_header(const usf_header_t *h)
if (h->flags & flag_names[i].flag)
printf("\t\t%s\n", flag_names[i].name);
}

printf("\tTime base: ");
switch (h->flags & USF_FLAG_TIME_MASK) {
case USF_FLAG_TIME_ACCESSES:
printf("accesses\n");
break;
case USF_FLAG_TIME_INSTRUCTIONS:
printf("instructions\n");
break;
case USF_FLAG_TIME_CYCLES:
printf("cycles\n");
break;
default:
printf("unknown (0x%x)\n", h->flags & USF_FLAG_TIME_MASK);
break;
}
}

static int
Expand Down

0 comments on commit 40ad678

Please sign in to comment.