[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] target-moxie: Add gdbstub support
From: |
Anthony Green |
Subject: |
[Qemu-devel] [PATCH] target-moxie: Add gdbstub support |
Date: |
Sat, 14 Dec 2013 22:35:00 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
This patch adds gdbstub support for the moxie target port.
Signed-off-by: Anthony Green <address@hidden>
---
target-moxie/Makefile.objs | 1 +
target-moxie/cpu.c | 3 +++
target-moxie/cpu.h | 2 ++
target-moxie/gdbstub.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 62 insertions(+)
create mode 100644 target-moxie/gdbstub.c
diff --git a/target-moxie/Makefile.objs b/target-moxie/Makefile.objs
index 6381d4d..9a690fb 100644
--- a/target-moxie/Makefile.objs
+++ b/target-moxie/Makefile.objs
@@ -1,2 +1,3 @@
obj-y += translate.o helper.o machine.o cpu.o machine.o
+obj-y += gdbstub.o
obj-$(CONFIG_SOFTMMU) += mmu.o
diff --git a/target-moxie/cpu.c b/target-moxie/cpu.c
index 484ecc2..e3b7995 100644
--- a/target-moxie/cpu.c
+++ b/target-moxie/cpu.c
@@ -102,10 +102,13 @@ static void moxie_cpu_class_init(ObjectClass *oc, void
*data)
cc->do_interrupt = moxie_cpu_do_interrupt;
cc->dump_state = moxie_cpu_dump_state;
cc->set_pc = moxie_cpu_set_pc;
+ cc->gdb_read_register = moxie_cpu_gdb_read_register;
+ cc->gdb_write_register = moxie_cpu_gdb_write_register;
#ifndef CONFIG_USER_ONLY
cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug;
cc->vmsd = &vmstate_moxie_cpu;
#endif
+ cc->gdb_num_core_regs = 16 + 1;
}
static void moxielite_initfn(Object *obj)
diff --git a/target-moxie/cpu.h b/target-moxie/cpu.h
index 5ce14b5..140cbe3 100644
--- a/target-moxie/cpu.h
+++ b/target-moxie/cpu.h
@@ -119,6 +119,8 @@ void moxie_cpu_do_interrupt(CPUState *cs);
void moxie_cpu_dump_state(CPUState *cpu, FILE *f,
fprintf_function cpu_fprintf, int flags);
hwaddr moxie_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+int moxie_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
+int moxie_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
void moxie_translate_init(void);
int cpu_moxie_signal_handler(int host_signum, void *pinfo,
void *puc);
diff --git a/target-moxie/gdbstub.c b/target-moxie/gdbstub.c
new file mode 100644
index 0000000..956d8a4
--- /dev/null
+++ b/target-moxie/gdbstub.c
@@ -0,0 +1,56 @@
+/*
+ * Moxie GDB server stub
+ *
+ * Copyright (c) 2013 Anthony Green
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+#include "config.h"
+#include "qemu-common.h"
+#include "exec/gdbstub.h"
+
+#define NUM_CORE_REGS (16 + 1)
+
+int moxie_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
+{
+ MoxieCPU *cpu = MOXIE_CPU(cs);
+ CPUMoxieState *env = &cpu->env;
+
+ if (n < 16) {
+ return gdb_get_reg32(mem_buf, env->gregs[n]);
+ } else if (n == 16) {
+ return gdb_get_reg32(mem_buf, env->pc);
+ }
+ return 0;
+}
+
+int moxie_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
+{
+ MoxieCPU *cpu = MOXIE_CPU(cs);
+ CPUMoxieState *env = &cpu->env;
+ uint32_t tmp;
+
+ if (n > NUM_CORE_REGS) {
+ return 0;
+ }
+
+ tmp = ldl_p(mem_buf);
+
+ if (n < 16) {
+ env->gregs[n] = tmp;
+ } else {
+ env->pc = tmp;
+ }
+ return 4;
+}
--
1.8.3.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH] target-moxie: Add gdbstub support,
Anthony Green <=