[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 2/9] qtest: Add local qtest_mem_as() getter
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 2/9] qtest: Add local qtest_mem_as() getter |
Date: |
Mon, 17 Aug 2020 18:18:46 +0200 |
Refactor the access to the default address space introducing the
qtest_mem_as() getter. This will help us to use another address
space in the next commit.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
softmmu/qtest.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 5672b75c35..81b5110783 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -273,6 +273,12 @@ static void qtest_irq_handler(void *opaque, int n, int
level)
}
}
+/* Default address space for MMIO accesses */
+static AddressSpace *qtest_mem_as(void)
+{
+ return first_cpu->as;
+}
+
static void qtest_process_command(CharBackend *chr, gchar **words)
{
const gchar *command;
@@ -434,22 +440,22 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
if (words[0][5] == 'b') {
uint8_t data = value;
- address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_write(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
&data, 1);
} else if (words[0][5] == 'w') {
uint16_t data = value;
tswap16s(&data);
- address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_write(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
&data, 2);
} else if (words[0][5] == 'l') {
uint32_t data = value;
tswap32s(&data);
- address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_write(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
&data, 4);
} else if (words[0][5] == 'q') {
uint64_t data = value;
tswap64s(&data);
- address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_write(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
&data, 8);
}
qtest_send_prefix(chr);
@@ -468,21 +474,21 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
if (words[0][4] == 'b') {
uint8_t data;
- address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_read(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
&data, 1);
value = data;
} else if (words[0][4] == 'w') {
uint16_t data;
- address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_read(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
&data, 2);
value = tswap16(data);
} else if (words[0][4] == 'l') {
uint32_t data;
- address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_read(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
&data, 4);
value = tswap32(data);
} else if (words[0][4] == 'q') {
- address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_read(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
&value, 8);
tswap64s(&value);
}
@@ -503,7 +509,7 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
g_assert(len);
data = g_malloc(len);
- address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
+ address_space_read(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED, data,
len);
enc = g_malloc(2 * len + 1);
@@ -529,7 +535,7 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
g_assert(ret == 0);
data = g_malloc(len);
- address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
+ address_space_read(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED, data,
len);
b64_data = g_base64_encode(data, len);
qtest_send_prefix(chr);
@@ -564,7 +570,7 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
data[i] = 0;
}
}
- address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
+ address_space_write(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED, data,
len);
g_free(data);
@@ -587,7 +593,7 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
if (len) {
data = g_malloc(len);
memset(data, pattern, len);
- address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
+ address_space_write(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED,
data, len);
g_free(data);
}
@@ -621,7 +627,7 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
out_len = MIN(out_len, len);
}
- address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
+ address_space_write(qtest_mem_as(), addr, MEMTXATTRS_UNSPECIFIED, data,
len);
qtest_send_prefix(chr);
--
2.26.2
- [RFC PATCH 0/9] hw/misc: Add support for interleaved memory accesses, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 2/9] qtest: Add local qtest_mem_as() getter,
Philippe Mathieu-Daudé <=
- [RFC PATCH 3/9] qtest: Directly use global address_space_memory when no CPU available, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 4/9] hw/misc: Add interleaver device to make interleaved memory accesses, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 1/9] memory: Initialize MemoryRegionOps for RAM memory regions, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 5/9] hw/misc: Add MMIO test device, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 9/9] hw/misc/interleaver: Display subregions in 'info mtree', Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 6/9] hw/core/null-machine: Allow to use the MMIO 'test' device, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 7/9] tests/qtest: Add generic MMIO tests, Philippe Mathieu-Daudé, 2020/08/17
- [RFC PATCH 8/9] memory: Allow memory region to display its subregions own descriptions, Philippe Mathieu-Daudé, 2020/08/17