mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Fix Sparc64 cross compilation in 32 bit environment, closes #17
git-svn-id: svn://coreboot.org/openbios/openbios-devel@436 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
@@ -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(~((ucell)1UL<<bit));
|
||||
reloc_table[pos] &= target_ucell(~((ucell)1ULL << 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((ucell)1UL<<bit);
|
||||
reloc_table[pos] |= target_ucell((ucell)1ULL << bit);
|
||||
d2[i] = target_ucell(target_ucell(d2[i]) - pointer2cell(d2));
|
||||
}
|
||||
}
|
||||
@@ -175,8 +175,9 @@ static void write_dictionary(const char *filename)
|
||||
.checksum = 0,
|
||||
.compression = 0,
|
||||
.relocation = -1,
|
||||
.length = target_ulong(dicthead),
|
||||
.last = target_ucell(((unsigned long)last-(unsigned long)dict)),
|
||||
.length = target_ulong((uint32_t)dicthead),
|
||||
.last = target_ucell((ucell)((unsigned long)last
|
||||
- (unsigned long)dict)),
|
||||
.reserved[0] = 0,
|
||||
.reserved[1] = 0,
|
||||
.reserved[2] = 0,
|
||||
@@ -464,7 +465,7 @@ static int interpret_source(char *fil)
|
||||
{
|
||||
FILE *f;
|
||||
char tib[160];
|
||||
long num;
|
||||
cell num;
|
||||
char *test;
|
||||
|
||||
const ucell SEMIS = (ucell)findword("(semis)");
|
||||
@@ -627,11 +628,12 @@ static int interpret_source(char *fil)
|
||||
u8 flags = read_byte((u8*)cell2pointer(res) -
|
||||
sizeof(cell) - 1);
|
||||
#ifdef CONFIG_DEBUG_INTERPRETER
|
||||
printk("%s is 0x%p\n", tib, (ucell) res);
|
||||
printk("%s is 0x%" FMT_CELL_x "\n", tib, (ucell) res);
|
||||
#endif
|
||||
if (!(*state) || (flags & 3)) {
|
||||
#ifdef CONFIG_DEBUG_INTERPRETER
|
||||
printk("executing %s, %p (flags: %s %s)\n",
|
||||
printk("executing %s, %" FMT_CELL_d
|
||||
" (flags: %s %s)\n",
|
||||
tib, res,
|
||||
(flags & 1) ? "immediate" : "",
|
||||
(flags & 2) ? "compile-only" : "");
|
||||
@@ -649,9 +651,9 @@ static int interpret_source(char *fil)
|
||||
|
||||
/* if not look if it's a number */
|
||||
if (tib[0] == '-')
|
||||
num = strtol(tib, &test, read_ucell(base));
|
||||
num = strtoll(tib, &test, read_ucell(base));
|
||||
else
|
||||
num = strtoul(tib, &test, read_ucell(base));
|
||||
num = strtoull(tib, &test, read_ucell(base));
|
||||
|
||||
|
||||
if (*test != 0) {
|
||||
@@ -667,12 +669,12 @@ static int interpret_source(char *fil)
|
||||
|
||||
if (*state == 0) {
|
||||
#ifdef CONFIG_DEBUG_INTERPRETER
|
||||
printk("pushed %x to stack\n\n", num);
|
||||
printk("pushed %" FMT_CELL_x " to stack\n\n", num);
|
||||
#endif
|
||||
PUSH(num);
|
||||
} else {
|
||||
#ifdef CONFIG_DEBUG_INTERPRETER
|
||||
printk("writing lit, %x to dict\n\n", num);
|
||||
printk("writing lit, %" FMT_CELL_x " to dict\n\n", num);
|
||||
#endif
|
||||
writecell(LIT); /* lit */
|
||||
writecell(num);
|
||||
|
||||
@@ -46,15 +46,12 @@
|
||||
#define target_ucell(value) ((ucell)target_long(value))
|
||||
#define target_cell(value) ((cell)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
|
||||
#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)))
|
||||
#else
|
||||
#error "Endianness not supported. Please report."
|
||||
#endif
|
||||
|
||||
@@ -167,7 +167,7 @@ ucell load_dictionary(const char *data, ucell len)
|
||||
l=(walk-(ucell *)dict);
|
||||
pos=l/BITS;
|
||||
bit=l&~(-BITS);
|
||||
if (reloc_table[pos]&target_ucell(1UL<<bit)) {
|
||||
if (reloc_table[pos] & target_ucell((ucell)1ULL << bit)) {
|
||||
// printk("%lx, pos %x, bit %d\n",*walk, pos, bit);
|
||||
write_ucell(walk, read_ucell(walk)+pointer2cell(dict));
|
||||
}
|
||||
|
||||
@@ -330,8 +330,18 @@ static void mudivmod(void)
|
||||
const ucell b = POP();
|
||||
const ducell a = DPOP();
|
||||
#ifdef NEED_FAKE_INT128_T
|
||||
fprintf(stderr, "mudivmode called\n");
|
||||
exit(-1);
|
||||
if (a.hi != 0) {
|
||||
fprintf(stderr, "mudivmod called (0x%016llx %016llx / 0x%016llx)\n",
|
||||
a.hi, a.lo, b);
|
||||
exit(-1);
|
||||
} else {
|
||||
ducell c;
|
||||
|
||||
PUSH(a.lo % b);
|
||||
c.hi = 0;
|
||||
c.lo = a.lo / b;
|
||||
DPUSH(c);
|
||||
}
|
||||
#else
|
||||
PUSH(a % b);
|
||||
DPUSH(a / b);
|
||||
@@ -480,8 +490,16 @@ static void dplus(void)
|
||||
const dcell d2 = DPOP();
|
||||
const dcell d1 = DPOP();
|
||||
#ifdef NEED_FAKE_INT128_T
|
||||
fprintf(stderr, "dplus called\n");
|
||||
exit(-1);
|
||||
ducell c;
|
||||
|
||||
if (d1.hi != 0 || d2.hi != 0) {
|
||||
fprintf(stderr, "dplus called (0x%016llx %016llx + 0x%016llx %016llx)\n",
|
||||
d1.hi, d1.lo, d2.hi, d2.lo);
|
||||
exit(-1);
|
||||
}
|
||||
c.hi = 0;
|
||||
c.lo = d1.lo + d2.lo;
|
||||
DPUSH(c);
|
||||
#else
|
||||
DPUSH(d1 + d2);
|
||||
#endif
|
||||
@@ -497,8 +515,16 @@ static void dminus(void)
|
||||
const dcell d2 = DPOP();
|
||||
const dcell d1 = DPOP();
|
||||
#ifdef NEED_FAKE_INT128_T
|
||||
fprintf(stderr, "dminus called\n");
|
||||
exit(-1);
|
||||
ducell c;
|
||||
|
||||
if (d1.hi != 0 || d2.hi != 0) {
|
||||
fprintf(stderr, "dminus called (0x%016llx %016llx + 0x%016llx %016llx)\n",
|
||||
d1.hi, d1.lo, d2.hi, d2.lo);
|
||||
exit(-1);
|
||||
}
|
||||
c.hi = 0;
|
||||
c.lo = d1.lo - d2.lo;
|
||||
DPUSH(c);
|
||||
#else
|
||||
DPUSH(d1 - d2);
|
||||
#endif
|
||||
@@ -514,8 +540,15 @@ static void mmult(void)
|
||||
const cell u2 = POP();
|
||||
const cell u1 = POP();
|
||||
#ifdef NEED_FAKE_INT128_T
|
||||
fprintf(stderr, "mmult called\n");
|
||||
exit(-1);
|
||||
ducell c;
|
||||
|
||||
if (0) { // XXX How to detect overflow?
|
||||
fprintf(stderr, "mmult called (%016llx * 0x%016llx)\n", u1, u2);
|
||||
exit(-1);
|
||||
}
|
||||
c.hi = 0;
|
||||
c.lo = u1 * u2;
|
||||
DPUSH(c);
|
||||
#else
|
||||
DPUSH((dcell) u1 * u2);
|
||||
#endif
|
||||
@@ -531,8 +564,15 @@ static void ummult(void)
|
||||
const ucell u2 = POP();
|
||||
const ucell u1 = POP();
|
||||
#ifdef NEED_FAKE_INT128_T
|
||||
fprintf(stderr, "ummult called\n");
|
||||
exit(-1);
|
||||
ducell c;
|
||||
|
||||
if (0) { // XXX How to detect overflow?
|
||||
fprintf(stderr, "ummult called (%016llx * 0x%016llx)\n", u1, u2);
|
||||
exit(-1);
|
||||
}
|
||||
c.hi = 0;
|
||||
c.lo = u1 * u2;
|
||||
DPUSH(c);
|
||||
#else
|
||||
DPUSH((ducell) u1 * u2);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user