From: "J. Mayer" <l_indien@magic.fr>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [ADD] PPC processor emulation
Date: 18 Nov 2003 08:49:29 +0100 [thread overview]
Message-ID: <1069141768.13659.2225.camel@rapid> (raw)
In-Reply-To: <1069140512.14646.2174.camel@rapid>
main.c.diff
Add PPC target main loop
diff -urNbB -x CVS qemu-current/main.c qemu/main.c
--- qemu-current/main.c Tue Nov 18 06:51:08 2003
+++ qemu/main.c Tue Nov 11 00:58:06 2003
@@ -324,6 +324,128 @@
#endif
+#ifdef TARGET_PPC
+#include "cpu.h"
+
+void cpu_loop(CPUPPCState *env)
+{
+ int trapnr;
+ target_siginfo_t info;
+
+ for(;;) {
+ trapnr = cpu_ppc_exec(env);
+ switch(trapnr) {
+ case EXCP_NONE:
+ case EXCP_INTERRUPT:
+ case EXCP_MTMSR: /* mtmsr instruction: */
+ case EXCP_BRANCH: /* branch instruction */
+ /* Single step mode */
+ break;
+#if 0
+ case EXCP_RESET: /* System reset */
+ fprintf(stderr, "RESET asked... Stop emulation\n");
+ cpu_ppc_dump_state(env, stderr, 0);
+ abort();
+#endif
+ case EXCP_MACHINE_CHECK: /* Machine check exception */
+ fprintf(stderr, "Machine check exeption... "
+ "See you in kernel code !\n");
+ cpu_ppc_dump_state(env, stderr, 0);
+ abort();
+ case EXCP_DSI: /* Impossible memory access */
+ fprintf(stderr, "Invalid memory access\n");
+ info.si_signo = SIGSEGV;
+ info.si_errno = 0;
+ info.si_code = TARGET_ILL_ILLOPN;
+ info._sifields._sigfault._addr = env->nip;
+ queue_signal(info.si_signo, &info);
+ break;
+ case EXCP_ISI: /* Impossible instruction fetch */
+ fprintf(stderr, "Invalid instruction fetch\n");
+ info.si_signo = SIGBUS;
+ info.si_errno = 0;
+ info.si_code = TARGET_ILL_ILLOPN;
+ info._sifields._sigfault._addr = env->nip;
+ queue_signal(info.si_signo, &info);
+ break;
+ case EXCP_EXTERNAL: /* External interruption */
+ fprintf(stderr, "External access exeption\n");
+ cpu_ppc_dump_state(env, stderr, 0);
+ abort();
+ case EXCP_ALIGN: /* Alignment exception */
+ fprintf(stderr, "Alignment exception\n");
+ cpu_ppc_dump_state(env, stderr, 0);
+ abort();
+ case EXCP_PROGRAM: /* Program exception */
+ fprintf(stderr, "Program exception\n");
+ cpu_ppc_dump_state(env, stderr, 0);
+ abort();
+ break;
+ /* Trap */
+ case EXCP_TRAP: /* Trap */
+ case EXCP_TRACE: /* Trace exception (optional) */
+ info.si_signo = SIGTRAP;
+ info.si_errno = 0;
+ info.si_code = TARGET_ILL_ILLOPN;
+ info._sifields._sigfault._addr = env->nip;
+ queue_signal(info.si_signo, &info);
+ break;
+ /* Invalid instruction */
+ case EXCP_INVAL:
+ info.si_signo = SIGILL;
+ info.si_errno = 0;
+ info.si_code = TARGET_ILL_ILLOPN;
+ info._sifields._sigfault._addr = env->nip;
+ queue_signal(info.si_signo, &info);
+ break;
+ /* Privileged instruction */
+ case EXCP_PRIV: /* Privileged instruction */
+ info.si_signo = SIGILL;
+ info.si_errno = 0;
+ info.si_code = TARGET_ILL_ILLOPN;
+ info._sifields._sigfault._addr = env->nip;
+ queue_signal(info.si_signo, &info);
+ break;
+ case EXCP_NO_FP: /* No floating point */
+ case EXCP_DECR: /* Decrementer exception */
+ case EXCP_RESA: /* Implementation specific */
+ case EXCP_RESB: /* Implementation specific */
+ case EXCP_FP_ASSIST: /* Floating-point assist (optional) */
+ fprintf(stderr, "Misc expt...\n");
+ cpu_ppc_dump_state(env, stderr, 0);
+ abort();
+
+ case EXCP_SYSCALL:
+ {
+ uint32_t ret;
+ /* system call */
+ /* WARNING:
+ * PPC ABI uses overflow flag in cr0 to signal an error
+ * in syscalls.
+ */
+ env->crf[0] &= ~0x1;
+ ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4],
+ env->gpr[5], env->gpr[6], env->gpr[7],
+ env->gpr[8]);
+ if (ret > (uint32_t)(-515)) {
+ env->crf[0] |= 0x1;
+ ret = -ret;
+ }
+ env->gpr[3] = ret;
+ break;
+ }
+ default:
+// error:
+ fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
+ trapnr);
+ cpu_ppc_dump_state(env, stderr, 0);
+ abort();
+ }
+ process_pending_signals(env);
+ }
+}
+#endif
+
void usage(void)
{
printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003 Fabrice Bellard\n"
@@ -517,6 +639,16 @@
#elif defined(TARGET_SPARC)
env->pc = regs->u_regs[0];
env->regwptr[6] = regs->u_regs[1]-0x40;
+#elif defined(TARGET_PPC)
+ {
+ int i;
+ for (i = 0; i < 32; i++)
+ env->msr[i] = (regs->msr >> i) & 1;
+ env->nip = regs->nip;
+ for(i = 0; i < 32; i++) {
+ env->gpr[i] = regs->gpr[i];
+ }
+ }
#else
#error unsupported target CPU
#endif
next prev parent reply other threads:[~2003-11-18 8:47 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-17 9:51 [Qemu-devel] new knoppix SegFault Jens Arm
2003-11-18 7:15 ` [Qemu-devel] [PATCH] Fixes for qemu J. Mayer
2003-11-18 7:30 ` J. Mayer
2003-11-18 7:31 ` Chad Page
2003-11-18 7:32 ` J. Mayer
2003-11-18 7:33 ` J. Mayer
2003-11-18 7:34 ` J. Mayer
2003-11-18 8:24 ` J. Mayer
2003-11-18 7:22 ` [Qemu-devel] [ADD] floppy disk emulation J. Mayer
2003-11-18 7:37 ` J. Mayer
2003-11-18 7:38 ` J. Mayer
2003-11-18 7:39 ` J. Mayer
2003-11-18 7:39 ` J. Mayer
2003-11-18 8:24 ` J. Mayer
2003-11-18 7:28 ` [Qemu-devel] [ADD] PPC processor emulation J. Mayer
2003-11-18 7:43 ` J. Mayer
2003-11-18 7:43 ` J. Mayer
2003-11-18 7:44 ` J. Mayer
2003-11-18 7:45 ` J. Mayer
2003-11-18 7:45 ` J. Mayer
2003-11-18 7:46 ` J. Mayer
2003-11-18 7:46 ` J. Mayer
2003-11-18 7:48 ` J. Mayer
2003-11-18 7:48 ` J. Mayer
2003-11-18 7:49 ` J. Mayer [this message]
2003-11-18 7:50 ` J. Mayer
2003-11-18 7:50 ` J. Mayer
2003-11-18 7:51 ` J. Mayer
2003-11-18 7:53 ` J. Mayer
2003-11-18 7:54 ` J. Mayer
2003-11-18 7:55 ` J. Mayer
2003-11-18 7:56 ` J. Mayer
2003-11-18 7:56 ` J. Mayer
2003-11-18 7:57 ` J. Mayer
2003-11-18 7:58 ` J. Mayer
2003-11-18 7:59 ` J. Mayer
2003-11-18 7:59 ` J. Mayer
2003-11-18 8:00 ` J. Mayer
2003-11-18 8:02 ` [Qemu-devel] [ADD] tests for PPC target J. Mayer
2003-11-18 8:06 ` J. Mayer
2003-11-18 8:08 ` J. Mayer
2003-11-18 8:08 ` J. Mayer
2003-11-18 8:09 ` J. Mayer
2003-11-18 8:10 ` J. Mayer
2003-11-18 8:25 ` J. Mayer
2003-11-18 8:24 ` [Qemu-devel] [ADD] PPC processor emulation J. Mayer
2003-11-18 9:37 ` Gwenole Beauchesne
2003-11-18 10:37 ` J. Mayer
2003-11-18 11:39 ` Raymond W. Lucke IV
2003-11-18 12:13 ` J. Mayer
2003-11-18 20:24 ` Raymond W. Lucke IV
2003-11-18 20:44 ` Jocelyn Mayer
2003-11-18 21:48 ` Chad Page
2003-11-18 22:50 ` J. Mayer
2003-11-19 1:11 ` Benjamin Herrenschmidt
2003-11-19 15:35 ` Jocelyn Mayer
2003-11-18 12:24 ` Gwenole Beauchesne
2003-11-18 12:57 ` Johan Rydberg
2003-11-18 14:52 ` Gwenole Beauchesne
2003-11-18 14:59 ` Jocelyn Mayer
2003-11-18 7:29 ` [Qemu-devel] [PATCH] Term prompt for qemu J. Mayer
2003-11-18 8:11 ` J. Mayer
2003-11-18 8:11 ` J. Mayer
2003-11-18 8:13 ` J. Mayer
2003-11-18 8:25 ` J. Mayer
-- strict thread matches above, loose matches on Subject: below --
2003-11-18 22:28 [Qemu-devel] [ADD] PPC processor emulation J. Mayer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1069141768.13659.2225.camel@rapid \
--to=l_indien@magic.fr \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).