From 1ca2d864dd09788ab69f461074889bab57a92ae8 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Wed, 30 Sep 2015 12:26:54 -0500 Subject: 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 Reviewed-on: http://review.coreboot.org/11757 Reviewed-by: Alexandru Gagniuc Tested-by: build bot (Jenkins) --- src/include/cbmem.h | 4 ++-- src/include/imd.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/cbmem.h b/src/include/cbmem.h index 0825f2936f..efaa44f9c9 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -37,6 +37,7 @@ #ifndef __ASSEMBLER__ #include #include +#include struct cbmem_entry; @@ -114,12 +115,11 @@ typedef void (* const cbmem_init_hook_t)(int is_recovery); void cbmem_run_init_hooks(int is_recovery); void cbmem_fail_resume(void); -#ifndef __PRE_RAM__ /* Ramstage only functions. */ /* Add the cbmem memory used to the memory map at boot. */ void cbmem_add_bootmem(void); void cbmem_list(void); -#endif /* __PRE_RAM__ */ +void cbmem_add_records_to_cbtable(struct lb_header *header); #if ENV_RAMSTAGE #define ROMSTAGE_CBMEM_INIT_HOOK(init_fn_) static cbmem_init_hook_t \ diff --git a/src/include/imd.h b/src/include/imd.h index 90a0dd5a90..6575312f3d 100644 --- a/src/include/imd.h +++ b/src/include/imd.h @@ -120,6 +120,9 @@ size_t imd_entry_size(const struct imd *imd, const struct imd_entry *entry); /* Returns pointer to region described by entry or NULL on failure. */ void *imd_entry_at(const struct imd *imd, const struct imd_entry *entry); +/* Returns id for the imd entry. */ +uint32_t imd_entry_id(const struct imd *imd, const struct imd_entry *entry); + /* Attempt to remove entry from imd. */ int imd_entry_remove(const struct imd *imd, const struct imd_entry *entry); @@ -132,6 +135,13 @@ struct imd_lookup { int imd_print_entries(const struct imd *imd, const struct imd_lookup *lookup, size_t size); +struct imd_cursor; +/* Initialize an imd_cursor object to walk the IMD entries. */ +int imd_cursor_init(const struct imd *imd, struct imd_cursor *cursor); + +/* Retrieve the next imd entry the cursor is referencing. Returns NULL when + * no more entries exist. */ +const struct imd_entry *imd_cursor_next(struct imd_cursor *cursor); /* * The struct imd is a handle for working with an in-memory directory. @@ -148,4 +158,10 @@ struct imd { struct imdr sm; }; +struct imd_cursor { + size_t current_imdr; + size_t current_entry; + const struct imdr *imdr[2]; +}; + #endif /* _IMD_H_ */ -- cgit v1.2.3