target/unicore32: Prefer qemu_semihosting_log_out() over curses

Use the common API for semihosting logging.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200603123754.19059-4-f4bug@amsat.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
Philippe Mathieu-Daudé 2020-06-03 14:37:54 +02:00 committed by Laurent Vivier
parent 7a7b663234
commit c7a856b42e
2 changed files with 6 additions and 52 deletions

View File

@ -3,3 +3,4 @@
# Boards: # Boards:
# #
CONFIG_PUV3=y CONFIG_PUV3=y
CONFIG_SEMIHOSTING=y

View File

@ -14,9 +14,7 @@
#include "cpu.h" #include "cpu.h"
#include "exec/exec-all.h" #include "exec/exec-all.h"
#include "exec/helper-proto.h" #include "exec/helper-proto.h"
#ifndef CONFIG_USER_ONLY #include "hw/semihosting/console.h"
#include "ui/console.h"
#endif
#undef DEBUG_UC32 #undef DEBUG_UC32
@ -161,58 +159,13 @@ uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop)
return 0; return 0;
} }
#ifdef CONFIG_CURSES void helper_cp1_putc(target_ulong regval)
/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */
#undef KEY_EVENT
#include <curses.h>
#undef KEY_EVENT
/*
* FIXME:
* 1. curses windows will be blank when switching back
* 2. backspace is not handled yet
*/
static void putc_on_screen(unsigned char ch)
{ {
static WINDOW *localwin; const char c = regval;
static int init;
if (!init) { qemu_semihosting_log_out(&c, sizeof(c));
/* Assume 80 * 30 screen to minimize the implementation */
localwin = newwin(30, 80, 0, 0);
scrollok(localwin, TRUE);
init = TRUE;
}
if (isprint(ch)) {
wprintw(localwin, "%c", ch);
} else {
switch (ch) {
case '\n':
wprintw(localwin, "%c", ch);
break;
case '\r':
/* If '\r' is put before '\n', the curses window will destroy the
* last print line. And meanwhile, '\n' implifies '\r' inside. */
break;
default: /* Not handled, so just print it hex code */
wprintw(localwin, "-- 0x%x --", ch);
}
}
wrefresh(localwin);
} }
#else #endif /* !CONFIG_USER_ONLY */
#define putc_on_screen(c) do { } while (0)
#endif
void helper_cp1_putc(target_ulong x)
{
putc_on_screen((unsigned char)x); /* Output to screen */
DPRINTF("%c", x); /* Output to stdout */
}
#endif
bool uc32_cpu_exec_interrupt(CPUState *cs, int interrupt_request) bool uc32_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
{ {