From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8545FC433EF for ; Tue, 25 Jan 2022 11:31:55 +0000 (UTC) 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) 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-Google-Smtp-Source: ABdhPJw/FRY4xj0U5lwH0KvQXHhEAZIl87PPcMBqE/i2gkLJb4k6F5l31JUxhJFFjwTlmPZRqxTtog== 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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);