Simon Glass | 6c9e3d1 | 2022-01-12 19:26:25 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause */ |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 2 | /* |
| 3 | * This provides a standard way of passing information between boot phases |
| 4 | * (TPL -> SPL -> U-Boot proper.) |
| 5 | * |
Simon Glass | 68ff6d3 | 2022-03-13 16:22:48 -0600 | [diff] [blame] | 6 | * It consists of a list of blobs of data, tagged with their owner / contents. |
| 7 | * The list resides in memory and can be updated by SPL, U-Boot, etc. |
| 8 | * |
| 9 | * Design goals for bloblist: |
| 10 | * |
| 11 | * 1. Small and efficient structure. This avoids UUIDs or 16-byte name fields, |
| 12 | * since a 32-bit tag provides enough space for all the tags we will even need. |
| 13 | * If UUIDs are desired, they can be added inside a particular blob. |
| 14 | * |
| 15 | * 2. Avoids use of pointers, so the structure can be relocated in memory. The |
| 16 | * data in each blob is inline, rather than using pointers. |
| 17 | * |
| 18 | * 3. Bloblist is designed to start small in TPL or SPL, when only a few things |
| 19 | * are needed, like the memory size or whether console output should be enabled. |
| 20 | * Then it can grow in U-Boot proper, e.g. to include space for ACPI tables. |
| 21 | * |
| 22 | * 4. The bloblist structure is simple enough that it can be implemented in a |
| 23 | * small amount of C code. The API does not require use of strings or UUIDs, |
| 24 | * which would add to code size. For Thumb-2 the code size needed in SPL is |
| 25 | * approximately 940 bytes (e.g. for chromebook_bob). |
| 26 | * |
| 27 | * 5. Bloblist uses 16-byte alignment internally and is designed to start on a |
| 28 | * 16-byte boundary. Its headers are multiples of 16 bytes. This makes it easier |
| 29 | * to deal with data structures which need this level of alignment, such as ACPI |
| 30 | * tables. For use in SPL and TPL the alignment can be relaxed, since it can be |
| 31 | * relocated to an aligned address in U-Boot proper. |
| 32 | * |
| 33 | * 6. Bloblist is designed to be passed to Linux as reserved memory. While linux |
| 34 | * doesn't understand the bloblist header, it can be passed the indivdual blobs. |
| 35 | * For example, ACPI tables can reside in a blob and the address of those is |
| 36 | * passed to Linux, without Linux ever being away of the existence of a |
| 37 | * bloblist. Having all the blobs contiguous in memory simplifies the |
| 38 | * reserved-memory space. |
| 39 | * |
| 40 | * 7. Bloblist tags are defined in the enum below. There is an area for |
| 41 | * project-specific stuff (e.g. U-Boot, TF-A) and vendor-specific stuff, e.g. |
| 42 | * something used only on a particular SoC. There is also a private area for |
| 43 | * temporary, local use. |
| 44 | * |
| 45 | * 8. Bloblist includes a simple checksum, so that each boot phase can update |
| 46 | * this and allow the next phase to check that all is well. While the bloblist |
| 47 | * is small, this is quite cheap to calculate. When it grows (e.g. in U-Boot\ |
| 48 | * proper), the CPU is likely running faster, so it is not prohibitive. Having |
| 49 | * said that, U-Boot is often the last phase that uses bloblist, so calculating |
| 50 | * the checksum there may not be necessary. |
| 51 | * |
| 52 | * 9. It would be possible to extend bloblist to support a non-contiguous |
| 53 | * structure, e.g. by creating a blob type that points to the next bloblist. |
| 54 | * This does not seem necessary for now. It adds complexity and code. We can |
| 55 | * always just copy it. |
| 56 | * |
| 57 | * 10. Bloblist is designed for simple structures, those that can be defined by |
| 58 | * a single C struct. More complex structures should be passed in a device tree. |
| 59 | * There are some exceptions, chiefly the various binary structures that Intel |
| 60 | * is fond of creating. But device tree provides a dictionary-type format which |
| 61 | * is fairly efficient (for use in U-Boot proper and Linux at least), along with |
| 62 | * a schema and a good set of tools. New formats should be designed around |
| 63 | * device tree rather than creating new binary formats, unless they are needed |
| 64 | * early in boot (where libfdt's 3KB of overhead is too large) and are trival |
| 65 | * enough to be described by a C struct. |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 66 | * |
| 67 | * Copyright 2018 Google, Inc |
| 68 | * Written by Simon Glass <sjg@chromium.org> |
| 69 | */ |
| 70 | |
| 71 | #ifndef __BLOBLIST_H |
| 72 | #define __BLOBLIST_H |
| 73 | |
Simon Glass | ff3bd49 | 2022-01-12 19:26:16 -0700 | [diff] [blame] | 74 | #include <mapmem.h> |
| 75 | |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 76 | enum { |
| 77 | BLOBLIST_VERSION = 0, |
| 78 | BLOBLIST_MAGIC = 0xb00757a3, |
| 79 | BLOBLIST_ALIGN = 16, |
| 80 | }; |
| 81 | |
Simon Glass | 4aed227 | 2020-09-19 18:49:26 -0600 | [diff] [blame] | 82 | /* Supported tags - add new ones to tag_name in bloblist.c */ |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 83 | enum bloblist_tag_t { |
| 84 | BLOBLISTT_NONE = 0, |
| 85 | |
Simon Glass | f16ec77 | 2022-01-12 19:26:19 -0700 | [diff] [blame] | 86 | /* |
| 87 | * Standard area to allocate blobs used across firmware components, for |
| 88 | * things that are very commonly used, particularly in multiple |
| 89 | * projects. |
| 90 | */ |
| 91 | BLOBLISTT_AREA_FIRMWARE_TOP = 0x1, |
| 92 | |
| 93 | /* Standard area to allocate blobs used across firmware components */ |
| 94 | BLOBLISTT_AREA_FIRMWARE = 0x100, |
Simon Glass | 99e555a | 2020-09-22 12:44:55 -0600 | [diff] [blame] | 95 | /* |
| 96 | * Advanced Configuration and Power Interface Global Non-Volatile |
| 97 | * Sleeping table. This forms part of the ACPI tables passed to Linux. |
| 98 | */ |
Simon Glass | f16ec77 | 2022-01-12 19:26:19 -0700 | [diff] [blame] | 99 | BLOBLISTT_ACPI_GNVS = 0x100, |
| 100 | BLOBLISTT_INTEL_VBT = 0x101, /* Intel Video-BIOS table */ |
| 101 | BLOBLISTT_TPM2_TCG_LOG = 0x102, /* TPM v2 log space */ |
| 102 | BLOBLISTT_TCPA_LOG = 0x103, /* TPM log space */ |
| 103 | BLOBLISTT_ACPI_TABLES = 0x104, /* ACPI tables for x86 */ |
| 104 | BLOBLISTT_SMBIOS_TABLES = 0x105, /* SMBIOS tables for x86 */ |
| 105 | BLOBLISTT_VBOOT_CTX = 0x106, /* Chromium OS verified boot context */ |
Simon Glass | 4aed227 | 2020-09-19 18:49:26 -0600 | [diff] [blame] | 106 | |
Simon Glass | f16ec77 | 2022-01-12 19:26:19 -0700 | [diff] [blame] | 107 | /* |
| 108 | * Project-specific tags are permitted here. Projects can be open source |
| 109 | * or not, but the format of the data must be fuily documented in an |
| 110 | * open source project, including all fields, bits, etc. Naming should |
| 111 | * be: BLOBLISTT_<project>_<purpose_here> |
| 112 | */ |
| 113 | BLOBLISTT_PROJECT_AREA = 0x8000, |
| 114 | BLOBLISTT_U_BOOT_SPL_HANDOFF = 0x8000, /* Hand-off info from SPL */ |
Simon Glass | d8b7c34 | 2022-10-20 18:23:18 -0600 | [diff] [blame] | 115 | BLOBLISTT_VBE = 0x8001, /* VBE per-phase state */ |
Simon Glass | f16ec77 | 2022-01-12 19:26:19 -0700 | [diff] [blame] | 116 | |
| 117 | /* |
| 118 | * Vendor-specific tags are permitted here. Projects can be open source |
| 119 | * or not, but the format of the data must be fuily documented in an |
| 120 | * open source project, including all fields, bits, etc. Naming should |
| 121 | * be BLOBLISTT_<vendor>_<purpose_here> |
| 122 | */ |
| 123 | BLOBLISTT_VENDOR_AREA = 0xc000, |
| 124 | |
| 125 | /* Tags after this are not allocated for now */ |
| 126 | BLOBLISTT_EXPANSION = 0x10000, |
| 127 | |
| 128 | /* |
| 129 | * Tags from here are on reserved for private use within a single |
| 130 | * firmware binary (i.e. a single executable or phase of a project). |
| 131 | * These tags can be passed between binaries within a local |
| 132 | * implementation, but cannot be used in upstream code. Allocate a |
| 133 | * tag in one of the areas above if you want that. |
| 134 | * |
| 135 | * This area may move in future. |
| 136 | */ |
| 137 | BLOBLISTT_PRIVATE_AREA = 0xffff0000, |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | /** |
| 141 | * struct bloblist_hdr - header for the bloblist |
| 142 | * |
| 143 | * This is stored at the start of the bloblist which is always on a 16-byte |
| 144 | * boundary. Records follow this header. The bloblist normally stays in the |
| 145 | * same place in memory as SPL and U-Boot execute, but it can be safely moved |
| 146 | * around. |
| 147 | * |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 148 | * None of the bloblist headers themselves contain pointers but it is possible |
| 149 | * to put pointers inside a bloblist record if desired. This is not encouraged, |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 150 | * since it can make part of the bloblist inaccessible if the pointer is |
| 151 | * no-longer valid. It is better to just store all the data inside a bloblist |
| 152 | * record. |
| 153 | * |
| 154 | * Each bloblist record is aligned to a 16-byte boundary and follows immediately |
| 155 | * from the last. |
| 156 | * |
Simon Glass | ff3bd49 | 2022-01-12 19:26:16 -0700 | [diff] [blame] | 157 | * @magic: BLOBLIST_MAGIC |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 158 | * @version: BLOBLIST_VERSION |
| 159 | * @hdr_size: Size of this header, normally sizeof(struct bloblist_hdr). The |
| 160 | * first bloblist_rec starts at this offset from the start of the header |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 161 | * @flags: Space for BLOBLISTF... flags (none yet) |
Simon Glass | faff554 | 2021-07-05 16:32:54 -0600 | [diff] [blame] | 162 | * @size: Total size of the bloblist (non-zero if valid) including this header. |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 163 | * The bloblist extends for this many bytes from the start of this header. |
Simon Glass | faff554 | 2021-07-05 16:32:54 -0600 | [diff] [blame] | 164 | * When adding new records, the bloblist can grow up to this size. |
| 165 | * @alloced: Total size allocated so far for this bloblist. This starts out as |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 166 | * sizeof(bloblist_hdr) since we need at least that much space to store a |
| 167 | * valid bloblist |
Simon Glass | e9b6b2c | 2020-09-19 18:49:30 -0600 | [diff] [blame] | 168 | * @spare: Spare space (for future use) |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 169 | * @chksum: CRC32 for the entire bloblist allocated area. Since any of the |
| 170 | * blobs can be altered after being created, this checksum is only valid |
| 171 | * when the bloblist is finalised before jumping to the next stage of boot. |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 172 | * Note that chksum is last to make it easier to exclude it from the |
| 173 | * checksum calculation. |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 174 | */ |
| 175 | struct bloblist_hdr { |
Simon Glass | ff3bd49 | 2022-01-12 19:26:16 -0700 | [diff] [blame] | 176 | u32 magic; |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 177 | u32 version; |
| 178 | u32 hdr_size; |
| 179 | u32 flags; |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 180 | |
| 181 | u32 size; |
| 182 | u32 alloced; |
| 183 | u32 spare; |
| 184 | u32 chksum; |
| 185 | }; |
| 186 | |
| 187 | /** |
| 188 | * struct bloblist_rec - record for the bloblist |
| 189 | * |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 190 | * The bloblist contains a number of records each consisting of this record |
| 191 | * structure followed by the data contained. Each records is 16-byte aligned. |
| 192 | * |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 193 | * NOTE: Only exported for testing purposes. Do not use this struct. |
| 194 | * |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 195 | * @tag: Tag indicating what the record contains |
| 196 | * @hdr_size: Size of this header, normally sizeof(struct bloblist_rec). The |
| 197 | * record's data starts at this offset from the start of the record |
| 198 | * @size: Size of record in bytes, excluding the header size. This does not |
| 199 | * need to be aligned (e.g. 3 is OK). |
| 200 | * @spare: Spare space for other things |
| 201 | */ |
| 202 | struct bloblist_rec { |
| 203 | u32 tag; |
| 204 | u32 hdr_size; |
| 205 | u32 size; |
| 206 | u32 spare; |
| 207 | }; |
| 208 | |
| 209 | /** |
Simon Glass | ff3bd49 | 2022-01-12 19:26:16 -0700 | [diff] [blame] | 210 | * bloblist_check_magic() - return a bloblist if the magic matches |
| 211 | * |
| 212 | * @addr: Address to check |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 213 | * Return: pointer to bloblist, if the magic matches, else NULL |
Simon Glass | ff3bd49 | 2022-01-12 19:26:16 -0700 | [diff] [blame] | 214 | */ |
| 215 | static inline void *bloblist_check_magic(ulong addr) |
| 216 | { |
| 217 | u32 *ptr; |
| 218 | |
| 219 | if (!addr) |
| 220 | return NULL; |
| 221 | ptr = map_sysmem(addr, 0); |
| 222 | if (*ptr != BLOBLIST_MAGIC) |
| 223 | return NULL; |
| 224 | |
| 225 | return ptr; |
| 226 | } |
| 227 | |
| 228 | /** |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 229 | * bloblist_find() - Find a blob |
| 230 | * |
| 231 | * Searches the bloblist and returns the blob with the matching tag |
| 232 | * |
| 233 | * @tag: Tag to search for (enum bloblist_tag_t) |
Simon Glass | e9b6b2c | 2020-09-19 18:49:30 -0600 | [diff] [blame] | 234 | * @size: Expected size of the blob, or 0 for any size |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 235 | * Return: pointer to blob if found, or NULL if not found, or a blob was found |
| 236 | * but it is the wrong size |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 237 | */ |
| 238 | void *bloblist_find(uint tag, int size); |
| 239 | |
| 240 | /** |
| 241 | * bloblist_add() - Add a new blob |
| 242 | * |
| 243 | * Add a new blob to the bloblist |
| 244 | * |
| 245 | * This should only be called if you konw there is no existing blob for a |
| 246 | * particular tag. It is typically safe to call in the first phase of U-Boot |
| 247 | * (e.g. TPL or SPL). After that, bloblist_ensure() should be used instead. |
| 248 | * |
| 249 | * @tag: Tag to add (enum bloblist_tag_t) |
| 250 | * @size: Size of the blob |
Simon Glass | 4c1497e | 2020-09-19 18:49:29 -0600 | [diff] [blame] | 251 | * @align: Alignment of the blob (in bytes), 0 for default |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 252 | * Return: pointer to the newly added block, or NULL if there is not enough |
| 253 | * space for the blob |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 254 | */ |
Simon Glass | 4c1497e | 2020-09-19 18:49:29 -0600 | [diff] [blame] | 255 | void *bloblist_add(uint tag, int size, int align); |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 256 | |
| 257 | /** |
| 258 | * bloblist_ensure_size() - Find or add a blob |
| 259 | * |
| 260 | * Find an existing blob, or add a new one if not found |
| 261 | * |
| 262 | * @tag: Tag to add (enum bloblist_tag_t) |
| 263 | * @size: Size of the blob |
| 264 | * @blobp: Returns a pointer to blob on success |
Simon Glass | 4c1497e | 2020-09-19 18:49:29 -0600 | [diff] [blame] | 265 | * @align: Alignment of the blob (in bytes), 0 for default |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 266 | * Return: 0 if OK, -ENOSPC if it is missing and could not be added due to lack |
| 267 | * of space, or -ESPIPE it exists but has the wrong size |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 268 | */ |
Simon Glass | 4c1497e | 2020-09-19 18:49:29 -0600 | [diff] [blame] | 269 | int bloblist_ensure_size(uint tag, int size, int align, void **blobp); |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 270 | |
| 271 | /** |
| 272 | * bloblist_ensure() - Find or add a blob |
| 273 | * |
| 274 | * Find an existing blob, or add a new one if not found |
| 275 | * |
| 276 | * @tag: Tag to add (enum bloblist_tag_t) |
| 277 | * @size: Size of the blob |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 278 | * Return: pointer to blob, or NULL if it is missing and could not be added due |
| 279 | * to lack of space, or it exists but has the wrong size |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 280 | */ |
| 281 | void *bloblist_ensure(uint tag, int size); |
| 282 | |
| 283 | /** |
Simon Glass | 5b04454 | 2020-01-27 08:49:50 -0700 | [diff] [blame] | 284 | * bloblist_ensure_size_ret() - Find or add a blob |
| 285 | * |
| 286 | * Find an existing blob, or add a new one if not found |
| 287 | * |
| 288 | * @tag: Tag to add (enum bloblist_tag_t) |
| 289 | * @sizep: Size of the blob to create; returns size of actual blob |
| 290 | * @blobp: Returns a pointer to blob on success |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 291 | * Return: 0 if OK, -ENOSPC if it is missing and could not be added due to lack |
| 292 | * of space |
Simon Glass | 5b04454 | 2020-01-27 08:49:50 -0700 | [diff] [blame] | 293 | */ |
| 294 | int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp); |
| 295 | |
| 296 | /** |
Simon Glass | 1fe5937 | 2021-07-05 16:32:53 -0600 | [diff] [blame] | 297 | * bloblist_resize() - resize a blob |
| 298 | * |
| 299 | * Any blobs above this one are relocated up or down. The resized blob remains |
| 300 | * in the same place. |
| 301 | * |
| 302 | * @tag: Tag to add (enum bloblist_tag_t) |
| 303 | * @new_size: New size of the blob (>0 to expand, <0 to contract) |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 304 | * Return: 0 if OK, -ENOSPC if the bloblist does not have enough space, -ENOENT |
| 305 | * if the tag is not found |
Simon Glass | 1fe5937 | 2021-07-05 16:32:53 -0600 | [diff] [blame] | 306 | */ |
| 307 | int bloblist_resize(uint tag, int new_size); |
| 308 | |
| 309 | /** |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 310 | * bloblist_new() - Create a new, empty bloblist of a given size |
| 311 | * |
| 312 | * @addr: Address of bloblist |
| 313 | * @size: Initial size for bloblist |
| 314 | * @flags: Flags to use for bloblist |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 315 | * Return: 0 if OK, -EFAULT if addr is not aligned correctly, -ENOSPC is the |
| 316 | * area is not large enough |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 317 | */ |
| 318 | int bloblist_new(ulong addr, uint size, uint flags); |
| 319 | |
| 320 | /** |
| 321 | * bloblist_check() - Check if a bloblist exists |
| 322 | * |
| 323 | * @addr: Address of bloblist |
| 324 | * @size: Expected size of blobsize, or 0 to detect the size |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 325 | * Return: 0 if OK, -ENOENT if the magic number doesn't match (indicating that |
| 326 | * there problem is no bloblist at the given address), -EPROTONOSUPPORT |
| 327 | * if the version does not match, -EIO if the checksum does not match, |
| 328 | * -EFBIG if the expected size does not match the detected size, -ENOSPC |
| 329 | * if the size is not large enough to hold the headers |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 330 | */ |
| 331 | int bloblist_check(ulong addr, uint size); |
| 332 | |
| 333 | /** |
| 334 | * bloblist_finish() - Set up the bloblist for the next U-Boot part |
| 335 | * |
| 336 | * This sets the correct checksum for the bloblist. This ensures that the |
| 337 | * bloblist will be detected correctly by the next phase of U-Boot. |
| 338 | * |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 339 | * Return: 0 |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 340 | */ |
| 341 | int bloblist_finish(void); |
| 342 | |
| 343 | /** |
Simon Glass | 4aed227 | 2020-09-19 18:49:26 -0600 | [diff] [blame] | 344 | * bloblist_get_stats() - Get information about the bloblist |
| 345 | * |
| 346 | * This returns useful information about the bloblist |
Simon Glass | faff554 | 2021-07-05 16:32:54 -0600 | [diff] [blame] | 347 | * |
| 348 | * @basep: Returns base address of bloblist |
| 349 | * @sizep: Returns the number of bytes used in the bloblist |
| 350 | * @allocedp: Returns the total space allocated to the bloblist |
Simon Glass | 4aed227 | 2020-09-19 18:49:26 -0600 | [diff] [blame] | 351 | */ |
| 352 | void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp); |
| 353 | |
| 354 | /** |
Simon Glass | e50a24a | 2022-01-12 19:26:23 -0700 | [diff] [blame] | 355 | * bloblist_get_base() - Get the base address of the bloblist |
| 356 | * |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 357 | * Return: base address of bloblist |
Simon Glass | e50a24a | 2022-01-12 19:26:23 -0700 | [diff] [blame] | 358 | */ |
| 359 | ulong bloblist_get_base(void); |
| 360 | |
| 361 | /** |
| 362 | * bloblist_get_size() - Get the size of the bloblist |
| 363 | * |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 364 | * Return: the size in bytes |
Simon Glass | e50a24a | 2022-01-12 19:26:23 -0700 | [diff] [blame] | 365 | */ |
| 366 | ulong bloblist_get_size(void); |
| 367 | |
| 368 | /** |
Simon Glass | 4aed227 | 2020-09-19 18:49:26 -0600 | [diff] [blame] | 369 | * bloblist_show_stats() - Show information about the bloblist |
| 370 | * |
| 371 | * This shows useful information about the bloblist on the console |
| 372 | */ |
| 373 | void bloblist_show_stats(void); |
| 374 | |
| 375 | /** |
| 376 | * bloblist_show_list() - Show a list of blobs in the bloblist |
| 377 | * |
| 378 | * This shows a list of blobs, showing their address, size and tag. |
| 379 | */ |
| 380 | void bloblist_show_list(void); |
| 381 | |
| 382 | /** |
| 383 | * bloblist_tag_name() - Get the name for a tag |
| 384 | * |
| 385 | * @tag: Tag to check |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 386 | * Return: name of tag, or "invalid" if an invalid tag is provided |
Simon Glass | 4aed227 | 2020-09-19 18:49:26 -0600 | [diff] [blame] | 387 | */ |
| 388 | const char *bloblist_tag_name(enum bloblist_tag_t tag); |
| 389 | |
| 390 | /** |
Simon Glass | 9fe0646 | 2021-01-13 20:29:43 -0700 | [diff] [blame] | 391 | * bloblist_reloc() - Relocate the bloblist and optionally resize it |
| 392 | * |
| 393 | * @to: Pointer to new bloblist location (must not overlap old location) |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 394 | * @to_size: New size for bloblist (must be larger than from_size) |
Simon Glass | 9fe0646 | 2021-01-13 20:29:43 -0700 | [diff] [blame] | 395 | * @from: Pointer to bloblist to relocate |
| 396 | * @from_size: Size of bloblist to relocate |
| 397 | */ |
| 398 | void bloblist_reloc(void *to, uint to_size, void *from, uint from_size); |
| 399 | |
| 400 | /** |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 401 | * bloblist_init() - Init the bloblist system with a single bloblist |
| 402 | * |
Simon Glass | 20a1493 | 2022-01-12 19:26:24 -0700 | [diff] [blame] | 403 | * This locates and sets up the blocklist for use. |
| 404 | * |
| 405 | * If CONFIG_BLOBLIST_FIXED is selected, it uses CONFIG_BLOBLIST_ADDR and |
| 406 | * CONFIG_BLOBLIST_SIZE to set up a bloblist for use by U-Boot. |
| 407 | * |
| 408 | * If CONFIG_BLOBLIST_ALLOC is selected, it allocates memory for a bloblist of |
| 409 | * size CONFIG_BLOBLIST_SIZE. |
| 410 | * |
| 411 | * If CONFIG_BLOBLIST_PASSAGE is selected, it uses the bloblist in the incoming |
| 412 | * standard passage. The size is detected automatically so CONFIG_BLOBLIST_SIZE |
| 413 | * can be 0. |
| 414 | * |
| 415 | * Return: 0 if OK, -ve on error |
Simon Glass | 9f407d4 | 2018-11-15 18:43:50 -0700 | [diff] [blame] | 416 | */ |
| 417 | int bloblist_init(void); |
| 418 | |
| 419 | #endif /* __BLOBLIST_H */ |