Skip to contentSkip to conversation

unicore32-softmmu: Add a minimal curses screen support

PATCH Superseded [email protected] 1 participant 1 message Jul 26, 2012 1 message not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 unicore32-softmmu: Add a minimal curses screen support

From: Guan Xuetao <[email protected]>

This patch adds a minimal curses screen support for unicore32-softmmu. We assume 80*30 screen size to minimize the implementation. Two problems are not solved, but they are innocuous.
1. curses windows will be blank when switching to monitor screen and back
2. backspace is not handled yet

---
 target-unicore32/helper.c |   35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)
target-unicore32/helper.c +33 -2
index d6eb758..8556beb 100644
@@ -13,6 +13,7 @@
 #include "gdbstub.h"
 #include "helper.h"
 #include "host-utils.h"
+#include "console.h"
 
 #undef DEBUG_UC32
 
@@ -186,10 +187,40 @@ uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop)
     return 0;
 }
 
+#ifdef CONFIG_CURSES
+/*
+ * 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;
+    static int init;
+
+    if (!init) {
+        /* Assume 80 * 30 screen to minimize the implementation */
+        localwin = newwin(30, 80, 0, 0);
+        scrollok(localwin, TRUE);
+        init = TRUE;
+    }
+
+    if ((isprint(ch)) || (ch == '\n') || (ch == '\r')) {
+        wprintw(localwin, "%c", ch);
+    } else {
+        wprintw(localwin, "0x%h", ch);
+    }
+
+    wrefresh(localwin);
+}
+#else
+#define putc_on_screen(c)               do { } while (0)
+#endif
+
 void helper_cp1_putc(target_ulong x)
 {
-    /* TODO: curses display should be added here for screen output. */
-    DPRINTF("%c", x);
+    putc_on_screen((unsigned char)x);   /* Output to screen */
+    DPRINTF("%c", x);                   /* Output to stdout */
 }
 #endif
 
Signature · 1 line
1.7.0.4