[RFC,7/7] target-alpha: Implement CPU reset

Submitted by Andreas Färber on Oct. 31, 2012, 3:04 a.m.

Details

Message ID 1351652644-18687-8-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber Oct. 31, 2012, 3:04 a.m.
The parent_reset class field was already prepared but unused so far.

No guarantees that this actually does The Right Thing, more fields
may need to be moved within CPUAlphaState or to AlphaCPU.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-alpha/cpu.c |   28 ++++++++++++++++++++++++++++
 1 Datei geändert, 28 Zeilen hinzugefügt(+)

Comments

Richard Henderson Oct. 31, 2012, 5:10 a.m.
On 2012-10-31 14:04, Andreas Färber wrote:
> +/* CPUClass::reset() */
> +static void alpha_cpu_reset(CPUState *s)
> +{
> +    AlphaCPU *cpu = ALPHA_CPU(s);
> +    AlphaCPUClass *acc = ALPHA_CPU_GET_CLASS(cpu);
> +    CPUAlphaState *env = &cpu->env;
> +
> +    if (qemu_loglevel_mask(CPU_LOG_RESET)) {
> +        qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
> +        log_cpu_state(env, 0);
> +    }
> +
> +    acc->parent_reset(s);
> +
> +    memset(env, 0, offsetof(CPUAlphaState, breakpoints));
> +    tlb_flush(env, 1);
> +}

Does this somehow reset the alarm_timer as well?  I'd sort of known about its
unfortunate position and resetting problems before, but I'd been ignoring it.

As for whether this works... I'd be surprised if the bios I wrote needs nothing
else for it to handle reset itself...


r~

Patch hide | download patch | download mbox

diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
index ab25c44..d798390 100644
--- a/target-alpha/cpu.c
+++ b/target-alpha/cpu.c
@@ -23,6 +23,24 @@ 
 #include "qemu-common.h"
 
 
+/* CPUClass::reset() */
+static void alpha_cpu_reset(CPUState *s)
+{
+    AlphaCPU *cpu = ALPHA_CPU(s);
+    AlphaCPUClass *acc = ALPHA_CPU_GET_CLASS(cpu);
+    CPUAlphaState *env = &cpu->env;
+
+    if (qemu_loglevel_mask(CPU_LOG_RESET)) {
+        qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
+        log_cpu_state(env, 0);
+    }
+
+    acc->parent_reset(s);
+
+    memset(env, 0, offsetof(CPUAlphaState, breakpoints));
+    tlb_flush(env, 1);
+}
+
 typedef struct AlphaCPUListState {
     fprintf_function cpu_fprintf;
     FILE *file;
@@ -221,6 +239,15 @@  static void alpha_cpu_initfn(Object *obj)
     env->fen = 1;
 }
 
+static void alpha_cpu_class_init(ObjectClass *oc, void *data)
+{
+    CPUClass *cc = CPU_CLASS(oc);
+    AlphaCPUClass *acc = ALPHA_CPU_CLASS(oc);
+
+    acc->parent_reset = cc->reset;
+    cc->reset = alpha_cpu_reset;
+}
+
 static void alpha_cpu_register(const AlphaCPUInfo *info)
 {
     TypeInfo type_info = {
@@ -239,6 +266,7 @@  static const TypeInfo alpha_cpu_type_info = {
     .instance_init = alpha_cpu_initfn,
     .abstract = true,
     .class_size = sizeof(AlphaCPUClass),
+    .class_init = alpha_cpu_class_init,
 };
 
 static void alpha_cpu_register_types(void)