Skip to content

Commit 8c027ae

Browse files
author
H. Peter Anvin
committed
[x86 setup] Save/restore DS around invocations of INT 10h
There exists at least one card, Trident TVGA8900CL (BIOS dated 1992/9/8) which clobbers DS when "scrolling in an SVGA text mode of more than 800x600 pixels." Although we are extremely unlikely to run into that situation, it is cheap insurance to save and restore DS, and it only adds a grand total of 50 bytes to the total output. Pointed out by Etienne Lorrain. Cc: Etienne Lorrain <[email protected]> Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 7ad37df commit 8c027ae

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

arch/i386/boot/tty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void __attribute__((section(".inittext"))) putchar(int ch)
3131

3232
/* int $0x10 is known to have bugs involving touching registers
3333
it shouldn't. Be extra conservative... */
34-
asm volatile("pushal; int $0x10; popal"
34+
asm volatile("pushal; pushw %%ds; int $0x10; popw %%ds; popal"
3535
: : "b" (0x0007), "c" (0x0001), "a" (0x0e00|ch));
3636
}
3737

arch/i386/boot/video.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,15 @@ extern int graphic_mode; /* Graphics mode with linear frame buffer */
117117
* int $0x10 is notorious for touching registers it shouldn't.
118118
* gcc doesn't like %ebp being clobbered, so define it as a push/pop
119119
* sequence here.
120+
*
121+
* A number of systems, including the original PC can clobber %bp in
122+
* certain circumstances, like when scrolling. There exists at least
123+
* one Trident video card which could clobber DS under a set of
124+
* circumstances that we are unlikely to encounter (scrolling when
125+
* using an extended graphics mode of more than 800x600 pixels), but
126+
* it's cheap insurance to deal with that here.
120127
*/
121-
#define INT10 "pushl %%ebp; int $0x10; popl %%ebp"
128+
#define INT10 "pushl %%ebp; pushw %%ds; int $0x10; popw %%ds; popl %%ebp"
122129

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

0 commit comments

Comments
 (0)