提交 4d007963 编写于 作者: J John Snow

qtest: add memset to qtest protocol

Previously, memset was just a frontend to write() and only
stupidly sent the pattern many times across the wire.

Let's not discuss who stupidly wrote it like that in the first place.
(Hint: It was me.)
Signed-off-by: NJohn Snow <jsnow@redhat.com>
Message-id: 1430864578-22072-4-git-send-email-jsnow@redhat.com
上级 7a6a740d
...@@ -125,6 +125,9 @@ static bool qtest_opened; ...@@ -125,6 +125,9 @@ static bool qtest_opened;
* > b64write ADDR SIZE B64_DATA * > b64write ADDR SIZE B64_DATA
* < OK * < OK
* *
* > memset ADDR SIZE VALUE
* < OK
*
* ADDR, SIZE, VALUE are all integers parsed with strtoul() with a base of 0. * ADDR, SIZE, VALUE are all integers parsed with strtoul() with a base of 0.
* *
* DATA is an arbitrarily long hex number prefixed with '0x'. If it's smaller * DATA is an arbitrarily long hex number prefixed with '0x'. If it's smaller
...@@ -471,6 +474,23 @@ static void qtest_process_command(CharDriverState *chr, gchar **words) ...@@ -471,6 +474,23 @@ static void qtest_process_command(CharDriverState *chr, gchar **words)
cpu_physical_memory_write(addr, data, len); cpu_physical_memory_write(addr, data, len);
g_free(data); g_free(data);
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
} else if (strcmp(words[0], "memset") == 0) {
uint64_t addr, len;
uint8_t *data;
uint8_t pattern;
g_assert(words[1] && words[2] && words[3]);
addr = strtoull(words[1], NULL, 0);
len = strtoull(words[2], NULL, 0);
pattern = strtoull(words[3], NULL, 0);
data = g_malloc(len);
memset(data, pattern, len);
cpu_physical_memory_write(addr, data, len);
g_free(data);
qtest_send_prefix(chr); qtest_send_prefix(chr);
qtest_send(chr, "OK\n"); qtest_send(chr, "OK\n");
} else if (strcmp(words[0], "b64write") == 0) { } else if (strcmp(words[0], "b64write") == 0) {
......
...@@ -741,13 +741,7 @@ void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size) ...@@ -741,13 +741,7 @@ void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size)
void qtest_memset(QTestState *s, uint64_t addr, uint8_t pattern, size_t size) void qtest_memset(QTestState *s, uint64_t addr, uint8_t pattern, size_t size)
{ {
size_t i; qtest_sendf(s, "memset 0x%" PRIx64 " 0x%zx 0x%02x\n", addr, size, pattern);
qtest_sendf(s, "write 0x%" PRIx64 " 0x%zx 0x", addr, size);
for (i = 0; i < size; i++) {
qtest_sendf(s, "%02x", pattern);
}
qtest_sendf(s, "\n");
qtest_rsp(s, 0); qtest_rsp(s, 0);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册