diff options
author | Simon Glass <sjg@chromium.org> | 2023-12-27 13:07:07 -0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-12-31 07:21:02 -0700 |
commit | b6e83826ef1f4d04d350e4d2c03e3b28ab1b0ae4 (patch) | |
tree | 9d1204b575ac60e875e31903126ef2f865d53bbd /common | |
parent | f9ef9fb033d5ea29d0a72349fea9d0e55a528d36 (diff) | |
download | u-boot-b6e83826ef1f4d04d350e4d2c03e3b28ab1b0ae4.tar.gz u-boot-b6e83826ef1f4d04d350e4d2c03e3b28ab1b0ae4.tar.bz2 u-boot-b6e83826ef1f4d04d350e4d2c03e3b28ab1b0ae4.zip |
bloblist: Reduce blob-header size
The v0.9 spec provides for an 8-byte header for each blob, with fewer
fields.
The blob data start address should be aligned to the alignment specified
by the bloblist header.
Update the implementation to match this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Co-developed-by: Raymond Mao <raymond.mao@linaro.org>
Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/bloblist.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/common/bloblist.c b/common/bloblist.c index 73dbbc01c0..1c97d61e4a 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -87,12 +87,14 @@ static struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr) static inline uint rec_hdr_size(struct bloblist_rec *rec) { - return rec->hdr_size; + return (rec->tag_and_hdr_size & BLOBLISTR_HDR_SIZE_MASK) >> + BLOBLISTR_HDR_SIZE_SHIFT; } static inline uint rec_tag(struct bloblist_rec *rec) { - return rec->tag; + return (rec->tag_and_hdr_size & BLOBLISTR_TAG_MASK) >> + BLOBLISTR_TAG_SHIFT; } static ulong bloblist_blob_end_ofs(struct bloblist_hdr *hdr, @@ -101,7 +103,13 @@ static ulong bloblist_blob_end_ofs(struct bloblist_hdr *hdr, ulong offset; offset = (void *)rec - (void *)hdr; - offset += rec_hdr_size(rec) + ALIGN(rec->size, BLOBLIST_ALIGN); + /* + * The data section of next TE should start from an address aligned + * to 1 << hdr->align_log2. + */ + offset += rec_hdr_size(rec) + rec->size; + offset = round_up(offset + rec_hdr_size(rec), 1 << hdr->align_log2); + offset -= rec_hdr_size(rec); return offset; } @@ -145,7 +153,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, int data_start, aligned_start, new_alloced; if (!align_log2) - align_log2 = BLOBLIST_ALIGN_LOG2; + align_log2 = BLOBLIST_BLOB_ALIGN_LOG2; /* Figure out where the new data will start */ data_start = map_to_sysmem(hdr) + hdr->alloced + sizeof(*rec); @@ -178,8 +186,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, } rec = (void *)hdr + hdr->alloced; - rec->tag = tag; - rec->hdr_size = sizeof(struct bloblist_rec); + rec->tag_and_hdr_size = tag | sizeof(*rec) << BLOBLISTR_HDR_SIZE_SHIFT; rec->size = size; /* Zero the record data */ @@ -283,8 +290,8 @@ static int bloblist_resize_rec(struct bloblist_hdr *hdr, int new_alloced; /* New value for @hdr->alloced */ ulong next_ofs; /* Offset of the record after @rec */ - expand_by = ALIGN(new_size - rec->size, BLOBLIST_ALIGN); - new_alloced = ALIGN(hdr->alloced + expand_by, BLOBLIST_ALIGN); + expand_by = ALIGN(new_size - rec->size, BLOBLIST_BLOB_ALIGN); + new_alloced = ALIGN(hdr->alloced + expand_by, BLOBLIST_BLOB_ALIGN); if (new_size < 0) { log_debug("Attempt to shrink blob size below 0 (%x)\n", new_size); |