* [Qemu-devel] [PATCHv2] unicore32-softmmu: Add a minimal curses screen support [not found] <cover.1343790517.git.gxt@mprc.pku.edu.cn> @ 2012-08-01 3:09 ` gxt 2012-08-01 14:23 ` Andreas Färber 0 siblings, 1 reply; 3+ messages in thread From: gxt @ 2012-08-01 3:09 UTC (permalink / raw) To: qemu-devel; +Cc: blauwirbel, Zhang Mengchi, gxt, afaerber, chenwj From: Guan Xuetao <gxt@mprc.pku.edu.cn> 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 v1->v2: add extra handler for '\r' Signed-off-by: Zhang Mengchi <zhangmengchi@mprc.pku.edu.cn> Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn> --- target-unicore32/helper.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 43 insertions(+), 2 deletions(-) diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index d6eb758..d21e7df 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -13,6 +13,7 @@ #include "gdbstub.h" #include "helper.h" #include "host-utils.h" +#include "console.h" #undef DEBUG_UC32 @@ -186,10 +187,50 @@ 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)) { + 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%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 -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCHv2] unicore32-softmmu: Add a minimal curses screen support 2012-08-01 3:09 ` [Qemu-devel] [PATCHv2] unicore32-softmmu: Add a minimal curses screen support gxt @ 2012-08-01 14:23 ` Andreas Färber 2012-08-02 3:53 ` guanxuetao 0 siblings, 1 reply; 3+ messages in thread From: Andreas Färber @ 2012-08-01 14:23 UTC (permalink / raw) To: gxt; +Cc: blauwirbel, Zhang Mengchi, qemu-devel, chenwj Am 01.08.2012 05:09, schrieb gxt@mprc.pku.edu.cn: > From: Guan Xuetao <gxt@mprc.pku.edu.cn> > > 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 > > v1->v2: add extra handler for '\r' > > Signed-off-by: Zhang Mengchi <zhangmengchi@mprc.pku.edu.cn> > Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn> > --- > target-unicore32/helper.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- > 1 files changed, 43 insertions(+), 2 deletions(-) > > diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c > index d6eb758..d21e7df 100644 > --- a/target-unicore32/helper.c > +++ b/target-unicore32/helper.c > @@ -13,6 +13,7 @@ > #include "gdbstub.h" > #include "helper.h" > #include "host-utils.h" > +#include "console.h" > > #undef DEBUG_UC32 > > @@ -186,10 +187,50 @@ 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)) { > + 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%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 > Why is a TCG helper missing with curses directly? Shouldn't that use QEMU's console infrastructure and leave it to the user whether to use curses as a backend at runtime? What is the problem you are trying to solve? If you just need scrolling support you can already use -curses, -nographic and friends... Regards, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCHv2] unicore32-softmmu: Add a minimal curses screen support 2012-08-01 14:23 ` Andreas Färber @ 2012-08-02 3:53 ` guanxuetao 0 siblings, 0 replies; 3+ messages in thread From: guanxuetao @ 2012-08-02 3:53 UTC (permalink / raw) To: Andreas F�rber; +Cc: blauwirbel, Zhang Mengchi, gxt, qemu-devel, chenwj > Am 01.08.2012 05:09, schrieb gxt@mprc.pku.edu.cn: > > Why is a TCG helper missing with curses directly? Shouldn't that use > QEMU's console infrastructure and leave it to the user whether to use > curses as a backend at runtime? > > What is the problem you are trying to solve? If you just need scrolling > support you can already use -curses, -nographic and friends... > > Regards, > Andreas > What we need is an output screen. The kernel (and busybox) outputs every char to cp1, and curses is used to just print it on the screen. This approach can generate the result as similar as the real debugging situations when we use fpga boards and debug boards to debug linux kernel. We need -curses to enable curses support, but we have no serial port support at present, so -nographic doesn't work. Thanks & Regards Guan Xuetao ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-02 3:06 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <cover.1343790517.git.gxt@mprc.pku.edu.cn> 2012-08-01 3:09 ` [Qemu-devel] [PATCHv2] unicore32-softmmu: Add a minimal curses screen support gxt 2012-08-01 14:23 ` Andreas Färber 2012-08-02 3:53 ` guanxuetao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).