Alexandru Gagniuc (mr.nuke.me@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5102
-gerrit
commit 883174f2907786a6af3b614350ae9af7feffe6e5 Author: Alexandru Gagniuc mr.nuke.me@gmail.com Date: Sun Feb 2 21:34:15 2014 -0600
cbfstool: Hide cbfstool_offset from the global namespace
This is part of a larger effort to reduce global variable usage in cbfstool. cbfstool_offset is particularly easy to hide since it's only used in common.c .
Change-Id: Ic45349b5148d4407f31e12682ea0ad4b68136711 Signed-off-by: Alexandru Gagniuc mr.nuke.me@gmail.com --- util/cbfstool/common.c | 12 +++++++++++- util/cbfstool/common.h | 11 ----------- 2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c index 356ba2f..b646cec 100644 --- a/util/cbfstool/common.c +++ b/util/cbfstool/common.c @@ -150,9 +150,19 @@ void *loadfile(const char *filename, uint32_t * romsize_p, void *content, static struct cbfs_header *cbfstool_master_header; static uint32_t phys_start, phys_end, align; uint32_t romsize; -void *cbfstool_offset; +static void *cbfstool_offset; uint32_t arch = CBFS_ARCHITECTURE_UNKNOWN;
+static inline void *phys_to_virt(uint32_t addr) +{ + return cbfstool_offset + addr; +} + +static inline uint32_t virt_to_phys(void *addr) +{ + return (unsigned long)(addr - cbfstool_offset) & 0xffffffff; +} + static struct { uint32_t arch; const char *name; diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h index e49a3f6..4a0a632 100644 --- a/util/cbfstool/common.h +++ b/util/cbfstool/common.h @@ -62,7 +62,6 @@ int buffer_write_file(struct buffer *buffer, const char *filename); /* Destroys a memory buffer. */ void buffer_delete(struct buffer *buffer);
-extern void *cbfstool_offset; extern uint32_t romsize; extern int host_bigendian; extern uint32_t arch; @@ -70,16 +69,6 @@ extern uint32_t arch; const char *arch_to_string(uint32_t a); uint32_t string_to_arch(const char *arch_string);
-static inline void *phys_to_virt(uint32_t addr) -{ - return cbfstool_offset + addr; -} - -static inline uint32_t virt_to_phys(void *addr) -{ - return (unsigned long)(addr - cbfstool_offset) & 0xffffffff; -} - #define ALIGN(val, by) (((val) + (by)-1)&~((by)-1))
size_t getfilesize(const char *filename);