Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf06de7b authored by H. Peter Anvin's avatar H. Peter Anvin Committed by H. Peter Anvin
Browse files

x86, setup: "glove box" BIOS interrupts in the video code



Impact: BIOS proofing

"Glove box" off BIOS interrupts in the video code.

LKML-Reference: <49DE7F79.4030106@zytor.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
parent 0a706db3
Loading
Loading
Loading
Loading
+13 −14
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@
 *
 *
 *   Copyright (C) 1991, 1992 Linus Torvalds
 *   Copyright (C) 1991, 1992 Linus Torvalds
 *   Copyright 2007 rPath, Inc. - All Rights Reserved
 *   Copyright 2007 rPath, Inc. - All Rights Reserved
 *   Copyright 2009 Intel Corporation; author H. Peter Anvin
 *
 *
 *   This file is part of the Linux kernel, and is made available under
 *   This file is part of the Linux kernel, and is made available under
 *   the terms of the GNU General Public License version 2.
 *   the terms of the GNU General Public License version 2.
@@ -29,21 +30,21 @@ static int bios_set_mode(struct mode_info *mi)


static int set_bios_mode(u8 mode)
static int set_bios_mode(u8 mode)
{
{
	u16 ax;
	struct biosregs ireg, oreg;
	u8 new_mode;
	u8 new_mode;


	ax = mode;		/* AH=0x00 Set Video Mode */
	initregs(&ireg);
	asm volatile(INT10
	ireg.al = mode;		/* AH=0x00 Set Video Mode */
		     : "+a" (ax)
	intcall(0x10, &ireg, NULL);
		     : : "ebx", "ecx", "edx", "esi", "edi");


	ax = 0x0f00;		/* Get Current Video Mode */

	asm volatile(INT10
	ireg.ah = 0x0f;		/* Get Current Video Mode */
		     : "+a" (ax)
	intcall(0x10, &ireg, &oreg);
		     : : "ebx", "ecx", "edx", "esi", "edi");


	do_restore = 1;		/* Assume video contents were lost */
	do_restore = 1;		/* Assume video contents were lost */
	new_mode = ax & 0x7f;	/* Not all BIOSes are clean with the top bit */

	/* Not all BIOSes are clean with the top bit */
	new_mode = ireg.al & 0x7f;


	if (new_mode == mode)
	if (new_mode == mode)
		return 0;	/* Mode change OK */
		return 0;	/* Mode change OK */
@@ -53,10 +54,8 @@ static int set_bios_mode(u8 mode)
		/* Mode setting failed, but we didn't end up where we
		/* Mode setting failed, but we didn't end up where we
		   started.  That's bad.  Try to revert to the original
		   started.  That's bad.  Try to revert to the original
		   video mode. */
		   video mode. */
		ax = boot_params.screen_info.orig_video_mode;
		ireg.ax = boot_params.screen_info.orig_video_mode;
		asm volatile(INT10
		intcall(0x10, &ireg, NULL);
			     : "+a" (ax)
			     : : "ebx", "ecx", "edx", "esi", "edi");
	}
	}
#endif
#endif
	return -1;
	return -1;
+60 −77
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@
 *
 *
 *   Copyright (C) 1991, 1992 Linus Torvalds
 *   Copyright (C) 1991, 1992 Linus Torvalds
 *   Copyright 2007 rPath, Inc. - All Rights Reserved
 *   Copyright 2007 rPath, Inc. - All Rights Reserved
 *   Copyright 2009 Intel Corporation; author H. Peter Anvin
 *
 *
 *   This file is part of the Linux kernel, and is made available under
 *   This file is part of the Linux kernel, and is made available under
 *   the terms of the GNU General Public License version 2.
 *   the terms of the GNU General Public License version 2.
@@ -31,7 +32,7 @@ static inline void vesa_store_mode_params_graphics(void) {}
static int vesa_probe(void)
static int vesa_probe(void)
{
{
#if defined(CONFIG_VIDEO_VESA) || defined(CONFIG_FIRMWARE_EDID)
#if defined(CONFIG_VIDEO_VESA) || defined(CONFIG_FIRMWARE_EDID)
	u16 ax, cx, di;
	struct biosregs ireg, oreg;
	u16 mode;
	u16 mode;
	addr_t mode_ptr;
	addr_t mode_ptr;
	struct mode_info *mi;
	struct mode_info *mi;
@@ -39,13 +40,12 @@ static int vesa_probe(void)


	video_vesa.modes = GET_HEAP(struct mode_info, 0);
	video_vesa.modes = GET_HEAP(struct mode_info, 0);


	ax = 0x4f00;
	initregs(&ireg);
	di = (size_t)&vginfo;
	ireg.ax = 0x4f00;
	asm(INT10
	ireg.di = (size_t)&vginfo;
	    : "+a" (ax), "+D" (di), "=m" (vginfo)
	intcall(0x10, &ireg, &oreg);
	    : : "ebx", "ecx", "edx", "esi");


	if (ax != 0x004f ||
	if (ireg.ax != 0x004f ||
	    vginfo.signature != VESA_MAGIC ||
	    vginfo.signature != VESA_MAGIC ||
	    vginfo.version < 0x0102)
	    vginfo.version < 0x0102)
		return 0;	/* Not present */
		return 0;	/* Not present */
@@ -65,14 +65,12 @@ static int vesa_probe(void)


		memset(&vminfo, 0, sizeof vminfo); /* Just in case... */
		memset(&vminfo, 0, sizeof vminfo); /* Just in case... */


		ax = 0x4f01;
		ireg.ax = 0x4f01;
		cx = mode;
		ireg.cx = mode;
		di = (size_t)&vminfo;
		ireg.di = (size_t)&vminfo;
		asm(INT10
		intcall(0x10, &ireg, &oreg);
		    : "+a" (ax), "+c" (cx), "+D" (di), "=m" (vminfo)
		    : : "ebx", "edx", "esi");


		if (ax != 0x004f)
		if (ireg.ax != 0x004f)
			continue;
			continue;


		if ((vminfo.mode_attr & 0x15) == 0x05) {
		if ((vminfo.mode_attr & 0x15) == 0x05) {
@@ -111,20 +109,19 @@ static int vesa_probe(void)


static int vesa_set_mode(struct mode_info *mode)
static int vesa_set_mode(struct mode_info *mode)
{
{
	u16 ax, bx, cx, di;
	struct biosregs ireg, oreg;
	int is_graphic;
	int is_graphic;
	u16 vesa_mode = mode->mode - VIDEO_FIRST_VESA;
	u16 vesa_mode = mode->mode - VIDEO_FIRST_VESA;


	memset(&vminfo, 0, sizeof vminfo); /* Just in case... */
	memset(&vminfo, 0, sizeof vminfo); /* Just in case... */


	ax = 0x4f01;
	initregs(&ireg);
	cx = vesa_mode;
	ireg.ax = 0x4f01;
	di = (size_t)&vminfo;
	ireg.cx = vesa_mode;
	asm(INT10
	ireg.di = (size_t)&vminfo;
	    : "+a" (ax), "+c" (cx), "+D" (di), "=m" (vminfo)
	intcall(0x10, &ireg, &oreg);
	    : : "ebx", "edx", "esi");


	if (ax != 0x004f)
	if (oreg.ax != 0x004f)
		return -1;
		return -1;


	if ((vminfo.mode_attr & 0x15) == 0x05) {
	if ((vminfo.mode_attr & 0x15) == 0x05) {
@@ -141,14 +138,12 @@ static int vesa_set_mode(struct mode_info *mode)
	}
	}




	ax = 0x4f02;
	initregs(&ireg);
	bx = vesa_mode;
	ireg.ax = 0x4f02;
	di = 0;
	ireg.bx = vesa_mode;
	asm volatile(INT10
	intcall(0x10, &ireg, &oreg);
		     : "+a" (ax), "+b" (bx), "+D" (di)
		     : : "ecx", "edx", "esi");


	if (ax != 0x004f)
	if (oreg.ax != 0x004f)
		return -1;
		return -1;


	graphic_mode = is_graphic;
	graphic_mode = is_graphic;
@@ -171,20 +166,17 @@ static int vesa_set_mode(struct mode_info *mode)
/* Switch DAC to 8-bit mode */
/* Switch DAC to 8-bit mode */
static void vesa_dac_set_8bits(void)
static void vesa_dac_set_8bits(void)
{
{
	struct biosregs ireg, oreg;
	u8 dac_size = 6;
	u8 dac_size = 6;


	/* If possible, switch the DAC to 8-bit mode */
	/* If possible, switch the DAC to 8-bit mode */
	if (vginfo.capabilities & 1) {
	if (vginfo.capabilities & 1) {
		u16 ax, bx;
		initregs(&ireg);

		ireg.ax = 0x4f08;
		ax = 0x4f08;
		ireg.bh = 0x08;
		bx = 0x0800;
		intcall(0x10, &ireg, &oreg);
		asm volatile(INT10
		if (oreg.ax == 0x004f)
			     : "+a" (ax), "+b" (bx)
			dac_size = oreg.bh;
			     : : "ecx", "edx", "esi", "edi");

		if (ax == 0x004f)
			dac_size = bx >> 8;
	}
	}


	/* Set the color sizes to the DAC size, and offsets to 0 */
	/* Set the color sizes to the DAC size, and offsets to 0 */
@@ -202,19 +194,17 @@ static void vesa_dac_set_8bits(void)
/* Save the VESA protected mode info */
/* Save the VESA protected mode info */
static void vesa_store_pm_info(void)
static void vesa_store_pm_info(void)
{
{
	u16 ax, bx, di, es;
	struct biosregs ireg, oreg;


	ax = 0x4f0a;
	initregs(&ireg);
	bx = di = 0;
	ireg.ax = 0x4f0a;
	asm("pushw %%es; "INT10"; movw %%es,%0; popw %%es"
	intcall(0x10, &ireg, &oreg);
	    : "=d" (es), "+a" (ax), "+b" (bx), "+D" (di)
	    : : "ecx", "esi");


	if (ax != 0x004f)
	if (oreg.ax != 0x004f)
		return;
		return;


	boot_params.screen_info.vesapm_seg = es;
	boot_params.screen_info.vesapm_seg = oreg.es;
	boot_params.screen_info.vesapm_off = di;
	boot_params.screen_info.vesapm_off = oreg.di;
}
}


/*
/*
@@ -252,7 +242,7 @@ static void vesa_store_mode_params_graphics(void)
void vesa_store_edid(void)
void vesa_store_edid(void)
{
{
#ifdef CONFIG_FIRMWARE_EDID
#ifdef CONFIG_FIRMWARE_EDID
	u16 ax, bx, cx, dx, di;
	struct biosregs ireg, oreg;


	/* Apparently used as a nonsense token... */
	/* Apparently used as a nonsense token... */
	memset(&boot_params.edid_info, 0x13, sizeof boot_params.edid_info);
	memset(&boot_params.edid_info, 0x13, sizeof boot_params.edid_info);
@@ -260,33 +250,26 @@ void vesa_store_edid(void)
	if (vginfo.version < 0x0200)
	if (vginfo.version < 0x0200)
		return;		/* EDID requires VBE 2.0+ */
		return;		/* EDID requires VBE 2.0+ */


	ax = 0x4f15;		/* VBE DDC */
	initregs(&ireg);
	bx = 0x0000;		/* Report DDC capabilities */
	ireg.ax = 0x4f15;		/* VBE DDC */
	cx = 0;			/* Controller 0 */
	/* ireg.bx = 0x0000; */		/* Report DDC capabilities */
	di = 0;			/* ES:DI must be 0 by spec */
	/* ireg.cx = 0;	*/		/* Controller 0 */

	ireg.es = 0;			/* ES:DI must be 0 by spec */
	/* Note: The VBE DDC spec is different from the main VESA spec;
	intcall(0x10, &ireg, &oreg);
	   we genuinely have to assume all registers are destroyed here. */

	asm("pushw %%es; movw %2,%%es; "INT10"; popw %%es"
	    : "+a" (ax), "+b" (bx), "+c" (cx), "+D" (di)
	    : : "esi", "edx");


	if (ax != 0x004f)
	if (oreg.ax != 0x004f)
		return;		/* No EDID */
		return;		/* No EDID */


	/* BH = time in seconds to transfer EDD information */
	/* BH = time in seconds to transfer EDD information */
	/* BL = DDC level supported */
	/* BL = DDC level supported */


	ax = 0x4f15;		/* VBE DDC */
	ireg.ax = 0x4f15;		/* VBE DDC */
	bx = 0x0001;		/* Read EDID */
	ireg.bx = 0x0001;		/* Read EDID */
	cx = 0;			/* Controller 0 */
	/* ireg.cx = 0; */		/* Controller 0 */
	dx = 0;			/* EDID block number */
	/* ireg.dx = 0;	*/		/* EDID block number */
	di =(size_t) &boot_params.edid_info; /* (ES:)Pointer to block */
	ireg.es = ds();
	asm(INT10
	ireg.di =(size_t)&boot_params.edid_info; /* (ES:)Pointer to block */
	    : "+a" (ax), "+b" (bx), "+d" (dx), "=m" (boot_params.edid_info),
	intcall(0x10, &ireg, &oreg);
	      "+c" (cx), "+D" (di)
	    : : "esi");
#endif /* CONFIG_FIRMWARE_EDID */
#endif /* CONFIG_FIRMWARE_EDID */
}
}


+59 −36
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@
 *
 *
 *   Copyright (C) 1991, 1992 Linus Torvalds
 *   Copyright (C) 1991, 1992 Linus Torvalds
 *   Copyright 2007 rPath, Inc. - All Rights Reserved
 *   Copyright 2007 rPath, Inc. - All Rights Reserved
 *   Copyright 2009 Intel Corporation; author H. Peter Anvin
 *
 *
 *   This file is part of the Linux kernel, and is made available under
 *   This file is part of the Linux kernel, and is made available under
 *   the terms of the GNU General Public License version 2.
 *   the terms of the GNU General Public License version 2.
@@ -39,30 +40,30 @@ static __videocard video_vga;
/* Set basic 80x25 mode */
/* Set basic 80x25 mode */
static u8 vga_set_basic_mode(void)
static u8 vga_set_basic_mode(void)
{
{
	struct biosregs ireg, oreg;
	u16 ax;
	u16 ax;
	u8 rows;
	u8 rows;
	u8 mode;
	u8 mode;


	initregs(&ireg);

#ifdef CONFIG_VIDEO_400_HACK
#ifdef CONFIG_VIDEO_400_HACK
	if (adapter >= ADAPTER_VGA) {
	if (adapter >= ADAPTER_VGA) {
		asm volatile(INT10
		ireg.ax = 0x1202;
			     : : "a" (0x1202), "b" (0x0030)
		ireg.bx = 0x0030;
			     : "ecx", "edx", "esi", "edi");
		intcall(0x10, &ireg, NULL);
	}
	}
#endif
#endif


	ax = 0x0f00;
	ax = 0x0f00;
	asm volatile(INT10
	intcall(0x10, &ireg, &oreg);
		     : "+a" (ax)
	mode = oreg.al;
		     : : "ebx", "ecx", "edx", "esi", "edi");

	mode = (u8)ax;


	set_fs(0);
	set_fs(0);
	rows = rdfs8(0x484);	/* rows minus one */
	rows = rdfs8(0x484);	/* rows minus one */


#ifndef CONFIG_VIDEO_400_HACK
#ifndef CONFIG_VIDEO_400_HACK
	if ((ax == 0x5003 || ax == 0x5007) &&
	if ((oreg.ax == 0x5003 || oreg.ax == 0x5007) &&
	    (rows == 0 || rows == 24))
	    (rows == 0 || rows == 24))
		return mode;
		return mode;
#endif
#endif
@@ -71,10 +72,8 @@ static u8 vga_set_basic_mode(void)
		mode = 3;
		mode = 3;


	/* Set the mode */
	/* Set the mode */
	ax = mode;
	ireg.ax = mode;		/* AH=0: set mode */
	asm volatile(INT10
	intcall(0x10, &ireg, NULL);
		     : "+a" (ax)
		     : : "ebx", "ecx", "edx", "esi", "edi");
	do_restore = 1;
	do_restore = 1;
	return mode;
	return mode;
}
}
@@ -82,43 +81,69 @@ static u8 vga_set_basic_mode(void)
static void vga_set_8font(void)
static void vga_set_8font(void)
{
{
	/* Set 8x8 font - 80x43 on EGA, 80x50 on VGA */
	/* Set 8x8 font - 80x43 on EGA, 80x50 on VGA */
	struct biosregs ireg;

	initregs(&ireg);


	/* Set 8x8 font */
	/* Set 8x8 font */
	asm volatile(INT10 : : "a" (0x1112), "b" (0));
	ireg.ax = 0x1112;
	/* ireg.bl = 0; */
	intcall(0x10, &ireg, NULL);


	/* Use alternate print screen */
	/* Use alternate print screen */
	asm volatile(INT10 : : "a" (0x1200), "b" (0x20));
	ireg.ax = 0x1200;
	ireg.bl = 0x20;
	intcall(0x10, &ireg, NULL);


	/* Turn off cursor emulation */
	/* Turn off cursor emulation */
	asm volatile(INT10 : : "a" (0x1201), "b" (0x34));
	ireg.ax = 0x1201;
	ireg.bl = 0x34;
	intcall(0x10, &ireg, NULL);


	/* Cursor is scan lines 6-7 */
	/* Cursor is scan lines 6-7 */
	asm volatile(INT10 : : "a" (0x0100), "c" (0x0607));
	ireg.ax = 0x0100;
	ireg.cx = 0x0607;
	intcall(0x10, &ireg, NULL);
}
}


static void vga_set_14font(void)
static void vga_set_14font(void)
{
{
	/* Set 9x14 font - 80x28 on VGA */
	/* Set 9x14 font - 80x28 on VGA */
	struct biosregs ireg;

	initregs(&ireg);


	/* Set 9x14 font */
	/* Set 9x14 font */
	asm volatile(INT10 : : "a" (0x1111), "b" (0));
	ireg.ax = 0x1111;
	/* ireg.bl = 0; */
	intcall(0x10, &ireg, NULL);


	/* Turn off cursor emulation */
	/* Turn off cursor emulation */
	asm volatile(INT10 : : "a" (0x1201), "b" (0x34));
	ireg.ax = 0x1201;
	ireg.bl = 0x34;
	intcall(0x10, &ireg, NULL);


	/* Cursor is scan lines 11-12 */
	/* Cursor is scan lines 11-12 */
	asm volatile(INT10 : : "a" (0x0100), "c" (0x0b0c));
	ireg.ax = 0x0100;
	ireg.cx = 0x0b0c;
	intcall(0x10, &ireg, NULL);
}
}


static void vga_set_80x43(void)
static void vga_set_80x43(void)
{
{
	/* Set 80x43 mode on VGA (not EGA) */
	/* Set 80x43 mode on VGA (not EGA) */
	struct biosregs ireg;

	initregs(&ireg);


	/* Set 350 scans */
	/* Set 350 scans */
	asm volatile(INT10 : : "a" (0x1201), "b" (0x30));
	ireg.ax = 0x1201;
	ireg.bl = 0x30;
	intcall(0x10, &ireg, NULL);


	/* Reset video mode */
	/* Reset video mode */
	asm volatile(INT10 : : "a" (0x0003));
	ireg.ax = 0x0003;
	intcall(0x10, &ireg, NULL);


	vga_set_8font();
	vga_set_8font();
}
}
@@ -225,8 +250,6 @@ static int vga_set_mode(struct mode_info *mode)
 */
 */
static int vga_probe(void)
static int vga_probe(void)
{
{
	u16 ega_bx;

	static const char *card_name[] = {
	static const char *card_name[] = {
		"CGA/MDA/HGC", "EGA", "VGA"
		"CGA/MDA/HGC", "EGA", "VGA"
	};
	};
@@ -240,26 +263,26 @@ static int vga_probe(void)
		sizeof(ega_modes)/sizeof(struct mode_info),
		sizeof(ega_modes)/sizeof(struct mode_info),
		sizeof(vga_modes)/sizeof(struct mode_info),
		sizeof(vga_modes)/sizeof(struct mode_info),
	};
	};
	u8 vga_flag;


	asm(INT10
	struct biosregs ireg, oreg;
	    : "=b" (ega_bx)

	    : "a" (0x1200), "b" (0x10) /* Check EGA/VGA */
	initregs(&ireg);
	    : "ecx", "edx", "esi", "edi");

	ireg.ax = 0x1200;
	ireg.bl = 0x10;		/* Check EGA/VGA */
	intcall(0x10, &ireg, &oreg);


#ifndef _WAKEUP
#ifndef _WAKEUP
	boot_params.screen_info.orig_video_ega_bx = ega_bx;
	boot_params.screen_info.orig_video_ega_bx = oreg.bx;
#endif
#endif


	/* If we have MDA/CGA/HGC then BL will be unchanged at 0x10 */
	/* If we have MDA/CGA/HGC then BL will be unchanged at 0x10 */
	if ((u8)ega_bx != 0x10) {
	if (oreg.bl != 0x10) {
		/* EGA/VGA */
		/* EGA/VGA */
		asm(INT10
		ireg.ax = 0x1a00;
		    : "=a" (vga_flag)
		intcall(0x10, &ireg, &oreg);
		    : "a" (0x1a00)
		    : "ebx", "ecx", "edx", "esi", "edi");


		if (vga_flag == 0x1a) {
		if (oreg.al == 0x1a) {
			adapter = ADAPTER_VGA;
			adapter = ADAPTER_VGA;
#ifndef _WAKEUP
#ifndef _WAKEUP
			boot_params.screen_info.orig_video_isVGA = 1;
			boot_params.screen_info.orig_video_isVGA = 1;
+19 −23
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@
 *
 *
 *   Copyright (C) 1991, 1992 Linus Torvalds
 *   Copyright (C) 1991, 1992 Linus Torvalds
 *   Copyright 2007 rPath, Inc. - All Rights Reserved
 *   Copyright 2007 rPath, Inc. - All Rights Reserved
 *   Copyright 2009 Intel Corporation; author H. Peter Anvin
 *
 *
 *   This file is part of the Linux kernel, and is made available under
 *   This file is part of the Linux kernel, and is made available under
 *   the terms of the GNU General Public License version 2.
 *   the terms of the GNU General Public License version 2.
@@ -18,33 +19,29 @@


static void store_cursor_position(void)
static void store_cursor_position(void)
{
{
	u16 curpos;
	struct biosregs ireg, oreg;
	u16 ax, bx;


	ax = 0x0300;
	initregs(&ireg);
	bx = 0;
	ireg.ah = 0x03;
	asm(INT10
	intcall(0x10, &ireg, &oreg);
	    : "=d" (curpos), "+a" (ax), "+b" (bx)
	    : : "ecx", "esi", "edi");


	boot_params.screen_info.orig_x = curpos;
	boot_params.screen_info.orig_x = oreg.dl;
	boot_params.screen_info.orig_y = curpos >> 8;
	boot_params.screen_info.orig_y = oreg.dh;
}
}


static void store_video_mode(void)
static void store_video_mode(void)
{
{
	u16 ax, page;
	struct biosregs ireg, oreg;


	/* N.B.: the saving of the video page here is a bit silly,
	/* N.B.: the saving of the video page here is a bit silly,
	   since we pretty much assume page 0 everywhere. */
	   since we pretty much assume page 0 everywhere. */
	ax = 0x0f00;
	initregs(&ireg);
	asm(INT10
	ireg.ah = 0x0f;
	    : "+a" (ax), "=b" (page)
	intcall(0x10, &ireg, &oreg);
	    : : "ecx", "edx", "esi", "edi");


	/* Not all BIOSes are clean with respect to the top bit */
	/* Not all BIOSes are clean with respect to the top bit */
	boot_params.screen_info.orig_video_mode = ax & 0x7f;
	boot_params.screen_info.orig_video_mode = oreg.al & 0x7f;
	boot_params.screen_info.orig_video_page = page >> 8;
	boot_params.screen_info.orig_video_page = oreg.bh;
}
}


/*
/*
@@ -257,7 +254,7 @@ static void restore_screen(void)
	int y;
	int y;
	addr_t dst = 0;
	addr_t dst = 0;
	u16 *src = saved.data;
	u16 *src = saved.data;
	u16 ax, bx, dx;
	struct biosregs ireg;


	if (graphic_mode)
	if (graphic_mode)
		return;		/* Can't restore onto a graphic mode */
		return;		/* Can't restore onto a graphic mode */
@@ -296,12 +293,11 @@ static void restore_screen(void)
	}
	}


	/* Restore cursor position */
	/* Restore cursor position */
	ax = 0x0200;		/* Set cursor position */
	initregs(&ireg);
	bx = 0;			/* Page number (<< 8) */
	ireg.ah = 0x02;		/* Set cursor position */
	dx = (saved.cury << 8)+saved.curx;
	ireg.dh = saved.cury;
	asm volatile(INT10
	ireg.dl = saved.curx;
		     : "+a" (ax), "+b" (bx), "+d" (dx)
	intcall(0x10, &ireg, NULL);
		     : : "ecx", "esi", "edi");
}
}
#else
#else
#define save_screen()		((void)0)
#define save_screen()		((void)0)
+0 −14
Original line number Original line Diff line number Diff line
@@ -112,20 +112,6 @@ extern int force_x, force_y; /* Don't query the BIOS for cols/rows */
extern int do_restore;		/* Restore screen contents */
extern int do_restore;		/* Restore screen contents */
extern int graphic_mode;	/* Graphics mode with linear frame buffer */
extern int graphic_mode;	/* Graphics mode with linear frame buffer */


/*
 * int $0x10 is notorious for touching registers it shouldn't.
 * gcc doesn't like %ebp being clobbered, so define it as a push/pop
 * sequence here.
 *
 * A number of systems, including the original PC can clobber %bp in
 * certain circumstances, like when scrolling.  There exists at least
 * one Trident video card which could clobber DS under a set of
 * circumstances that we are unlikely to encounter (scrolling when
 * using an extended graphics mode of more than 800x600 pixels), but
 * it's cheap insurance to deal with that here.
 */
#define INT10 "pushl %%ebp; pushw %%ds; int $0x10; popw %%ds; popl %%ebp"

/* Accessing VGA indexed registers */
/* Accessing VGA indexed registers */
static inline u8 in_idx(u16 port, u8 index)
static inline u8 in_idx(u16 port, u8 index)
{
{