64bit fixes from blueswirl

git-svn-id: svn://coreboot.org/openbios/openbios-devel@83 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Stefan Reinauer
2006-09-14 15:06:38 +00:00
parent 84c8ff3704
commit 1a34b8a360
8 changed files with 47 additions and 29 deletions

View File

@@ -18,27 +18,45 @@
(__bswap32((x) & 0xffffffff) << 32) )
#ifdef CONFIG_LITTLE_ENDIAN
#define __cpu_to_le64(x) ((u64) (x))
#define __le64_to_cpu(x) ((u64) (x))
#define __cpu_to_le32(x) ((u32) (x))
#define __le32_to_cpu(x) ((u32) (x))
#define __cpu_to_le16(x) ((u16) (x))
#define __le16_to_cpu(x) ((u16) (x))
#define __cpu_to_be64(x) (__bswap64((u64) (x)))
#define __be64_to_cpu(x) (__bswap64((u64) (x)))
#define __cpu_to_be32(x) (__bswap32((u32) (x)))
#define __be32_to_cpu(x) (__bswap32((u32) (x)))
#define __cpu_to_be16(x) (__bswap16((u16) (x)))
#define __be16_to_cpu(x) (__bswap16((u16) (x)))
#endif
#ifdef CONFIG_BIG_ENDIAN
#define __cpu_to_le64(x) (__bswap64((u64) (x)))
#define __le64_to_cpu(x) (__bswap64((u64) (x)))
#define __cpu_to_le32(x) (__bswap32((u32) (x)))
#define __le32_to_cpu(x) (__bswap32((u32) (x)))
#define __cpu_to_le16(x) (__bswap16((u16) (x)))
#define __le16_to_cpu(x) (__bswap16((u16) (x)))
#define __cpu_to_be64(x) ((u64) (x))
#define __be64_to_cpu(x) ((u64) (x))
#define __cpu_to_be32(x) ((u32) (x))
#define __be32_to_cpu(x) ((u32) (x))
#define __cpu_to_be16(x) ((u16) (x))
#define __be16_to_cpu(x) ((u16) (x))
#endif
#if BITS==32
#define __becell_to_cpu(x) (__be32_to_cpu(x))
#define __lecell_to_cpu(x) (__le32_to_cpu(x))
#define __cpu_to_becell(x) (__cpu_to_be32(x))
#define __cpu_to_lecell(x) (__cpu_to_le32(x))
#else
#define __becell_to_cpu(x) (__be64_to_cpu(x))
#define __lecell_to_cpu(x) (__le64_to_cpu(x))
#define __cpu_to_becell(x) (__cpu_to_be64(x))
#define __cpu_to_lecell(x) (__cpu_to_le64(x))
#endif
#endif

View File

@@ -61,8 +61,8 @@ extern void close_dev( ihandle_t ih );
extern void set_property( phandle_t ph, const char *name,
const char *buf, int len );
extern void set_int_property( phandle_t ph, const char *name,
int val );
extern int get_int_property( phandle_t ph, const char *name,
cell val );
extern cell get_int_property( phandle_t ph, const char *name,
int *retlen );
extern char *get_property( phandle_t ph, const char *name,
int *retlen );
@@ -76,7 +76,7 @@ static inline phandle_t dt_find_type( const char *type ) {
}
/* forth bindings */
extern int feval( const char *str );
extern cell feval( const char *str );
extern void bind_xtfunc( const char *name, xt_t xt,
ucell arg, void (*func)(void) );
extern void bind_func( const char *name, void (*func)(void) );
@@ -85,7 +85,7 @@ extern void push_str( const char *str );
extern char *pop_fstr_copy( void );
extern int _fword( const char *word, xt_t *cache_xt );
extern int _eword( const char *word, xt_t *cache_xt, int nargs );
extern cell _eword( const char *word, xt_t *cache_xt, int nargs );
extern int _selfword( const char *method, xt_t *cache_xt );
extern int _parword( const char *method, xt_t *cache_xt );

View File

@@ -84,7 +84,7 @@
#define unaligned_write_long(addr, value) \
unaligned_write_word(addr, value & 0xffff); \
unaligned_write_word(addr, value >> 16)
unaligned_write_word(addr + 2, value >> 16)
#endif
@@ -100,7 +100,7 @@
#define unaligned_write_long(addr, value) \
unaligned_write_word(addr, value >> 16); \
unaligned_write_word(addr, value & 0xffff)
unaligned_write_word(addr + 2, value & 0xffff)
#endif
/* bit width handling */

View File

@@ -115,14 +115,14 @@ static void lit(void)
static void docon(void)
{ /* DOCON */
ucell tmp = read_cell(cell2pointer(read_ucell(cell2pointer(PC)) + sizeof(ucell)));
ucell tmp = read_ucell(cell2pointer(read_ucell(cell2pointer(PC)) + sizeof(ucell)));
PUSH(tmp);
dbg_interp_printk("docon: PC=%x, value=%x\n", PC, tmp);
}
static void dovar(void)
{ /* DOVAR */
ucell tmp = read_cell(cell2pointer(PC)) + sizeof(ucell);
ucell tmp = read_ucell(cell2pointer(PC)) + sizeof(ucell);
PUSH(tmp); /* returns address to variable */
dbg_interp_printk("dovar: PC: %x, %x\n", PC, tmp);
}

View File

@@ -33,18 +33,18 @@ push_str( const char *str )
}
/* WARNING: sloooow - AVOID */
int
cell
feval( const char *str )
{
push_str( str );
return eword("evaluate", 2);
}
int
cell
_eword( const char *word, xt_t *cache_xt, int nargs )
{
static xt_t catch_xt = 0;
int ret = -1;
cell ret = -1;
if( !catch_xt )
catch_xt = findword("catch");
@@ -285,10 +285,10 @@ set_property( phandle_t ph, const char *name, const char *buf, int len )
}
void
set_int_property( phandle_t ph, const char *name, int val )
set_int_property( phandle_t ph, const char *name, cell val )
{
int swapped=__cpu_to_be32(val);
set_property( ph, name, (char*)&swapped, 4 );
cell swapped=__cpu_to_becell(val);
set_property( ph, name, (char*)&swapped, sizeof(cell) );
}
char *
@@ -310,14 +310,14 @@ get_property( phandle_t ph, const char *name, int *retlen )
return (char*)POP();
}
int
cell
get_int_property( phandle_t ph, const char *name, int *retlen )
{
int *p;
cell *p;
if( !(p=(int*)get_property(ph, name, retlen)) )
if( !(p=(cell *)get_property(ph, name, retlen)) )
return 0;
return *p;
return __becell_to_cpu(*p);
}
@@ -423,7 +423,7 @@ make_openable( int only_parents )
static void
call1_func( void )
{
void (*func)(int v);
void (*func)(cell v);
func = (void*)POP();
(*func)( POP() );

View File

@@ -20,7 +20,7 @@
#include "modules.h"
typedef struct {
ullong mark;
ducell mark;
xt_t read_xt;
xt_t write_xt;
@@ -70,14 +70,14 @@ deblk_close( deblk_info_t *di )
static void
deblk_seek( deblk_info_t *di )
{
uint pos_hi = POP();
uint pos_lo = POP();
ullong mark = ((ullong)pos_hi << 32) | pos_lo;
ucell pos_hi = POP();
ucell pos_lo = POP();
ducell mark = ((ducell)pos_hi << BITS) | pos_lo;
/* printk("deblk_seek %x %08x\n", pos_hi, pos_lo ); */
/* -1 means seek to EOF (at least in our implementation) */
if( (llong)mark == -1 )
if( (dcell)mark == -1 )
RET(-1);
di->mark = mark;
@@ -102,7 +102,7 @@ typedef struct {
int nblks;
/* byte operation */
int offs;
cell offs;
int len;
char *data; /* start of data */
} work_t;

View File

@@ -22,8 +22,8 @@
typedef struct {
int fd;
ullong offs;
ullong size;
ducell offs;
ducell size;
int type; /* partition type or -1 */
ihandle_t part_ih;

View File

@@ -203,7 +203,7 @@ static void
files_seek( files_info_t *mi )
{
llong pos = DPOP();
int ret;
cell ret;
if( mi->file ) {
int offs = (int)pos;