Turns out I was returning values from syscalls in the wrong register; fixed.
More tests pass.
This commit is contained in:
parent
ab660a44e9
commit
78eaf836be
|
@ -303,7 +303,7 @@ void dump_state(FILE* stream)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fprintf(stream, "\n");
|
fprintf(stream, "\n");
|
||||||
fprintf(stream, "pc=0x%08x lr=0x%08x ctr=0x%08x xer=0x%08x cr=0x%08x\n",
|
fprintf(stream, "pc=0x%08x lr=0x%08x ctr=0x%08x xer=0x%08x cr=0x%08x",
|
||||||
cpu.cia, cpu.lr, cpu.ctr, cpu.xer, cpu.cr);
|
cpu.cia, cpu.lr, cpu.ctr, cpu.xer, cpu.cr);
|
||||||
for (i=0; i<32; i++)
|
for (i=0; i<32; i++)
|
||||||
{
|
{
|
||||||
|
@ -311,11 +311,11 @@ void dump_state(FILE* stream)
|
||||||
fprintf(stream, "\n");
|
fprintf(stream, "\n");
|
||||||
fprintf(stream, "gpr%02d=0x%08x ", i, cpu.gpr[i]);
|
fprintf(stream, "gpr%02d=0x%08x ", i, cpu.gpr[i]);
|
||||||
}
|
}
|
||||||
fprintf(stream, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
/* This might fail and cause a reentrant trap if cia is invalid, so
|
/* This might fail and cause a reentrant trap if cia is invalid, so
|
||||||
* do it last. */
|
* do it last. */
|
||||||
fprintf(stream, "insn=0x%08x", read_long(cpu.cia));
|
fprintf(stream, "insn=0x%08x\n", read_long(cpu.cia));
|
||||||
}
|
}
|
||||||
|
|
||||||
void single_step(void)
|
void single_step(void)
|
||||||
|
|
|
@ -136,8 +136,8 @@ void system_call(uint8_t trapno)
|
||||||
uint32_t len = cpu.gpr[5];
|
uint32_t len = cpu.gpr[5];
|
||||||
void* ptr = ram + transform_address(address);
|
void* ptr = ram + transform_address(address);
|
||||||
transform_address(address+len); /* bounds check */
|
transform_address(address+len); /* bounds check */
|
||||||
cpu.gpr[4] = write(fd, ptr, len);
|
cpu.gpr[3] = write(fd, ptr, len);
|
||||||
if (cpu.gpr[4] == -1)
|
if (cpu.gpr[3] == -1)
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -146,13 +146,13 @@ void system_call(uint8_t trapno)
|
||||||
{
|
{
|
||||||
uint32_t newpos = cpu.gpr[3];
|
uint32_t newpos = cpu.gpr[3];
|
||||||
if (newpos == 0)
|
if (newpos == 0)
|
||||||
cpu.gpr[4] = brkpos;
|
cpu.gpr[3] = brkpos;
|
||||||
else if ((newpos < brkbase) || (newpos >= BRK_TOP))
|
else if ((newpos < brkbase) || (newpos >= BRK_TOP))
|
||||||
cpu.gpr[4] = -ENOMEM;
|
cpu.gpr[3] = -ENOMEM;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
brkpos = newpos;
|
brkpos = newpos;
|
||||||
cpu.gpr[4] = 0;
|
cpu.gpr[3] = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ void system_call(uint8_t trapno)
|
||||||
case 67: /* sigaction */
|
case 67: /* sigaction */
|
||||||
case 78: /* gettimeofday */
|
case 78: /* gettimeofday */
|
||||||
case 126: /* sigprocmask */
|
case 126: /* sigprocmask */
|
||||||
cpu.gpr[4] = 0;
|
cpu.gpr[3] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
Loading…
Reference in a new issue