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