From patchwork Thu Mar 8 15:40:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 883188 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zxvwD1Lw7z9shR for ; Fri, 9 Mar 2018 02:45:00 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C4536C21F50; Thu, 8 Mar 2018 15:41:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 56780C21EA2; Thu, 8 Mar 2018 15:40:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3E2DBC21C2C; Thu, 8 Mar 2018 15:40:41 +0000 (UTC) Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 98CAFC21EAE for ; Thu, 8 Mar 2018 15:40:39 +0000 (UTC) Received: by mail.bootlin.com (Postfix, from userid 110) id 08D7620755; Thu, 8 Mar 2018 16:40:38 +0100 (CET) Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id C8B69207DD; Thu, 8 Mar 2018 16:40:27 +0100 (CET) From: Miquel Raynal To: u-boot@lists.denx.de Date: Thu, 8 Mar 2018 16:40:09 +0100 Message-Id: <20180308154021.25255-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180308154021.25255-1-miquel.raynal@bootlin.com> References: <20180308154021.25255-1-miquel.raynal@bootlin.com> Subject: [U-Boot] [PATCH 06/18] tpm: add macros for TPMv2 commands X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" TPM commands are much easier to handle with these macros that will transform words or integers into byte string. 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 --- lib/tpm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/tpm.c b/lib/tpm.c index 38b76b4961..1b3a112311 100644 --- a/lib/tpm.c +++ b/lib/tpm.c @@ -15,6 +15,12 @@ /* Internal error of TPM command library */ #define TPM_LIB_ERROR ((uint32_t)~0u) +/* To make strings of commands more easily */ +#define __MSB(x) ((x) >> 8) +#define __LSB(x) ((x) & 0xFF) +#define STRINGIFY16(x) __MSB(x), __LSB(x) +#define STRINGIFY32(x) STRINGIFY16((x) >> 16), STRINGIFY16((x) & 0xFFFF) + /* Global boolean to discriminate TPMv2.x from TPMv1.x functions */ static bool is_tpmv2;