u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: Simon Glass <sjg@chromium.org>,
	U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Christian Melki <christian.melki@t2data.com>,
	Bin Meng <bmeng.cn@gmail.com>, Tom Rini <trini@konsulko.com>,
	Alexander Graf <agraf@csgraf.de>
Subject: Re: [PATCH v5 02/28] efi: Add EFI uclass for media
Date: Thu, 9 Dec 2021 10:54:37 -0800	[thread overview]
Message-ID: <62c671bb-fdb6-ce36-e669-53748ee19ac5@gmx.de> (raw)
In-Reply-To: <20211204085647.v5.2.I50ca59e389adf282bbff50eecc593f010a89c0f7@changeid>

On 12/4/21 07:56, Simon Glass wrote:
> At present UCLASS_EFI is used to represent an EFI filesystem among other

%s/UCLASS_EFI/UCLASS_EFI_LOADER/

> things. The description of this uclass is "EFI managed devices" which is
> pretty vague. The only driver that uses this uclass is in fact not a real
> U-Boot driver, since its operations do not include a struct udevice.
>
> Rather than mess with this, create a new UCLASS_EFI_MEDIA uclass to handle
> EFI media such as disks. Make this the uclass to use for EFI media so that

The new uclass is for devices provided by an UEFI implementation loading
U-Boot as an EFI application.

> it can be used with 'part list', for example.
>
> The existing implementation using UCLASS_EFI remains as is, for

%s/UCLASS_EFI/UCLASS_EFI_LOADER/

The existing uclass is for devices created by UEFI applications loaded
by U-Boot.


> discussion.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v2)
>
> Changes in v2:
> - Add MAINTAINERS entry
> - Show the correct interface type with 'part list'
> - Update the commit message to explain things better
>
>   MAINTAINERS                      |  3 +++
>   arch/sandbox/dts/test.dts        |  4 ++++
>   disk/part.c                      |  5 ++++-
>   drivers/block/Kconfig            | 23 +++++++++++++++++++++++
>   drivers/block/Makefile           |  3 +++
>   drivers/block/blk-uclass.c       |  2 ++
>   drivers/block/efi-media-uclass.c | 15 +++++++++++++++
>   drivers/block/sb_efi_media.c     | 20 ++++++++++++++++++++
>   include/blk.h                    |  1 +
>   include/dm/uclass-id.h           |  1 +
>   test/dm/Makefile                 |  1 +
>   test/dm/efi_media.c              | 24 ++++++++++++++++++++++++
>   12 files changed, 101 insertions(+), 1 deletion(-)
>   create mode 100644 drivers/block/efi-media-uclass.c
>   create mode 100644 drivers/block/sb_efi_media.c
>   create mode 100644 test/dm/efi_media.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 9045e509d73..5b162ad2978 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -714,8 +714,11 @@ W:	https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html
>   F:	board/efi/efi-x86_app
>   F:	configs/efi-x86_app*
>   F:	doc/develop/uefi/u-boot_on_efi.rst
> +F:	drivers/block/efi-media-uclass.c
> +F:	drivers/block/sb_efi_media.c
>   F:	lib/efi/efi_app.c
>   F:	scripts/build-efi.sh
> +F:	test/dm/efi_media.c
>
>   EFI PAYLOAD
>   M:	Heinrich Schuchardt <xypron.glpk@gmx.de>
> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
> index e5261bb9fa2..48ca3e1e472 100644
> --- a/arch/sandbox/dts/test.dts
> +++ b/arch/sandbox/dts/test.dts
> @@ -499,6 +499,10 @@
>   		compatible = "sandbox,clk-ccf";
>   	};
>
> +	efi-media {
> +		compatible = "sandbox,efi-media";
> +	};
> +
>   	eth@10002000 {
>   		compatible = "sandbox,eth";
>   		reg = <0x10002000 0x1000>;
> diff --git a/disk/part.c b/disk/part.c
> index fe1ebd4adf7..e857a9f9585 100644
> --- a/disk/part.c
> +++ b/disk/part.c
> @@ -296,8 +296,11 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
>   	case IF_TYPE_VIRTIO:
>   		puts("VirtIO");
>   		break;
> +	case IF_TYPE_EFI_MEDIA:
> +		puts("EFI");
> +		break;
>   	default:
> -		puts ("UNKNOWN");
> +		puts("UNKNOWN");
>   		break;
>   	}
>   	printf (" device %d  --   Partition Type: %s\n\n",
> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> index 56a4eec05ac..755fdccb574 100644
> --- a/drivers/block/Kconfig
> +++ b/drivers/block/Kconfig
> @@ -61,6 +61,29 @@ config TPL_BLOCK_CACHE
>   	help
>   	  This option enables the disk-block cache in TPL
>
> +config EFI_MEDIA
> +	bool "Support EFI media drivers"
> +	default y if EFI || SANDBOX
> +	help
> +	  Enable this to support media devices on top of UEFI. This enables
> +	  just the uclass so you also need a specific driver to make this do
> +	  anything.
> +
> +	  For sandbox there is a test driver.
> +
> +if EFI_MEDIA
> +
> +config EFI_MEDIA_SANDBOX
> +	bool "Sandbox EFI media driver"
> +	depends on SANDBOX
> +	default y
> +	help
> +	  Enables a simple sandbox media driver, used for testing just the
> +	  EFI_MEDIA uclass. It does not do anything useful, since sandbox does
> +	  not actually support running on top of UEFI.
> +
> +endif  # EFI_MEDIA
> +
>   config IDE
>   	bool "Support IDE controllers"
>   	select HAVE_BLOCK_DEVICE
> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
> index 94ab5c6f906..3778633da1d 100644
> --- a/drivers/block/Makefile
> +++ b/drivers/block/Makefile
> @@ -14,3 +14,6 @@ obj-$(CONFIG_IDE) += ide.o
>   endif
>   obj-$(CONFIG_SANDBOX) += sandbox.o
>   obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o
> +
> +obj-$(CONFIG_EFI_MEDIA) += efi-media-uclass.o
> +obj-$(CONFIG_EFI_MEDIA_SANDBOX) += sb_efi_media.o
> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> index a7470ae28d5..4ae8af6d609 100644
> --- a/drivers/block/blk-uclass.c
> +++ b/drivers/block/blk-uclass.c
> @@ -28,6 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
>   	[IF_TYPE_SATA]		= "sata",
>   	[IF_TYPE_HOST]		= "host",
>   	[IF_TYPE_NVME]		= "nvme",
> +	[IF_TYPE_EFI_MEDIA]	= "efi",
>   	[IF_TYPE_EFI_LOADER]	= "efiloader",
>   	[IF_TYPE_VIRTIO]	= "virtio",
>   	[IF_TYPE_PVBLOCK]	= "pvblock",
> @@ -44,6 +45,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
>   	[IF_TYPE_SATA]		= UCLASS_AHCI,
>   	[IF_TYPE_HOST]		= UCLASS_ROOT,
>   	[IF_TYPE_NVME]		= UCLASS_NVME,
> +	[IF_TYPE_EFI_MEDIA]	= UCLASS_EFI_MEDIA,
>   	[IF_TYPE_EFI_LOADER]	= UCLASS_EFI_LOADER,
>   	[IF_TYPE_VIRTIO]	= UCLASS_VIRTIO,
>   	[IF_TYPE_PVBLOCK]	= UCLASS_PVBLOCK,
> diff --git a/drivers/block/efi-media-uclass.c b/drivers/block/efi-media-uclass.c
> new file mode 100644
> index 00000000000..e012f6f2f4c
> --- /dev/null
> +++ b/drivers/block/efi-media-uclass.c
> @@ -0,0 +1,15 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Uclass for EFI media devices
> + *
> + * Copyright 2021 Google LLC
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +
> +UCLASS_DRIVER(efi_media) = {
> +	.id		= UCLASS_EFI_MEDIA,
> +	.name		= "efi_media",
> +	.flags		= DM_UC_FLAG_SEQ_ALIAS,
> +};
> diff --git a/drivers/block/sb_efi_media.c b/drivers/block/sb_efi_media.c
> new file mode 100644
> index 00000000000..52af155a600
> --- /dev/null
> +++ b/drivers/block/sb_efi_media.c
> @@ -0,0 +1,20 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * EFI_MEDIA driver for sandbox
> + *
> + * Copyright 2021 Google LLC
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +
> +static const struct udevice_id sandbox_efi_media_ids[] = {
> +	{ .compatible = "sandbox,efi-media" },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(sandbox_efi_media) = {
> +	.name		= "sandbox_efi_media",
> +	.id		= UCLASS_EFI_MEDIA,
> +	.of_match	= sandbox_efi_media_ids,
> +};
> diff --git a/include/blk.h b/include/blk.h
> index f0835c3fed5..dde21732572 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -37,6 +37,7 @@ enum if_type {
>   	IF_TYPE_EFI_LOADER,
>   	IF_TYPE_PVBLOCK,
>   	IF_TYPE_VIRTIO,
> +	IF_TYPE_EFI_MEDIA,
>
>   	IF_TYPE_COUNT,			/* Number of interface types */
>   };
> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
> index 5e503960aa7..15fff409a83 100644
> --- a/include/dm/uclass-id.h
> +++ b/include/dm/uclass-id.h
> @@ -49,6 +49,7 @@ enum uclass_id {
>   	UCLASS_DSA,		/* Distributed (Ethernet) Switch Architecture */
>   	UCLASS_ECDSA,		/* Elliptic curve cryptographic device */
>   	UCLASS_EFI_LOADER,	/* Devices managed by EFI_LOADER */
> +	UCLASS_EFI_MEDIA,	/* EFI media (e.g. a disk) */

%s/EFI media (e.g. a disk)/devices provided by UEFI firmware */

With those changes:

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

>   	UCLASS_ETH,		/* Ethernet device */
>   	UCLASS_ETH_PHY,		/* Ethernet PHY device */
>   	UCLASS_FIRMWARE,	/* Firmware */
> diff --git a/test/dm/Makefile b/test/dm/Makefile
> index 548649f8e82..d46552fbf32 100644
> --- a/test/dm/Makefile
> +++ b/test/dm/Makefile
> @@ -37,6 +37,7 @@ obj-$(CONFIG_DMA) += dma.o
>   obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o
>   obj-$(CONFIG_DM_DSA) += dsa.o
>   obj-$(CONFIG_ECDSA_VERIFY) += ecdsa.o
> +obj-$(CONFIG_EFI_MEDIA_SANDBOX) += efi_media.o
>   obj-$(CONFIG_DM_ETH) += eth.o
>   ifneq ($(CONFIG_EFI_PARTITION),)
>   obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o
> diff --git a/test/dm/efi_media.c b/test/dm/efi_media.c
> new file mode 100644
> index 00000000000..e343a0e9c85
> --- /dev/null
> +++ b/test/dm/efi_media.c
> @@ -0,0 +1,24 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Test for EFI_MEDIA uclass
> + *
> + * Copyright 2021 Google LLC
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <asm/test.h>
> +#include <dm/test.h>
> +#include <test/test.h>
> +#include <test/ut.h>
> +
> +/* Test that we can use the EFI_MEDIA uclass */
> +static int dm_test_efi_media(struct unit_test_state *uts)
> +{
> +	struct udevice *dev;
> +
> +	ut_assertok(uclass_first_device_err(UCLASS_EFI_MEDIA, &dev));
> +
> +	return 0;
> +}
> +DM_TEST(dm_test_efi_media, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
>


  reply	other threads:[~2021-12-09 18:54 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-04 15:56 [PATCH v5 00/28] efi: Improvements to U-Boot running on top of UEFI Simon Glass
2021-12-04 15:56 ` [PATCH v5 01/28] efi: Rename UCLASS_EFI and IF_TYPE_EFI Simon Glass
2021-12-09 18:38   ` Heinrich Schuchardt
2021-12-04 15:56 ` [PATCH v5 02/28] efi: Add EFI uclass for media Simon Glass
2021-12-09 18:54   ` Heinrich Schuchardt [this message]
2021-12-04 15:56 ` [PATCH v5 03/28] efi: Add a media/block driver for EFI block devices Simon Glass
2021-12-09 19:04   ` Heinrich Schuchardt
2021-12-04 15:56 ` [PATCH v5 04/28] efi: Locate all block devices in the app Simon Glass
2021-12-04 18:43   ` Heinrich Schuchardt
2021-12-09 19:23     ` Heinrich Schuchardt
2021-12-17 16:37       ` Simon Glass
2021-12-04 15:56 ` [PATCH v5 05/28] efi: serial: Support arrow keys Simon Glass
2021-12-09 19:39   ` Heinrich Schuchardt
2021-12-17 16:37     ` Simon Glass
2021-12-17 17:09       ` Heinrich Schuchardt
2021-12-17 17:42         ` Simon Glass
2021-12-04 15:56 ` [PATCH v5 06/28] bloblist: Support allocating the bloblist Simon Glass
2021-12-04 15:56 ` [PATCH v5 07/28] x86: Allow booting a kernel from the EFI app Simon Glass
2021-12-04 15:56 ` [PATCH v5 08/28] x86: Don't process the kernel command line unless enabled Simon Glass
2021-12-04 15:56 ` [PATCH v5 09/28] x86: efi: Add room for the binman definition in the dtb Simon Glass
2021-12-04 15:56 ` [PATCH v5 10/28] efi: Drop device_path from struct efi_priv Simon Glass
2021-12-04 15:56 ` [PATCH v5 11/28] efi: Add comments to " Simon Glass
2021-12-04 15:56 ` [PATCH v5 12/28] efi: Fix ll_boot_init() operation with the app Simon Glass
2021-12-04 15:56 ` [PATCH v5 13/28] efi: Add a few comments to the stub Simon Glass
2021-12-04 19:10   ` Heinrich Schuchardt
2021-12-04 15:56 ` [PATCH v5 14/28] efi: Share struct efi_priv between the app and stub code Simon Glass
2021-12-04 15:56 ` [PATCH v5 15/28] efi: Move exit_boot_services into a function Simon Glass
2021-12-04 19:13   ` Heinrich Schuchardt
2021-12-17 16:37     ` Simon Glass
2021-12-04 15:56 ` [PATCH v5 16/28] efi: Check for failure when initing the app Simon Glass
2021-12-09 20:17   ` Heinrich Schuchardt
2021-12-04 15:56 ` [PATCH v5 17/28] efi: Mention that efi_info_get() is only used in the stub Simon Glass
2021-12-09 20:20   ` Heinrich Schuchardt
2021-12-04 15:56 ` [PATCH v5 18/28] efi: Show when allocated pages are used Simon Glass
2021-12-09 19:55   ` Heinrich Schuchardt
2021-12-17 16:37     ` Simon Glass
2021-12-04 15:56 ` [PATCH v5 19/28] efi: Allow easy selection of serial-only operation Simon Glass
2021-12-04 15:56 ` [PATCH v5 20/28] x86: efi: Update efi_get_next_mem_desc() to avoid needing a map Simon Glass
2021-12-04 15:56 ` [PATCH v5 21/28] efi: Support the efi command in the app Simon Glass
2021-12-09 20:27   ` Heinrich Schuchardt
2021-12-17 16:37     ` Simon Glass
2021-12-20  2:38       ` AKASHI Takahiro
2021-12-29 13:36         ` Simon Glass
2021-12-04 15:56 ` [PATCH v5 22/28] x86: efi: Show the system-table revision Simon Glass
2021-12-09 20:29   ` Heinrich Schuchardt
2021-12-17 16:37     ` Simon Glass
2021-12-04 15:56 ` [PATCH v5 23/28] x86: efi: Don't set up global_data again with EFI Simon Glass
2021-12-04 15:56 ` [PATCH v5 24/28] x86: efi: Tweak the code used for the 64-bit EFI app Simon Glass
2021-12-04 15:56 ` [PATCH v5 25/28] x86: efi: Round out the link script for 64-bit EFI Simon Glass
2021-12-04 15:56 ` [PATCH v5 26/28] x86: efi: Don't use the 64-bit link script for the EFI app Simon Glass
2021-12-05 14:03   ` Christian Melki
2021-12-04 15:56 ` [PATCH v5 27/28] x86: efi: Set the correct link flags for the 64-bit " Simon Glass
2021-12-05 14:03   ` Christian Melki
2021-12-04 15:56 ` [PATCH v5 28/28] efi: Build the 64-bit app properly Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=62c671bb-fdb6-ce36-e669-53748ee19ac5@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=agraf@csgraf.de \
    --cc=bmeng.cn@gmail.com \
    --cc=christian.melki@t2data.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).