Move cell2pointer and pointer2cell macros

These will be needed elsewhere for ppc64.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>


git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@917 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Andreas Färber
2010-10-24 18:55:59 +00:00
committed by Andreas Färber
parent 73d261ad4a
commit fbfaaa780f
2 changed files with 12 additions and 6 deletions

View File

@@ -30,6 +30,18 @@ typedef ucell phandle_t;
#ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
#define pointer2cell(x) ((ucell)(x))
#define cell2pointer(x) ((u8 *)(x))
#endif
#ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
#define pointer2cell(x) ((ucell)(((unsigned long)(x))-base_address))
#define cell2pointer(x) ((u8 *)(((unsigned long)(x))+base_address))
#endif
#ifdef NATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH
#define pointer2cell(x) ((ucell)(unsigned long)(x))
#define cell2pointer(x) ((u8 *)((unsigned long)(x)&0xFFFFFFFFUL))
#endif
static inline void PUSH(ucell value) { static inline void PUSH(ucell value) {
dstack[++dstackcnt] = (value); dstack[++dstackcnt] = (value);

View File

@@ -103,8 +103,6 @@
/* bit width handling */ /* bit width handling */
#ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH #ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
#define pointer2cell(x) ((ucell)(x))
#define cell2pointer(x) ((u8 *)(x))
#if BITS==32 #if BITS==32
#define FMT_CELL_x "x" #define FMT_CELL_x "x"
#define FMT_CELL_d "d" #define FMT_CELL_d "d"
@@ -116,15 +114,11 @@
#ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH #ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
extern unsigned long base_address; extern unsigned long base_address;
#define pointer2cell(x) ((ucell)(((unsigned long)(x))-base_address))
#define cell2pointer(x) ((u8 *)(((unsigned long)(x))+base_address))
#define FMT_CELL_x "x" #define FMT_CELL_x "x"
#define FMT_CELL_d "d" #define FMT_CELL_d "d"
#endif #endif
#ifdef NATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH #ifdef NATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH
#define pointer2cell(x) ((ucell)(unsigned long)(x))
#define cell2pointer(x) ((u8 *)((unsigned long)(x)&0xFFFFFFFFUL))
#define FMT_CELL_x "llx" #define FMT_CELL_x "llx"
#define FMT_CELL_d "lld" #define FMT_CELL_d "lld"
#endif #endif