From patchwork Fri Nov 10 04:25:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 742843 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp12683wrw; Thu, 9 Nov 2023 20:29:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXvS/onc8FPjPZAKjXmig3F49/myQEUXsUVabs6ENMYN2O4U/yZWqx71HgDKaurVBmpU3Y X-Received: by 2002:a17:907:9815:b0:9de:32bb:fa95 with SMTP id ji21-20020a170907981500b009de32bbfa95mr6618958ejc.35.1699590558542; Thu, 09 Nov 2023 20:29:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699590558; cv=none; d=google.com; s=arc-20160816; b=dE2ylmchBU8GZlED4v/zRXf7jJ+ZQtkGpwmkwK5pNw8LJOoGYw7oYjdcNuKpriDmOm FxrMxmMUazlRX4ZeY09G3orWL0UD8rYWHuF3ONPrE2bKpt/+oMhBJcLHLOWggAEGKzXT IgT19SbucxrGvRvufaK4td4FLLZtq1STTv52vlyy2EH8aRQnV5bkH/O4kPSmj3N7+vH/ Om2Udiqi6eZCVHXqcDYz7erhfQyD1POuqpq1DUj0BAlemkjo3CZR5D3wkumMEA+N75mI BKV4rw10N1Boq6LuBb2gJn5wwgo+wSZOlvT8r9yTUC2NDdS4LKPHIMeGmZuwtiMBGLsH dD6A== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=si9i4cdutpBbC+26YE8jjQg39hK8ZliLEIT6vpdk+so=; fh=UwEaQaZSKscgV8VKorL4WxKMlykH7WzwOcMeBrHkxSs=; b=eNlavNmY2MrurcJupKolv7IBqrDLJCnVSJFQYkucSkEqP+W0LPE8O7QkwnMgQeX6SG n0ofUw5MdIFndSioOn1NUgvdO1/ykBhFwfW+w1I0fVQKTGyv8BCOOOKt6yzzPQL0Eo/m d6nrMhvV5G+TEQSSG9EBrXTYR1HeK/cLbL2qgCAHjAXW8VxvmBg9huzOrDC/jk32PgoT JWQFLOu/LeF3pcJn2zTrUhxPotszteq1EFYmzoy4tD656u7dNUDHkJJFlI7FdkXvGw8I fq1ClNRzFLGcU1tL3Wu1wbbBK9BJZPTHGgzQsOKTe2Eurb3Ls9OGQGkzVaJBO2CEbWkh HewA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KUs4iRV1; 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 hd16-20020a170907969000b0099cd74432d6si4495217ejc.439.2023.11.09.20.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 20:29:18 -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=KUs4iRV1; 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 675A68778B; Fri, 10 Nov 2023 05:28:10 +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="KUs4iRV1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 07A398779F; Fri, 10 Nov 2023 05:27:56 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ua1-x932.google.com (mail-ua1-x932.google.com [IPv6:2607:f8b0:4864:20::932]) (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 4B2B387783 for ; Fri, 10 Nov 2023 05:27: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=masahisa.kojima@linaro.org Received: by mail-ua1-x932.google.com with SMTP id a1e0cc1a2514c-7b9bd9f8bfaso661748241.0 for ; Thu, 09 Nov 2023 20:27:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699590457; x=1700195257; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=si9i4cdutpBbC+26YE8jjQg39hK8ZliLEIT6vpdk+so=; b=KUs4iRV15N4vv8nmu+bQA+KFdlCmjYdRSie9hidytzUEmS6uMT+2Oz4RnqYAQ0e40H Zk2nTx68aNEveIRZOTnsG7w50AnB/6jr3O59DMuJjov+TCPL8/HkEKJbfz5UzO9+L0cd r2rs9TP9SuNxZxXxDfllTTnw2shC/cSMrkEiV4pjR4DvFzFffhmhqvC9BPtKY1VfD+Fu DP7xWuMqnaK1JHgGg8ZTOX0+Ik+DKtXxiZ/xPSKskX1Tlsdd6WfLxWJdjZBxAQgsBjfr fV9ykbB+z01MnINEXWqLaxqK7nX2YBJ25dYTsF4HG0q9MvrU02cWf4UifSvNNHbHnYhE OYhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699590457; x=1700195257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=si9i4cdutpBbC+26YE8jjQg39hK8ZliLEIT6vpdk+so=; b=rdE7Li88XfQ8qbZ2aAMiuUImhTvl4nW28jxKrLpX9zx5q0MJ+4f+a4LKz5Q0V9Nkfn FfKEmnIFk94ALS5RqeIDguATsIkv3o0rlEPUFC820pinGVJohlnELt4ZyBIdGHOG44fA 6plZ7nQLKoqdeGcmUICQMRuv4ggOSjMB3CHjyd+6LsJxZISjwhp7rFGWyg2SWKoGy61q weMjCp3g/BFmFGtE48s7Ey1xKJfU6OVaq6/h7nL/fqrN32zELwVAvztY2HG3feHKc89z URyvl+ie0PxdJhac+NjaMDfqRE7l3LCNNfVRY/8K9HCgZDE88DG/VHAlSYWjMxKEqZHz snVg== X-Gm-Message-State: AOJu0YzIZSA+auyjofOmQev9CfRENknb4JnzthQLEXdl8KVEqyG347sz SynUWXh98a7Nl5FZmjc6zmY4SdKLmCTO3mOnjp0= X-Received: by 2002:a67:e149:0:b0:45f:75e0:131e with SMTP id o9-20020a67e149000000b0045f75e0131emr6823998vsl.33.1699590457531; Thu, 09 Nov 2023 20:27:37 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id h19-20020a170902f7d300b001c8836a3795sm4337016plw.271.2023.11.09.20.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 20:27:36 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Michal Simek , Masahisa Kojima , Joe Hershberger , Ramon Fried Subject: [PATCH v12 8/9] cmd: efidebug: add uri device path Date: Fri, 10 Nov 2023 13:25:41 +0900 Message-Id: <20231110042542.3797301-9-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231110042542.3797301-1-masahisa.kojima@linaro.org> References: <20231110042542.3797301-1-masahisa.kojima@linaro.org> 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.8 at phobos.denx.de X-Virus-Status: Clean This adds the URI device path option for 'boot add' subcommand. User can add the URI load option for downloading ISO image file or EFI application through network. Currently HTTP is only supported. Signed-off-by: Masahisa Kojima --- cmd/efidebug.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/net.h | 8 ++++++ net/wget.c | 71 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 201531ac19..78ef16f4cb 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -707,6 +708,65 @@ out: return initrd_dp; } +/** + * efi_boot_add_uri() - set URI load option + * + * @argc: Number of arguments + * @argv: Argument array + * @var_name16: variable name buffer + * @var_name16_size: variable name buffer size + * @lo: pointer to the load option + * @file_path: buffer to set the generated device path pointer + * @fp_size: file_path size + * Return: CMD_RET_SUCCESS on success, + * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure + */ +static int efi_boot_add_uri(int argc, char *const argv[], u16 *var_name16, + size_t var_name16_size, struct efi_load_option *lo, + struct efi_device_path **file_path, + efi_uintn_t *fp_size) +{ + int id; + char *pos; + char *endp; + u16 *label; + efi_uintn_t uridp_len; + struct efi_device_path_uri *uridp; + + if (argc < 3 || lo->label) + return CMD_RET_USAGE; + + id = (int)hextoul(argv[1], &endp); + if (*endp != '\0' || id > 0xffff) + return CMD_RET_USAGE; + + label = efi_convert_string(argv[2]); + if (!label) + return CMD_RET_FAILURE; + + if (!wget_validate_uri(argv[3])) { + printf("ERROR: invalid URI\n"); + return CMD_RET_FAILURE; + } + + efi_create_indexed_name(var_name16, var_name16_size, "Boot", id); + lo->label = label; + + uridp_len = sizeof(struct efi_device_path) + strlen(argv[3]) + 1; + uridp = efi_alloc(uridp_len + sizeof(END)); + uridp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; + uridp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_URI; + uridp->dp.length = uridp_len; + strcpy(uridp->uri, argv[3]); + pos = (char *)uridp + uridp_len; + memcpy(pos, &END, sizeof(END)); + + *file_path = &uridp->dp; + *fp_size += uridp_len + sizeof(END); + + return CMD_RET_SUCCESS; +} + /** * do_efi_boot_add() - set UEFI load option * @@ -829,6 +889,21 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, argc -= 1; argv += 1; break; + case 'u': + if (IS_ENABLED(CONFIG_EFI_HTTP_BOOT)) { + r = efi_boot_add_uri(argc, argv, var_name16, + sizeof(var_name16), &lo, + &file_path, &fp_size); + if (r != CMD_RET_SUCCESS) + goto out; + fp_free = file_path; + argc -= 3; + argv += 3; + } else{ + r = CMD_RET_USAGE; + goto out; + } + break; default: r = CMD_RET_USAGE; goto out; @@ -1491,6 +1566,9 @@ U_BOOT_LONGHELP(efidebug, " -b|-B