From nobody Sat May 10 10:25:32 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1504851557129500.8418216900492; Thu, 7 Sep 2017 23:19:17 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1dqCcl-0002Wj-B1; Fri, 08 Sep 2017 08:18:43 +0200 Received: from mx1.redhat.com ([209.132.183.28]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1dqCcQ-0002TH-9N for seabios@seabios.org; Fri, 08 Sep 2017 08:18:36 +0200 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55ACB4E341 for ; Fri, 8 Sep 2017 06:18:37 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-175.ams2.redhat.com [10.36.117.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7DBF80A87; Fri, 8 Sep 2017 06:18:35 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1743B41A80; Fri, 8 Sep 2017 08:18:28 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 55ACB4E341 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 8 Sep 2017 08:18:27 +0200 Message-Id: <20170908061828.13732-6-kraxel@redhat.com> In-Reply-To: <20170908061828.13732-1-kraxel@redhat.com> References: <20170908061828.13732-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 08 Sep 2017 06:18:37 +0000 (UTC) X-Spam-Score: -6.5 (------) Subject: [SeaBIOS] [PATCH 5/6] sercon: split-output implementation X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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/sercon.c | 106 ++++++++++++++++++++++++++++++++++++++++++++-------= ---- src/romlayout.S | 46 ++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 21 deletions(-) diff --git a/src/optionroms.c b/src/optionroms.c index 8665db42e3..76a70ea686 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -442,6 +442,8 @@ vgarom_setup(void) } =20 VgaROM =3D (void*)BUILD_ROM_START; + if (romfile_loadint("etc/sercon-enable", 0)) + sercon_setup(); enable_vga_console(); } =20 diff --git a/src/sercon.c b/src/sercon.c index f785aa8fd9..5699905f32 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" =20 @@ -45,6 +46,9 @@ static void cursor_pos_set(u8 row, u8 col) ****************************************************************/ =20 VARLOW u16 sercon_port; +VARLOW u8 sercon_split; +VARLOW u8 sercon_enable; +VARFSEG struct segoff_s sercon_real_vga_handler; =20 /* * We have a small output buffer here, for lazy output. That allows @@ -64,6 +68,11 @@ VARLOW u8 sercon_attr =3D 0x07; =20 static VAR16 u8 sercon_cmap[8] =3D { '0', '4', '2', '6', '1', '5', '3', '7= ' }; =20 +static int sercon_splitmode(void) +{ + return GET_LOW(sercon_split); +} + static void sercon_putchar(u8 chr) { u16 addr =3D GET_LOW(sercon_port); @@ -174,6 +183,15 @@ static void sercon_print_utf8(u8 chr) } } =20 +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 =3D cursor_pos_row(); @@ -222,7 +240,7 @@ static void sercon_lazy_flush(void) =20 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 +259,7 @@ static void sercon_lazy_backspace(void) =20 static void sercon_lazy_cr(void) { - cursor_pos_set(cursor_pos_row(), 0); + sercon_cursor_pos_set(cursor_pos_row(), 0); } =20 static void sercon_lazy_lf(void) @@ -256,7 +274,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()); } =20 static void sercon_lazy_move_cursor(void) @@ -268,7 +286,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); } } =20 @@ -293,23 +311,28 @@ static void sercon_1000(struct bregs *regs) u8 mode =3D regs->al & 0x7f; u8 rows, cols; =20 - switch (mode) { - case 0x03: - default: - cols =3D 80; - rows =3D 25; - regs->al =3D 0x30; + if (!sercon_splitmode()) { + switch (mode) { + case 0x03: + default: + cols =3D 80; + rows =3D 25; + regs->al =3D 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 { + SET_LOW(sercon_enable, (mode =3D=3D 0x03)); + /* let vgabios handle mode init */ } + SET_LOW(sercon_col_last, 0); SET_LOW(sercon_row_last, 0); SET_LOW(sercon_attr_last, 0); =20 - 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 +349,7 @@ static void sercon_1001(struct bregs *regs) /* Set cursor position */ static void sercon_1002(struct bregs *regs) { - u8 row =3D regs->dh; - u8 col =3D regs->dl; - - cursor_pos_set(row, col); + sercon_cursor_pos_set(regs->dh, regs->dl); } =20 /* Get cursor position */ @@ -427,7 +447,13 @@ static void sercon_100f(struct bregs *regs) /* VBE 2.0 */ static void sercon_104f(struct bregs *regs) { - regs->ax =3D 0x0100; + if (!sercon_splitmode()) { + regs->ax =3D 0x0100; + } else { + // Disable sercon entry point on any vesa modeset + if (regs->al =3D=3D 0x00) + SET_LOW(sercon_enable, 0); + } } =20 static void sercon_10XX(struct bregs *regs) @@ -458,6 +484,31 @@ sercon_10(struct bregs *regs) } } =20 +void VISIBLE16 +sercon_10_splitmode(struct bregs *regs) +{ + if (!CONFIG_SERCON) + return; + if (!GET_LOW(sercon_port)) + return; + + switch (regs->ah) { + case 0x01: + case 0x02: + case 0x03: + case 0x08: + case 0x0f: + /* 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; + case 0x4f: sercon_104f(regs); break; + default: sercon_10XX(regs); break; + } +} + void sercon_setup(void) { if (!CONFIG_SERCON) @@ -466,6 +517,19 @@ void sercon_setup(void) struct segoff_s seabios, vgabios; u16 addr =3D PORT_SERIAL1; =20 + vgabios =3D GET_IVT(0x10); + seabios =3D FUNC16(entry_10); + if (vgabios.seg !=3D seabios.seg || + vgabios.offset !=3D 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_real_vga_handler =3D vgabios; + SET_IVT(0x10, FUNC16(entry_sercon)); + SET_LOW(sercon_split, 1); + } + SET_LOW(sercon_port, addr); outb(0x03, addr + SEROFF_LCR); // 8N1 outb(0x01, addr + 0x02); // enable fifo diff --git a/src/romlayout.S b/src/romlayout.S index 89b3784d60..1c9d56df1b 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -414,6 +414,52 @@ __csm_return: popfw lretw =20 +// Serial console "hooked vga" entry point + DECLFUNC entry_sercon +entry_sercon: + // Setup for chain loading to real vga handler + pushfw + pushl %cs:sercon_real_vga_handler + + // Set %ds to varlow segment + cli + cld + pushw %ds + pushl %eax + movl $_zonelow_seg, %eax + movl %eax, %ds + + // Test if the sercon handler can be called + movl %esp, %eax // Test for broken x86emu + pushl $1f + retl +1: cmpl %esp, %eax + jne 4f + cmpb $0, sercon_enable // Test that sercon is enabled + je 3f + +2: popl %eax + popw %ds + pushl $sercon_10_splitmode +#if CONFIG_ENTRY_EXTRASTACK + jmp irqentry_arg_extrastack +#else + jmp irqentry_arg +#endif + + // sercon disabled - verify not 0x03 modeset and otherwise exit +3: popl %eax + cmpw $0x0003, %ax + jne 5f + pushl %eax + jmp 2b + + // Running on broken x86emu - restore stack and exit +4: movl %eax, %esp + popl %eax +5: popw %ds + iretw + =20 /**************************************************************** * Interrupt entry points --=20 2.9.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios