All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Reif <reif@earthlink.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] implement hw/eccmemctl.c version differences
Date: Tue, 23 Dec 2008 09:45:33 -0500	[thread overview]
Message-ID: <4950F98D.3090702@earthlink.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 60 bytes --]

Implement Memory Enable Register behavior based on version.

[-- Attachment #2: eccmemctl.diff.txt --]
[-- Type: text/plain, Size: 4624 bytes --]

Index: hw/eccmemctl.c
===================================================================
--- hw/eccmemctl.c	(revision 6121)
+++ hw/eccmemctl.c	(working copy)
@@ -40,6 +40,10 @@
  * SMC (version 0, implementation 2) SS-10SX and SS-20
  */
 
+#define ECC_MCC        0x00000000
+#define ECC_EMC        0x10000000
+#define ECC_SMC        0x20000000
+
 /* Register indexes */
 #define ECC_MER        0               /* Memory Enable Register */
 #define ECC_MDR        1               /* Memory Delay Register */
@@ -63,12 +67,15 @@
 #define ECC_MER_MRR5   0x00000080      /* SIMM 5 */
 #define ECC_MER_MRR6   0x00000100      /* SIMM 6 */
 #define ECC_MER_MRR7   0x00000200      /* SIMM 7 */
-#define ECC_MER_REU    0x00000200      /* Memory Refresh Enable (600MP) */
+#define ECC_MER_REU    0x00000100      /* Memory Refresh Enable (600MP) */
 #define ECC_MER_MRR    0x000003fc      /* MRR mask */
-#define ECC_MEM_A      0x00000400      /* Memory controller addr map select */
+#define ECC_MER_A      0x00000400      /* Memory controller addr map select */
 #define ECC_MER_DCI    0x00000800      /* Disables Coherent Invalidate ACK */
 #define ECC_MER_VER    0x0f000000      /* Version */
 #define ECC_MER_IMPL   0xf0000000      /* Implementation */
+#define ECC_MER_MASK_0 0x00000103      /* Version 0 (MCC) mask */
+#define ECC_MER_MASK_1 0x00000bff      /* Version 1 (EMC) mask */
+#define ECC_MER_MASK_2 0x00000bff      /* Version 2 (SMC) mask */
 
 /* ECC memory delay register */
 #define ECC_MDR_RRI    0x000003ff      /* Refresh Request Interval */
@@ -122,6 +129,7 @@
     qemu_irq irq;
     uint32_t regs[ECC_NREGS];
     uint8_t diag[ECC_DIAG_SIZE];
+    uint32_t version;
 } ECCState;
 
 static void ecc_mem_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
@@ -130,8 +138,12 @@
 
     switch (addr >> 2) {
     case ECC_MER:
-        s->regs[ECC_MER] = (s->regs[ECC_MER] & (ECC_MER_VER | ECC_MER_IMPL)) |
-            (val & ~(ECC_MER_VER | ECC_MER_IMPL));
+        if (s->version == ECC_MCC)
+            s->regs[ECC_MER] = (val & ECC_MER_MASK_0);
+        else if (s->version == ECC_EMC)
+            s->regs[ECC_MER] = s->version | (val & ECC_MER_MASK_1);
+        else if (s->version == ECC_SMC)
+            s->regs[ECC_MER] = s->version | (val & ECC_MER_MASK_2);
         DPRINTF("Write memory enable %08x\n", val);
         break;
     case ECC_MDR:
@@ -140,6 +152,7 @@
         break;
     case ECC_MFSR:
         s->regs[ECC_MFSR] =  val;
+        qemu_irq_lower(s->irq);
         DPRINTF("Write memory fault status %08x\n", val);
         break;
     case ECC_VCR:
@@ -148,7 +161,7 @@
         break;
     case ECC_DR:
         s->regs[ECC_DR] =  val;
-        DPRINTF("Write diagnosiic %08x\n", val);
+        DPRINTF("Write diagnostic %08x\n", val);
         break;
     case ECC_ECR0:
         s->regs[ECC_ECR0] =  val;
@@ -254,7 +267,7 @@
     ECCState *s = opaque;
     int i;
 
-    if (version_id != 2)
+    if (version_id != 3)
         return -EINVAL;
 
     for (i = 0; i < ECC_NREGS; i++)
@@ -263,6 +276,8 @@
     for (i = 0; i < ECC_DIAG_SIZE; i++)
         qemu_get_8s(f, &s->diag[i]);
 
+    qemu_get_be32s(f, &s->version);
+
     return 0;
 }
 
@@ -276,14 +291,19 @@
 
     for (i = 0; i < ECC_DIAG_SIZE; i++)
         qemu_put_8s(f, &s->diag[i]);
+
+    qemu_put_be32s(f, &s->version);
 }
 
 static void ecc_reset(void *opaque)
 {
     ECCState *s = opaque;
 
-    s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL);
-    s->regs[ECC_MER] |= ECC_MER_MRR;
+    if (s->version == ECC_MCC)
+        s->regs[ECC_MER] &= ECC_MER_REU;
+    else
+        s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL | ECC_MER_MRR |
+                             ECC_MER_DCI);
     s->regs[ECC_MDR] = 0x20;
     s->regs[ECC_MFSR] = 0;
     s->regs[ECC_VCR] = 0;
@@ -303,18 +323,19 @@
     if (!s)
         return NULL;
 
+    s->version = version;
     s->regs[0] = version;
     s->irq = irq;
 
     ecc_io_memory = cpu_register_io_memory(0, ecc_mem_read, ecc_mem_write, s);
     cpu_register_physical_memory(base, ECC_SIZE, ecc_io_memory);
-    if (version == 0) { // SS-600MP only
+    if (version == ECC_MCC) { // SS-600MP only
         ecc_io_memory = cpu_register_io_memory(0, ecc_diag_mem_read,
                                                ecc_diag_mem_write, s);
         cpu_register_physical_memory(base + 0x1000, ECC_DIAG_SIZE,
                                      ecc_io_memory);
     }
-    register_savevm("ECC", base, 2, ecc_save, ecc_load, s);
+    register_savevm("ECC", base, 3, ecc_save, ecc_load, s);
     qemu_register_reset(ecc_reset, s);
     ecc_reset(s);
     return s;

             reply	other threads:[~2008-12-23 14:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-23 14:45 Robert Reif [this message]
2008-12-23 15:08 ` [Qemu-devel] [PATCH] implement hw/eccmemctl.c version differences Blue Swirl

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=4950F98D.3090702@earthlink.net \
    --to=reif@earthlink.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.