From 0af61b6c82d7ff02426a26bf435b7c6ee768a602 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 12 Jan 2014 13:45:52 +0100 Subject: lib/cbfs_core.c: Supply size of file as well in cbfs_get_file_content Change-Id: I5b93e5321e470f19ad22ca2cfdb1ebf3b340b252 Signed-off-by: Vladimir Serbinenko Reviewed-on: http://review.coreboot.org/4659 Reviewed-by: Patrick Georgi Tested-by: build bot (Jenkins) --- src/lib/cbfs.c | 8 ++++---- src/lib/cbfs_core.c | 9 ++++++++- src/lib/coreboot_table.c | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 1f44695fb2..e38f856de7 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -96,7 +96,7 @@ void *cbfs_load_optionrom(struct cbfs_media *media, uint16_t vendor, tohex16(device, name+8); orom = (struct cbfs_optionrom *) - cbfs_get_file_content(media, name, CBFS_TYPE_OPTIONROM); + cbfs_get_file_content(media, name, CBFS_TYPE_OPTIONROM, NULL); if (orom == NULL) return NULL; @@ -187,7 +187,7 @@ static void *load_stage_from_cbfs(struct cbfs_media *media, const char *name, const struct cbmem_entry *ramstage_entry; stage = (struct cbfs_stage *) - cbfs_get_file_content(media, name, CBFS_TYPE_STAGE); + cbfs_get_file_content(media, name, CBFS_TYPE_STAGE, NULL); if (stage == NULL) return (void *) -1; @@ -257,7 +257,7 @@ void * cbfs_load_stage(struct cbfs_media *media, const char *name) void * cbfs_load_stage(struct cbfs_media *media, const char *name) { struct cbfs_stage *stage = (struct cbfs_stage *) - cbfs_get_file_content(media, name, CBFS_TYPE_STAGE); + cbfs_get_file_content(media, name, CBFS_TYPE_STAGE, NULL); /* this is a mess. There is no ntohll. */ /* for now, assume compatible byte order until we solve this. */ uint32_t entry; @@ -302,7 +302,7 @@ void *cbfs_load_payload(struct cbfs_media *media, const char *name) return payload; payload = (struct cbfs_payload *)cbfs_get_file_content( - media, name, CBFS_TYPE_PAYLOAD); + media, name, CBFS_TYPE_PAYLOAD, NULL); return payload; } #endif diff --git a/src/lib/cbfs_core.c b/src/lib/cbfs_core.c index 612fef2a6f..839b994cf3 100644 --- a/src/lib/cbfs_core.c +++ b/src/lib/cbfs_core.c @@ -173,10 +173,14 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name) return NULL; } -void *cbfs_get_file_content(struct cbfs_media *media, const char *name, int type) +void *cbfs_get_file_content(struct cbfs_media *media, const char *name, + int type, size_t *sz) { struct cbfs_file *file = cbfs_get_file(media, name); + if (sz) + *sz = 0; + if (file == NULL) { ERROR("Could not find file '%s'.\n", name); return NULL; @@ -188,6 +192,9 @@ void *cbfs_get_file_content(struct cbfs_media *media, const char *name, int type return NULL; } + if (sz) + *sz = ntohl(file->len); + return (void *)CBFS_SUBHEADER(file); } diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 772729adf5..f433e86b7d 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -505,7 +505,7 @@ unsigned long write_coreboot_table( { struct cmos_option_table *option_table = cbfs_get_file_content( CBFS_DEFAULT_MEDIA, "cmos_layout.bin", - CBFS_COMPONENT_CMOS_LAYOUT); + CBFS_COMPONENT_CMOS_LAYOUT, NULL); if (option_table) { struct lb_record *rec_dest = lb_new_record(head); /* Copy the option config table, it's already a lb_record... */ -- cgit v1.2.3