[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v2 10/28] target/mips: convert UHI_plog to use common
From: |
Alex Bennée |
Subject: |
[Qemu-arm] [PATCH v2 10/28] target/mips: convert UHI_plog to use common semihosting code |
Date: |
Thu, 23 May 2019 11:25:14 +0100 |
Rather than printing directly to stdout lets use our common
semihosting code. There is one minor difference in that the output
currently defaults to stderr instead of stdout however this can be
controlled by connecting semihosting to a chardev.
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Aleksandar Markovic <address@hidden>
---
target/mips/mips-semi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/target/mips/mips-semi.c b/target/mips/mips-semi.c
index eac8374fb34..35bdfd7c77e 100644
--- a/target/mips/mips-semi.c
+++ b/target/mips/mips-semi.c
@@ -23,6 +23,7 @@
#include "exec/helper-proto.h"
#include "exec/softmmu-semi.h"
#include "hw/semihosting/semihost.h"
+#include "hw/semihosting/console.h"
typedef enum UHIOp {
UHI_exit = 1,
@@ -329,13 +330,12 @@ void helper_do_semihosting(CPUMIPSState *env)
p2 = strstr(p, "%d");
if (p2) {
int char_num = p2 - p;
- char *buf = g_malloc(char_num + 1);
- strncpy(buf, p, char_num);
- buf[char_num] = '\0';
- gpr[2] = printf("%s%d%s", buf, (int)gpr[5], p2 + 2);
- g_free(buf);
+ GString *s = g_string_new_len(p, char_num);
+ g_string_append_printf(s, "%d%s", (int)gpr[5], p2 + 2);
+ gpr[2] = qemu_semihosting_log_out(s->str, s->len);
+ g_string_free(s, true);
} else {
- gpr[2] = printf("%s", p);
+ gpr[2] = qemu_semihosting_log_out(p, strlen(p));
}
FREE_TARGET_STRING(p, gpr[4]);
break;
--
2.20.1
- [Qemu-arm] [PATCH v2 13/28] tests/docker: Test more components on the Fedora default image, (continued)
- [Qemu-arm] [PATCH v2 13/28] tests/docker: Test more components on the Fedora default image, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 02/28] semihosting: introduce CONFIG_SEMIHOSTING, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 07/28] target/arm: add LOG_UNIMP messages to arm-semi, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 20/28] tests/tcg/multiarch: expand system memory test to cover more, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 09/28] target/mips: only build mips-semi for softmmu, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 16/28] editorconfig: add settings for .s/.S files, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 05/28] target/arm: fixup some of the commentary for arm-semi, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 10/28] target/mips: convert UHI_plog to use common semihosting code,
Alex Bennée <=
- [Qemu-arm] [PATCH v2 08/28] target/arm: correct return values for WRITE/READ in arm-semi, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 11/28] MAINTAINERS: update for semihostings new home, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 06/28] target/arm: use the common interface for WRITE0/WRITEC in arm-semi, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 14/28] tests/tcg/multiarch: add support for multiarch system tests, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 04/28] semihosting: enable chardev backed output for console, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 03/28] semihosting: implement a semihosting console, Alex Bennée, 2019/05/23