summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>2013-12-08 01:13:43 -0600
committerAlexandru Gagniuc <mr.nuke.me@gmail.com>2013-12-09 19:56:57 +0100
commit299c26510202faa3cf7383040f330d502d224fdf (patch)
treefd10e2e39dc68ba335925e5a45e3419ccae9ac25 /src/include
parentf87c20a00dca412ad8fa255ef38fd954762afa4b (diff)
downloadcoreboot-299c26510202faa3cf7383040f330d502d224fdf.tar.xz
Refactor usage of walkcbfs to permit access to CBFS headers
walkcbfs() is used only with ROMCC. Besides finding stages during the bootblock, it's also used when applying microcode updates during the bootblock phase. The function used to return only a pointer to the data of the CBFS file, while making the header completely inaccessible. Since the header contains the length of the CBFS file, the caller did not have a way to know how long the data was. Then, other conventions had to be used to determine the EOF, which might present problems if the user replaces the CBFS file. This is not an issue when jumping to a stage (romstage), but can present problems when accessing a microcode file which has not been NULL-terminated. Refactor walkcbfs_asm to return a pointer to the CBFS file header rather than the data. Rename walkcbfs() to walkcbfs_head(), and reimplement a new walkcbfs() based on walkcbfs_head(). Thus current usage of walkcbfs() remains unaffected. The code has been verified to run successfully under qemu. Subsequent patches will change usage of walkcbfs() to walkcbfs_head where knowing the length of the data is needed. Change-Id: I21cbf19e130e1480e2749754e5d5130d36036f8e Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://review.coreboot.org/4504 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/cbfs_core.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/include/cbfs_core.h b/src/include/cbfs_core.h
index 08fe8150ed..04b5dd7f23 100644
--- a/src/include/cbfs_core.h
+++ b/src/include/cbfs_core.h
@@ -134,6 +134,15 @@ struct cbfs_file {
uint32_t offset;
} __attribute__((packed));
+#define CBFS_NAME(_c) (((char *) (_c)) + sizeof(struct cbfs_file))
+#define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + ntohl((_p)->offset))) )
+
+/*
+ * ROMCC does not understand uint64_t, so we hide future definitions as they are
+ * unlikely to be ever needed from ROMCC
+ */
+#ifndef __ROMCC__
+
/*** Component sub-headers ***/
/* Following are component sub-headers for the "standard"
@@ -177,9 +186,6 @@ struct cbfs_optionrom {
uint32_t len;
} __attribute__((packed));
-#define CBFS_NAME(_c) (((char *) (_c)) + sizeof(struct cbfs_file))
-#define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + ntohl((_p)->offset))) )
-
#define CBFS_MEDIA_INVALID_MAP_ADDRESS ((void*)(0xffffffff))
#define CBFS_DEFAULT_MEDIA ((void*)(0x0))
@@ -225,4 +231,6 @@ int cbfs_decompress(int algo, void *src, void *dst, int len);
* on failure */
const struct cbfs_header *cbfs_get_header(struct cbfs_media *media);
+#endif /* __ROMCC__ */
+
#endif