summaryrefslogtreecommitdiff
path: root/util/cbfstool/common.h
diff options
context:
space:
mode:
authorRonald G. Minnich <rminnich@google.com>2013-12-03 11:13:35 -0800
committerAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-01-29 20:03:44 +0100
commitaa2f739ae87386b8a29068ecfdc2b25bcf4a19ca (patch)
tree7d69d6c6edc92c633ff6138f6d8b626151522c0a /util/cbfstool/common.h
parent8449b5e0a9e5eca3c91c1d9351d5f21eaa0ba582 (diff)
cbfs: fix issues with word size and endianness.
Add XDR functions and use them to convert the ELF headers to native headers, using the Elf64 structs to ensure we accomodate all word sizes. Also, use these XDR functions for output. This may seem overly complex but it turned out to be much the easiest way to do this. Note that the basic elf parsing function in cbfs-mkstage.c now works over all ELF files, for all architectures, endian, and word size combinations. At the same time, the basic elf parsing in cbfs-mkstage.c is a loop that has no architecture-specific conditionals. Add -g to the LDFLAGS while we're here. It's on the CFLAGS so there is no harm done. This code has been tested on all chromebooks that use coreboot to date. I added most of the extra checks from ChromeOS and they triggered a lot of warnings, hence the other changes. I had to take -Wshadow back out due to the many errors it triggers in LZMA. BUG=None TEST=Build and boot for Peppy; works fine. Build and boot for nyan, works fine. Build for qemu targets and armv8 targets. BRANCH=None Change-Id: I5a4cee9854799189115ac701e22efc406a8d902f Signed-off-by: Ronald G. Minnich <rminnich@google.com> Reviewed-on: https://chromium-review.googlesource.com/178606 Reviewed-by: Ronald Minnich <rminnich@chromium.org> Commit-Queue: Ronald Minnich <rminnich@chromium.org> Tested-by: Ronald Minnich <rminnich@chromium.org> Reviewed-on: http://review.coreboot.org/4817 Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'util/cbfstool/common.h')
-rw-r--r--util/cbfstool/common.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 6e12fcb064..ed75a7fd02 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -62,7 +62,7 @@ int buffer_write_file(struct buffer *buffer, const char *filename);
/* Destroys a memory buffer. */
void buffer_delete(struct buffer *buffer);
-extern void *offset;
+extern void *cbfstool_offset;
extern uint32_t romsize;
extern int host_bigendian;
extern uint32_t arch;
@@ -72,12 +72,12 @@ uint32_t string_to_arch(const char *arch_string);
static inline void *phys_to_virt(uint32_t addr)
{
- return offset + addr;
+ return cbfstool_offset + addr;
}
static inline uint32_t virt_to_phys(void *addr)
{
- return (unsigned long)(addr - offset) & 0xffffffff;
+ return (unsigned long)(addr - cbfstool_offset) & 0xffffffff;
}
#define ALIGN(val, by) (((val) + (by)-1)&~((by)-1))
@@ -124,7 +124,6 @@ int add_file_to_cbfs(void *content, uint32_t contentsize, uint32_t location);
int remove_file_from_cbfs(const char *filename);
void print_cbfs_directory(const char *filename);
int extract_file_from_cbfs(const char *filename, const char *payloadname, const char *outpath);
-int remove_file_from_cbfs(const char *filename);
uint32_t cbfs_find_location(const char *romfile, uint32_t filesize,
const char *filename, uint32_t align);
@@ -132,5 +131,30 @@ uint32_t cbfs_find_location(const char *romfile, uint32_t filesize,
void print_supported_filetypes(void);
#define ARRAY_SIZE(a) (int)(sizeof(a) / sizeof((a)[0]))
+/* lzma/lzma.c */
+void do_lzma_compress(char *in, int in_len, char *out, int *out_len);
+void do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len);
+/* xdr.c */
+struct xdr {
+ uint16_t (*get16)(struct buffer *input);
+ uint32_t (*get32)(struct buffer *input);
+ uint64_t (*get64)(struct buffer *input);
+ void (*put16)(struct buffer *input, uint16_t val);
+ void (*put32)(struct buffer *input, uint32_t val);
+ void (*put64)(struct buffer *input, uint64_t val);
+};
+
+/* common.c */
+
+int find_master_header(void *romarea, size_t size);
+void recalculate_rom_geometry(void *romarea);
+const char *strfiletype(uint32_t number);
+
+/* cbfs_image.c */
+uint32_t get_cbfs_entry_type(const char *name, uint32_t default_value);
+const char *get_cbfs_entry_type_name(uint32_t type);
+uint32_t get_cbfs_compression(const char *name, uint32_t unknown);
+
+extern struct xdr xdr_le, xdr_be;
#endif