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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BB44C433F5 for ; Sun, 7 Nov 2021 08:11:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DE857610A6 for ; Sun, 7 Nov 2021 08:11:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DE857610A6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 54F73837AB; Sun, 7 Nov 2021 09:11:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de 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; secure) header.d=gmx.net header.i=@gmx.net header.b="AiYhTJP4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FF6D837B1; Sun, 7 Nov 2021 09:11:05 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8CAD98378E for ; Sun, 7 Nov 2021 09:11:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1636272658; bh=9ARdv6PwBZYKC5bzVtSy4VfWLv7a4yp6cVzR9vY5XJs=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=AiYhTJP47uuN7c9CEUBiFN02ohOBEDrq41X8XO81tnqcUEbUs7kq2HkGE+5LsrLZK HJS6X6AUCy2pEk7w+mC1xH+3nO6FmMc7gLJ9bWXVvcn3p4w53zkr9t4FR/emoWC1Gt TBx97wzrz51610W082k7hyeSX8yGMB+NS8lWcPeE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.35] ([88.152.144.157]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MVNAr-1n8DEk3uq7-00SLBM; Sun, 07 Nov 2021 09:10:58 +0100 Message-ID: Date: Sun, 7 Nov 2021 09:10:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH v4 08/34] efi: Add video support to the app Content-Language: en-US To: Simon Glass , U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Christian Melki , Bin Meng , Alexander Graf References: <20211104030936.2446706-1-sjg@chromium.org> <20211103210920.v4.8.Ibf877904b58b5ba17bdd00f80dcd3f8b8e0c1f39@changeid> From: Heinrich Schuchardt In-Reply-To: <20211103210920.v4.8.Ibf877904b58b5ba17bdd00f80dcd3f8b8e0c1f39@changeid> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:3JrxWxgu4fsnEGZCrHvbqvMt7gOSAkJ1tJhnVHhpi7XgQWap8Zz 1oUY6CHeCXKTN/DXMjTrPnD42kKmW7BhINnlxXYTND6Ktmp1FhJDtqzx5bGcY4X7d0+gdTJ cjyqiAN8xJu/O4aPfnYtX+ncmH2uf5Msozz03Df3//9Cc1dpnW7R9b4yyn+D6hXcb4zr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TnRqWc1u2DEW2FWyNNn42zBkGfw1elf3eCenv1wyr fWV8OmXljNTQe7oKs4aJ9GT5kBpHaFjYwMBQpfu2Ya07pwYpjH2Vc1pl9hjkJkOWw7X9Zmy48 R9UMa/k0huM3dA= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On 11/4/21 04:09, Simon Glass wrote: > The current EFI video driver only works when running in the stub. In tha= t > case the stub calls boot services (before jumping to U-Boot proper) and > copies the graphics info over to the efi table. This is necessary becaus= e > the stub exits boot services before jumping to U-Boot. > > The app maintains access to boot services throughout its life, so does n= ot > need to do this. Update the driver to support calling boot services > directly. > > Enable video output for the app. Note that this uses the > EFI_GRAPHICS_OUTPUT_PROTOCOL protocol, even though it mentions vesa. > > A sample qemu command-line for this case is: > > qemu-system-x86_64 -bios /usr/share/edk2.git/ovmf-ia32/OVMF-pure-efi= .fd > -drive id=3Ddisk,file=3Dtry.img,if=3Dnone,format=3Draw -nic none > -device ahci,id=3Dahci -device ide-hd,drive=3Ddisk,bus=3Dahci.0 > > Signed-off-by: Simon Glass > --- > > (no changes since v2) > > Changes in v2: > - Add a note that EFI_GRAPHICS_OUTPUT_PROTOCOL is used > - Update documentation > > arch/x86/dts/efi-x86_app.dts | 4 +++ > board/efi/efi-x86_app/Kconfig | 4 +++ > doc/develop/uefi/u-boot_on_efi.rst | 2 +- > drivers/video/Kconfig | 2 +- > drivers/video/efi.c | 45 ++++++++++++++++++++++++------ > include/configs/efi-x86_app.h | 6 ++-- > 6 files changed, 50 insertions(+), 13 deletions(-) > > diff --git a/arch/x86/dts/efi-x86_app.dts b/arch/x86/dts/efi-x86_app.dts > index 04e044a07a8..a5316e2a1a7 100644 > --- a/arch/x86/dts/efi-x86_app.dts > +++ b/arch/x86/dts/efi-x86_app.dts > @@ -25,4 +25,8 @@ > compatible =3D "efi,reset"; > u-boot,dm-pre-reloc; > }; > + efi-fb { > + compatible =3D "efi-fb"; > + }; > + > }; > diff --git a/board/efi/efi-x86_app/Kconfig b/board/efi/efi-x86_app/Kconf= ig > index e412702eed7..ecd08d73146 100644 > --- a/board/efi/efi-x86_app/Kconfig > +++ b/board/efi/efi-x86_app/Kconfig > @@ -12,4 +12,8 @@ config SYS_SOC > config SYS_CONFIG_NAME > default "efi-x86_app" > > +config BOARD_SPECIFIC_OPTIONS # dummy > + def_bool y > + imply VIDEO_EFI > + > endif > diff --git a/doc/develop/uefi/u-boot_on_efi.rst b/doc/develop/uefi/u-boo= t_on_efi.rst > index f275a524ce7..5f2f850f071 100644 > --- a/doc/develop/uefi/u-boot_on_efi.rst > +++ b/doc/develop/uefi/u-boot_on_efi.rst > @@ -265,7 +265,7 @@ This work could be extended in a number of ways: > > - Figure out how to solve the interrupt problem > > -- Add more drivers to the application side (e.g. video, block devices, = USB, > +- Add more drivers to the application side (e.g. block devices, USB, > environment access). This would mostly be an academic exercise as a = strong > use case is not readily apparent, but it might be fun. > > diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig > index 2f4650f8309..a58f87f479b 100644 > --- a/drivers/video/Kconfig > +++ b/drivers/video/Kconfig > @@ -250,7 +250,7 @@ config VIDEO_COREBOOT > > config VIDEO_EFI > bool "Enable EFI framebuffer driver support" > - depends on EFI_STUB > + depends on EFI_STUB || EFI_APP > help > Turn on this option to enable a framebuffeer driver when U-Boot is > loaded as a payload (see README.u-boot_on_efi) by an EFI BIOS where > diff --git a/drivers/video/efi.c b/drivers/video/efi.c > index c248bd352a7..4e13a3efcb1 100644 > --- a/drivers/video/efi.c > +++ b/drivers/video/efi.c > @@ -50,6 +50,28 @@ static void efi_find_pixel_bits(u32 mask, u8 *pos, u8= *size) > *size =3D len; > } > > +static int get_mode_info(struct vesa_mode_info *vesa) > +{ > + efi_guid_t efi_gop_guid =3D EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; > + struct efi_boot_services *boot =3D efi_get_boot(); > + struct efi_gop_mode *mode; > + struct efi_gop *gop; > + int ret; > + > + if (!boot) > + return log_msg_ret("sys", -ENOSYS); > + ret =3D boot->locate_protocol(&efi_gop_guid, NULL, (void **)&gop); > + if (ret) > + return log_msg_ret("prot", -ENOTSUPP); > + > + mode =3D gop->mode; > + vesa->phys_base_ptr =3D mode->fb_base; > + vesa->x_resolution =3D mode->info->width; > + vesa->y_resolution =3D mode->info->height; > + > + return 0; > +} > + > static int save_vesa_mode(struct vesa_mode_info *vesa) > { > struct efi_entry_gopmode *mode; > @@ -57,16 +79,23 @@ static int save_vesa_mode(struct vesa_mode_info *ves= a) > int size; > int ret; > > - ret =3D efi_info_get(EFIET_GOP_MODE, (void **)&mode, &size); > - if (ret =3D=3D -ENOENT) { > - debug("efi graphics output protocol mode not found\n"); > - return -ENXIO; > + if (IS_ENABLED(CONFIG_EFI_APP)) { > + ret =3D get_mode_info(vesa); > + if (ret) { > + printf("efi graphics output protocol not found\n"); > + return -ENXIO; > + } > + } else { > + ret =3D efi_info_get(EFIET_GOP_MODE, (void **)&mode, &size); > + if (ret =3D=3D -ENOENT) { > + printf("efi graphics output protocol mode not found\n"); %s/efi/EFI/ I will correct this when merging. Reviewed-by: Heinrich Schuchardt > + return -ENXIO; > + } > + vesa->phys_base_ptr =3D mode->fb_base; > + vesa->x_resolution =3D mode->info->width; > + vesa->y_resolution =3D mode->info->height; > } > > - vesa->phys_base_ptr =3D mode->fb_base; > - vesa->x_resolution =3D mode->info->width; > - vesa->y_resolution =3D mode->info->height; > - > if (mode->info->pixel_format < EFI_GOT_BITMASK) { > fbinfo =3D &efi_framebuffer_format_map[mode->info->pixel_format]; > vesa->red_mask_size =3D fbinfo->red.size; > diff --git a/include/configs/efi-x86_app.h b/include/configs/efi-x86_app= .h > index 33418cfbec4..6061a6db0a4 100644 > --- a/include/configs/efi-x86_app.h > +++ b/include/configs/efi-x86_app.h > @@ -10,8 +10,8 @@ > > #undef CONFIG_TPM_TIS_BASE_ADDRESS > > -#define CONFIG_STD_DEVICES_SETTINGS "stdin=3Dusbkbd,vga,serial\0" \ > - "stdout=3Dvga,serial\0" \ > - "stderr=3Dvga,serial\0" > +#define CONFIG_STD_DEVICES_SETTINGS "stdin=3Dserial\0" \ > + "stdout=3Dvidconsole\0" \ > + "stderr=3Dvidconsole\0" > > #endif >