[SeaBIOS] [PATCH 08/15] Fix finding VESA mode

Kevin O'Connor kevin at koconnor.net
Mon Sep 3 19:57:37 CEST 2012


On Mon, Sep 03, 2012 at 06:12:34PM +0200, Christian Gmeiner wrote:
> 2012/9/3 Kevin O'Connor <kevin at koconnor.net>:
> > On Sat, Sep 01, 2012 at 05:12:59PM +0200, Christian Gmeiner wrote:
> >> With the current code the following happens:
> >>
> >> VBE mode info request: 4101
> >> VBE mode 4101 not found
> >> get_mode failed.
> >>
> >> Looking at the provided mode (cx register) only bits 8-0
> >> define the video mode number. I am not sure if the current
> >> code ever worked.
> >>
> >> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> >> ---
> >>  vgasrc/vbe.c | 17 ++++++++++++++++-
> >>  1 file changed, 16 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c
> >> index 227a244..af72324 100644
> >> --- a/vgasrc/vbe.c
> >> +++ b/vgasrc/vbe.c
> >> @@ -72,9 +72,24 @@ vbe_104f01(struct bregs *regs)
> >>      struct vbe_mode_info *info = (void*)(regs->di+0);
> >>      u16 mode = regs->cx;
> >>
> >> +    /*
> >> +     * Bitfields for VESA/VBE video mode number:
> >> +     *
> >> +     * Bit(s)  Description     (Table 04082)
> >> +     * 15     preserve display memory on mode change
> >> +     * 14     (VBE v2.0+) use linear (flat) frame buffer
> >> +     * 13     (VBE/AF 1.0P) VBE/AF initializes accelerator hardware
> >> +     * 12     reserved for VBE/AF
> >> +     * 11     (VBE v3.0) user user-specified CRTC refresh rate values
> >> +     * 10-9   reserved for future expansion
> >> +     * 8-0    video mode number (0xxh are non-VESA modes, 1xxh are VESA-defined)
> >> +     *
> >> +     * see http://www.ctyme.com/intr/rb-0274.htm
> >> +     */
> >
> > This is true for the call to set mode (vbe_104f02), but the spec does
> > not say this for the get mode info call (104f01).  It would be odd to
> > pass in these additional bits when the caller just wants to get info
> > on the given mode.
> 
> But if I want more information's about mode 0x101 with linear
> framebuffer support - thats
> the only way to get it. Also this is triggered by src/bootsplash.c so
> it seems to be a valid
> use-case.

Okay - looking at this closer.  It looks to me that what bootsplash is
doing is wrong.  However, it also looks like real vgabios will ignore
the bits.  So, I propose changing both bootsplash and the vbe code.

Thanks.

-Kevin


>From c8a3d3ee0194f0bb76e7ec8eeb59d7b986c24016 Mon Sep 17 00:00:00 2001
From: Kevin O'Connor <kevin at koconnor.net>
Date: Mon, 3 Sep 2012 13:52:50 -0400
Subject: [PATCH 1/2] bootsplash: Don't pass mode flags to VBE get_mode_info
 call.
To: seabios at seabios.org

The spec doesn't specify one can pass flags into the get_mode_info
call, so don't do that.

Also, use the VBE_MODE_LINEAR_FRAME_BUFFER name where appropriate.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/bootsplash.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/bootsplash.c b/src/bootsplash.c
index a85e2b2..78023a5 100644
--- a/src/bootsplash.c
+++ b/src/bootsplash.c
@@ -11,7 +11,8 @@
 #include "util.h" // dprintf
 #include "jpeg.h" // splash
 #include "vbe.h" // struct vbe_info
-#include "bmp.h"
+#include "bmp.h" // bmp_alloc
+
 
 /****************************************************************
  * Helper functions
@@ -63,7 +64,7 @@ find_videomode(struct vbe_info *vesa_info, struct vbe_mode_info *mode_info
         struct bregs br;
         memset(&br, 0, sizeof(br));
         br.ax = 0x4f01;
-        br.cx = (1 << 14) | videomode;
+        br.cx = videomode;
         br.di = FLATPTR_TO_OFFSET(mode_info);
         br.es = FLATPTR_TO_SEG(mode_info);
         call16_int10(&br);
@@ -216,7 +217,7 @@ enable_bootsplash(void)
     dprintf(5, "Switching to graphics mode\n");
     memset(&br, 0, sizeof(br));
     br.ax = 0x4f02;
-    br.bx = (1 << 14) | videomode;
+    br.bx = videomode | VBE_MODE_LINEAR_FRAME_BUFFER;
     call16_int10(&br);
     if (br.ax != 0x4f) {
         dprintf(1, "set_mode failed.\n");
-- 
1.7.11.4



>From ef4f9e183751df5ccd32eb5dda2ce6816b53695f Mon Sep 17 00:00:00 2001
From: Kevin O'Connor <kevin at koconnor.net>
Date: Mon, 3 Sep 2012 13:54:28 -0400
Subject: [PATCH 2/2] vgabios: Ignore mode flags in vbe get_mode_info call.
To: seabios at seabios.org

Ignore any mode flags a caller may have set on the vbe get_mode_info
call.  The spec doesn't require ignoring of flags, but it appears at
least some real-world vgabios vbe implementations do this.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 vgasrc/vbe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vgasrc/vbe.c b/vgasrc/vbe.c
index 227a244..01c8071 100644
--- a/vgasrc/vbe.c
+++ b/vgasrc/vbe.c
@@ -74,7 +74,7 @@ vbe_104f01(struct bregs *regs)
 
     dprintf(1, "VBE mode info request: %x\n", mode);
 
-    struct vgamode_s *vmode_g = vgahw_find_mode(mode);
+    struct vgamode_s *vmode_g = vgahw_find_mode(mode & ~MF_VBEFLAGS);
     if (! vmode_g) {
         dprintf(1, "VBE mode %x not found\n", mode);
         regs->ax = 0x014f;
-- 
1.7.11.4




More information about the SeaBIOS mailing list