aboutsummaryrefslogtreecommitdiff
path: root/util/cbfstool/fmd.h
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2019-03-04 14:28:37 +0800
committerPatrick Georgi <pgeorgi@google.com>2019-03-05 19:31:43 +0000
commit9497fcb742cebafb8d47f4cc3f0da796b0490498 (patch)
treeac57f48fb65ab7e5d3831509b7d7cd57f90dd4ff /util/cbfstool/fmd.h
parent7362768c5097249bf8823d5c4446804f3ccd87e6 (diff)
cbfstool: Change FMD annotation to flags
The idea of "annotation" for firmware sections was pretty flexible, but in future we will want multiple attributes applied to same area. For example, indicate the section must be preserved when updating firmware so serial number or MAC address can be preserved. The solution here is to extend annotation so it can take multiple identifiers (flags) in a row. For example, to declare a 64KB COREBOOT section as CBFS using annotation: COREBOOT(CBFS)@0x0 64k If there's a new flag "PRESERVE" indicating the section must be preserved before update, we can declare it following CBFS flag: COREBOOT(CBFS PRESERVE)@0x0 64k The flags are directly parsed in fmd_parser, and stored in an union flashmap_flags. Output modules can choose to ignore or process the flags. Currently the only supported flag is "CBFS" (for backward compatible with annotation). There will be more new flags in follow up patches. BUG=chromium:936768 TEST=make; boots on x86 "google/eve" and arm "google/kukui" devices Change-Id: Ie2d99f570e6faff6ed3a4344d6af7526a4515fae Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/31706 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/cbfstool/fmd.h')
-rw-r--r--util/cbfstool/fmd.h44
1 files changed, 25 insertions, 19 deletions
diff --git a/util/cbfstool/fmd.h b/util/cbfstool/fmd.h
index a4131c36f5..2d8c57f922 100644
--- a/util/cbfstool/fmd.h
+++ b/util/cbfstool/fmd.h
@@ -23,6 +23,19 @@
#define FMD_NOTFOUND UINT_MAX
+/**
+ * Flags used by flashmap_descriptor.
+ * These flags can be set by adding (NAME) after description name.
+ * For example, declaring a CBFS section named as COREBOOT for 16k:
+ * COREBOOT(CBFS) 16k
+ */
+union flashmap_flags {
+ struct {
+ int cbfs: 1; /* The section contains a CBFS area. */
+ } f;
+ int v;
+};
+
struct flashmap_descriptor {
char *name;
bool offset_known;
@@ -40,32 +53,25 @@ struct flashmap_descriptor {
/** It is an error to read this field unless size_known is set. */
unsigned size;
size_t list_len;
+ union flashmap_flags flags;
/** It is an error to dereference this array if list_len is 0. */
struct flashmap_descriptor **list;
};
/**
- * **Client-defined** callback.
- * This call is used to notify client code that the user has annotated the given
- * section node by accompanying it with a string enclosed in parentheses. It is
- * only invoked for nodes that have annotations, and then only once per node.
- * The annotations' syntactic validity and semantic meaning are not determined
- * by the compiler; rather, implementations of this function should use their
- * return type to tell the compiler whether the annotation was valid syntax, as
- * well as perform whatever actions are necessary given the particular
- * annotation. It's worth reiterating that this is only called on section nodes,
- * and will never be called with the final, complete flashmap_descriptor because
- * it is impossible to annotate the image as a whole. Note that, although the
- * node received by this function will be preserved in memory as part of the
- * ultimate flashmap_descriptor, the annotation string will only persist during
- * this function call: if the implementation needs it longer, it must copy it.
+ * **Client-defined** callback for flag "CBFS".
+ * This call is used to notify client code that the user has requested the given
+ * section node to be flagged with "CBFS". Implementations of this function
+ * should use their return type to tell the compiler whether the flag can be
+ * applied and can perform whatever actions are necessary.
+ * It's worth reiterating that this is only called on section nodes, and will
+ * never be called with the final, complete flashmap_descriptor because
+ * it is impossible to set flags for the image as a whole.
*
- * @param flashmap_descriptor The section node carrying the annotation
- * @param annotation What the user wrote (only valid during callback)
- * @return Whether this annotation represented valid syntax
+ * @param flashmap_descriptor The section node with flag set
+ * @return Whether this flag can be applied
*/
-bool fmd_process_annotation_impl(const struct flashmap_descriptor *node,
- const char *annotation);
+bool fmd_process_flag_cbfs(const struct flashmap_descriptor *node);
/**
* Parse and validate a flashmap descriptor from the specified stream.