From: "H. Peter Anvin" <hpa@linux.intel.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
tglx@linutronix.de, hpa@linux.intel.com
Subject: [tip:x86/setup] x86, setup: "glove box" BIOS interrupts in the EDD code
Date: Thu, 9 Apr 2009 23:13:24 GMT [thread overview]
Message-ID: <tip-3435d3476c5ed955d56a6216ed2d156847b3a575@git.kernel.org> (raw)
In-Reply-To: <49DE7F79.4030106@zytor.com>
Commit-ID: 3435d3476c5ed955d56a6216ed2d156847b3a575
Gitweb: http://git.kernel.org/tip/3435d3476c5ed955d56a6216ed2d156847b3a575
Author: H. Peter Anvin <hpa@linux.intel.com>
AuthorDate: Wed, 1 Apr 2009 18:17:17 -0700
Committer: H. Peter Anvin <hpa@zytor.com>
CommitDate: Thu, 9 Apr 2009 16:08:11 -0700
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: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/boot/edd.c | 71 ++++++++++++++++++++++----------------------------
1 files changed, 31 insertions(+), 40 deletions(-)
diff --git a/arch/x86/boot/edd.c b/arch/x86/boot/edd.c
index 1aae8f3..c501a5b 100644
--- a/arch/x86/boot/edd.c
+++ b/arch/x86/boot/edd.c
@@ -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,17 +23,17 @@
*/
static int read_mbr(u8 devno, void *buf)
{
- u16 ax, bx, cx, dx;
+ struct biosregs ireg, oreg;
- ax = 0x0201; /* Legacy Read, one sector */
- cx = 0x0001; /* Sector 0-0-1 */
- dx = devno;
- bx = (size_t)buf;
- asm volatile("pushfl; stc; int $0x13; setc %%al; popfl"
- : "+a" (ax), "+c" (cx), "+d" (dx), "+b" (bx)
- : : "esi", "edi", "memory");
+ initregs(&ireg);
+ ireg.ax = 0x0201; /* Legacy Read, one sector */
+ ireg.cx = 0x0001; /* Sector 0-0-1 */
+ ireg.dl = devno;
+ ireg.bx = (size_t)buf;
- 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)
@@ -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)
{
- u16 ax, bx, cx, dx, di;
+ struct biosregs ireg, oreg;
memset(ei, 0, sizeof *ei);
/* Check Extensions Present */
- ax = 0x4100;
- bx = EDDMAGIC1;
- dx = devno;
- asm("pushfl; stc; int $0x13; setc %%al; popfl"
- : "+a" (ax), "+b" (bx), "=c" (cx), "+d" (dx)
- : : "esi", "edi");
+ initregs(&ireg);
+ ireg.ah = 0x41;
+ ireg.bx = EDDMAGIC1;
+ ireg.dl = devno;
+ intcall(0x13, &ireg, &oreg);
- if ((u8)ax)
+ if (oreg.eflags & X86_EFLAGS_CF)
return -1; /* No extended information */
- if (bx != EDDMAGIC2)
+ if (oreg.bx != EDDMAGIC2)
return -1;
ei->device = devno;
- ei->version = ax >> 8; /* EDD version number */
- ei->interface_support = cx; /* EDD functionality subsets */
+ ei->version = oreg.ah; /* EDD version number */
+ ei->interface_support = oreg.cx; /* EDD functionality subsets */
/* Extended Get Device Parameters */
ei->params.length = sizeof(ei->params);
- ax = 0x4800;
- dx = devno;
- asm("pushfl; int $0x13; popfl"
- : "+a" (ax), "+d" (dx), "=m" (ei->params)
- : "S" (&ei->params)
- : "ebx", "ecx", "edi");
+ ireg.ah = 0x48;
+ ireg.si = (size_t)&ei->params;
+ intcall(0x13, &ireg, &oreg);
/* Get legacy CHS parameters */
/* Ralf Brown recommends setting ES:DI to 0:0 */
- ax = 0x0800;
- dx = devno;
- di = 0;
- asm("pushw %%es; "
- "movw %%di,%%es; "
- "pushfl; stc; int $0x13; setc %%al; popfl; "
- "popw %%es"
- : "+a" (ax), "=b" (bx), "=c" (cx), "+d" (dx), "+D" (di)
- : : "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;
+ ireg.ah = 0x08;
+ ireg.es = 0;
+ intcall(0x13, &ireg, &oreg);
+
+ if (!(oreg.eflags & X86_EFLAGS_CF)) {
+ ei->legacy_max_cylinder = oreg.ch + ((oreg.cl & 0xc0) << 2);
+ ei->legacy_max_head = oreg.dh;
+ ei->legacy_sectors_per_track = oreg.cl & 0x3f;
}
return 0;
next prev parent reply other threads:[~2009-04-09 23:14 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-09 23:06 [PATCH 0/6] x86, setup: "glove box" BIOS interrupts H. Peter Anvin
2009-04-09 23:12 ` [tip:x86/setup] x86, setup: "glove box" BIOS calls -- infrastructure H. Peter Anvin
2009-04-10 8:04 ` Pavel Machek
2009-04-10 10:39 ` Ingo Molnar
2009-04-10 10:46 ` Pavel Machek
2009-04-10 11:25 ` Ingo Molnar
2009-04-10 11:38 ` Pavel Machek
2009-04-10 11:49 ` Ingo Molnar
2009-04-11 16:13 ` Avi Kivity
2009-04-12 5:21 ` H. Peter Anvin
2009-04-12 14:01 ` Ingo Molnar
2009-04-12 14:39 ` Avi Kivity
2009-04-12 14:59 ` Linus Torvalds
2009-04-12 16:33 ` Ingo Molnar
2009-04-12 18:57 ` Avi Kivity
2009-04-13 4:16 ` Ingo Molnar
2009-04-13 4:24 ` Ingo Molnar
2009-04-13 16:27 ` H. Peter Anvin
2009-04-13 16:57 ` Pavel Machek
2009-04-13 17:00 ` H. Peter Anvin
2009-04-13 18:34 ` Alan Jenkins
2009-04-13 19:08 ` H. Peter Anvin
2009-04-14 0:06 ` Ingo Molnar
2009-04-14 4:42 ` H. Peter Anvin
2009-04-14 9:03 ` Jeremy Fitzhardinge
2009-04-14 15:59 ` H. Peter Anvin
2009-04-13 6:44 ` Avi Kivity
2009-04-12 17:51 ` H. Peter Anvin
2009-04-10 17:17 ` H. Peter Anvin
2009-04-10 17:19 ` H. Peter Anvin
2009-04-09 23:13 ` [tip:x86/setup] x86, setup: "glove box" BIOS interrupts in the core boot code H. Peter Anvin
2009-04-09 23:13 ` [tip:x86/setup] x86, setup: "glove box" BIOS interrupts in the APM code H. Peter Anvin
2009-04-09 23:13 ` H. Peter Anvin [this message]
2009-04-09 23:13 ` [tip:x86/setup] x86, setup: "glove box" BIOS interrupts in the MCA code H. Peter Anvin
2009-04-09 23:13 ` [tip:x86/setup] x86, setup: "glove box" BIOS interrupts in the video code H. Peter Anvin
2009-04-10 8:05 ` Pavel Machek
2009-04-10 18:05 ` [PATCH 0/6] x86, setup: "glove box" BIOS interrupts Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-3435d3476c5ed955d56a6216ed2d156847b3a575@git.kernel.org \
--to=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).