Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10920
-gerrit
commit 5aa793df3e50dca6fce2758aa97e814765da5d01 Author: Patrick Georgi pgeorgi@chromium.org Date: Tue Jul 14 22:29:04 2015 +0200
libpayload: assume cbfs file alignment is 64 byte
Change-Id: I8dfd8fbd452ce92fbca2cf095bc5e43e4a26969d Signed-off-by: Patrick Georgi pgeorgi@chromium.org --- payloads/libpayload/include/cbfs_core.h | 2 +- payloads/libpayload/libcbfs/cbfs_core.c | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/payloads/libpayload/include/cbfs_core.h b/payloads/libpayload/include/cbfs_core.h index 1f8b7ee..a633232 100644 --- a/payloads/libpayload/include/cbfs_core.h +++ b/payloads/libpayload/include/cbfs_core.h @@ -94,7 +94,7 @@ struct cbfs_header { uint32_t version; uint32_t romsize; uint32_t bootblocksize; - uint32_t align; + uint32_t align; /* fixed to 64 bytes */ uint32_t offset; uint32_t architecture; uint32_t pad[1]; diff --git a/payloads/libpayload/libcbfs/cbfs_core.c b/payloads/libpayload/libcbfs/cbfs_core.c index 44205f6..98345f1 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,13 @@ 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) % 64)) + romsize -= (64 - (ntohl(header->bootblocksize) % 64)); 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 +142,9 @@ 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 = 64; + if (offset % 64) + new_align += 64 - (offset % 64); ERROR("ERROR: No file header found at 0x%xx - " "try next aligned address: 0x%x.\n", offset, offset + new_align); @@ -179,8 +178,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 % 64) + offset += 64 - (offset % 64); } media->close(media); LOG("WARNING: '%s' not found.\n", name);