summaryrefslogtreecommitdiffstats
path: root/util/cbfstool/common.c
diff options
context:
space:
mode:
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-02-02 21:34:15 -0600
committerAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-02-04 19:37:26 +0100
commitc677c7d6e43c1f88ddfbd86ff32c81425f665596 (patch)
tree5961069803ca617a44428bdf18f0d61efe070f6c /util/cbfstool/common.c
parentf592c08b68f78bf3c7feef9ea8a420a10e28338d (diff)
downloadcoreboot-c677c7d6e43c1f88ddfbd86ff32c81425f665596.tar.gz
coreboot-c677c7d6e43c1f88ddfbd86ff32c81425f665596.tar.bz2
coreboot-c677c7d6e43c1f88ddfbd86ff32c81425f665596.zip
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> Reviewed-on: http://review.coreboot.org/5102 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'util/cbfstool/common.c')
-rw-r--r--util/cbfstool/common.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
index e10d9fb4c4bb..0aaeb1317813 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;