Commit 3435d347 authored by H. Peter Anvin's avatar H. Peter Anvin Committed by H. Peter Anvin

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

Impact: BIOS proofing

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

LKML-Reference: <49DE7F79.4030106@zytor.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent d54ea252
...@@ -2,6 +2,7 @@ ...@@ -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.
...@@ -22,17 +23,17 @@ ...@@ -22,17 +23,17 @@
*/ */
static int read_mbr(u8 devno, void *buf) static int read_mbr(u8 devno, void *buf)
{ {
u16 ax, bx, cx, dx; struct biosregs ireg, oreg;
ax = 0x0201; /* Legacy Read, one sector */ initregs(&ireg);
cx = 0x0001; /* Sector 0-0-1 */ ireg.ax = 0x0201; /* Legacy Read, one sector */
dx = devno; ireg.cx = 0x0001; /* Sector 0-0-1 */
bx = (size_t)buf; ireg.dl = devno;
asm volatile("pushfl; stc; int $0x13; setc %%al; popfl" ireg.bx = (size_t)buf;
: "+a" (ax), "+c" (cx), "+d" (dx), "+b" (bx)
: : "esi", "edi", "memory");
return -(u8)ax; /* 0 or -1 */ intcall(0x13, &ireg, &oreg);
return -(oreg.eflags & X86_EFLAGS_CF); /* 0 or -1 */
} }
static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig) static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig)
...@@ -72,56 +73,46 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig) ...@@ -72,56 +73,46 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei, u32 *mbrsig)
static int get_edd_info(u8 devno, struct edd_info *ei) static int get_edd_info(u8 devno, struct edd_info *ei)
{ {
u16 ax, bx, cx, dx, di; struct biosregs ireg, oreg;
memset(ei, 0, sizeof *ei); memset(ei, 0, sizeof *ei);
/* Check Extensions Present */ /* Check Extensions Present */
ax = 0x4100; initregs(&ireg);
bx = EDDMAGIC1; ireg.ah = 0x41;
dx = devno; ireg.bx = EDDMAGIC1;
asm("pushfl; stc; int $0x13; setc %%al; popfl" ireg.dl = devno;
: "+a" (ax), "+b" (bx), "=c" (cx), "+d" (dx) intcall(0x13, &ireg, &oreg);
: : "esi", "edi");
if ((u8)ax) if (oreg.eflags & X86_EFLAGS_CF)
return -1; /* No extended information */ return -1; /* No extended information */
if (bx != EDDMAGIC2) if (oreg.bx != EDDMAGIC2)
return -1; return -1;
ei->device = devno; ei->device = devno;
ei->version = ax >> 8; /* EDD version number */ ei->version = oreg.ah; /* EDD version number */
ei->interface_support = cx; /* EDD functionality subsets */ ei->interface_support = oreg.cx; /* EDD functionality subsets */
/* Extended Get Device Parameters */ /* Extended Get Device Parameters */
ei->params.length = sizeof(ei->params); ei->params.length = sizeof(ei->params);
ax = 0x4800; ireg.ah = 0x48;
dx = devno; ireg.si = (size_t)&ei->params;
asm("pushfl; int $0x13; popfl" intcall(0x13, &ireg, &oreg);
: "+a" (ax), "+d" (dx), "=m" (ei->params)
: "S" (&ei->params)
: "ebx", "ecx", "edi");
/* Get legacy CHS parameters */ /* Get legacy CHS parameters */
/* Ralf Brown recommends setting ES:DI to 0:0 */ /* Ralf Brown recommends setting ES:DI to 0:0 */
ax = 0x0800; ireg.ah = 0x08;
dx = devno; ireg.es = 0;
di = 0; intcall(0x13, &ireg, &oreg);
asm("pushw %%es; "
"movw %%di,%%es; " if (!(oreg.eflags & X86_EFLAGS_CF)) {
"pushfl; stc; int $0x13; setc %%al; popfl; " ei->legacy_max_cylinder = oreg.ch + ((oreg.cl & 0xc0) << 2);
"popw %%es" ei->legacy_max_head = oreg.dh;
: "+a" (ax), "=b" (bx), "=c" (cx), "+d" (dx), "+D" (di) ei->legacy_sectors_per_track = oreg.cl & 0x3f;
: : "esi");
if ((u8)ax == 0) {
ei->legacy_max_cylinder = (cx >> 8) + ((cx & 0xc0) << 2);
ei->legacy_max_head = dx >> 8;
ei->legacy_sectors_per_track = cx & 0x3f;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment