Skip to contentSkip to conversation

target/unicore32: Semihosting cleanup

PATCH Applied Philippe Mathieu-Daudé 4 participants 10 messages Jun 3, 2020 – Jun 9, 2020

lore
Share & tools
lore
#0 lore raw

cover target/unicore32: Semihosting cleanup

Trivial cleanups around semihosting code.

Guan: Do you have binaries to run testing?

I couldn't rebuild anything from https://github.com/gxt/UniCore32
that you referenced here:
https://www.mail-archive.com/[email protected]/msg608054.html
- u-boot patches are missing
- which gnu-toolchain-unicore should we use?
- your webpage is down: http://mprc.pku.edu.cn/~guanxuetao/
- there are too many warnings reported for QEMU 2.7-stable.

Philippe Mathieu-Daudé (3):
target/unicore32: Remove unused headers target/unicore32: Replace DPRINTF() by qemu_log_mask(GUEST_ERROR) target/unicore32: Prefer qemu_semihosting_log_out() over curses

 default-configs/unicore32-softmmu.mak |  1 +
 target/unicore32/helper.c             | 70 +++++----------------------
 2 files changed, 13 insertions(+), 58 deletions(-)
Signature · 1 line
2.21.3
#1 lore raw

PATCH 1/3 target/unicore32: Remove unused headers

---
 target/unicore32/helper.c | 2 --
 1 file changed, 2 deletions(-)
target/unicore32/helper.c +0 -2
index 7d538e2144..53292ae311 100644
@@ -12,9 +12,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
-#include "exec/gdbstub.h"
 #include "exec/helper-proto.h"
-#include "qemu/host-utils.h"
 #ifndef CONFIG_USER_ONLY
 #include "ui/console.h"
 #endif
Signature · 1 line
2.21.3
#3 lore raw

Re: [PATCH 1/3] target/unicore32: Remove unused headers

In reply to Philippe Mathieu-Daudé

Le 03/06/2020 à 14:37, Philippe Mathieu-Daudé a écrit :

Quoted 11 lines
---
 target/unicore32/helper.c | 2 --
 1 file changed, 2 deletions(-)
target/unicore32/helper.c +0 -0
index 7d538e2144..53292ae311 100644

target/unicore32/helper.c line 18

Quoted 9 lines
target/unicore32/helper.c +0 -2
@@ -12,9 +12,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
-#include "exec/gdbstub.h"
 #include "exec/helper-proto.h"
-#include "qemu/host-utils.h"
 #ifndef CONFIG_USER_ONLY
 #include "ui/console.h"
 #endif

Applied to my trivial-patches branch.

Thanks,
Laurent

#4 lore raw

PATCH 2/3 target/unicore32: Replace DPRINTF() by qemu_log_mask(GUEST_ERROR)

In reply to Philippe Mathieu-Daudé

Replace disabled DPRINTF() by qemu_log_mask(GUEST_ERROR).

---
 target/unicore32/helper.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
target/unicore32/helper.c +7 -4
index 53292ae311..00371a7da6 100644
@@ -10,6 +10,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/log.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
 #include "exec/helper-proto.h"
@@ -106,8 +107,9 @@ void helper_cp0_set(CPUUniCore32State *env, uint32_t val, uint32_t creg,
     }
     return;
 unrecognized:
-    DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
-            creg, cop);
+    qemu_log_mask(LOG_GUEST_ERROR,
+                  "Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
+                  creg, cop);
 }
 
 uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop)
@@ -153,8 +155,9 @@ uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop)
         }
         break;
     }
-    DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
-            creg, cop);
+    qemu_log_mask(LOG_GUEST_ERROR,
+                  "Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
+                  creg, cop);
     return 0;
 }
 
Signature · 1 line
2.21.3
#6 lore raw

Re: [PATCH 2/3] target/unicore32: Replace DPRINTF() by qemu_log_mask(GUEST_ERROR)

In reply to Philippe Mathieu-Daudé

Le 03/06/2020 à 14:37, Philippe Mathieu-Daudé a écrit :

Quoted 34 lines

Replace disabled DPRINTF() by qemu_log_mask(GUEST_ERROR).

---
 target/unicore32/helper.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
target/unicore32/helper.c +4 -2
index 53292ae311..00371a7da6 100644
@@ -10,6 +10,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/log.h"
 #include "cpu.h"
 #include "exec/exec-all.h"
 #include "exec/helper-proto.h"
@@ -106,8 +107,9 @@ void helper_cp0_set(CPUUniCore32State *env, uint32_t val, uint32_t creg,
     }
     return;
 unrecognized:
-    DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
-            creg, cop);
+    qemu_log_mask(LOG_GUEST_ERROR,
+                  "Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
+                  creg, cop);
 }
 
 uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop)
@@ -153,8 +155,9 @@ uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop)
         }

target/unicore32/helper.c uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop) · line 163

Quoted 10 lines
target/unicore32/helper.c +3 -2
         break;
     }
-    DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
-            creg, cop);
+    qemu_log_mask(LOG_GUEST_ERROR,
+                  "Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
+                  creg, cop);
     return 0;
 }
 

Applied to my trivial-patches branch.

Thanks,
Laurent

#7 lore raw

PATCH 3/3 target/unicore32: Prefer qemu_semihosting_log_out() over curses

In reply to Philippe Mathieu-Daudé

Use the common API for semihosting logging.

---
 default-configs/unicore32-softmmu.mak |  1 +
 target/unicore32/helper.c             | 57 +++------------------------
 2 files changed, 6 insertions(+), 52 deletions(-)
default-configs/unicore32-softmmu.mak +1 -0
index 0bfce48c6d..899288e3d7 100644
@@ -3,3 +3,4 @@
 # Boards:
 #
 CONFIG_PUV3=y
+CONFIG_SEMIHOSTING=y
target/unicore32/helper.c +5 -52

72 lines not on this page · raw message

Signature · 1 line
2.21.3
Reviewed-by on v1 3/3
#8 lore raw

Re: [PATCH 3/3] target/unicore32: Prefer qemu_semihosting_log_out() over curses

Quoted 7 lines · Philippe Mathieu-Daudé

Use the common API for semihosting logging.

---
 default-configs/unicore32-softmmu.mak |  1 +
 target/unicore32/helper.c             | 57 +++------------------------
 2 files changed, 6 insertions(+), 52 deletions(-)

r~

#9 lore raw

Re: [PATCH 3/3] target/unicore32: Prefer qemu_semihosting_log_out() over curses

In reply to Philippe Mathieu-Daudé

Le 03/06/2020 à 14:37, Philippe Mathieu-Daudé a écrit :

Quoted 86 lines

Use the common API for semihosting logging.

---
 default-configs/unicore32-softmmu.mak |  1 +
 target/unicore32/helper.c             | 57 +++------------------------
 2 files changed, 6 insertions(+), 52 deletions(-)
default-configs/unicore32-softmmu.mak +1 -0
index 0bfce48c6d..899288e3d7 100644
@@ -3,3 +3,4 @@
 # Boards:
 #
 CONFIG_PUV3=y
+CONFIG_SEMIHOSTING=y
target/unicore32/helper.c +4 -46
index 00371a7da6..54c26871fe 100644
@@ -14,9 +14,7 @@
 #include "cpu.h"
 #include "exec/exec-all.h"
 #include "exec/helper-proto.h"
-#ifndef CONFIG_USER_ONLY
-#include "ui/console.h"
-#endif
+#include "hw/semihosting/console.h"
 
 #undef DEBUG_UC32
 
@@ -161,58 +159,13 @@ uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop)
     return 0;
 }
 
-#ifdef CONFIG_CURSES
-
-/* 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)
+void helper_cp1_putc(target_ulong regval)
 {
-    static WINDOW *localwin;
-    static int init;
+    const char c = regval;
 
-    if (!init) {
-        /* 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);
+    qemu_semihosting_log_out(&c, sizeof(c));
 }
-#else
-#define putc_on_screen(c)               do { } while (0)
-#endif
-

target/unicore32/helper.c uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop) · line 171

Quoted 10 lines
target/unicore32/helper.c +1 -6
-void helper_cp1_putc(target_ulong x)
-{
-    putc_on_screen((unsigned char)x);   /* Output to screen */
-    DPRINTF("%c", x);                   /* Output to stdout */
-}
-#endif
+#endif /* !CONFIG_USER_ONLY */
 
 bool uc32_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 {

Applied to my trivial-patches branch.

Thanks,
Laurent