Skip to content

Commit

Permalink
tpm: add macros to enhance TPM commands readability
Browse files Browse the repository at this point in the history
TPM commands are much easier to read/write with these macros that will
transform words or integers into byte strings. This way, there is no
need to call pack_byte_string() while all variable length in a command
are known (and at must 4 bytes, which is a lot of them).

Signed-off-by: Miquel Raynal <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Reviewed-by: Tom Rini <[email protected]>
  • Loading branch information
miquelraynal authored and trini committed May 26, 2018
1 parent ff32245 commit f687281
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/tpm-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
/* Internal error of TPM command library */
#define TPM_LIB_ERROR ((u32)~0u)

/* To make strings of commands more easily */
#define __MSB(x) ((x) >> 8)
#define __LSB(x) ((x) & 0xFF)
#define tpm_u16(x) __MSB(x), __LSB(x)
#define tpm_u32(x) tpm_u16((x) >> 16), tpm_u16((x) & 0xFFFF)

/**
* tpm_open() - Request access to locality 0 for the caller
*
Expand Down

0 comments on commit f687281

Please sign in to comment.