blob: 28431039adc77828a31d50a49d68459339a48530 [file] [log] [blame]
Simon Glass4d7bb452021-09-08 07:33:52 -06001.. SPDX-License-Identifier: GPL-2.0+
Simon Glasscff88702018-11-15 18:43:54 -07002
3Blob Lists - bloblist
4=====================
5
6Introduction
7------------
8
9A bloblist provides a way to store collections of binary information (blobs) in
10a central structure. Each record of information is assigned a tag so that its
11owner can find it and update it. Each record is generally described by a C
12structure defined by the code that owns it.
13
Simon Glass68ff6d32022-03-13 16:22:48 -060014For the design goals of bloblist, please see the comments at the top of the
15`bloblist.h` header file.
Simon Glasscff88702018-11-15 18:43:54 -070016
Simon Glasse266d272023-12-27 13:07:10 -080017Bloblist is an implementation with the `Firmware Handoff`_ protocol.
18
Simon Glasscff88702018-11-15 18:43:54 -070019Passing state through the boot process
20--------------------------------------
21
22The bloblist is created when the first U-Boot component runs (often SPL,
23sometimes TPL). It is passed through to each successive part of the boot and
24can be accessed as needed. This provides a way to transfer state from one part
25to the next. For example, TPL may determine that a watchdog reset occurred by
26reading an SoC register. Reading the register may reset the value, so that it
27cannot be read a second time. So TPL can store that in a bloblist record which
28can be passed through to SPL and U-Boot proper, which can print a message
29indicating that something went wrong and the watchdog fired.
30
31
32Blobs
33-----
34
35While each blob in the bloblist can be of any length, bloblists are designed to
36hold small amounts of data, typically a few KB at most. It is not possible to
37change the length of a blob once it has been written. Each blob is normally
Simon Glass20a14932022-01-12 19:26:24 -070038created from a C structure which can be used to access its fields.
Simon Glasscff88702018-11-15 18:43:54 -070039
40
41Blob tags
42---------
43
44Each blob has a tag which is a 32-bit number. This uniquely identifies the
45owner of the blob. Blob tags are listed in enum blob_tag_t and are named
Simon Glass4d7bb452021-09-08 07:33:52 -060046with a `BLOBT_` prefix.
Simon Glasscff88702018-11-15 18:43:54 -070047
48
49Single structure
50----------------
51
52There is normally only one bloblist in U-Boot. Since a bloblist can store
53multiple blobs it does not seem useful to allow multiple bloblists. Of course
54there could be reasons for this, such as needing to spread the blobs around in
55different memory areas due to fragmented memory, but it is simpler to just have
56a single bloblist.
57
58
59API
60---
61
Simon Glassb83994d2020-01-27 08:49:52 -070062Bloblist provides a fairly simple API which allows blobs to be created and
63found. All access is via the blob's tag. Blob records are zeroed when added.
Simon Glasscff88702018-11-15 18:43:54 -070064
65
Simon Glassd5b6e912021-11-03 21:09:20 -060066Placing the bloblist
67--------------------
68
69The bloblist is typically positioned at a fixed address by TPL, or SPL. This
70is controlled by `CONFIG_BLOBLIST_ADDR`. But in some cases it is preferable to
71allocate the bloblist in the malloc() space. Use the `CONFIG_BLOBLIST_ALLOC`
72option to enable this.
73
74The bloblist is automatically relocated as part of U-Boot relocation. Sometimes
75it is useful to expand the bloblist in U-Boot proper, since it may want to add
76information for use by Linux. Note that this does not mean that Linux needs to
77know anything about the bloblist format, just that it is convenient to use
78bloblist to place things contiguously in memory. Set
79`CONFIG_BLOBLIST_SIZE_RELOC` to define the expanded size, if needed.
80
81
Simon Glasscff88702018-11-15 18:43:54 -070082Finishing the bloblist
83----------------------
84
85When a part of U-Boot is about to jump to the next part, it can 'finish' the
86bloblist in preparation for the next stage. This involves adding a checksum so
87that the next stage can make sure that the data arrived safely. While the
88bloblist is in use, changes can be made which will affect the checksum, so it
89is easier to calculate the checksum at the end after all changes are made.
90
91
92Future work
93-----------
94
95Bootstage has a mechanism to 'stash' its records for passing to the next part.
96This should move to using bloblist, to avoid having its own mechanism for
97passing information between U-Boot parts.
98
99
Simon Glass20a14932022-01-12 19:26:24 -0700100API documentation
101-----------------
102
103.. kernel-doc:: include/bloblist.h
Simon Glasse266d272023-12-27 13:07:10 -0800104.. _`Firmware Handoff`: https://github.com/FirmwareHandoff/firmware_handoff
Simon Glass20a14932022-01-12 19:26:24 -0700105
Simon Glasscff88702018-11-15 18:43:54 -0700106Simon Glass
107sjg@chromium.org
10812-Aug-2018