]> Git Repo - qemu.git/blobdiff - hw/armv7m_nvic.c
linux-user: mremap(): handle MREMAP_FIXED and MREMAP_MAYMOVE correctly
[qemu.git] / hw / armv7m_nvic.c
index 99ea9873a7c29295e2b997d99a37e2854b00a6cc..86d0cf8f9ec3ab366e401d56668b93fce6ce7d16 100644 (file)
@@ -14,7 +14,9 @@
 #include "qemu-timer.h"
 #include "arm-misc.h"
 
-#define GIC_NIRQ 64
+/* 32 internal lines (16 used for system exceptions) plus 64 external
+   interrupt lines.  */
+#define GIC_NIRQ 96
 #define NCPU 1
 #define NVIC 1
 
@@ -48,14 +50,13 @@ typedef struct {
 #define SYSTICK_CLKSOURCE (1 << 2)
 #define SYSTICK_COUNTFLAG (1 << 16)
 
-/* Conversion factor from qemu timer to SysTick frequencies.
-   QEMU uses a base of 1GHz, so these give 20MHz and 1MHz for core and
-   reference frequencies.  */
+int system_clock_scale;
 
+/* Conversion factor from qemu timer to SysTick frequencies.  */
 static inline int64_t systick_scale(nvic_state *s)
 {
     if (s->systick.control & SYSTICK_CLKSOURCE)
-        return 50;
+        return system_clock_scale;
     else
         return 1000;
 }
@@ -365,6 +366,31 @@ static void nvic_writel(void *opaque, uint32_t offset, uint32_t value)
     }
 }
 
+static void nvic_save(QEMUFile *f, void *opaque)
+{
+    nvic_state *s = (nvic_state *)opaque;
+
+    qemu_put_be32(f, s->systick.control);
+    qemu_put_be32(f, s->systick.reload);
+    qemu_put_be64(f, s->systick.tick);
+    qemu_put_timer(f, s->systick.timer);
+}
+
+static int nvic_load(QEMUFile *f, void *opaque, int version_id)
+{
+    nvic_state *s = (nvic_state *)opaque;
+
+    if (version_id != 1)
+        return -EINVAL;
+
+    s->systick.control = qemu_get_be32(f);
+    s->systick.reload = qemu_get_be32(f);
+    s->systick.tick = qemu_get_be64(f);
+    qemu_get_timer(f, s->systick.timer);
+
+    return 0;
+}
+
 qemu_irq *armv7m_nvic_init(CPUState *env)
 {
     nvic_state *s;
@@ -378,5 +404,6 @@ qemu_irq *armv7m_nvic_init(CPUState *env)
     if (env->v7m.nvic)
         cpu_abort(env, "CPU can only have one NVIC\n");
     env->v7m.nvic = s;
+    register_savevm("armv7m_nvic", -1, 1, nvic_save, nvic_load, s);
     return s->gic->in;
 }
This page took 0.025621 seconds and 4 git commands to generate.