~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/boot/video-bios.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /* -*- linux-c -*- ------------------------------------------------------- *
  3  *
  4  *   Copyright (C) 1991, 1992 Linus Torvalds
  5  *   Copyright 2007 rPath, Inc. - All Rights Reserved
  6  *   Copyright 2009 Intel Corporation; author H. Peter Anvin
  7  *
  8  * ----------------------------------------------------------------------- */
  9 
 10 /*
 11  * Standard video BIOS modes
 12  *
 13  * We have two options for this; silent and scanned.
 14  */
 15 
 16 #include "boot.h"
 17 #include "video.h"
 18 
 19 static __videocard video_bios;
 20 
 21 /* Set a conventional BIOS mode */
 22 static int set_bios_mode(u8 mode);
 23 
 24 static int bios_set_mode(struct mode_info *mi)
 25 {
 26         return set_bios_mode(mi->mode - VIDEO_FIRST_BIOS);
 27 }
 28 
 29 static int set_bios_mode(u8 mode)
 30 {
 31         struct biosregs ireg, oreg;
 32         u8 new_mode;
 33 
 34         initregs(&ireg);
 35         ireg.al = mode;         /* AH=0x00 Set Video Mode */
 36         intcall(0x10, &ireg, NULL);
 37 
 38         ireg.ah = 0x0f;         /* Get Current Video Mode */
 39         intcall(0x10, &ireg, &oreg);
 40 
 41         do_restore = 1;         /* Assume video contents were lost */
 42 
 43         /* Not all BIOSes are clean with the top bit */
 44         new_mode = oreg.al & 0x7f;
 45 
 46         if (new_mode == mode)
 47                 return 0;       /* Mode change OK */
 48 
 49 #ifndef _WAKEUP
 50         if (new_mode != boot_params.screen_info.orig_video_mode) {
 51                 /* Mode setting failed, but we didn't end up where we
 52                    started.  That's bad.  Try to revert to the original
 53                    video mode. */
 54                 ireg.ax = boot_params.screen_info.orig_video_mode;
 55                 intcall(0x10, &ireg, NULL);
 56         }
 57 #endif
 58         return -1;
 59 }
 60 
 61 static int bios_probe(void)
 62 {
 63         u8 mode;
 64 #ifdef _WAKEUP
 65         u8 saved_mode = 0x03;
 66 #else
 67         u8 saved_mode = boot_params.screen_info.orig_video_mode;
 68 #endif
 69         u16 crtc;
 70         struct mode_info *mi;
 71         int nmodes = 0;
 72 
 73         if (adapter != ADAPTER_EGA && adapter != ADAPTER_VGA)
 74                 return 0;
 75 
 76         set_fs(0);
 77         crtc = vga_crtc();
 78 
 79         video_bios.modes = GET_HEAP(struct mode_info, 0);
 80 
 81         for (mode = 0x14; mode <= 0x7f; mode++) {
 82                 if (!heap_free(sizeof(struct mode_info)))
 83                         break;
 84 
 85                 if (mode_defined(VIDEO_FIRST_BIOS+mode))
 86                         continue;
 87 
 88                 if (set_bios_mode(mode))
 89                         continue;
 90 
 91                 /* Try to verify that it's a text mode. */
 92 
 93                 /* Attribute Controller: make graphics controller disabled */
 94                 if (in_idx(0x3c0, 0x10) & 0x01)
 95                         continue;
 96 
 97                 /* Graphics Controller: verify Alpha addressing enabled */
 98                 if (in_idx(0x3ce, 0x06) & 0x01)
 99                         continue;
100 
101                 /* CRTC cursor location low should be zero(?) */
102                 if (in_idx(crtc, 0x0f))
103                         continue;
104 
105                 mi = GET_HEAP(struct mode_info, 1);
106                 mi->mode = VIDEO_FIRST_BIOS+mode;
107                 mi->depth = 0;  /* text */
108                 mi->x = rdfs16(0x44a);
109                 mi->y = rdfs8(0x484)+1;
110                 nmodes++;
111         }
112 
113         set_bios_mode(saved_mode);
114 
115         return nmodes;
116 }
117 
118 static __videocard video_bios =
119 {
120         .card_name      = "BIOS",
121         .probe          = bios_probe,
122         .set_mode       = bios_set_mode,
123         .unsafe         = 1,
124         .xmode_first    = VIDEO_FIRST_BIOS,
125         .xmode_n        = 0x80,
126 };
127 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php