[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/2] system/qtest: Remove uses of 'first_cpu'
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 1/2] system/qtest: Remove uses of 'first_cpu' |
Date: |
Thu, 12 Dec 2024 00:37:26 +0100 |
There is no vCPU within the QTest accelerator (well, they
are stubs doing nothing, see dummy_cpu_thread_fn).
Directly access the global &address_space_memory to reduce
access to the 'first_cpu' global (which is meaningless in
a heterogeneous emulation setup).
Cast the returned value to (void) to explicit we don't
care about invalid accesses.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
We will likely remove &address_space_memory too, but one
global at a time. first_cpu is more annoying so I'm starting
with it.
---
system/qtest.c | 53 +++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 26 deletions(-)
diff --git a/system/qtest.c b/system/qtest.c
index 12703a20455..cc26dd75bef 100644
--- a/system/qtest.c
+++ b/system/qtest.c
@@ -16,6 +16,7 @@
#include "sysemu/qtest.h"
#include "sysemu/runstate.h"
#include "chardev/char-fe.h"
+#include "exec/address-spaces.h"
#include "exec/ioport.h"
#include "exec/memory.h"
#include "exec/tswap.h"
@@ -514,23 +515,23 @@ 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,
- &data, 1);
+ (void)address_space_write(&address_space_memory, 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,
- &data, 2);
+ (void)address_space_write(&address_space_memory, 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,
- &data, 4);
+ (void)address_space_write(&address_space_memory, 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,
- &data, 8);
+ (void)address_space_write(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, &data, 8);
}
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
@@ -548,22 +549,22 @@ 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,
- &data, 1);
+ (void)address_space_read(&address_space_memory, 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,
- &data, 2);
+ (void)address_space_read(&address_space_memory, 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,
- &data, 4);
+ (void)address_space_read(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, &data, 4);
value = tswap32(data);
} else if (words[0][4] == 'q') {
- address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
- &value, 8);
+ (void)address_space_read(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, &value, 8);
tswap64s(&value);
}
qtest_send_prefix(chr);
@@ -583,8 +584,8 @@ 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,
- len);
+ (void)address_space_read(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, data, len);
enc = qemu_hexdump_line(NULL, data, len, 0, 0);
@@ -605,8 +606,8 @@ 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,
- len);
+ (void)address_space_read(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, data, len);
b64_data = g_base64_encode(data, len);
qtest_send_prefix(chr);
qtest_sendf(chr, "OK %s\n", b64_data);
@@ -640,8 +641,8 @@ static void qtest_process_command(CharBackend *chr, gchar
**words)
data[i] = 0;
}
}
- address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
- len);
+ (void)address_space_write(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, data, len);
g_free(data);
qtest_send_prefix(chr);
@@ -663,8 +664,8 @@ 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,
- data, len);
+ (void)address_space_write(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, data, len);
g_free(data);
}
@@ -697,8 +698,8 @@ 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,
- len);
+ (void)address_space_write(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, data, len);
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
--
2.45.2