From patchwork Tue Nov 21 11:35:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1866649 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=YVbqca75; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SZMmJ0xFKz1yRg for ; Tue, 21 Nov 2023 22:37:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 487938759E; Tue, 21 Nov 2023 12:36:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YVbqca75"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C060287581; Tue, 21 Nov 2023 12:36:12 +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,DKIMWL_WL_HIGH, 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-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 E7AC4875A2 for ; Tue, 21 Nov 2023 12:36:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-7a67f447bf0so214586239f.2 for ; Tue, 21 Nov 2023 03:36:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1700566568; x=1701171368; 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=dB/vG1X4+Ly+6sHdNUNJSb6d66cX5fxIJ0GmIdbR/ZQ=; b=YVbqca750yxrjWNoqdZSMTCWI4jT6RKcPJV57mqBaogII9bBeyMNB+i+Nd/Whbk0ff AKQ0biwSF4xkv/5DJ8g+RPh+SkswGpe615cXA9ol/fsa5G8SawTq1VbHyd1WFKOU8mxi TWKQrR3z5Jwv1A3h/pTBsmMMI7Bm7p54sllDo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700566568; x=1701171368; 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=dB/vG1X4+Ly+6sHdNUNJSb6d66cX5fxIJ0GmIdbR/ZQ=; b=CI+ELtdCtBUey5mAovnxndmRxF66WeFa6ptm8Aon8x/uK/wxRygOxnLszf/sBDKjgT LulSJJKw+BeI8ueFggf9DmjX1PV2gVkIm8DXqqt6yC+QC7kYkLIBNWmQavEylrfX8/90 1eItxRncvULjnuv8I1FDfBTHnDps9ICwvqRllNcs2gUVHQFrw59iTb/mUGvtIbFSCAUj fNfR0Ek4qEf7vHkeXrqGlbyjliUFtx2P96nYIoYy9OsL4D5uNNr5Pc1Ig/qdgsdpnB16 CmA08vb5oU4ZHEDXxSlxMfvgzu8etPxetYpbXhVEYeeTbv0Wgz9eYoFpN8uoBC55ljNW OICg== X-Gm-Message-State: AOJu0YzUBlS6pFYoawf3vRMLKyWrKRCj5THYOTb/zsr+AkWAwFDWZtcI VrjQD3lKeV4ivwMTyR1Ggua/kIUYlNk099xQfhzXfA== X-Google-Smtp-Source: AGHT+IFVH1Zh7d5CzIlqzEjACiDMUpBXCIgCcx9SCN/y53GVQ8dQJIE758Zrnc9ifIatdMVyKymTSg== X-Received: by 2002:a5d:9389:0:b0:7ab:ec1f:f4a2 with SMTP id c9-20020a5d9389000000b007abec1ff4a2mr4863491iol.8.1700566568497; Tue, 21 Nov 2023 03:36:08 -0800 (PST) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id h10-20020a0566380f8a00b0045bb982a3d2sm2559190jal.60.2023.11.21.03.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 03:36:08 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass Subject: [PATCH 6/7] WIP: efi: Allow helloworld to exit boot services Date: Tue, 21 Nov 2023 04:35:52 -0700 Message-ID: <20231121113557.800353-7-sjg@chromium.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231121113557.800353-1-sjg@chromium.org> References: <20231121113557.800353-1-sjg@chromium.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 allows testing of the exit_boot_services call, providing more coverage of the EFI bootmeth. Signed-off-by: Simon Glass --- lib/efi_loader/helloworld.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c index 1135d3a3c37e..1fb5fb5a62f2 100644 --- a/lib/efi_loader/helloworld.c +++ b/lib/efi_loader/helloworld.c @@ -206,6 +206,26 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, (con_out, u"Cannot open loaded image protocol\r\n"); goto out; } + + { + ulong ptr = (ulong)loaded_image; + u16 str[80]; + int i; + + for (i = 0; i < 8; i++) { + uint digit = (ptr >> ((7 - i) * 4)) & 0xf; + + if (digit > 9) + digit = 'a' + digit - 10; + else + digit += '0'; + str[i] = digit; + } + str[i] = 0; + con_out->output_string(con_out, str); + con_out->output_string(con_out, u"\n"); + } + print_load_options(loaded_image); /* Get the device path to text protocol */ @@ -243,7 +263,21 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, goto out; out: - boottime->exit(handle, ret, 0, NULL); + /* + * TODO: Use vendor string to decide whether to call exit-boot-services + */ + efi_uintn_t map_size = 0; + efi_uintn_t map_key; + efi_uintn_t desc_size; + u32 desc_version; + + ret = boottime->get_memory_map(&map_size, NULL, &map_key, &desc_size, + &desc_version); + con_out->output_string(con_out, u"Exiting boot sevices\n"); + + boottime->exit_boot_services(handle, map_key); + + ret = boottime->exit(handle, ret, 0, NULL); /* We should never arrive here */ return ret;