[PATCH v2 0/9] blk: blkmap: Composable virtual block devices

Tobias Waldekranz tobias at waldekranz.com
Thu Feb 16 16:33:46 CET 2023


Block maps are a way of looking at various sources of data through the
lens of a regular block device. It lets you treat devices that are not
block devices, like RAM, as if they were. It also lets you export a
slice of an existing block device, which does not have to correspond to
a partition boundary, as a new block device.

This is primarily useful because U-Boot's filesystem drivers only
operate on block devices, so a block map lets you access filesystems
wherever they might be located.

The implementation is loosely modeled on Linux's "Device Mapper"
subsystem, see the kernel documentation [1] for more information.

The primary use-cases are to access filesystem images stored in RAM, and
within FIT images stored on disk. See doc/usage/blkmap.rst for more
details.

The architecture is pluggable, so adding other types of mappings should
be quite easy.

[1]: https://docs.kernel.org/admin-guide/device-mapper/index.html

v1 -> v2:
 - Change internal API to use device pointers
 - Convert test suite from Python to C
 - Various cosmetic fixes

Tobias Waldekranz (9):
  image: Fix script execution from FIT images with external data
  cmd: blk: Allow generic read/write operations to work in sandbox
  blk: blkmap: Add basic infrastructure
  blk: blkmap: Add memory mapping support
  blk: blkmap: Add linear device mapping support
  cmd: blkmap: Add blkmap command
  test: blkmap: Add test suite
  doc: blkmap: Add introduction and examples
  efi_loader: device_path: support blkmap devices

 MAINTAINERS                      |   9 +
 boot/image-board.c               |   3 +-
 cmd/Kconfig                      |  19 ++
 cmd/Makefile                     |   1 +
 cmd/blk_common.c                 |  15 +-
 cmd/blkmap.c                     | 233 ++++++++++++++
 configs/sandbox_defconfig        |   1 +
 disk/part.c                      |   1 +
 doc/usage/blkmap.rst             | 111 +++++++
 doc/usage/index.rst              |   1 +
 drivers/block/Kconfig            |  18 ++
 drivers/block/Makefile           |   1 +
 drivers/block/blk-uclass.c       |   1 +
 drivers/block/blkmap.c           | 519 +++++++++++++++++++++++++++++++
 include/blkmap.h                 |  77 +++++
 include/dm/uclass-id.h           |   1 +
 include/efi_loader.h             |   4 +
 lib/efi_loader/efi_device_path.c |  30 ++
 test/dm/Makefile                 |   1 +
 test/dm/blkmap.c                 | 201 ++++++++++++
 20 files changed, 1242 insertions(+), 5 deletions(-)
 create mode 100644 cmd/blkmap.c
 create mode 100644 doc/usage/blkmap.rst
 create mode 100644 drivers/block/blkmap.c
 create mode 100644 include/blkmap.h
 create mode 100644 test/dm/blkmap.c

-- 
2.34.1



More information about the U-Boot mailing list