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 16DB9C433EF for ; Sun, 13 Mar 2022 22:23:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A7CA83B57; Sun, 13 Mar 2022 23:23:09 +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="G0WNIVBX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6AC6E83915; Sun, 13 Mar 2022 23:23:07 +0100 (CET) Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 BD7B9831B5 for ; Sun, 13 Mar 2022 23:23:02 +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-pg1-x52e.google.com with SMTP id e6so12210191pgn.2 for ; Sun, 13 Mar 2022 15:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QWhj7g7bKkiigvggJOdMns9cduCZldfFWhiPez+Mwwo=; b=G0WNIVBXSEyDeQPbun/B2wzcmRwDKETuxfKgf7ynxQMha/6ikF9bFSQiHAl9X5WpEy uMeh9aQRCZUSIImEIfjFwNx0owX/uRy4y/mCa6+i/x0jF+poD49oyFZmJf6DpW0KKEHY iTY6YqNoMhyG8WA3jd90vb/0wlK7HkfD7hAMs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QWhj7g7bKkiigvggJOdMns9cduCZldfFWhiPez+Mwwo=; b=5KBWHUIV+PwiT25NJ6HwK1yjXevbIiSpKvM86ZtnykViSVLfGMCJdeySXAakOASkP4 cqNSv+a7+C3evIjaVMLmpxJExIJZX8NDCAplIMdC2eCJtp0qDZcy1EJK+ayzsSbw3R/R 00o55V0amgTtSpWsJmM2NwIF1wTdWpZGTcgCFTnDsKMt9XY8GRu1jpcrrLt8m8T58JKO LtZFk1kcI7xOFYsUrCGYDjF6ZFXgQ0FhBharw43HjHytb+Wl4gIiOXVHoLBv6KwGgjLX gU62yz64AO+zSL04oThEncF47RoHybRXkysliOCKIabuusMRucxQ1eIQFOewCEj5+wLF Y/4g== X-Gm-Message-State: AOAM530ac8ahQ+Rja0M2/m8PesQtg4wLMy5ghbXC8IJhX/FZeb4eD20O A0wTf9awGgmd0J3ihaJppn+dNS3TXFY5yw== X-Google-Smtp-Source: ABdhPJyg3a12LR/jSWSUy9TonTlMQHEqZHDxPgm1LpDt95q7NDH3Mx02apq/BJKmLkZM19+R1YHNFg== X-Received: by 2002:a63:c110:0:b0:380:7412:3955 with SMTP id w16-20020a63c110000000b0038074123955mr17545839pgf.55.1647210180684; Sun, 13 Mar 2022 15:23:00 -0700 (PDT) Received: from sjg1.roam.corp.google.com ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id a5-20020a621a05000000b004f79f8f795fsm7289596pfa.0.2022.03.13.15.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Mar 2022 15:23:00 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Jose Marinho , Simon Glass , Heinrich Schuchardt Subject: [PATCH] bloblist: Describe the design goals Date: Sun, 13 Mar 2022 16:22:48 -0600 Message-Id: <20220313222248.679293-1-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.723.g4982287a31-goog 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.5 at phobos.denx.de X-Virus-Status: Clean Add a comment explaining the design goals of bloblist, to make it easier for people to understand and comment on the structure. Signed-off-by: Simon Glass --- doc/develop/bloblist.rst | 2 ++ include/bloblist.h | 62 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/doc/develop/bloblist.rst b/doc/develop/bloblist.rst index 572aa65d764..81643c7674b 100644 --- a/doc/develop/bloblist.rst +++ b/doc/develop/bloblist.rst @@ -11,6 +11,8 @@ a central structure. Each record of information is assigned a tag so that its owner can find it and update it. Each record is generally described by a C structure defined by the code that owns it. +For the design goals of bloblist, please see the comments at the top of the +`bloblist.h` header file. Passing state through the boot process -------------------------------------- diff --git a/include/bloblist.h b/include/bloblist.h index d0e128acf10..9684bfd5f4b 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -3,8 +3,66 @@ * This provides a standard way of passing information between boot phases * (TPL -> SPL -> U-Boot proper.) * - * A list of blobs of data, tagged with their owner. The list resides in memory - * and can be updated by SPL, U-Boot, etc. + * It consists of a list of blobs of data, tagged with their owner / contents. + * The list resides in memory and can be updated by SPL, U-Boot, etc. + * + * Design goals for bloblist: + * + * 1. Small and efficient structure. This avoids UUIDs or 16-byte name fields, + * since a 32-bit tag provides enough space for all the tags we will even need. + * If UUIDs are desired, they can be added inside a particular blob. + * + * 2. Avoids use of pointers, so the structure can be relocated in memory. The + * data in each blob is inline, rather than using pointers. + * + * 3. Bloblist is designed to start small in TPL or SPL, when only a few things + * are needed, like the memory size or whether console output should be enabled. + * Then it can grow in U-Boot proper, e.g. to include space for ACPI tables. + * + * 4. The bloblist structure is simple enough that it can be implemented in a + * small amount of C code. The API does not require use of strings or UUIDs, + * which would add to code size. For Thumb-2 the code size needed in SPL is + * approximately 940 bytes (e.g. for chromebook_bob). + * + * 5. Bloblist uses 16-byte alignment internally and is designed to start on a + * 16-byte boundary. Its headers are multiples of 16 bytes. This makes it easier + * to deal with data structures which need this level of alignment, such as ACPI + * tables. For use in SPL and TPL the alignment can be relaxed, since it can be + * relocated to an aligned address in U-Boot proper. + * + * 6. Bloblist is designed to be passed to Linux as reserved memory. While linux + * doesn't understand the bloblist header, it can be passed the indivdual blobs. + * For example, ACPI tables can reside in a blob and the address of those is + * passed to Linux, without Linux ever being away of the existence of a + * bloblist. Having all the blobs contiguous in memory simplifies the + * reserved-memory space. + * + * 7. Bloblist tags are defined in the enum below. There is an area for + * project-specific stuff (e.g. U-Boot, TF-A) and vendor-specific stuff, e.g. + * something used only on a particular SoC. There is also a private area for + * temporary, local use. + * + * 8. Bloblist includes a simple checksum, so that each boot phase can update + * this and allow the next phase to check that all is well. While the bloblist + * is small, this is quite cheap to calculate. When it grows (e.g. in U-Boot\ + * proper), the CPU is likely running faster, so it is not prohibitive. Having + * said that, U-Boot is often the last phase that uses bloblist, so calculating + * the checksum there may not be necessary. + * + * 9. It would be possible to extend bloblist to support a non-contiguous + * structure, e.g. by creating a blob type that points to the next bloblist. + * This does not seem necessary for now. It adds complexity and code. We can + * always just copy it. + * + * 10. Bloblist is designed for simple structures, those that can be defined by + * a single C struct. More complex structures should be passed in a device tree. + * There are some exceptions, chiefly the various binary structures that Intel + * is fond of creating. But device tree provides a dictionary-type format which + * is fairly efficient (for use in U-Boot proper and Linux at least), along with + * a schema and a good set of tools. New formats should be designed around + * device tree rather than creating new binary formats, unless they are needed + * early in boot (where libfdt's 3KB of overhead is too large) and are trival + * enough to be described by a C struct. * * Copyright 2018 Google, Inc * Written by Simon Glass -- 2.35.1.723.g4982287a31-goog