Message ID | 20180515095728.16572-14-miquel.raynal@bootlin.com |
---|---|
State | Accepted |
Delegated to: | Tom Rini |
Headers | show |
Series | Introduce TPMv2.0 support | expand |
On Tue, May 15, 2018 at 11:57:09AM +0200, Miquel Raynal wrote: > 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 <miquel.raynal@bootlin.com> > Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
On Tue, May 15, 2018 at 11:57:09AM +0200, Miquel Raynal wrote: > 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 <miquel.raynal@bootlin.com> > Reviewed-by: Simon Glass <sjg@chromium.org> > Reviewed-by: Tom Rini <trini@konsulko.com> Applied to u-boot/master, thanks!
diff --git a/lib/tpm-utils.h b/lib/tpm-utils.h index 429da46232..9c875e6fa7 100644 --- a/lib/tpm-utils.h +++ b/lib/tpm-utils.h @@ -13,6 +13,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 *