libpayload/libcbfs: add a function to return all the payload headers

For choosing payloads we need to be able to read out all the payload
headers. cbfs_payload_headers() delivers names and all the info available
about any payloads.

BUG=None
TEST=builds, tested on Nyan, works fine.
BRANCH=None

Change-Id: If98437819d53cc01d175234fc7429d6aa3383c2c
Signed-off-by: Ronald G. Minnich <rminnich@google.com>
Reviewed-on: https://chromium-review.googlesource.com/180352
Commit-Queue: Ronald Minnich <rminnich@chromium.org>
Tested-by: Ronald Minnich <rminnich@chromium.org>
Reviewed-by: Puneet Kumar <puneetster@chromium.org>
This commit is contained in:
Ronald G. Minnich 2013-12-04 11:38:53 -08:00 committed by chrome-internal-fetch
commit 8476c04022
2 changed files with 127 additions and 2 deletions

View file

@ -150,8 +150,10 @@ struct cbfs_stage {
uint32_t memlen; /** total length of object in memory */
} __attribute__((packed));
/** this is the sub-header for payload components. Payloads
are loaded by coreboot at the end of the boot process */
/** this is the sub-header for payload components. Payloads are
* loaded by coreboot or other payloads at the end of the boot
* process
*/
struct cbfs_payload_segment {
uint32_t type;
@ -166,6 +168,19 @@ struct cbfs_payload {
struct cbfs_payload_segment segments;
};
/* for returning payload info to (e.g.) bayou.
* Return the file header, payload header, and name.
* It must be done this way because we can't
* assume file headers and names are contiguous.
* Walking the headers can be expensive, so we get all
* the information we can.
*/
struct cbfs_payload_info {
struct cbfs_file file;
struct cbfs_payload payload;
const char *name;
};
#define PAYLOAD_SEGMENT_CODE 0x45444F43
#define PAYLOAD_SEGMENT_DATA 0x41544144
#define PAYLOAD_SEGMENT_BSS 0x20535342
@ -214,6 +229,14 @@ struct cbfs_media {
/* returns pointer to a file entry inside CBFS or NULL */
struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name);
/* Fills the pointer info with an array of payload file info structs.
* Reads at most maxentries items.
* Returns number we found.
*/
int cbfs_payload_headers(struct cbfs_media *media,
struct cbfs_payload_info *info,
int maxentries);
/* returns pointer to file content inside CBFS after if type is correct */
void *cbfs_get_file_content(struct cbfs_media *media, const char *name,
int type);