[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/boot: make "vga=current" work with graphics modes



commit 927aee59826fbebb87f099cc95b945f1dcb1ba5c
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Apr 11 12:29:14 2022 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Apr 11 12:29:14 2022 +0200

    x86/boot: make "vga=current" work with graphics modes
    
    GrUB2 can be told to leave the screen in the graphics mode it has been
    using (or any other one), via "set gfxpayload=keep" (or suitable
    variants thereof). In this case we can avoid doing another mode switch
    ourselves. This in particular avoids possibly setting the screen to a
    less desirable mode: On one of my test systems the set of modes
    reported available by the VESA BIOS depends on whether the interposed
    KVM switch has that machine set as the active one. If it's not active,
    only modes up to 1024x768 get reported, while when active 1280x1024
    modes are also included. For things to always work with an explicitly
    specified mode (via the "vga=" option), that mode therefore needs be a
    1024x768 one.
    
    For some reason this only works for me with "multiboot2" (and
    "module2"); "multiboot" (and "module") still forces the screen into text
    mode, despite my reading of the sources suggesting otherwise.
    
    For starters I'm limiting this to graphics modes; I do think this ought
    to also work for text modes, but
    - I can't tell whether GrUB2 can set any text mode other than 80x25
      (I've only found plain "text" to be valid as a "gfxpayload" setting),
    - I'm uncertain whether supporting that is worth it, since I'm uncertain
      how many people would be running their systems/screens in text mode,
    - I'd like to limit the amount of code added to the realmode trampoline.
    
    For starters I'm also limiting mode information retrieval to raw BIOS
    accesses. This will allow things to work (in principle) also with other
    boot environments where a graphics mode can be left in place. The
    downside is that this then still is dependent upon switching back to
    real mode, so retrieving the needed information from multiboot info is
    likely going to be desirable down the road.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Acked-by: Henry Wang <Henry.Wang@xxxxxxx>
---
 CHANGELOG.md              |  4 ++++
 xen/arch/x86/boot/video.S | 34 +++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83d85fad5b..6a7755d7b0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@ The format is based on [Keep a 
Changelog](https://keepachangelog.com/en/1.0.0/)
 
 ## [unstable 
UNRELEASED](https://xenbits.xen.org/gitweb/?p=xen.git;a=shortlog;h=staging) - 
TBD
 
+### Changed
+ - On x86 "vga=current" can now be used together with GrUB2's gfxpayload 
setting. Note that
+   this requires use of "multiboot2" (and "module2") as the GrUB commands 
loading Xen.
+
 ### Removed / support downgraded
  - dropped support for the (x86-only) "vesa-mtrr" and "vesa-remap" command 
line options
 
diff --git a/xen/arch/x86/boot/video.S b/xen/arch/x86/boot/video.S
index ee993e1073..1b3f363fc4 100644
--- a/xen/arch/x86/boot/video.S
+++ b/xen/arch/x86/boot/video.S
@@ -566,7 +566,6 @@ set14:  movw    $0x1111, %ax            # Use 9x14 font
         movb    $0x01, %ah              # Define cursor scan lines 11-12
         movw    $0x0b0c, %cx
         int     $0x10
-set_current:
         stc
         ret
 
@@ -680,6 +679,39 @@ vga_modes:
         .word   VIDEO_80x60, 0x50,0x3c,0        # 80x60
 vga_modes_end:
 
+# If the current mode is a VESA graphics one, obtain its parameters.
+set_current:
+        leaw    vesa_glob_info, %di
+        movw    $0x4f00, %ax
+        int     $0x10
+        cmpw    $0x004f, %ax
+        jne     .Lsetc_done
+
+        movw    $0x4f03, %ax
+        int     $0x10
+        cmpw    $0x004f, %ax
+        jne     .Lsetc_done
+
+        leaw    vesa_mode_info, %di     # Get mode information structure
+        movw    %bx, %cx
+        movw    $0x4f01, %ax
+        int     $0x10
+        cmpw    $0x004f, %ax
+        jne     .Lsetc_done
+
+        movb    (%di), %al              # Check mode attributes
+        andb    $0x9b, %al
+        cmpb    $0x9b, %al
+        jne     .Lsetc_done             # Doh! No linear frame buffer
+
+        movb    $1, bootsym(graphic_mode)
+        movw    %bx, bootsym(boot_vid_mode)
+        movw    %bx, bootsym(video_mode)
+
+.Lsetc_done:
+        stc
+        ret
+
 # Detect VESA modes.
 vesa_modes:
         movw    %di, %bp                # BP=original mode table end
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.