mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
efi: Add uclass for devices provided by UEFI firmware
UCLASS_EFI_LOADER is used for devices created by applications and drivers loaded by U-Boots UEFI implementation. This patch provides a new uclass (UCLASS_EFI_MEDIA) to be used for devices that provided by a UEFI firmware calling U-Boot as an EFI application. If the two uclasses can be unified, is left to future redesign. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
parent
2abd8d1c99
commit
42b7f4212a
12 changed files with 101 additions and 1 deletions
|
@ -713,8 +713,11 @@ W: https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html
|
||||||
F: board/efi/efi-x86_app
|
F: board/efi/efi-x86_app
|
||||||
F: configs/efi-x86_app*
|
F: configs/efi-x86_app*
|
||||||
F: doc/develop/uefi/u-boot_on_efi.rst
|
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: lib/efi/efi_app.c
|
||||||
F: scripts/build-efi.sh
|
F: scripts/build-efi.sh
|
||||||
|
F: test/dm/efi_media.c
|
||||||
|
|
||||||
EFI PAYLOAD
|
EFI PAYLOAD
|
||||||
M: Heinrich Schuchardt <xypron.glpk@gmx.de>
|
M: Heinrich Schuchardt <xypron.glpk@gmx.de>
|
||||||
|
|
|
@ -498,6 +498,10 @@
|
||||||
compatible = "sandbox,clk-ccf";
|
compatible = "sandbox,clk-ccf";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
efi-media {
|
||||||
|
compatible = "sandbox,efi-media";
|
||||||
|
};
|
||||||
|
|
||||||
eth@10002000 {
|
eth@10002000 {
|
||||||
compatible = "sandbox,eth";
|
compatible = "sandbox,eth";
|
||||||
reg = <0x10002000 0x1000>;
|
reg = <0x10002000 0x1000>;
|
||||||
|
|
|
@ -296,8 +296,11 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
|
||||||
case IF_TYPE_VIRTIO:
|
case IF_TYPE_VIRTIO:
|
||||||
puts("VirtIO");
|
puts("VirtIO");
|
||||||
break;
|
break;
|
||||||
|
case IF_TYPE_EFI_MEDIA:
|
||||||
|
puts("EFI");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
puts ("UNKNOWN");
|
puts("UNKNOWN");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf (" device %d -- Partition Type: %s\n\n",
|
printf (" device %d -- Partition Type: %s\n\n",
|
||||||
|
|
|
@ -61,6 +61,29 @@ config TPL_BLOCK_CACHE
|
||||||
help
|
help
|
||||||
This option enables the disk-block cache in TPL
|
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
|
config IDE
|
||||||
bool "Support IDE controllers"
|
bool "Support IDE controllers"
|
||||||
select HAVE_BLOCK_DEVICE
|
select HAVE_BLOCK_DEVICE
|
||||||
|
|
|
@ -14,3 +14,6 @@ obj-$(CONFIG_IDE) += ide.o
|
||||||
endif
|
endif
|
||||||
obj-$(CONFIG_SANDBOX) += sandbox.o
|
obj-$(CONFIG_SANDBOX) += sandbox.o
|
||||||
obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.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
|
||||||
|
|
|
@ -28,6 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
|
||||||
[IF_TYPE_SATA] = "sata",
|
[IF_TYPE_SATA] = "sata",
|
||||||
[IF_TYPE_HOST] = "host",
|
[IF_TYPE_HOST] = "host",
|
||||||
[IF_TYPE_NVME] = "nvme",
|
[IF_TYPE_NVME] = "nvme",
|
||||||
|
[IF_TYPE_EFI_MEDIA] = "efi",
|
||||||
[IF_TYPE_EFI_LOADER] = "efiloader",
|
[IF_TYPE_EFI_LOADER] = "efiloader",
|
||||||
[IF_TYPE_VIRTIO] = "virtio",
|
[IF_TYPE_VIRTIO] = "virtio",
|
||||||
[IF_TYPE_PVBLOCK] = "pvblock",
|
[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_SATA] = UCLASS_AHCI,
|
||||||
[IF_TYPE_HOST] = UCLASS_ROOT,
|
[IF_TYPE_HOST] = UCLASS_ROOT,
|
||||||
[IF_TYPE_NVME] = UCLASS_NVME,
|
[IF_TYPE_NVME] = UCLASS_NVME,
|
||||||
|
[IF_TYPE_EFI_MEDIA] = UCLASS_EFI_MEDIA,
|
||||||
[IF_TYPE_EFI_LOADER] = UCLASS_EFI_LOADER,
|
[IF_TYPE_EFI_LOADER] = UCLASS_EFI_LOADER,
|
||||||
[IF_TYPE_VIRTIO] = UCLASS_VIRTIO,
|
[IF_TYPE_VIRTIO] = UCLASS_VIRTIO,
|
||||||
[IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK,
|
[IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK,
|
||||||
|
|
15
drivers/block/efi-media-uclass.c
Normal file
15
drivers/block/efi-media-uclass.c
Normal file
|
@ -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,
|
||||||
|
};
|
20
drivers/block/sb_efi_media.c
Normal file
20
drivers/block/sb_efi_media.c
Normal file
|
@ -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,
|
||||||
|
};
|
|
@ -37,6 +37,7 @@ enum if_type {
|
||||||
IF_TYPE_EFI_LOADER,
|
IF_TYPE_EFI_LOADER,
|
||||||
IF_TYPE_PVBLOCK,
|
IF_TYPE_PVBLOCK,
|
||||||
IF_TYPE_VIRTIO,
|
IF_TYPE_VIRTIO,
|
||||||
|
IF_TYPE_EFI_MEDIA,
|
||||||
|
|
||||||
IF_TYPE_COUNT, /* Number of interface types */
|
IF_TYPE_COUNT, /* Number of interface types */
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,6 +49,7 @@ enum uclass_id {
|
||||||
UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */
|
UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */
|
||||||
UCLASS_ECDSA, /* Elliptic curve cryptographic device */
|
UCLASS_ECDSA, /* Elliptic curve cryptographic device */
|
||||||
UCLASS_EFI_LOADER, /* Devices created by UEFI applications */
|
UCLASS_EFI_LOADER, /* Devices created by UEFI applications */
|
||||||
|
UCLASS_EFI_MEDIA, /* Devices provided by UEFI firmware */
|
||||||
UCLASS_ETH, /* Ethernet device */
|
UCLASS_ETH, /* Ethernet device */
|
||||||
UCLASS_ETH_PHY, /* Ethernet PHY device */
|
UCLASS_ETH_PHY, /* Ethernet PHY device */
|
||||||
UCLASS_FIRMWARE, /* Firmware */
|
UCLASS_FIRMWARE, /* Firmware */
|
||||||
|
|
|
@ -37,6 +37,7 @@ obj-$(CONFIG_DMA) += dma.o
|
||||||
obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o
|
obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o
|
||||||
obj-$(CONFIG_DM_DSA) += dsa.o
|
obj-$(CONFIG_DM_DSA) += dsa.o
|
||||||
obj-$(CONFIG_ECDSA_VERIFY) += ecdsa.o
|
obj-$(CONFIG_ECDSA_VERIFY) += ecdsa.o
|
||||||
|
obj-$(CONFIG_EFI_MEDIA_SANDBOX) += efi_media.o
|
||||||
obj-$(CONFIG_DM_ETH) += eth.o
|
obj-$(CONFIG_DM_ETH) += eth.o
|
||||||
ifneq ($(CONFIG_EFI_PARTITION),)
|
ifneq ($(CONFIG_EFI_PARTITION),)
|
||||||
obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o
|
obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o
|
||||||
|
|
24
test/dm/efi_media.c
Normal file
24
test/dm/efi_media.c
Normal file
|
@ -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);
|
Loading…
Add table
Add a link
Reference in a new issue