summaryrefslogtreecommitdiff
path: root/payloads/libpayload/libcbfs
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@chromium.org>2015-07-14 22:29:04 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-07-15 16:34:50 +0200
commit2272b80a1dafdee57d8ca89860e9e988f1dceafc (patch)
treefbcd2207d107712d497c2f5bb0c2f881cdc6ce44 /payloads/libpayload/libcbfs
parent4d3e4c421e94814884d1ff035a4c4ec80d4b33b2 (diff)
downloadcoreboot-2272b80a1dafdee57d8ca89860e9e988f1dceafc.tar.xz
libpayload: assume cbfs file alignment is 64 byte
Change-Id: I8dfd8fbd452ce92fbca2cf095bc5e43e4a26969d Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/10920 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'payloads/libpayload/libcbfs')
-rw-r--r--payloads/libpayload/libcbfs/cbfs_core.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/payloads/libpayload/libcbfs/cbfs_core.c b/payloads/libpayload/libcbfs/cbfs_core.c
index 44205f666f..7926d9d650 100644
--- a/payloads/libpayload/libcbfs/cbfs_core.c
+++ b/payloads/libpayload/libcbfs/cbfs_core.c
@@ -98,7 +98,7 @@ const struct cbfs_header *cbfs_get_header(struct cbfs_media *media)
struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
{
const char *file_name;
- uint32_t offset, align, romsize, name_len;
+ uint32_t offset, romsize, name_len;
const struct cbfs_header *header;
struct cbfs_file file, *file_ptr;
struct cbfs_media default_media;
@@ -116,7 +116,6 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
// Logical offset (for source media) of first file.
offset = ntohl(header->offset);
- align = ntohl(header->align);
romsize = ntohl(header->romsize);
// TODO Add a "size" in CBFS header for a platform independent way to
@@ -129,13 +128,14 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
// fine tune the length to handle alignment positioning.
// using (bootblock size) % align, to derive the
// number of bytes the bootblock is off from the alignment size.
- if ((ntohl(header->bootblocksize) % align))
- romsize -= (align - (ntohl(header->bootblocksize) % align));
+ if ((ntohl(header->bootblocksize) % CBFS_ALIGNMENT))
+ romsize -= (CBFS_ALIGNMENT -
+ (ntohl(header->bootblocksize) % CBFS_ALIGNMENT));
else
romsize -= 1;
#endif
- DEBUG("CBFS location: 0x%x~0x%x, align: %d\n", offset, romsize, align);
+ DEBUG("CBFS location: 0x%x~0x%x\n", offset, romsize);
DEBUG("Looking for '%s' starting from 0x%x.\n", name, offset);
media->open(media);
@@ -143,9 +143,10 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
media->read(media, &file, offset, sizeof(file)) == sizeof(file)) {
if (memcmp(CBFS_FILE_MAGIC, file.magic,
sizeof(file.magic)) != 0) {
- uint32_t new_align = align;
- if (offset % align)
- new_align += align - (offset % align);
+ uint32_t new_align = CBFS_ALIGNMENT;
+ if (offset % CBFS_ALIGNMENT)
+ new_align += CBFS_ALIGNMENT -
+ (offset % CBFS_ALIGNMENT);
ERROR("ERROR: No file header found at 0x%xx - "
"try next aligned address: 0x%x.\n", offset,
offset + new_align);
@@ -179,8 +180,8 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
// Move to next file.
offset += ntohl(file.len) + ntohl(file.offset);
- if (offset % align)
- offset += align - (offset % align);
+ if (offset % CBFS_ALIGNMENT)
+ offset += CBFS_ALIGNMENT - (offset % CBFS_ALIGNMENT);
}
media->close(media);
LOG("WARNING: '%s' not found.\n", name);