From patchwork Wed Aug 1 03:09:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guan Xuetao X-Patchwork-Id: 174365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 78BC62C00A1 for ; Wed, 1 Aug 2012 13:01:05 +1000 (EST) Received: from localhost ([::1]:34398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwPBH-0003LU-KW for incoming@patchwork.ozlabs.org; Tue, 31 Jul 2012 23:01:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwPBB-0003LP-JW for qemu-devel@nongnu.org; Tue, 31 Jul 2012 23:00:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwPB8-0003Oe-FM for qemu-devel@nongnu.org; Tue, 31 Jul 2012 23:00:57 -0400 Received: from mprc.pku.edu.cn ([162.105.203.9]:54568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwPB7-0003Lc-JX for qemu-devel@nongnu.org; Tue, 31 Jul 2012 23:00:54 -0400 Received: from linuxdev-32 ([162.105.203.8]) by mprc.pku.edu.cn (8.13.8/8.13.8) with ESMTP id q713llcX027133; Wed, 1 Aug 2012 11:47:47 +0800 Received: by linuxdev-32 (Postfix, from userid 1000) id 48B9514600A0; Wed, 1 Aug 2012 11:09:52 +0800 (CST) From: gxt@mprc.pku.edu.cn To: qemu-devel@nongnu.org Date: Wed, 1 Aug 2012 11:09:43 +0800 Message-Id: <6e00a77f0ea5e11b7a060803040d4e58bf935c01.1343790517.git.gxt@mprc.pku.edu.cn> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 162.105.203.9 Cc: blauwirbel@gmail.com, Zhang Mengchi , gxt@mprc.pku.edu.cn, afaerber@suse.de, chenwj@iis.sinica.edu.tw Subject: [Qemu-devel] [PATCHv2] unicore32-softmmu: Add a minimal curses screen support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Guan Xuetao 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 Signed-off-by: Guan Xuetao --- 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