From patchwork Tue Jan 25 11:31:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 536484 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp3625417imr; Tue, 25 Jan 2022 03:31:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1AtHJbOzuzgAZr7WzHG2BnCAg7XgWmDcz5yLWIggCgJBVLnE225qE8m4RXW5aDj8gC3V+ X-Received: by 2002:a17:907:62a3:: with SMTP id nd35mr16268192ejc.650.1643110314378; Tue, 25 Jan 2022 03:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643110314; cv=none; d=google.com; s=arc-20160816; b=ZniFtGzjjyeMgKmjK79NaZNjvL7kExugpJ9oCBk48GuMK3eHiltzEFMuYG8ABCA/5k mTO03CsFyGhroJCMKJv+8nhpxkd5cINTzz2FFKIl/AMuj4Dp/QobNxzBe90rtPZVYs9A 4LXqwNthZJ0yQFRaCoR1JuPmGX2TZkbT8kXlPHBOtfzQBkd9y5yGpzTJjQlgm3teWSUA mVMXaLLJ9YQN+RGi2mF+KeOt+Fi2LCn5QRDLqoQ1NOUTHbEfLBtx4dyPZ5eKdIH4ERSu Opj+8Q9nswxdxkmGuyoal5asnmAcxXMyvFM8PiMTP2mNyX/UAD+9Q8eNGJXRwW+P/tIc wZ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=8PSNwsqmygvzIPuXCWu+wOIsHFqdY0r8NjQ+TAo6AmI=; b=Hy8SrzKTIHMTB8TeLuOYSiJglrYPLPPoLZnJHVrbT/wTtv9uHBJ4IBHnisnwNljdxZ g/3CA5fqG8PX48OeqepaaF9L6JGvf64kPF1Qu8pESpmUxSmMtkRdMCLWecOLWpr3FM1c S0zJGUxkrAc4mKvP/3IYvrwRb0POtpn7P9xcJDVZ/7l5xANqwmxBbOPsU0btgsNs0fMg vf/eyGL9yCBtwq72F1UoUZkg55SHMttOCtJlZXwOUQ+48uk7NF+wRL7w8vN8atbZP/TT go/WBFhKTeVmMp5Kd8PZIfAFaXHPGYBW4G4IdLpWkSlncT/AlSxaQnSl+SWkxSk/kkSP ZoOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NiigFpsk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id z8si9367910ejl.24.2022.01.25.03.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 03:31:54 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NiigFpsk; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91D47837C5; Tue, 25 Jan 2022 12:31:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NiigFpsk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A2880837C4; Tue, 25 Jan 2022 12:31:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 74AD4837D2 for ; Tue, 25 Jan 2022 12:31:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pl1-x62a.google.com with SMTP id b15so4422713plg.3 for ; Tue, 25 Jan 2022 03:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=8PSNwsqmygvzIPuXCWu+wOIsHFqdY0r8NjQ+TAo6AmI=; b=NiigFpskSRHf8URoK1syjUxJ4ujH+zXYzY1V8lT+9xX73RrMx+9dwZ+MQEG5Zkjyum YcNgS1xFFgYmrDC+68f7XG2WqsOeAuJwW9CIY60cX3dqMda/ut6KJzQvNDCaXW6qqY8I t1VYriLOoZs9QJoXuknYBKGXSfkrkp/+euLt8lsUSWqajQ1JG/Hi8tYqh0Kc5M4u1fY9 TdJMCYhuIqx5cxo5T9lM7XjT6LED1GbsAKctj3UhiBiUHvfocZE62CFmaNj+eMKFoxuo IcDXB5ns2+SyJGtjBef7xywIv2+IkZDENZdOxQMyYpp0iRyW3Sha+h4FGen71bCbfu9F bYFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=8PSNwsqmygvzIPuXCWu+wOIsHFqdY0r8NjQ+TAo6AmI=; b=2kaUSayzTZ0OeqISGPsEcDIXTEC4y3ENwf5WmNDU0sdm5KP8yzycxhIy8/1t0g8D37 5cha2GyUNUpKRs/lhO0bwYbP6kcmp44+xM/cpBBzNqV/72+4Fr/x+8Wsqe6rfsDmu44a 4S497mBX5h0Esn4k9D+fsi9musC/9h7l4HDGdjH2GJdieNOfFilNfrbBtpRvWyvl2xv4 lovjBc9Xr2tjrtmHWsd4a5TtxAbbWFug/wRubqy2BKBJL6TRedyD2LVUAhU/lagOMGQx Yw8EiY3uiG3xqIOy9yTmZ5rjc1lYGHnx2O5HnWfbLM1OXlbJd9AQpc13uKmvpeMXFPxY gFxA== X-Gm-Message-State: AOAM533yyCzbB0h7oaIpUghP9Gu6qY3fcyuIc7STr6zbe2jSGQhdtxe/ Hm0xU+IakSSvoJVDco0LI5BLVBYbpvvzRg== X-Received: by 2002:a17:902:cec8:b0:14b:3a22:670a with SMTP id d8-20020a170902cec800b0014b3a22670amr11936695plg.56.1643110304586; Tue, 25 Jan 2022 03:31:44 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id t6sm14863815pgr.90.2022.01.25.03.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 03:31:44 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [PATCH 2/2] mkeficapsule: Support "--flags reset" option Date: Tue, 25 Jan 2022 20:31:39 +0900 Message-Id: <164311029935.175897.10993229897651804648.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164311027891.175897.14232281505893559986.stgit@localhost> References: <164311027891.175897.14232281505893559986.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Support "--flags reset" option to set the CAPSULE_FLAGS_INITIATE_RESET flag to capsule header. Signed-off-by: Masami Hiramatsu --- tools/mkeficapsule.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index 4995ba4e0c..ca3a1c77ad 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -44,6 +44,7 @@ static struct option options[] = { {"raw", required_argument, NULL, 'r'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'}, + {"flags", required_argument, NULL, 'F' }, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}, }; @@ -57,12 +58,13 @@ static void print_usage(void) "\t-r, --raw new raw image file\n" "\t-i, --index update image index\n" "\t-I, --instance update hardware instance\n" + "\t-F, --flags set capsule flags (support only \"reset\")\n" "\t-h, --help print a help message\n", tool_name); } static int create_fwbin(char *path, char *bin, efi_guid_t *guid, - unsigned long index, unsigned long instance) + unsigned long index, unsigned long instance, u32 flags) { struct efi_capsule_header header; struct efi_firmware_management_capsule_header capsule; @@ -101,7 +103,7 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, header.capsule_guid = efi_guid_fm_capsule; header.header_size = sizeof(header); /* TODO: The current implementation ignores flags */ - header.flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET; + header.flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET | flags; header.capsule_image_size = sizeof(header) + sizeof(capsule) + sizeof(u64) + sizeof(image) @@ -171,6 +173,14 @@ err_1: return -1; } +int decode_capsule_flags(const char *flagstr, u32 *flags) +{ + if (strcmp(flagstr, "reset")) + return -EINVAL; + *flags = CAPSULE_FLAGS_INITIATE_RESET; + return 0; +} + /* * Usage: * $ mkeficapsule -f @@ -178,6 +188,7 @@ err_1: int main(int argc, char **argv) { char *file; + u32 flags; efi_guid_t *guid; unsigned long index, instance; int c, idx; @@ -186,8 +197,9 @@ int main(int argc, char **argv) guid = NULL; index = 0; instance = 0; + flags = 0; for (;;) { - c = getopt_long(argc, argv, "f:r:i:I:v:h", options, &idx); + c = getopt_long(argc, argv, "f:r:i:I:v:F:h", options, &idx); if (c == -1) break; @@ -214,6 +226,12 @@ int main(int argc, char **argv) case 'I': instance = strtoul(optarg, NULL, 0); break; + case 'F': + if (decode_capsule_flags(optarg, &flags) < 0) { + printf("Unsupported flags %s\n", optarg); + return -1; + } + break; case 'h': print_usage(); return 0; @@ -232,7 +250,7 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); } - if (create_fwbin(argv[optind], file, guid, index, instance) + if (create_fwbin(argv[optind], file, guid, index, instance, flags) < 0) { printf("Creating firmware capsule failed\n"); exit(EXIT_FAILURE);