Patchwork [1/2] memory: Fix old portio word accesses

login
register
mail settings
Submitter Jan Kiszka
Date Sept. 18, 2011, 12:44 p.m.
Message ID <4E75E7A4.50702@web.de>
Download mbox | patch
Permalink /patch/115234/
State New
Headers show

Comments

Jan Kiszka - Sept. 18, 2011, 12:44 p.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

As we register old portio regions via ioport_register, we are also
responsible for providing the word access wrapper.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 memory.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
Richard Henderson - Sept. 18, 2011, 2:44 p.m.
On 09/18/2011 05:44 AM, Jan Kiszka wrote:
> +            *data = mrp->read(mr->opaque, offset + mr->offset) |
> +                    mrp->read(mr->opaque, offset + mr->offset + 1);

Missing shift.

Also, a comment about the fact that the legacy interface doesn't
handle size 4 would also be welcome.


r~

Patch

diff --git a/memory.c b/memory.c
index b3ee232..f712d95 100644
--- a/memory.c
+++ b/memory.c
@@ -397,6 +397,11 @@  static void memory_region_iorange_read(IORange *iorange,
         *data = ((uint64_t)1 << (width * 8)) - 1;
         if (mrp) {
             *data = mrp->read(mr->opaque, offset + mr->offset);
+        } else if (width == 2) {
+            mrp = find_portio(mr, offset, 1, false);
+            assert(mrp);
+            *data = mrp->read(mr->opaque, offset + mr->offset) |
+                    mrp->read(mr->opaque, offset + mr->offset + 1);
         }
         return;
     }
@@ -419,6 +424,11 @@  static void memory_region_iorange_write(IORange *iorange,
 
         if (mrp) {
             mrp->write(mr->opaque, offset + mr->offset, data);
+        } else if (width == 2) {
+            mrp = find_portio(mr, offset, 1, false);
+            assert(mrp);
+            mrp->write(mr->opaque, offset + mr->offset, data & 0xff);
+            mrp->write(mr->opaque, offset + mr->offset + 1, data >> 8);
         }
         return;
     }