[U-Boot] [RFC v2 00/15] dm, efi: integrate efi objects into DM

AKASHI Takahiro takahiro.akashi at linaro.org
Fri Feb 8 08:15:27 UTC 2019


# bootefi doesn't work with this patch set yet

This patch set came from the past discussion[1] on my "removable device
support" patch and is intended to be an attempt to integrate efi objects
 into u-boot's Driver Model as much seamlessly as possible.

[1] https://lists.denx.de/pipermail/u-boot/2019-January/354010.html

Since this patch is a prototype (or POC, Proof-Of-Concept), the aim here
is to discuss further about how in a better shape we will be able to
merge the two worlds.

After RFC, Simon suggested that efi protocols could be also presented
as DM devices. This is a major change in RFC v2.

Basic idea is
* efi_root is a DM device
* Any efi object, refered to by efi_handle_t in UEFI world,
  has a corresponding DM device.
  - define efi_handle_t as "struct udevice *"
  - for efi_disk,
    * add "struct efi_disk_obj" to blk_desc
  - for the objects below, there is only one instance for each and so
    they are currently global data:
      efi_gop_obj,
      efi_net_obj,
      simple_text_output_mode
  - for loaded_image,
    * link efi_loaded_image_obj to device's platdata

* Any efi protocol has a corresponding DM device.
  - link "struct efi_handler" to device's uclass_platdata
  - be a child of a efi object (hence DM device) in DM device hierarchy
    so that enumerating protocols belonging to efi object is done by
    traversing the tree.

* Any efi object which has a backing DM device should be created
  when that DM device is detected (and probed).
* For efi_disk (or any object with EFI_BLOCK_IO_PROTOCOL),
  - add UCLASS_PARTITION
  - put partitions under a raw block device
  - partitions as well as raw devices can be efi_disk

With those extensive changes, there still exists plenty of
"wrapper" code. Do you have any idea to reduce it?


***** Example operation ******
(Two scsi disks, one with no partition, one with two partitions)

=> efi dev
EFI: Initializing UCLASS_EFI_DRIVER
Device           Device Path
================ ====================
000000007eef9470 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
=> scsi rescan

Reset SCSI
scanning bus for devices...
Target spinup took 0 ms.
Target spinup took 0 ms.
SATA link 2 timeout.
SATA link 3 timeout.
SATA link 4 timeout.
SATA link 5 timeout.
AHCI 0001.0000 32 slots 6 ports 1.5 Gbps 0x3f impl SATA mode
flags: 64bit ncq only 
  Device 0: (0:0) Vendor: ATA Prod.: QEMU HARDDISK Rev: 2.5+
            Type: Hard Disk
            Capacity: 16.0 MB = 0.0 GB (32768 x 512)
  Device 0: (1:0) Vendor: ATA Prod.: QEMU HARDDISK Rev: 2.5+
            Type: Hard Disk
            Capacity: 256.0 MB = 0.2 GB (524288 x 512)
=> efi dev
Device           Device Path
================ ====================
000000007eef9470 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
000000007ef01c90 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(0,0)
000000007ef04910 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)
000000007ef04ee0 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)/HD(335544330,MBR,0x086246ba,0x17ff4f1a0,0x7eee3770)
000000007ef055a0 /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)/HD(335544330,MBR,0x086246ba,0x17ff4f1a0,0x7eee3770)
=> dm tree
 Class    index  Probed  Driver                Name
-----------------------------------------------------------
 root        0  [ + ]   root_driver           root_driver
 simple_bus  0  [   ]   generic_simple_bus    |-- platform at c000000
 virtio      0  [ + ]   virtio-mmio           |-- virtio_mmio at a000000

 [snip]

 pci         0  [ + ]   pci_generic_ecam      |-- pcie at 10000000
 pci_generi  0  [   ]   pci_generic_drv       |   |-- pci_0:0.0
 virtio      32  [   ]   virtio-pci.l          |   |-- virtio-pci.l#0
 ahci        0  [ + ]   ahci_pci              |   `-- ahci_pci
 scsi        0  [ + ]   ahci_scsi             |       `-- ahci_scsi
 blk         0  [ + ]   scsi_blk              |           |-- ahci_scsi.id0lun0
 efi_protoc  8  [ + ]   efi_disk              |           |   |-- BLOCK_IO
 efi_protoc  9  [ + ]   efi_device_path       |           |   `-- Scsi(0,0)
 blk         1  [ + ]   scsi_blk              |           `-- ahci_scsi.id1lun0
 efi_protoc  10  [ + ]   efi_disk              |               |-- BLOCK_IO
 efi_protoc  11  [ + ]   efi_device_path       |               |-- Scsi(1,0)
 partition   0  [ + ]   blk_partition         |               |-- ahci_scsi.id1lun0:1
 efi_protoc  12  [ + ]   efi_disk              |               |   |-- BLOCK_IO
 efi_protoc  13  [ + ]   efi_device_path       |               |   |-- HD(335544330,MBR,0x086246ba,0x17ff4f1a0,0x7eee3770)
 efi_protoc  14  [ + ]   efi_simple_file_syst  |               |   `-- SIMPLE_FILE_SYSTEM
 partition   1  [ + ]   blk_partition         |               `-- ahci_scsi.id1lun0:2
 efi_protoc  15  [ + ]   efi_disk              |                   |-- BLOCK_IO
 efi_protoc  16  [ + ]   efi_device_path       |                   |-- HD(335544330,MBR,0x086246ba,0x17ff4f1a0,0x7eee3770)
 efi_protoc  17  [ + ]   efi_simple_file_syst  |                   `-- SIMPLE_FILE_SYSTEM
 rtc         0  [   ]   rtc-pl031             |-- pl031 at 9010000
 serial      0  [   ]   serial_pl01x          |-- pl011 at 9050000
 serial      1  [ + ]   serial_pl01x          |-- pl011 at 9000000
 efi_protoc  0  [ + ]   efi_simple_text_outp  |   |-- SIMPLE_TEXT_OUTPUT
 efi_protoc  1  [ + ]   efi_simple_text_inpu  |   |-- SIMPLE_TEXT_INPUT
 efi_protoc  2  [ + ]   efi_simple_text_inpu  |   `-- SIMPLE_TEXT_INPUT_EX
 mtd         0  [ + ]   cfi_flash             |-- flash at 0
 firmware    0  [ + ]   psci                  |-- psci
 sysreset    0  [   ]   psci-sysreset         |   `-- psci-sysreset
 efi         0  [ + ]   efi_root              `-- UEFI sub system
 efi_protoc  3  [ + ]   efi_device_path           |-- VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
 efi_protoc  4  [ + ]   efi_device_path_to_t      |-- DEVICE_PATH_TO_TEXT
 efi_protoc  5  [ + ]   efi_device_path_util      |-- DEVICE_PATH_UTILITIES
 efi_protoc  6  [ + ]   efi_unicode_collatio      |-- en
 efi_driver  0  [ + ]   EFI block driver          `-- EFI block driver
 efi_protoc  7  [ + ]   efi_driver_binding            `-- DRIVER_BINDING



Thanks,
-Takahiro Akashi

AKASHI Takahiro (15):
  efi_loader: efi objects and protocols as DM devices
  efi_loader: boottime: convert efi_loaded_image_obj to DM
  efi_loader: image_loader: aligned with DM
  efi_driver: rename UCLASS_EFI to UCLASS_EFI_DRIVER
  efi_loader: convert efi_root_node to DM
  efi_loader: device path: convert efi_device_path to DM
  efi_loader: unicode_collation: converted to DM
  efi_loader: console: convert efi console input/output to DM
  efi_loader: net: convert efi_net_obj to DM
  efi_loader: gop: convert efi_gop_obj to DM
  dm: blk: add UCLASS_PARTITION
  efi_loader: disk: convert efi_disk_obj to DM
  drivers: align block device drivers with DM-efi integration
  efi_driver: converted to DM
  cmd: efidebug: aligned with DM-efi integration

 cmd/bootefi.c                              |  61 +--
 cmd/efidebug.c                             |   5 +-
 common/usb_storage.c                       |  27 +-
 drivers/block/blk-uclass.c                 |  61 +++
 drivers/scsi/scsi.c                        |  22 +
 drivers/serial/serial-uclass.c             |   6 +
 drivers/video/video-uclass.c               |   9 +
 include/blk.h                              |  24 +
 include/dm/device.h                        |   3 +
 include/dm/uclass-id.h                     |   6 +-
 include/efi.h                              |   4 +-
 include/efi_loader.h                       |  50 +-
 lib/efi_driver/efi_block_device.c          |  36 +-
 lib/efi_driver/efi_uclass.c                |  37 +-
 lib/efi_loader/efi_boottime.c              | 605 ++++++++++++++-------
 lib/efi_loader/efi_console.c               |  64 ++-
 lib/efi_loader/efi_device_path.c           | 136 +++--
 lib/efi_loader/efi_device_path_to_text.c   |  55 ++
 lib/efi_loader/efi_device_path_utilities.c |  14 +
 lib/efi_loader/efi_disk.c                  | 216 +++++---
 lib/efi_loader/efi_file.c                  |  14 +
 lib/efi_loader/efi_gop.c                   |  28 +-
 lib/efi_loader/efi_image_loader.c          |  61 ++-
 lib/efi_loader/efi_net.c                   |  50 +-
 lib/efi_loader/efi_root_node.c             |  14 +-
 lib/efi_loader/efi_setup.c                 |  60 +-
 lib/efi_loader/efi_unicode_collation.c     |  19 +
 net/eth-uclass.c                           |   5 +
 28 files changed, 1226 insertions(+), 466 deletions(-)

-- 
2.19.1



More information about the U-Boot mailing list