Skip to content

Commit bd8bc53

Browse files
committed
efi_driver: create a parent device for all EFI block devices
Up to now root has been the parent device for all block devices created via calling ConnectController(). This does not work well together with the implementation of bootstd. Add a dummy parent device for all EFI block devices. With this change EFI block devices are also accessible via commands like 'cat', 'load', and 'ls'. => dm tree Class Seq Probed Driver Name ----------------------------------------------------------- efi 0 [ + ] EFI block driver `-- efi blk 3 [ + ] efi_blk `-- efi.efiblk#0 partition 0 [ + ] blk_partition `-- efi.efiblk#0:1 => ls efiloader 0:1 13 hello.txt 7 u-boot.txt 2 file(s), 0 dir(s) => cat efiloader 0:1 hello.txt Hello world! => efidebug dh 0000000018df1700 (efi.efiblk#0:1) /VenHw(dbca4c98-6cb0-694d-0872-819c650cb7b8)/HD(1,MBR,0xd1535d21,0x1,0x7f) Block IO Simple File System Adjust the event dump unit test to consider the new event spy. Signed-off-by: Heinrich Schuchardt <[email protected]>
1 parent 530e869 commit bd8bc53

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/efi_driver/efi_block_device.c

+28-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@
3535
#include <efi_driver.h>
3636
#include <malloc.h>
3737
#include <dm/device-internal.h>
38+
#include <dm/lists.h>
3839
#include <dm/root.h>
3940
#include <dm/tag.h>
41+
#include <dm/uclass-internal.h>
4042

4143
/**
4244
* struct efi_blk_plat - attributes of a block device
@@ -118,13 +120,18 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
118120
static efi_status_t
119121
efi_bl_create_block_device(efi_handle_t handle, void *interface)
120122
{
121-
struct udevice *bdev = NULL, *parent = dm_root();
123+
struct udevice *bdev = NULL, *parent;
122124
efi_status_t ret;
125+
int r;
123126
int devnum;
124127
char *name;
125128
struct efi_block_io *io = interface;
126129
struct efi_blk_plat *plat;
127130

131+
r = uclass_find_first_device(UCLASS_EFI_LOADER, &parent);
132+
if (r)
133+
return EFI_OUT_OF_RESOURCES;
134+
128135
devnum = blk_next_free_devnum(UCLASS_EFI_LOADER);
129136
if (devnum < 0)
130137
return EFI_OUT_OF_RESOURCES;
@@ -221,6 +228,24 @@ efi_bl_init(struct efi_driver_binding_extended_protocol *this)
221228
return EFI_SUCCESS;
222229
}
223230

231+
/**
232+
* efi_block_device_create() - create parent for EFI block devices
233+
*
234+
* Create a device that serves as parent for all block devices created via
235+
* ConnectController().
236+
*
237+
* Return: 0 for success
238+
*/
239+
static int efi_block_device_create(void)
240+
{
241+
int ret;
242+
struct udevice *dev;
243+
244+
ret = device_bind_driver(gd->dm_root, "EFI block driver", "efi", &dev);
245+
246+
return ret;
247+
}
248+
224249
/* Block device driver operators */
225250
static const struct blk_ops efi_blk_ops = {
226251
.read = efi_bl_read,
@@ -249,3 +274,5 @@ U_BOOT_DRIVER(efi_block) = {
249274
.id = UCLASS_EFI_LOADER,
250275
.ops = &driver_ops,
251276
};
277+
278+
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, efi_block_device_create);

test/py/tests/test_event_dump.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def test_event_dump(u_boot_console):
1919
EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.*
2020
EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple_os.c:.*
2121
EVT_LAST_STAGE_INIT alloc_write_acpi_tables .*lib/acpi/acpi_table.c:.*
22+
EVT_LAST_STAGE_INIT efi_block_device_create .*lib/efi_driver/efi_block_device.c:.*
2223
EVT_LAST_STAGE_INIT install_smbios_table .*lib/efi_loader/efi_smbios.c:.*
2324
EVT_MISC_INIT_F sandbox_early_getopt_check .*arch/sandbox/cpu/start.c:.*
2425
EVT_TEST h_adder_simple .*test/common/event.c:'''

0 commit comments

Comments
 (0)