x86, setup: "glove box" BIOS interrupts in the core boot code
Impact: BIOS proofing "Glove box" off BIOS interrupts in the core boot code. LKML-Reference: <49DE7F79.4030106@zytor.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
committed by
H. Peter Anvin
parent
7a734e7dd9
commit
df7699c564
@@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||
* 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
|
||||
* the terms of the GNU General Public License version 2.
|
||||
@@ -22,24 +23,23 @@
|
||||
|
||||
void __attribute__((section(".inittext"))) putchar(int ch)
|
||||
{
|
||||
unsigned char c = ch;
|
||||
struct biosregs ireg;
|
||||
|
||||
if (c == '\n')
|
||||
if (ch == '\n')
|
||||
putchar('\r'); /* \n -> \r\n */
|
||||
|
||||
/* int $0x10 is known to have bugs involving touching registers
|
||||
it shouldn't. Be extra conservative... */
|
||||
asm volatile("pushal; pushw %%ds; int $0x10; popw %%ds; popal"
|
||||
: : "b" (0x0007), "c" (0x0001), "a" (0x0e00|ch));
|
||||
initregs(&ireg);
|
||||
ireg.bx = 0x0007;
|
||||
ireg.cx = 0x0001;
|
||||
ireg.ah = 0x0e;
|
||||
ireg.al = ch;
|
||||
intcall(0x10, &ireg, NULL);
|
||||
}
|
||||
|
||||
void __attribute__((section(".inittext"))) puts(const char *str)
|
||||
{
|
||||
int n = 0;
|
||||
while (*str) {
|
||||
while (*str)
|
||||
putchar(*str++);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -49,14 +49,13 @@ void __attribute__((section(".inittext"))) puts(const char *str)
|
||||
|
||||
static u8 gettime(void)
|
||||
{
|
||||
u16 ax = 0x0200;
|
||||
u16 cx, dx;
|
||||
struct biosregs ireg, oreg;
|
||||
|
||||
asm volatile("int $0x1a"
|
||||
: "+a" (ax), "=c" (cx), "=d" (dx)
|
||||
: : "ebx", "esi", "edi");
|
||||
initregs(&ireg);
|
||||
ireg.ah = 0x02;
|
||||
intcall(0x1a, &ireg, &oreg);
|
||||
|
||||
return dx >> 8;
|
||||
return oreg.dh;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -64,19 +63,24 @@ static u8 gettime(void)
|
||||
*/
|
||||
int getchar(void)
|
||||
{
|
||||
u16 ax = 0;
|
||||
asm volatile("int $0x16" : "+a" (ax));
|
||||
struct biosregs ireg, oreg;
|
||||
|
||||
return ax & 0xff;
|
||||
initregs(&ireg);
|
||||
/* ireg.ah = 0x00; */
|
||||
intcall(0x16, &ireg, &oreg);
|
||||
|
||||
return oreg.al;
|
||||
}
|
||||
|
||||
static int kbd_pending(void)
|
||||
{
|
||||
u8 pending;
|
||||
asm volatile("int $0x16; setnz %0"
|
||||
: "=qm" (pending)
|
||||
: "a" (0x0100));
|
||||
return pending;
|
||||
struct biosregs ireg, oreg;
|
||||
|
||||
initregs(&ireg);
|
||||
ireg.ah = 0x01;
|
||||
intcall(0x16, &ireg, &oreg);
|
||||
|
||||
return !(oreg.eflags & X86_EFLAGS_ZF);
|
||||
}
|
||||
|
||||
void kbd_flush(void)
|
||||
|
Reference in New Issue
Block a user