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