64-bit fixes

General 64-bit fixes and a hack for x86 to Sparc64 crosscompiling problem,
where x86 misses 128-bit types.



git-svn-id: svn://coreboot.org/openbios/openbios-devel@68 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Stefan Reinauer
2006-07-18 21:42:16 +00:00
parent b03ab3d3ae
commit e492087dbe
12 changed files with 117 additions and 39 deletions

View File

@@ -43,11 +43,11 @@ static int errors = 0;
static int segfault = 0;
int verbose = 0;
static FILE *srcfiles[64];
static FILE *srcfiles[128];
static unsigned int cursrc = 0;
#ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
unsigned long base_address;
ucell base_address;
#endif
/* include path handling */
@@ -116,7 +116,7 @@ static void relocation_table(unsigned char * dict_one, unsigned char *dict_two,
bit=i&~(-BITS);
if(d1[i]==d2[i]) {
reloc_table[pos] &= target_ucell(~(1UL<<bit));
reloc_table[pos] &= target_ucell(~((ucell)1UL<<bit));
// This check might bring false positives in data.
//if(d1[i] >= pointer2cell(dict_one) &&
@@ -124,7 +124,7 @@ static void relocation_table(unsigned char * dict_one, unsigned char *dict_two,
// printk("\nWARNING: inconsistent relocation (%x:%x)!\n", d1[i], d2[i]);
} else {
/* This is a pointer, it needs relocation, d2==dict */
reloc_table[pos] |= target_ucell(1UL<<bit);
reloc_table[pos] |= target_ucell((ucell)1UL<<bit);
d2[i] = target_ucell(target_ucell(d2[i]) - pointer2cell(d2));
}
}
@@ -792,9 +792,9 @@ segv_handler(int signo __attribute__ ((unused)),
addr = read_cell(cell2pointer(PC));
printk("panic: segmentation violation at %p\n", (char *)si->si_addr);
printk("dict=%p here=%p(dict+0x%x) pc=0x%x(dict+0x%x)\n",
printk("dict=%p here=%p(dict+0x%" FMT_CELL_x ") pc=0x%" FMT_CELL_x "(dict+0x%" FMT_CELL_x ")\n",
dict, dict + dicthead, dicthead, PC, PC - pointer2cell(dict));
printk("dstackcnt=%d rstackcnt=%d instruction=%x\n",
printk("dstackcnt=%d rstackcnt=%d instruction=%" FMT_CELL_x "\n",
dstackcnt, rstackcnt, addr);
printdstack();
@@ -833,7 +833,7 @@ void exception(cell no)
printk(" undefined word.\n");
break;
default:
printk("\nError %d occured.\n", no);
printk("\nError %" FMT_CELL_d " occured.\n", no);
}
exit(1);
}

View File

@@ -46,10 +46,15 @@
#define target_ucell(value) (target_long(value))
#define target_cell(value) (target_long(value))
#elif BITS==64
#ifdef NATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH
#define target_ucell(value) ( ((ucell)target_long((value)&0xffffffff))<<32 )
#define target_cell(value) ( ((cell)target_long((value)&0xffffffff))<<32 )
#else
#define target_ucell(value) ( ((ucell)target_long((value)&0xffffffff))<<32 | \
((ucell)target_long((value)>>32)) )
#define target_cell(value) ( ((cell)target_long((value)&0xffffffff))<<32 | \
((cell)target_long((value)>>32)) )
#endif
#else
#error "Endianness not supported. Please report."
#endif
@@ -103,17 +108,23 @@
#ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
#define pointer2cell(x) ((ucell)(x))
#define cell2pointer(x) ((u8 *)(x))
#define FMT_CELL_x "x"
#define FMT_CELL_d "d"
#endif
#ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
extern unsigned long base_address;
#define pointer2cell(x) ((ucell)(((unsigned long)x)-base_address))
#define cell2pointer(x) ((u8 *)(((unsigned long)x)+base_address))
extern ucell 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_d "d"
#endif
#ifdef NATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH
#define pointer2cell(x) ((ucell)(x))
#define cell2pointer(x) ((u8 *)((unsigned long)x&0xFFFFFFFFUL))
#define pointer2cell(x) ((ucell)(unsigned long)(x))
#define cell2pointer(x) ((u8 *)((unsigned long)(x)&0xFFFFFFFFUL))
#define FMT_CELL_x "llx"
#define FMT_CELL_d "lld"
#endif
#endif

View File

@@ -119,7 +119,7 @@ void dump_header(dictionary_header_t *header)
printk(" relocation: %s\n", header->relocation?"yes":"no");
printk(" checksum: %08x\n", target_long(header->checksum));
printk(" length: %08x\n", target_long(header->length));
printk(" last: %08x\n", target_cell(header->last));
printk(" last: %0" FMT_CELL_x "\n", target_cell(header->last));
}
ucell load_dictionary(const char *data, ucell len)

View File

@@ -330,8 +330,13 @@ static void mudivmod(void)
{
const ucell b = POP();
const ducell a = DPOP();
#ifdef NEED_FAKE_INT128_T
fprintf(stderr, "mudivmode called\n");
exit(-1);
#else
PUSH(a % b);
DPUSH(a / b);
#endif
}
@@ -475,7 +480,12 @@ static void dplus(void)
{
const dcell d2 = DPOP();
const dcell d1 = DPOP();
#ifdef NEED_FAKE_INT128_T
fprintf(stderr, "dplus called\n");
exit(-1);
#else
DPUSH(d1 + d2);
#endif
}
@@ -487,7 +497,12 @@ static void dminus(void)
{
const dcell d2 = DPOP();
const dcell d1 = DPOP();
#ifdef NEED_FAKE_INT128_T
fprintf(stderr, "dminus called\n");
exit(-1);
#else
DPUSH(d1 - d2);
#endif
}
@@ -499,7 +514,12 @@ static void mmult(void)
{
const cell u2 = POP();
const cell u1 = POP();
#ifdef NEED_FAKE_INT128_T
fprintf(stderr, "mmult called\n");
exit(-1);
#else
DPUSH((dcell) u1 * u2);
#endif
}
@@ -511,7 +531,12 @@ static void ummult(void)
{
const ucell u2 = POP();
const ucell u1 = POP();
#ifdef NEED_FAKE_INT128_T
fprintf(stderr, "ummult called\n");
exit(-1);
#else
DPUSH((ducell) u1 * u2);
#endif
}

View File

@@ -9,6 +9,7 @@
#include "openbios/config.h"
#include "openbios/stack.h"
#include "cross.h"
#define dstacksize 512
int dstackcnt = 0;
@@ -24,7 +25,7 @@ void printdstack(void)
int i;
printk("dstack:");
for (i = 0; i <= dstackcnt; i++) {
printk(" 0x%x", dstack[i]);
printk(" 0x%" FMT_CELL_x , dstack[i]);
}
printk("\n");
}
@@ -35,7 +36,7 @@ void printrstack(void)
int i;
printk("rstack:");
for (i = 0; i <= rstackcnt; i++) {
printk(" 0x%x", rstack[i]);
printk(" 0x%" FMT_CELL_x , rstack[i]);
}
printk("\n");
}