Simon Glass | 63479bd | 2022-10-29 19:47:18 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | .. Copyright (c) 2014 The Chromium OS Authors. |
| 3 | .. sectionauthor:: Simon Glass <sjg@chromium.org> |
| 4 | |
| 5 | Sandbox block devices (implementation) |
| 6 | ====================================== |
| 7 | |
| 8 | (See :ref:`sandbox_blk` for operation) |
| 9 | |
| 10 | Sandbox block devices are implemented using the `UCLASS_HOST` uclass. Only one |
| 11 | driver is provided (`host_sb_drv`) so all devices in the uclass use the same |
| 12 | driver. |
| 13 | |
| 14 | The uclass has a simple API allowing files to be attached and detached. |
| 15 | Attaching a file results in it appearing as a block device in sandbox. This |
| 16 | allows filesystems and whole disk images to be accessed from U-Boot. This is |
| 17 | particularly useful for tests. |
| 18 | |
| 19 | Devices are created using `host_create_device()`. This sets up a new |
| 20 | `UCLASS_HOST`. |
| 21 | |
| 22 | The device can then be attached to a file with `host_attach_file()`. This |
| 23 | creates the child block device (and bootdev device). |
| 24 | |
| 25 | The host device's block device must be probed before use, as normal. |
| 26 | |
| 27 | To destroy a device, call host_destroy_device(). This removes the device (and |
| 28 | its children of course), then closes any attached file, then unbinds the device. |
| 29 | |
| 30 | There is no arbitrary limit to the number of host devices that can be created. |
| 31 | |
| 32 | |
| 33 | Uclass API |
| 34 | ---------- |
| 35 | |
| 36 | This is incomplete as it isn't clear how to make Sphinx do the right thing for |
| 37 | struct host_ops. See `include/sandbox_host.h` for full details. |
| 38 | |
| 39 | .. kernel-doc:: include/sandbox_host.h |