commonlib/device_tree: Make END token part of struct_size
According to the FDT specification the FDT_END token is supposed to be the last token in the structure block, not a free-floating token immediately outside of it. That means we're supposed to count it in struct_size. It seems that the kernel never cared about this, but some FDT parsing utilities like `fdtgrep` do. Change-Id: Icdeadbeefcafed00dbabefeed1337c0debc86836 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/85462 Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
8ad1ee9b0a
commit
bcced7caea
1 changed files with 2 additions and 3 deletions
|
|
@ -935,12 +935,11 @@ void dt_flatten(const struct device_tree *tree, void *start_dest)
|
|||
|
||||
uint8_t *struct_start = dest;
|
||||
header->structure_offset = htobe32(dest - (uint8_t *)start_dest);
|
||||
be32enc(&dest[struct_size], FDT_TOKEN_END);
|
||||
struct_size += sizeof(uint32_t);
|
||||
header->structure_size = htobe32(struct_size);
|
||||
dest += struct_size;
|
||||
|
||||
*((uint32_t *)dest) = htobe32(FDT_TOKEN_END);
|
||||
dest += sizeof(uint32_t);
|
||||
|
||||
uint8_t *strings_start = dest;
|
||||
header->strings_offset = htobe32(dest - (uint8_t *)start_dest);
|
||||
header->strings_size = htobe32(strings_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue