1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
9 * ----------------------------------------------------------------------- */
12 * arch/i386/boot/video-bios.c
14 * Standard video BIOS modes
16 * We have two options for this; silent and scanned.
22 __videocard video_bios
;
24 /* Set a conventional BIOS mode */
25 static int set_bios_mode(u8 mode
);
27 static int bios_set_mode(struct mode_info
*mi
)
29 return set_bios_mode(mi
->mode
- VIDEO_FIRST_BIOS
);
32 static int set_bios_mode(u8 mode
)
37 ax
= mode
; /* AH=0x00 Set Video Mode */
40 : : "ebx", "ecx", "edx", "esi", "edi");
42 ax
= 0x0f00; /* Get Current Video Mode */
45 : : "ebx", "ecx", "edx", "esi", "edi");
47 do_restore
= 1; /* Assume video contents were lost */
48 new_mode
= ax
& 0x7f; /* Not all BIOSes are clean with the top bit */
51 return 0; /* Mode change OK */
54 if (new_mode
!= boot_params
.screen_info
.orig_video_mode
) {
55 /* Mode setting failed, but we didn't end up where we
56 started. That's bad. Try to revert to the original
58 ax
= boot_params
.screen_info
.orig_video_mode
;
61 : : "ebx", "ecx", "edx", "esi", "edi");
67 static int bios_probe(void)
73 u8 saved_mode
= boot_params
.screen_info
.orig_video_mode
;
79 if (adapter
!= ADAPTER_EGA
&& adapter
!= ADAPTER_VGA
)
85 video_bios
.modes
= GET_HEAP(struct mode_info
, 0);
87 for (mode
= 0x14; mode
<= 0x7f; mode
++) {
88 if (!heap_free(sizeof(struct mode_info
)))
91 if (mode_defined(VIDEO_FIRST_BIOS
+mode
))
94 if (set_bios_mode(mode
))
97 /* Try to verify that it's a text mode. */
99 /* Attribute Controller: make graphics controller disabled */
100 if (in_idx(0x3c0, 0x10) & 0x01)
103 /* Graphics Controller: verify Alpha addressing enabled */
104 if (in_idx(0x3ce, 0x06) & 0x01)
107 /* CRTC cursor location low should be zero(?) */
108 if (in_idx(crtc
, 0x0f))
111 mi
= GET_HEAP(struct mode_info
, 1);
112 mi
->mode
= VIDEO_FIRST_BIOS
+mode
;
113 mi
->depth
= 0; /* text */
114 mi
->x
= rdfs16(0x44a);
115 mi
->y
= rdfs8(0x484)+1;
119 set_bios_mode(saved_mode
);
124 __videocard video_bios
=
128 .set_mode
= bios_set_mode
,
130 .xmode_first
= VIDEO_FIRST_BIOS
,