From patchwork Wed Sep 28 09:07:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9353467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E81B260757 for ; Wed, 28 Sep 2016 09:12:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6C11293E0 for ; Wed, 28 Sep 2016 09:12:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB637293E4; Wed, 28 Sep 2016 09:12:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3DF69293E0 for ; Wed, 28 Sep 2016 09:12:40 +0000 (UTC) Received: from localhost ([::1]:57049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpAut-0006KM-Bs for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Sep 2016 05:12:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpAq1-0001or-KA for qemu-devel@nongnu.org; Wed, 28 Sep 2016 05:07:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpAq0-0001oF-8J for qemu-devel@nongnu.org; Wed, 28 Sep 2016 05:07:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpApz-0001nf-Ug for qemu-devel@nongnu.org; Wed, 28 Sep 2016 05:07:36 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8CB7931B31A; Wed, 28 Sep 2016 09:07:35 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-31.ams2.redhat.com [10.36.116.31]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8S97Xdc030785; Wed, 28 Sep 2016 05:07:34 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id EB80980C66; Wed, 28 Sep 2016 11:07:30 +0200 (CEST) From: Gerd Hoffmann To: seabios@seabios.org Date: Wed, 28 Sep 2016 11:07:18 +0200 Message-Id: <1475053640-30483-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1475053640-30483-1-git-send-email-kraxel@redhat.com> References: <1475053640-30483-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 28 Sep 2016 09:07:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/7] sercon: split-output implementation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Allows to run the serial console in parallel with a vga display. Output will show up on both vga and serial line. Input will be accepted from both keyboard and serial line. Signed-off-by: Gerd Hoffmann --- src/optionroms.c | 2 ++ src/romlayout.S | 14 +++++++++ src/sercon.c | 95 ++++++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 91 insertions(+), 20 deletions(-) diff --git a/src/optionroms.c b/src/optionroms.c index f9e9593..f08fcb1 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -442,6 +442,8 @@ vgarom_setup(void) } VgaROM = (void*)BUILD_ROM_START; + if (romfile_loadint("etc/sercon-enable", 0)) + sercon_enable(); enable_vga_console(); } diff --git a/src/romlayout.S b/src/romlayout.S index 89b3784..a968e62 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -524,6 +524,20 @@ irqentry_arg: DECL_IRQ_ENTRY hwpic1 DECL_IRQ_ENTRY hwpic2 + // hooked int10, for sercon + DECLFUNC entry_10_hooked +entry_10_hooked: + // Setup for iretw in irqentry_arg + pushfw + pushl %cs:sercon_int10_hook_resume + + pushl $sercon_10_splitmode +#if CONFIG_ENTRY_EXTRASTACK + jmp irqentry_arg_extrastack +#else + jmp irqentry_arg +#endif + // int 18/19 are special - they reset stack and call into 32bit mode. DECLFUNC entry_19 entry_19: diff --git a/src/sercon.c b/src/sercon.c index 69b0c63..d9b6143 100644 --- a/src/sercon.c +++ b/src/sercon.c @@ -9,6 +9,7 @@ #include "stacks.h" // yield #include "output.h" // dprintf #include "util.h" // irqtimer_calc_ticks +#include "string.h" // memcpy #include "hw/serialio.h" // SEROFF_IER #include "cp437.h" @@ -45,6 +46,8 @@ static void cursor_pos_set(u8 row, u8 col) ****************************************************************/ VARLOW u16 sercon_port; +VARLOW u8 sercon_split; +VARFSEG struct segoff_s sercon_int10_hook_resume; /* * We have a small output buffer here, for lazy output. That allows @@ -64,6 +67,11 @@ VARLOW u8 sercon_attr = 0x07; static VAR16 u8 sercon_cmap[8] = { '0', '4', '2', '6', '1', '5', '3', '7' }; +static int sercon_splitmode(void) +{ + return GET_LOW(sercon_split); +} + static void sercon_putchar(u8 chr) { u16 addr = GET_LOW(sercon_port); @@ -174,6 +182,15 @@ static void sercon_print_utf8(u8 chr) } } +static void sercon_cursor_pos_set(u8 row, u8 col) +{ + if (!sercon_splitmode()) { + cursor_pos_set(row, col); + } else { + /* let vgabios update cursor */ + } +} + static void sercon_lazy_cursor_sync(void) { u8 row = cursor_pos_row(); @@ -222,7 +239,7 @@ static void sercon_lazy_flush(void) static void sercon_lazy_cursor_update(u8 row, u8 col) { - cursor_pos_set(row, col); + sercon_cursor_pos_set(row, col); SET_LOW(sercon_row_last, row); SET_LOW(sercon_col_last, col); } @@ -241,7 +258,7 @@ static void sercon_lazy_backspace(void) static void sercon_lazy_cr(void) { - cursor_pos_set(cursor_pos_row(), 0); + sercon_cursor_pos_set(cursor_pos_row(), 0); } static void sercon_lazy_lf(void) @@ -256,7 +273,7 @@ static void sercon_lazy_lf(void) SET_LOW(sercon_row_last, GET_LOW(sercon_row_last) - 1); } } - cursor_pos_set(row, cursor_pos_col()); + sercon_cursor_pos_set(row, cursor_pos_col()); } static void sercon_lazy_move_cursor(void) @@ -268,7 +285,7 @@ static void sercon_lazy_move_cursor(void) sercon_lazy_cr(); sercon_lazy_lf(); } else { - cursor_pos_set(cursor_pos_row(), col); + sercon_cursor_pos_set(cursor_pos_row(), col); } } @@ -293,23 +310,27 @@ static void sercon_1000(struct bregs *regs) u8 mode = regs->al & 0x7f; u8 rows, cols; - switch (mode) { - case 0x03: - default: - cols = 80; - rows = 25; - regs->al = 0x30; + if (!sercon_splitmode()) { + switch (mode) { + case 0x03: + default: + cols = 80; + rows = 25; + regs->al = 0x30; + } + cursor_pos_set(0, 0); + SET_BDA(video_mode, mode); + SET_BDA(video_cols, cols); + SET_BDA(video_rows, rows-1); + SET_BDA(cursor_type, 0x0007); + } else { + /* let vgabios handle mode init */; } + SET_LOW(sercon_col_last, 0); SET_LOW(sercon_row_last, 0); SET_LOW(sercon_attr_last, 0); - cursor_pos_set(0, 0); - SET_BDA(video_mode, mode); - SET_BDA(video_cols, cols); - SET_BDA(video_rows, rows-1); - SET_BDA(cursor_type, 0x0007); - sercon_term_reset(); sercon_term_no_linewrap(); if (clearscreen) @@ -326,10 +347,7 @@ static void sercon_1001(struct bregs *regs) /* Set cursor position */ static void sercon_1002(struct bregs *regs) { - u8 row = regs->dh; - u8 col = regs->dl; - - cursor_pos_set(row, col); + sercon_cursor_pos_set(regs->dh, regs->dl); } /* Get cursor position */ @@ -456,10 +474,47 @@ sercon_10(struct bregs *regs) } } +void VISIBLE16 +sercon_10_splitmode(struct bregs *regs) +{ + if (!GET_LOW(sercon_port)) + return; + + switch (regs->ah) { + case 0x01: + case 0x02: + case 0x03: + case 0x08: + case 0x0f: + case 0x4f: + /* nothing, vgabios did all work */ + break; + case 0x00: sercon_1000(regs); break; + case 0x06: sercon_1006(regs); break; + case 0x09: sercon_1009(regs); break; + case 0x0e: sercon_100e(regs); break; + default: sercon_10XX(regs); break; + } +} + void sercon_enable(void) { + struct segoff_s seabios, vgabios; u16 addr = PORT_SERIAL1; + vgabios = GET_IVT(0x10); + seabios = FUNC16(entry_10); + if (vgabios.seg != seabios.seg || + vgabios.offset != seabios.offset) { + dprintf(1, "%s:%d: using splitmode (vgabios %04x:%04x, hook %04x:%04x)\n", + __func__, __LINE__, + vgabios.seg, vgabios.offset, + seabios.seg, seabios.offset); + sercon_int10_hook_resume = vgabios; + SET_IVT(0x10, FUNC16(entry_10_hooked)); + SET_LOW(sercon_split, 1); + } + SET_LOW(sercon_port, addr); outb(0x03, addr + SEROFF_LCR); // 8N1 outb(0x01, addr + 0x02); // enable fifo