Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6241C433FE for ; Sun, 30 Oct 2022 01:51:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C6E278517F; Sun, 30 Oct 2022 02:48:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="TP5ptOlV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C8B9385110; Sun, 30 Oct 2022 02:47:59 +0100 (CET) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0027C85166 for ; Sun, 30 Oct 2022 02:47:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x131.google.com with SMTP id g13so4796266ile.0 for ; Sat, 29 Oct 2022 18:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H1NwA8piRDtCcViZo/vmDFbwZrf2bHW+2s8Gye50DA8=; b=TP5ptOlVzty9WZefVrPHe/tp5JhC/TGXqK3v9Bs2U7OwiQasomG1L9ZTj6UGeDUeu/ 5m+KKOjjEr7a0t8UNzNcGaaI4mRs9YzcgGhRHGGV9ghspX1WLJYxjHrnyfy2h5JWPnG8 9wTeACLJlr8uY/GB/KwN6Ob7hKekl0vg4qh/8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H1NwA8piRDtCcViZo/vmDFbwZrf2bHW+2s8Gye50DA8=; b=SRigDCREuwjUVkqTl2asajOPxFWISLacfFkWOp0bhfQhtTCqAU6lCA3OiTbZqxyOvS eXv/EdPoast9+jJO84+F62uGdWiYk+n95ulrvUD/IVdDupgmoWjJOOq65r8GOX5C9tQg qVZfCugaVsTKfUeD3pGmXtib9c2UXs6JgRxu9paCsGjF2G8Hp6mZlpgazDLlqrNpJNTs dsy3FyPUZJfN/C22z02Cm1EUsqElKC4IC3WMZNKJCSrHZi9SAqoARMaKNDJSzEedHC9u us3DfWXErABzPD5MtPgNuvYBTxn0eLVBCon1mwJc+FL7zbkVwU6vN4nWw0I3uKQ+GJnO 6m/A== X-Gm-Message-State: ACrzQf1Q5Vlyy65o4sM6kd583aq9SoZjwz/jtcAP1VDUlyCZD3cDDtZi 3wJdQaz3EFLpShrKS+E6+jxruxQJ+S8zgQ== X-Google-Smtp-Source: AMsMyM4E2f8ULhzm8zsyV6wd1yrngJcUfr4cf9Mc+6tIdzVCuHYZM8xCtS5GFuXo/BYFYpNfIvQnaw== X-Received: by 2002:a05:6e02:158a:b0:2d5:12f0:4dce with SMTP id m10-20020a056e02158a00b002d512f04dcemr3195375ilu.159.1667094472163; Sat, 29 Oct 2022 18:47:52 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id x66-20020a0294c8000000b00363c4307bb2sm810287jah.79.2022.10.29.18.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 18:47:51 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Heinrich Schuchardt , Simon Glass , Bin Meng , Ilias Apalodimas , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Marek Vasut , Pavel Herrmann , Rick Chen , Roger Knecht , Sean Anderson Subject: [PATCH 16/17] dm: Add documentation for host command and implementation Date: Sat, 29 Oct 2022 19:47:18 -0600 Message-Id: <20221030014719.147327-17-sjg@chromium.org> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog In-Reply-To: <20221030014719.147327-1-sjg@chromium.org> References: <20221030014719.147327-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Document the 'host' command and also the internals of how it is implemented. Signed-off-by: Simon Glass --- doc/arch/index.rst | 2 +- doc/arch/sandbox/block_impl.rst | 39 ++++++++++ doc/arch/sandbox/index.rst | 12 +++ doc/arch/{ => sandbox}/sandbox.rst | 9 ++- doc/usage/cmd/host.rst | 116 +++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + 6 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 doc/arch/sandbox/block_impl.rst create mode 100644 doc/arch/sandbox/index.rst rename doc/arch/{ => sandbox}/sandbox.rst (98%) create mode 100644 doc/usage/cmd/host.rst diff --git a/doc/arch/index.rst b/doc/arch/index.rst index 792d9182c31..b3e85f9bf34 100644 --- a/doc/arch/index.rst +++ b/doc/arch/index.rst @@ -11,7 +11,7 @@ Architecture-specific doc m68k mips nios2 - sandbox + sandbox/index sh x86 xtensa diff --git a/doc/arch/sandbox/block_impl.rst b/doc/arch/sandbox/block_impl.rst new file mode 100644 index 00000000000..344c74f718b --- /dev/null +++ b/doc/arch/sandbox/block_impl.rst @@ -0,0 +1,39 @@ +.. SPDX-License-Identifier: GPL-2.0+ */ +.. Copyright (c) 2014 The Chromium OS Authors. +.. sectionauthor:: Simon Glass + +Sandbox block devices (implementation) +====================================== + +(See :ref:`sandbox_blk` for operation) + +Sandbox block devices are implemented using the `UCLASS_HOST` uclass. Only one +driver is provided (`host_sb_drv`) so all devices in the uclass use the same +driver. + +The uclass has a simple API allowing files to be attached and detached. +Attaching a file results in it appearing as a block device in sandbox. This +allows filesystems and whole disk images to be accessed from U-Boot. This is +particularly useful for tests. + +Devices are created using `host_create_device()`. This sets up a new +`UCLASS_HOST`. + +The device can then be attached to a file with `host_attach_file()`. This +creates the child block device (and bootdev device). + +The host device's block device must be probed before use, as normal. + +To destroy a device, call host_destroy_device(). This removes the device (and +its children of course), then closes any attached file, then unbinds the device. + +There is no arbitrary limit to the number of host devices that can be created. + + +Uclass API +---------- + +This is incomplete as it isn't clear how to make Sphinx do the right thing for +struct host_ops. See `include/sandbox_host.h` for full details. + +.. kernel-doc:: include/sandbox_host.h diff --git a/doc/arch/sandbox/index.rst b/doc/arch/sandbox/index.rst new file mode 100644 index 00000000000..1f1f5de4b03 --- /dev/null +++ b/doc/arch/sandbox/index.rst @@ -0,0 +1,12 @@ +.. SPDX-License-Identifier: GPL-2.0+ */ +.. Copyright 2022 Google LLC +.. sectionauthor:: Simon Glass + +Sandbox +======= + +.. toctree:: + :maxdepth: 2 + + sandbox + block_impl diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox/sandbox.rst similarity index 98% rename from doc/arch/sandbox.rst rename to doc/arch/sandbox/sandbox.rst index 068d4a3be40..f37152303dc 100644 --- a/doc/arch/sandbox.rst +++ b/doc/arch/sandbox/sandbox.rst @@ -43,7 +43,7 @@ Note that standalone/API support is not available at present. Prerequisites ------------- -Install the dependencies noted in :doc:`../build/gcc`. +Install the dependencies noted in :doc:`../../build/gcc`. Basic Operation @@ -374,6 +374,7 @@ also use low-level SPI commands:: This is issuing a READ_ID command and getting back 20 (ST Micro) part 0x2015 (the M25P16). +.. _sandbox_blk: Block Device Emulation ---------------------- @@ -401,6 +402,8 @@ or utilize the device described in test/py/make_test_disk.py:: import make_test_disk make_test_disk.makeDisk() +For more technical details, see :doc:`block_impl`. + Writing Sandbox Drivers ----------------------- @@ -600,8 +603,8 @@ Testing U-Boot sandbox can be used to run various tests, mostly in the test/ directory. -See :doc:`../develop/tests_sandbox` for more information and -:doc:`../develop/testing` for information about testing generally. +See :doc:`../../develop/tests_sandbox` for more information and +:doc:`../../develop/testing` for information about testing generally. Memory Map diff --git a/doc/usage/cmd/host.rst b/doc/usage/cmd/host.rst new file mode 100644 index 00000000000..e14508986ca --- /dev/null +++ b/doc/usage/cmd/host.rst @@ -0,0 +1,116 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +host command +============ + +Synopis +------- + +:: + + host bind [-r]