From 78eaf836bebce72450b4f2916574dcbfef9c65eb Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 17 Jun 2018 10:22:20 +0200 Subject: [PATCH] Turns out I was returning values from syscalls in the wrong register; fixed. More tests pass. --- plat/linuxppc/emu/emu.c | 6 +++--- plat/linuxppc/emu/main.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plat/linuxppc/emu/emu.c b/plat/linuxppc/emu/emu.c index 3653d8c2e..ae1fb929f 100644 --- a/plat/linuxppc/emu/emu.c +++ b/plat/linuxppc/emu/emu.c @@ -303,7 +303,7 @@ void dump_state(FILE* stream) int i; 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); for (i=0; i<32; i++) { @@ -311,11 +311,11 @@ void dump_state(FILE* stream) fprintf(stream, "\n"); 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 * 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) diff --git a/plat/linuxppc/emu/main.c b/plat/linuxppc/emu/main.c index 79e2634d1..0c2aaea5f 100755 --- a/plat/linuxppc/emu/main.c +++ b/plat/linuxppc/emu/main.c @@ -136,8 +136,8 @@ void system_call(uint8_t trapno) uint32_t len = cpu.gpr[5]; void* ptr = ram + transform_address(address); transform_address(address+len); /* bounds check */ - cpu.gpr[4] = write(fd, ptr, len); - if (cpu.gpr[4] == -1) + cpu.gpr[3] = write(fd, ptr, len); + if (cpu.gpr[3] == -1) goto error; break; } @@ -146,13 +146,13 @@ void system_call(uint8_t trapno) { uint32_t newpos = cpu.gpr[3]; if (newpos == 0) - cpu.gpr[4] = brkpos; + cpu.gpr[3] = brkpos; else if ((newpos < brkbase) || (newpos >= BRK_TOP)) - cpu.gpr[4] = -ENOMEM; + cpu.gpr[3] = -ENOMEM; else { brkpos = newpos; - cpu.gpr[4] = 0; + cpu.gpr[3] = 0; } break; } @@ -163,7 +163,7 @@ void system_call(uint8_t trapno) case 67: /* sigaction */ case 78: /* gettimeofday */ case 126: /* sigprocmask */ - cpu.gpr[4] = 0; + cpu.gpr[3] = 0; break; error: