[SeaBIOS] [PATCH 7/6] sercon: use a single entry point

Gerd Hoffmann posted 6 patches 7 years, 8 months ago
There is a newer version of this series
[SeaBIOS] [PATCH 7/6] sercon: use a single entry point
Posted by Gerd Hoffmann 7 years, 8 months ago
---
 src/config.h    |  1 -
 src/misc.c      |  9 ---------
 src/sercon.c    | 49 ++++++++++++++++++-------------------------------
 src/romlayout.S |  5 +++--
 4 files changed, 21 insertions(+), 43 deletions(-)

diff --git a/src/config.h b/src/config.h
index baca029f0e..93c8dbc2d5 100644
--- a/src/config.h
+++ b/src/config.h
@@ -76,7 +76,6 @@
 #define DEBUG_ISR_08 20
 #define DEBUG_ISR_09 9
 #define DEBUG_ISR_0e 9
-#define DEBUG_HDL_10 20
 #define DEBUG_HDL_11 2
 #define DEBUG_HDL_12 2
 #define DEBUG_HDL_13 10
diff --git a/src/misc.c b/src/misc.c
index f4b656dd35..387a3482c9 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -52,15 +52,6 @@ handle_05(struct bregs *regs)
     debug_enter(regs, DEBUG_HDL_05);
 }
 
-// INT 10h Video Support Service Entry Point
-void VISIBLE16
-handle_10(struct bregs *regs)
-{
-    debug_enter(regs, DEBUG_HDL_10);
-    // don't do anything, since the VGA BIOS handles int10h requests
-    sercon_10(regs);
-}
-
 // NMI handler
 void VISIBLE16
 handle_02(void)
diff --git a/src/sercon.c b/src/sercon.c
index 5699905f32..9c49a2fc4c 100644
--- a/src/sercon.c
+++ b/src/sercon.c
@@ -325,10 +325,10 @@ static void sercon_1000(struct bregs *regs)
         SET_BDA(video_rows, rows-1);
         SET_BDA(cursor_type, 0x0007);
     } else {
-        SET_LOW(sercon_enable, (mode == 0x03));
         /* let vgabios handle mode init */
     }
 
+    SET_LOW(sercon_enable, (mode == 0x03));
     SET_LOW(sercon_col_last, 0);
     SET_LOW(sercon_row_last, 0);
     SET_LOW(sercon_attr_last, 0);
@@ -470,40 +470,26 @@ sercon_10(struct bregs *regs)
         return;
 
     switch (regs->ah) {
-    case 0x00: sercon_1000(regs); break;
-    case 0x01: sercon_1001(regs); break;
-    case 0x02: sercon_1002(regs); break;
-    case 0x03: sercon_1003(regs); break;
-    case 0x06: sercon_1006(regs); break;
-    case 0x08: sercon_1008(regs); break;
-    case 0x09: sercon_1009(regs); break;
-    case 0x0e: sercon_100e(regs); break;
-    case 0x0f: sercon_100f(regs); break;
-    case 0x4f: sercon_104f(regs); break;
-    default:   sercon_10XX(regs); break;
-    }
-}
-
-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;
+        if (sercon_splitmode())
+            /* nothing, vgabios handles it */
+            return;
+    }
+
+    switch (regs->ah) {
     case 0x00: sercon_1000(regs); break;
+    case 0x01: sercon_1001(regs); break;
+    case 0x02: sercon_1002(regs); break;
+    case 0x03: sercon_1003(regs); break;
     case 0x06: sercon_1006(regs); break;
+    case 0x08: sercon_1008(regs); break;
     case 0x09: sercon_1009(regs); break;
     case 0x0e: sercon_100e(regs); break;
+    case 0x0f: sercon_100f(regs); break;
     case 0x4f: sercon_104f(regs); break;
     default:   sercon_10XX(regs); break;
     }
@@ -521,15 +507,16 @@ void sercon_setup(void)
     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);
+        dprintf(1, "sercon: configuring in splitmode (vgabios %04x:%04x)\n",
+                vgabios.seg, vgabios.offset);
         sercon_real_vga_handler = vgabios;
-        SET_IVT(0x10, FUNC16(entry_sercon));
         SET_LOW(sercon_split, 1);
+    } else {
+        dprintf(1, "sercon: configuring as primary display\n");
+        sercon_real_vga_handler = seabios;
     }
 
+    SET_IVT(0x10, FUNC16(entry_sercon));
     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 1c9d56df1b..911a416d7f 100644
--- a/src/romlayout.S
+++ b/src/romlayout.S
@@ -440,7 +440,7 @@ entry_sercon:
 
 2:      popl %eax
         popw %ds
-        pushl $sercon_10_splitmode
+        pushl $sercon_10
 #if CONFIG_ENTRY_EXTRASTACK
         jmp irqentry_arg_extrastack
 #else
@@ -643,7 +643,8 @@ entry_10_0x0f:
         iretw
 
         ORG 0xf065
-        IRQ_ENTRY_ARG 10
+entry_10:
+        iretw
 
         // 0xf0a4 - VideoParams in misc.c
 
-- 
2.9.3


_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios
Re: [SeaBIOS] [PATCH 7/6] sercon: use a single entry point
Posted by Kevin O'Connor 7 years, 8 months ago
On Mon, Sep 11, 2017 at 01:18:15PM +0200, Gerd Hoffmann wrote:
> ---
>  src/config.h    |  1 -
>  src/misc.c      |  9 ---------
>  src/sercon.c    | 49 ++++++++++++++++++-------------------------------
>  src/romlayout.S |  5 +++--
>  4 files changed, 21 insertions(+), 43 deletions(-)
> 
> diff --git a/src/config.h b/src/config.h
> index baca029f0e..93c8dbc2d5 100644
> --- a/src/config.h
> +++ b/src/config.h
> @@ -76,7 +76,6 @@
>  #define DEBUG_ISR_08 20
>  #define DEBUG_ISR_09 9
>  #define DEBUG_ISR_0e 9
> -#define DEBUG_HDL_10 20
>  #define DEBUG_HDL_11 2
>  #define DEBUG_HDL_12 2
>  #define DEBUG_HDL_13 10
> diff --git a/src/misc.c b/src/misc.c
> index f4b656dd35..387a3482c9 100644
> --- a/src/misc.c
> +++ b/src/misc.c
> @@ -52,15 +52,6 @@ handle_05(struct bregs *regs)
>      debug_enter(regs, DEBUG_HDL_05);
>  }
>  
> -// INT 10h Video Support Service Entry Point
> -void VISIBLE16
> -handle_10(struct bregs *regs)
> -{
> -    debug_enter(regs, DEBUG_HDL_10);
> -    // don't do anything, since the VGA BIOS handles int10h requests
> -    sercon_10(regs);
> -}

Thanks.  With all the entry points hardened, I'm good with this
series.  (All my other comments are minor.)

-Kevin

_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios
[SeaBIOS] [PATCH 8/6] sercon: add text modes != 3
Posted by Gerd Hoffmann 7 years, 8 months ago
---
 src/sercon.c    | 11 ++++++++++-
 src/romlayout.S | 12 +++++++-----
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/sercon.c b/src/sercon.c
index 9c49a2fc4c..7d38afb816 100644
--- a/src/sercon.c
+++ b/src/sercon.c
@@ -313,11 +313,20 @@ static void sercon_1000(struct bregs *regs)
 
     if (!sercon_splitmode()) {
         switch (mode) {
+        case 0x00:
+        case 0x01:
+            cols = 40;
+            rows = 25;
+            regs->al = 0x30;
+            break;
+        case 0x02:
         case 0x03:
+        case 0x07:
         default:
             cols = 80;
             rows = 25;
             regs->al = 0x30;
+            break;
         }
         cursor_pos_set(0, 0);
         SET_BDA(video_mode, mode);
@@ -328,7 +337,7 @@ static void sercon_1000(struct bregs *regs)
         /* let vgabios handle mode init */
     }
 
-    SET_LOW(sercon_enable, (mode == 0x03));
+    SET_LOW(sercon_enable, (mode <= 0x03) || (mode == 0x07));
     SET_LOW(sercon_col_last, 0);
     SET_LOW(sercon_row_last, 0);
     SET_LOW(sercon_attr_last, 0);
diff --git a/src/romlayout.S b/src/romlayout.S
index 911a416d7f..2ef857103e 100644
--- a/src/romlayout.S
+++ b/src/romlayout.S
@@ -434,7 +434,7 @@ entry_sercon:
         pushl $1f
         retl
 1:      cmpl %esp, %eax
-        jne 4f
+        jne 5f
         cmpb $0, sercon_enable  // Test that sercon is enabled
         je 3f
 
@@ -449,15 +449,17 @@ entry_sercon:
 
         // sercon disabled - verify not 0x03 modeset and otherwise exit
 3:      popl %eax
+        cmpw $0x0007, %ax
+        je 4f
         cmpw $0x0003, %ax
-        jne 5f
-        pushl %eax
+        jg 6f
+4:      pushl %eax
         jmp 2b
 
         // Running on broken x86emu - restore stack and exit
-4:      movl %eax, %esp
+5:      movl %eax, %esp
         popl %eax
-5:      popw %ds
+6:      popw %ds
         iretw
 
 
-- 
2.9.3


_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios
Re: [SeaBIOS] [PATCH 8/6] sercon: add text modes != 3
Posted by Kevin O'Connor 7 years, 8 months ago
On Mon, Sep 11, 2017 at 01:18:16PM +0200, Gerd Hoffmann wrote:
[...]
> --- a/src/romlayout.S
> +++ b/src/romlayout.S
> @@ -434,7 +434,7 @@ entry_sercon:
>          pushl $1f
>          retl
>  1:      cmpl %esp, %eax
> -        jne 4f
> +        jne 5f
>          cmpb $0, sercon_enable  // Test that sercon is enabled
>          je 3f
>  
> @@ -449,15 +449,17 @@ entry_sercon:
>  
>          // sercon disabled - verify not 0x03 modeset and otherwise exit
>  3:      popl %eax
> +        cmpw $0x0007, %ax
> +        je 4f
>          cmpw $0x0003, %ax
> -        jne 5f
> -        pushl %eax
> +        jg 6f
> +4:      pushl %eax
>          jmp 2b
>  
>          // Running on broken x86emu - restore stack and exit
> -4:      movl %eax, %esp
> +5:      movl %eax, %esp
>          popl %eax
> -5:      popw %ds
> +6:      popw %ds
>          iretw

The asm could be simplified a bit:

// 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 zonelow 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

        // Call handle_sercon()
        popl %eax
        popw %ds
2:      pushl $handle_sercon
#if CONFIG_ENTRY_EXTRASTACK
        jmp irqentry_arg_extrastack
#else
        jmp irqentry_arg
#endif

        // sercon disabled - check for legacy text modeset and otherwise exit
3:      popl %eax
        popw %ds
        cmpw $0x0007, %ax
        jle 2b
        iretw

        // Running on broken x86emu - restore stack and exit
4:      movl %eax, %esp
        popl %eax
        popw %ds
        iretw

_______________________________________________
SeaBIOS mailing list
SeaBIOS@seabios.org
https://mail.coreboot.org/mailman/listinfo/seabios