summaryrefslogtreecommitdiff
path: root/src/lib/imd_cbmem.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2015-09-30 12:26:54 -0500
committerAaron Durbin <adurbin@chromium.org>2015-11-03 00:19:46 +0100
commit1ca2d864dd09788ab69f461074889bab57a92ae8 (patch)
tree2322173b00869e63e7d07a56b10064abd72d88d2 /src/lib/imd_cbmem.c
parent730a043fb6cb4dd3cb5af8f8640365727b598648 (diff)
downloadcoreboot-1ca2d864dd09788ab69f461074889bab57a92ae8.tar.xz
cbmem: add coreboot table records for each cbmem entry
In order to not expose the cbmem data structures to userland that are used by coreboot internally add each of the cbmem entries to a coreboot table record. The payload ABI uses coreboot tables so this just provides a shortcut for cbmem entries which were manually added previously by doing the work on behalf of all entries. A cursor structure and associated functions are added to the imd code for walking the entries in order to be placed in the coreboot tables. Additionally a struct lb_cbmem_entry is added that lists the base address, size, and id of the cbmem entry. BUG=chrome-os-partner:43731 BRANCH=None TEST=Booted glados. View coreboot table entries with cbmem. Change-Id: I125940aa1898c3e99077ead0660eff8aa905b13b Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/11757 Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/lib/imd_cbmem.c')
-rw-r--r--src/lib/imd_cbmem.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c
index 7cc34f5878..49faad97b4 100644
--- a/src/lib/imd_cbmem.c
+++ b/src/lib/imd_cbmem.c
@@ -263,7 +263,6 @@ void *cbmem_entry_start(const struct cbmem_entry *entry)
return imd_entry_at(imd, cbmem_to_imd(entry));
}
-#if ENV_RAMSTAGE
void cbmem_add_bootmem(void)
{
void *base = NULL;
@@ -273,10 +272,50 @@ void cbmem_add_bootmem(void)
bootmem_add_range((uintptr_t)base, size, LB_MEM_TABLE);
}
+#if ENV_RAMSTAGE
+/*
+ * -fdata-sections doesn't work so well on read only strings. They all
+ * get put in the same section even though those strings may never be
+ * referenced in the final binary.
+ */
void cbmem_list(void)
{
static const struct imd_lookup lookup[] = { CBMEM_ID_TO_NAME_TABLE };
imd_print_entries(cbmem_get_imd(), lookup, ARRAY_SIZE(lookup));
}
-#endif /* __PRE_RAM__ */
+#endif
+
+void cbmem_add_records_to_cbtable(struct lb_header *header)
+{
+ struct imd_cursor cursor;
+ struct imd *imd;
+
+ imd = cbmem_get_imd();
+
+ if (imd_cursor_init(imd, &cursor))
+ return;
+
+ while (1) {
+ const struct imd_entry *e;
+ struct lb_cbmem_entry *lbe;
+ uint32_t id;
+
+ e = imd_cursor_next(&cursor);
+
+ if (e == NULL)
+ break;
+
+ id = imd_entry_id(imd, e);
+ /* Don't add these metadata entries. */
+ if (id == CBMEM_ID_IMD_ROOT || id == CBMEM_ID_IMD_SMALL)
+ continue;
+
+ lbe = (struct lb_cbmem_entry *)lb_new_record(header);
+ lbe->tag = LB_TAG_CBMEM_ENTRY;
+ lbe->size = sizeof(*lbe);
+ lbe->address = (uintptr_t)imd_entry_at(imd, e);
+ lbe->entry_size = imd_entry_size(imd, e);
+ lbe->id = id;
+ }
+}