Skip to content

Commit

Permalink
Merge tag 'efi-2022-10-rc3-2' of https://source.denx.de/u-boot/custod…
Browse files Browse the repository at this point in the history
…ians/u-boot-efi

Pull request for efi-2022-10-rc3-2

Documentation:

* improve description of device probing
* describe booting RISC-V with KVM and QEMU

UEFI

* fix Makefile for mkeficapsule
  • Loading branch information
trini committed Aug 20, 2022
2 parents 1ea6966 + 2a4fb47 commit e9a4a17
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 27 deletions.
13 changes: 13 additions & 0 deletions doc/board/emulation/qemu-riscv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ An attached disk can be emulated in RISC-V virt machine by adding::

You will have to run 'scsi scan' to use it.

Running with KVM
----------------

Running with QEMU using KVM requires an S-mode U-Boot binary as created by
qemu-riscv64_smode_defconfig.

Provide the U-Boot S-mode ELF image as *-kernel* parameter and do not add a
*-bios* parameter, e.g.

.. code-block:: bash
qemu-system-riscv64 -accel kvm -nographic -machine virt -kernel u-boot
Debug UART
----------

Expand Down
47 changes: 33 additions & 14 deletions doc/develop/driver-model/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -794,34 +794,53 @@ fall afoul of this rule.
Activation/probe
^^^^^^^^^^^^^^^^

When a device needs to be used, U-Boot activates it, by first reading ofdata
as above and then following these steps (see device_probe()):
To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader,
not an operating system. Many devices are never used during an U-Boot run, and
probing them takes time, requires memory, may add delays to the main loop, etc.

The device should be probed by the uclass code or generic device code (e.g.
device_find_global_by_ofnode()). Uclasses differ but two common use cases can be
seen:

1. The uclass is asked to look up a specific device, such as SPI bus 0,
first chip select - in this case the returned device should be
activated.

2. The uclass is asked to perform a specific function on any device that
supports it, eg. reset the board using any sysreset that can be found -
for this case the core uclass code provides iterators that activate
each device before returning it, and the uclass typically implements a
walk function that iterates over all devices of the uclass and tries
to perform the requested function on each in turn until succesful.

To activate a device U-Boot first reads ofdata as above and then follows these
steps (see device_probe()):

1. All parent devices are probed. It is not possible to activate a device
unless its predecessors (all the way up to the root device) are activated.
This means (for example) that an I2C driver will require that its bus
be activated.
unless its predecessors (all the way up to the root device) are activated.
This means (for example) that an I2C driver will require that its bus
be activated.

2. The device's probe() method is called. This should do anything that
is required by the device to get it going. This could include checking
that the hardware is actually present, setting up clocks for the
hardware and setting up hardware registers to initial values. The code
in probe() can access:
is required by the device to get it going. This could include checking
that the hardware is actually present, setting up clocks for the
hardware and setting up hardware registers to initial values. The code
in probe() can access:

- platform data in dev->plat (for configuration)
- private data in dev->priv (for run-time state)
- uclass data in dev->uclass_priv (for things the uclass stores
about this device)

Note: If you don't use priv_auto then you will need to
allocate the priv space here yourself. The same applies also to
plat_auto. Remember to free them in the remove() method.
Note: If you don't use priv_auto then you will need to
allocate the priv space here yourself. The same applies also to
plat_auto. Remember to free them in the remove() method.

3. The device is marked 'activated'

4. The uclass's post_probe() method is called, if one exists. This may
cause the uclass to do some housekeeping to record the device as
activated and 'known' by the uclass.
cause the uclass to do some housekeeping to record the device as
activated and 'known' by the uclass.

Running stage
^^^^^^^^^^^^^
Expand Down
13 changes: 2 additions & 11 deletions lib/efi_loader/efi_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID;
*
* @header: EFI object header
* @ops: EFI disk I/O protocol interface
* @ifname: interface name for block device
* @dev_index: device index of block device
* @media: block I/O media information
* @dp: device path to the block device
Expand All @@ -40,7 +39,6 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID;
struct efi_disk_obj {
struct efi_object header;
struct efi_block_io ops;
const char *ifname;
int dev_index;
struct efi_block_io_media media;
struct efi_device_path *dp;
Expand Down Expand Up @@ -379,7 +377,6 @@ static int efi_fs_exists(struct blk_desc *desc, int part)
*
* @parent: parent handle
* @dp_parent: parent device path
* @if_typename: interface name for block device
* @desc: internal block device
* @dev_index: device index for block device
* @part_info: partition info
Expand All @@ -390,7 +387,6 @@ static int efi_fs_exists(struct blk_desc *desc, int part)
static efi_status_t efi_disk_add_dev(
efi_handle_t parent,
struct efi_device_path *dp_parent,
const char *if_typename,
struct blk_desc *desc,
int dev_index,
struct disk_partition *part_info,
Expand Down Expand Up @@ -475,7 +471,6 @@ static efi_status_t efi_disk_add_dev(
return ret;
}
diskobj->ops = block_io_disk_template;
diskobj->ifname = if_typename;
diskobj->dev_index = dev_index;

/* Fill in EFI IO Media info (for read/write callbacks) */
Expand Down Expand Up @@ -533,15 +528,13 @@ static int efi_disk_create_raw(struct udevice *dev)
{
struct efi_disk_obj *disk;
struct blk_desc *desc;
const char *if_typename;
int diskid;
efi_status_t ret;

desc = dev_get_uclass_plat(dev);
if_typename = blk_get_if_type_name(desc->if_type);
diskid = desc->devnum;

ret = efi_disk_add_dev(NULL, NULL, if_typename, desc,
ret = efi_disk_add_dev(NULL, NULL, desc,
diskid, NULL, 0, &disk);
if (ret != EFI_SUCCESS) {
if (ret == EFI_NOT_READY)
Expand Down Expand Up @@ -575,7 +568,6 @@ static int efi_disk_create_part(struct udevice *dev)
{
efi_handle_t parent;
struct blk_desc *desc;
const char *if_typename;
struct disk_part *part_data;
struct disk_partition *info;
unsigned int part;
Expand All @@ -589,7 +581,6 @@ static int efi_disk_create_part(struct udevice *dev)
return -1;

desc = dev_get_uclass_plat(dev_get_parent(dev));
if_typename = blk_get_if_type_name(desc->if_type);
diskid = desc->devnum;

part_data = dev_get_uclass_plat(dev);
Expand All @@ -601,7 +592,7 @@ static int efi_disk_create_part(struct udevice *dev)
return -1;
dp_parent = (struct efi_device_path *)handler->protocol_interface;

ret = efi_disk_add_dev(parent, dp_parent, if_typename, desc, diskid,
ret = efi_disk_add_dev(parent, dp_parent, desc, diskid,
info, part, &disk);
if (ret != EFI_SUCCESS) {
log_err("Adding partition for %s failed\n", dev->name);
Expand Down
8 changes: 6 additions & 2 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,13 @@ hostprogs-$(CONFIG_ASN1_COMPILER) += asn1_compiler
HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include

HOSTCFLAGS_mkeficapsule.o += \
$(shell pkg-config --cflags gnutls uuid 2> /dev/null || echo "")
$(shell pkg-config --cflags gnutls 2> /dev/null || echo "")
HOSTCFLAGS_mkeficapsule.o += \
$(shell pkg-config --cflags uuid 2> /dev/null || echo "")
HOSTLDLIBS_mkeficapsule += \
$(shell pkg-config --libs gnutls 2> /dev/null || echo "-lgnutls")
HOSTLDLIBS_mkeficapsule += \
$(shell pkg-config --libs gnutls uuid 2> /dev/null || echo "-lgnutls -luuid")
$(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid")
hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule

# We build some files with extra pedantic flags to try to minimize things
Expand Down

0 comments on commit e9a4a17

Please sign in to comment.