util/cbfstool/fmaptool: generate defines for all fmap sections
Add defines for the start and size of the FMAP sections to the optionally generated header file. For the defines the name of the corresponding FMAP section is used without the full path, since every section name should be unique anyway as documented here: Documentation/lib/flashmap.md BUG=b:157068645 TEST=Generated header file contains expected defines. BRANCH=zork Change-Id: Ie31161cfd304b69a3cb4bb366bf365d979e77c64 Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/45594 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
parent
c99bd4a6c9
commit
d57c1286de
|
@ -71,6 +71,29 @@ static void list_cbfs_section_names(FILE *out)
|
|||
fputc('\n', out);
|
||||
}
|
||||
|
||||
static void write_header_fmap_sections(FILE *header, const struct flashmap_descriptor *root,
|
||||
unsigned int offset)
|
||||
{
|
||||
assert(root);
|
||||
/*
|
||||
* The offset may only be unknown for the root node in a system where the flash isn't
|
||||
* memory-mapped.
|
||||
*/
|
||||
if (!root->offset_known && offset != 0)
|
||||
return;
|
||||
|
||||
const unsigned int current_offset = offset + (root->offset_known ? root->offset : 0);
|
||||
fprintf(header, "#define FMAP_SECTION_%s_START %#x\n", root->name, current_offset);
|
||||
|
||||
if (!root->size_known)
|
||||
return;
|
||||
|
||||
fprintf(header, "#define FMAP_SECTION_%s_SIZE %#x\n", root->name, root->size);
|
||||
|
||||
fmd_foreach_child(child, root)
|
||||
write_header_fmap_sections(header, child, current_offset);
|
||||
}
|
||||
|
||||
static bool write_header(const char *out_fname,
|
||||
const struct flashmap_descriptor *root,
|
||||
const int fmap_size)
|
||||
|
@ -93,6 +116,9 @@ static bool write_header(const char *out_fname,
|
|||
fprintf(header, "#define %s %#x\n", HEADER_FMAP_OFFSET, fmap_offset);
|
||||
fprintf(header, "#define %s %#x\n\n", HEADER_FMAP_SIZE, fmap_size);
|
||||
|
||||
write_header_fmap_sections(header, root, 0);
|
||||
fputs("\n", header);
|
||||
|
||||
fputs("#endif\n", header);
|
||||
|
||||
fclose(header);
|
||||
|
|
Loading…
Reference in New Issue