cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From bf17f7d5651bdf24cc15268ff20ecbccf74ea138 Mon Sep 17 00:00:00 2001
0a122b
From: Laszlo Ersek <lersek@redhat.com>
0a122b
Date: Sat, 11 Jan 2014 17:59:54 +0100
0a122b
Subject: [PATCH 04/22] memory: Rename readable flag to romd_mode
0a122b
0a122b
RH-Author: Laszlo Ersek <lersek@redhat.com>
0a122b
Message-id: <1389463208-6278-5-git-send-email-lersek@redhat.com>
0a122b
Patchwork-id: 56617
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH 04/18] memory: Rename readable flag to romd_mode
0a122b
Bugzilla: 1032346
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Amos Kong <akong@redhat.com>
0a122b
RH-Acked-by: Andrew Jones <drjones@redhat.com>
0a122b
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
0a122b
0a122b
From: Jan Kiszka <jan.kiszka@siemens.com>
0a122b
0a122b
"Readable" is a very unfortunate name for this flag because even a
0a122b
rom_device region will always be readable from the guest POV. What
0a122b
differs is the mapping, just like the comments had to explain already.
0a122b
Also, readable could currently be understood as being a generic region
0a122b
flag, but it only applies to rom_device regions.
0a122b
0a122b
So rename the flag and the function to modify it after the original term
0a122b
"ROMD" which could also be interpreted as "ROM direct", i.e. ROM mode
0a122b
with direct access. In any case, the scope of the flag is clearer now.
0a122b
0a122b
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
0a122b
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
0a122b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
(cherry picked from commit 5f9a5ea1c0a8391033e7d33abd335dd804a1001a)
0a122b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
0a122b
---
0a122b
 include/exec/memory.h   | 22 +++++++++++-----------
0a122b
 hw/block/pflash_cfi01.c |  6 +++---
0a122b
 hw/block/pflash_cfi02.c |  2 +-
0a122b
 memory.c                | 30 +++++++++++++++---------------
0a122b
 4 files changed, 30 insertions(+), 30 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 hw/block/pflash_cfi01.c |    6 +++---
0a122b
 hw/block/pflash_cfi02.c |    2 +-
0a122b
 include/exec/memory.h   |   22 +++++++++++-----------
0a122b
 memory.c                |   30 +++++++++++++++---------------
0a122b
 4 files changed, 30 insertions(+), 30 deletions(-)
0a122b
0a122b
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
0a122b
index 0bbb1a3..18eb0bc 100644
0a122b
--- a/hw/block/pflash_cfi01.c
0a122b
+++ b/hw/block/pflash_cfi01.c
0a122b
@@ -105,7 +105,7 @@ static void pflash_timer (void *opaque)
0a122b
     DPRINTF("%s: command %02x done\n", __func__, pfl->cmd);
0a122b
     /* Reset flash */
0a122b
     pfl->status ^= 0x80;
0a122b
-    memory_region_rom_device_set_readable(&pfl->mem, true);
0a122b
+    memory_region_rom_device_set_romd(&pfl->mem, true);
0a122b
     pfl->wcycle = 0;
0a122b
     pfl->cmd = 0;
0a122b
 }
0a122b
@@ -281,7 +281,7 @@ static void pflash_write(pflash_t *pfl, hwaddr offset,
0a122b
 
0a122b
     if (!pfl->wcycle) {
0a122b
         /* Set the device in I/O access mode */
0a122b
-        memory_region_rom_device_set_readable(&pfl->mem, false);
0a122b
+        memory_region_rom_device_set_romd(&pfl->mem, false);
0a122b
     }
0a122b
 
0a122b
     switch (pfl->wcycle) {
0a122b
@@ -458,7 +458,7 @@ static void pflash_write(pflash_t *pfl, hwaddr offset,
0a122b
                   "\n", __func__, offset, pfl->wcycle, pfl->cmd, value);
0a122b
 
0a122b
  reset_flash:
0a122b
-    memory_region_rom_device_set_readable(&pfl->mem, true);
0a122b
+    memory_region_rom_device_set_romd(&pfl->mem, true);
0a122b
 
0a122b
     pfl->wcycle = 0;
0a122b
     pfl->cmd = 0;
0a122b
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
0a122b
index 9a7fa70..5f25246 100644
0a122b
--- a/hw/block/pflash_cfi02.c
0a122b
+++ b/hw/block/pflash_cfi02.c
0a122b
@@ -111,7 +111,7 @@ static void pflash_setup_mappings(pflash_t *pfl)
0a122b
 
0a122b
 static void pflash_register_memory(pflash_t *pfl, int rom_mode)
0a122b
 {
0a122b
-    memory_region_rom_device_set_readable(&pfl->orig_mem, rom_mode);
0a122b
+    memory_region_rom_device_set_romd(&pfl->orig_mem, rom_mode);
0a122b
     pfl->rom_mode = rom_mode;
0a122b
 }
0a122b
 
0a122b
diff --git a/include/exec/memory.h b/include/exec/memory.h
0a122b
index bd6d31a..3bbe378 100644
0a122b
--- a/include/exec/memory.h
0a122b
+++ b/include/exec/memory.h
0a122b
@@ -124,7 +124,7 @@ struct MemoryRegion {
0a122b
     ram_addr_t ram_addr;
0a122b
     bool subpage;
0a122b
     bool terminates;
0a122b
-    bool readable;
0a122b
+    bool romd_mode;
0a122b
     bool ram;
0a122b
     bool readonly; /* For RAM regions */
0a122b
     bool enabled;
0a122b
@@ -353,16 +353,16 @@ uint64_t memory_region_size(MemoryRegion *mr);
0a122b
 bool memory_region_is_ram(MemoryRegion *mr);
0a122b
 
0a122b
 /**
0a122b
- * memory_region_is_romd: check whether a memory region is ROMD
0a122b
+ * memory_region_is_romd: check whether a memory region is in ROMD mode
0a122b
  *
0a122b
- * Returns %true is a memory region is ROMD and currently set to allow
0a122b
+ * Returns %true if a memory region is a ROM device and currently set to allow
0a122b
  * direct reads.
0a122b
  *
0a122b
  * @mr: the memory region being queried
0a122b
  */
0a122b
 static inline bool memory_region_is_romd(MemoryRegion *mr)
0a122b
 {
0a122b
-    return mr->rom_device && mr->readable;
0a122b
+    return mr->rom_device && mr->romd_mode;
0a122b
 }
0a122b
 
0a122b
 /**
0a122b
@@ -500,18 +500,18 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,
0a122b
 void memory_region_set_readonly(MemoryRegion *mr, bool readonly);
0a122b
 
0a122b
 /**
0a122b
- * memory_region_rom_device_set_readable: enable/disable ROM readability
0a122b
+ * memory_region_rom_device_set_romd: enable/disable ROMD mode
0a122b
  *
0a122b
  * Allows a ROM device (initialized with memory_region_init_rom_device() to
0a122b
- * to be marked as readable (default) or not readable.  When it is readable,
0a122b
- * the device is mapped to guest memory.  When not readable, reads are
0a122b
- * forwarded to the #MemoryRegion.read function.
0a122b
+ * set to ROMD mode (default) or MMIO mode.  When it is in ROMD mode, the
0a122b
+ * device is mapped to guest memory and satisfies read access directly.
0a122b
+ * When in MMIO mode, reads are forwarded to the #MemoryRegion.read function.
0a122b
+ * Writes are always handled by the #MemoryRegion.write function.
0a122b
  *
0a122b
  * @mr: the memory region to be updated
0a122b
- * @readable: whether reads are satisified directly (%true) or via callbacks
0a122b
- *            (%false)
0a122b
+ * @romd_mode: %true to put the region into ROMD mode
0a122b
  */
0a122b
-void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable);
0a122b
+void memory_region_rom_device_set_romd(MemoryRegion *mr, bool romd_mode);
0a122b
 
0a122b
 /**
0a122b
  * memory_region_set_coalescing: Enable memory coalescing for the region.
0a122b
diff --git a/memory.c b/memory.c
0a122b
index 685912d..edaf6fd 100644
0a122b
--- a/memory.c
0a122b
+++ b/memory.c
0a122b
@@ -214,7 +214,7 @@ struct FlatRange {
0a122b
     hwaddr offset_in_region;
0a122b
     AddrRange addr;
0a122b
     uint8_t dirty_log_mask;
0a122b
-    bool readable;
0a122b
+    bool romd_mode;
0a122b
     bool readonly;
0a122b
 };
0a122b
 
0a122b
@@ -237,7 +237,7 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b)
0a122b
     return a->mr == b->mr
0a122b
         && addrrange_equal(a->addr, b->addr)
0a122b
         && a->offset_in_region == b->offset_in_region
0a122b
-        && a->readable == b->readable
0a122b
+        && a->romd_mode == b->romd_mode
0a122b
         && a->readonly == b->readonly;
0a122b
 }
0a122b
 
0a122b
@@ -277,7 +277,7 @@ static bool can_merge(FlatRange *r1, FlatRange *r2)
0a122b
                                 r1->addr.size),
0a122b
                      int128_make64(r2->offset_in_region))
0a122b
         && r1->dirty_log_mask == r2->dirty_log_mask
0a122b
-        && r1->readable == r2->readable
0a122b
+        && r1->romd_mode == r2->romd_mode
0a122b
         && r1->readonly == r2->readonly;
0a122b
 }
0a122b
 
0a122b
@@ -533,7 +533,7 @@ static void render_memory_region(FlatView *view,
0a122b
             fr.offset_in_region = offset_in_region;
0a122b
             fr.addr = addrrange_make(base, now);
0a122b
             fr.dirty_log_mask = mr->dirty_log_mask;
0a122b
-            fr.readable = mr->readable;
0a122b
+            fr.romd_mode = mr->romd_mode;
0a122b
             fr.readonly = readonly;
0a122b
             flatview_insert(view, i, &fr);
0a122b
             ++i;
0a122b
@@ -553,7 +553,7 @@ static void render_memory_region(FlatView *view,
0a122b
         fr.offset_in_region = offset_in_region;
0a122b
         fr.addr = addrrange_make(base, remain);
0a122b
         fr.dirty_log_mask = mr->dirty_log_mask;
0a122b
-        fr.readable = mr->readable;
0a122b
+        fr.romd_mode = mr->romd_mode;
0a122b
         fr.readonly = readonly;
0a122b
         flatview_insert(view, i, &fr);
0a122b
     }
0a122b
@@ -802,7 +802,7 @@ void memory_region_init(MemoryRegion *mr,
0a122b
     mr->enabled = true;
0a122b
     mr->terminates = false;
0a122b
     mr->ram = false;
0a122b
-    mr->readable = true;
0a122b
+    mr->romd_mode = true;
0a122b
     mr->readonly = false;
0a122b
     mr->rom_device = false;
0a122b
     mr->destructor = memory_region_destructor_none;
0a122b
@@ -1118,11 +1118,11 @@ void memory_region_set_readonly(MemoryRegion *mr, bool readonly)
0a122b
     }
0a122b
 }
0a122b
 
0a122b
-void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable)
0a122b
+void memory_region_rom_device_set_romd(MemoryRegion *mr, bool romd_mode)
0a122b
 {
0a122b
-    if (mr->readable != readable) {
0a122b
+    if (mr->romd_mode != romd_mode) {
0a122b
         memory_region_transaction_begin();
0a122b
-        mr->readable = readable;
0a122b
+        mr->romd_mode = romd_mode;
0a122b
         memory_region_update_pending |= mr->enabled;
0a122b
         memory_region_transaction_commit();
0a122b
     }
0a122b
@@ -1644,9 +1644,9 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
0a122b
                    base + mr->addr
0a122b
                    + (hwaddr)int128_get64(mr->size) - 1,
0a122b
                    mr->priority,
0a122b
-                   mr->readable ? 'R' : '-',
0a122b
-                   !mr->readonly && !(mr->rom_device && mr->readable) ? 'W'
0a122b
-                                                                      : '-',
0a122b
+                   mr->romd_mode ? 'R' : '-',
0a122b
+                   !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'
0a122b
+                                                                       : '-',
0a122b
                    mr->name,
0a122b
                    mr->alias->name,
0a122b
                    mr->alias_offset,
0a122b
@@ -1659,9 +1659,9 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
0a122b
                    base + mr->addr
0a122b
                    + (hwaddr)int128_get64(mr->size) - 1,
0a122b
                    mr->priority,
0a122b
-                   mr->readable ? 'R' : '-',
0a122b
-                   !mr->readonly && !(mr->rom_device && mr->readable) ? 'W'
0a122b
-                                                                      : '-',
0a122b
+                   mr->romd_mode ? 'R' : '-',
0a122b
+                   !mr->readonly && !(mr->rom_device && mr->romd_mode) ? 'W'
0a122b
+                                                                       : '-',
0a122b
                    mr->name);
0a122b
     }
0a122b
 
0a122b
-- 
0a122b
1.7.1
0a122b