Re: [RFC] 2.6.0 EDD enhancements
From: Matt Domsch
Date: Fri Dec 19 2003 - 14:03:17 EST
This is equivalent to the code in 2.4.23 + fix posted today. -Matt
You can import this changeset into BK by piping this whole message to
'| bk receive [path to repository]' or apply the patch as usual.
===================================================================
ChangeSet@xxxxxxxxxx, 2003-12-18 15:13:36-06:00, Matt_Domsch@xxxxxxxx
EDD: read disk80 MBR signature, export through edd module
There are 4 bytes in the MSDOS master boot record, at offset 0x1b8,
which may contain a per-system-unique signature. By first writing a
unique signature to each disk in the system, then rebooting, and then
reading the MBR to get the signature for the boot disk (int13 dev
80h), userspace may use it to compare against disks it knows as named
/dev/[hs]d[a-z], and thus determine which disk is the BIOS boot disk,
thus where the /boot, / and boot loaders should be placed.
This is useful in the case where the BIOS is not EDD3.0 compliant,
thus doesn't provide the PCI bus/dev/fn and IDE/SCSI location of the
boot disk, yet you need to know which disk is the boot disk. It's
most useful in OS installers.
This patch retrieves the signature from the disk in setup.S, stores it
in a space reserved in the empty_zero_page, copies it somewhere safe
in setup.c, and exports it via
/sys/firmware/edd/int13_disk80/mbr_signature in edd.c. Code is
covered under CONFIG_EDD=[ym].
Documentation/i386/zero-page.txt | 4 +++-
arch/i386/boot/setup.S | 21 +++++++++++++++++++++
arch/i386/kernel/edd.c | 22 +++++++++++++++++++++-
arch/i386/kernel/i386_ksyms.c | 6 ------
arch/i386/kernel/setup.c | 7 +++++++
include/asm-i386/edd.h | 6 +++++-
include/asm-i386/setup.h | 1 +
7 files changed, 58 insertions, 9 deletions
diff -Nru a/Documentation/i386/zero-page.txt b/Documentation/i386/zero-page.txt
--- a/Documentation/i386/zero-page.txt Fri Dec 19 12:52:44 2003
+++ b/Documentation/i386/zero-page.txt Fri Dec 19 12:52:44 2003
@@ -66,8 +66,10 @@
0x21c unsigned long INITRD_SIZE, size in bytes of ramdisk image
0x220 4 bytes (setup.S)
0x224 unsigned short setup.S heap end pointer
+0x2cc 4 bytes DISK80_SIG_BUFFER (setup.S)
0x2d0 - 0x600 E820MAP
-0x600 - 0x7D4 EDDBUF (setup.S)
+0x600 - 0x7ff EDDBUF (setup.S) for disk signature read sector
+0x600 - 0x7d3 EDDBUF (setup.S) for edd data
0x800 string, 2K max COMMAND_LINE, the kernel commandline as
copied using CL_OFFSET.
diff -Nru a/arch/i386/boot/setup.S b/arch/i386/boot/setup.S
--- a/arch/i386/boot/setup.S Fri Dec 19 12:52:44 2003
+++ b/arch/i386/boot/setup.S Fri Dec 19 12:52:44 2003
@@ -49,6 +49,8 @@
* by Matt Domsch <Matt_Domsch@xxxxxxxx> October 2002
* conformant to T13 Committee www.t13.org
* projects 1572D, 1484D, 1386D, 1226DT
+ * disk signature read by Matt Domsch <Matt_Domsch@xxxxxxxx>
+ * and Andrew Wilks <Andrew_Wilks@xxxxxxxx> September 2003
*/
#include <linux/config.h>
@@ -578,6 +580,25 @@
#endif
#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
+# Read the first sector of device 80h and store the 4-byte signature
+ movl $0xFFFFFFFF, %eax
+ movl %eax, (DISK80_SIG_BUFFER) # assume failure
+ movb $READ_SECTORS, %ah
+ movb $1, %al # read 1 sector
+ movb $0x80, %dl # from device 80
+ movb $0, %dh # at head 0
+ movw $1, %cx # cylinder 0, sector 0
+ pushw %es
+ pushw %ds
+ popw %es
+ movw $EDDBUF, %bx
+ int $0x13
+ jc disk_sig_done
+ movl (EDDBUF+MBR_SIG_OFFSET), %eax
+ movl %eax, (DISK80_SIG_BUFFER) # store success
+disk_sig_done:
+ popw %es
+
# Do the BIOS Enhanced Disk Drive calls
# This consists of two calls:
# int 13h ah=41h "Check Extensions Present"
diff -Nru a/arch/i386/kernel/edd.c b/arch/i386/kernel/edd.c
--- a/arch/i386/kernel/edd.c Fri Dec 19 12:52:44 2003
+++ b/arch/i386/kernel/edd.c Fri Dec 19 12:52:44 2003
@@ -2,6 +2,7 @@
* linux/arch/i386/kernel/edd.c
* Copyright (C) 2002, 2003 Dell Inc.
* by Matt Domsch <Matt_Domsch@xxxxxxxx>
+ * disk80 signature by Matt Domsch, Andrew Wilks, and Sandeep K. Shandilya
*
* BIOS Enhanced Disk Drive Services (EDD)
* conformant to T13 Committee www.t13.org
@@ -59,7 +60,7 @@
MODULE_DESCRIPTION("sysfs interface to BIOS EDD information");
MODULE_LICENSE("GPL");
-#define EDD_VERSION "0.10 2003-Oct-11"
+#define EDD_VERSION "0.11 2003-Dec-17"
#define EDD_DEVICE_NAME_SIZE 16
#define REPORT_URL "http://domsch.com/linux/edd30/results.html"
@@ -260,6 +261,14 @@
}
static ssize_t
+edd_show_disk80_sig(struct edd_device *edev, char *buf)
+{
+ char *p = buf;
+ p += snprintf(p, left, "0x%08x\n", edd_disk80_sig);
+ return (p - buf);
+}
+
+static ssize_t
edd_show_extensions(struct edd_device *edev, char *buf)
{
struct edd_info *info = edd_dev_get_info(edev);
@@ -429,6 +438,15 @@
return 1;
}
+static int
+edd_has_disk80_sig(struct edd_device *edev)
+{
+ struct edd_info *info = edd_dev_get_info(edev);
+ if (!edev || !info)
+ return 0;
+ return info->device == 0x80;
+}
+
static EDD_DEVICE_ATTR(raw_data, 0444, edd_show_raw_data, NULL);
static EDD_DEVICE_ATTR(version, 0444, edd_show_version, NULL);
static EDD_DEVICE_ATTR(extensions, 0444, edd_show_extensions, NULL);
@@ -443,6 +461,7 @@
edd_has_default_sectors_per_track);
static EDD_DEVICE_ATTR(interface, 0444, edd_show_interface, edd_has_edd30);
static EDD_DEVICE_ATTR(host_bus, 0444, edd_show_host_bus, edd_has_edd30);
+static EDD_DEVICE_ATTR(mbr_signature, 0444, edd_show_disk80_sig, edd_has_disk80_sig);
/* These are default attributes that are added for every edd
@@ -464,6 +483,7 @@
&edd_attr_default_sectors_per_track,
&edd_attr_interface,
&edd_attr_host_bus,
+ &edd_attr_mbr_signature,
NULL,
};
diff -Nru a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c
--- a/arch/i386/kernel/i386_ksyms.c Fri Dec 19 12:52:44 2003
+++ b/arch/i386/kernel/i386_ksyms.c Fri Dec 19 12:52:44 2003
@@ -32,7 +32,6 @@
#include <asm/pgalloc.h>
#include <asm/tlbflush.h>
#include <asm/nmi.h>
-#include <asm/edd.h>
#include <asm/ist.h>
extern void dump_thread(struct pt_regs *, struct user *);
@@ -201,11 +200,6 @@
EXPORT_SYMBOL(kmap_atomic);
EXPORT_SYMBOL(kunmap_atomic);
EXPORT_SYMBOL(kmap_atomic_to_page);
-#endif
-
-#ifdef CONFIG_EDD_MODULE
-EXPORT_SYMBOL(edd);
-EXPORT_SYMBOL(eddnr);
#endif
#if defined(CONFIG_X86_SPEEDSTEP_SMI) || defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
diff -Nru a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
--- a/arch/i386/kernel/setup.c Fri Dec 19 12:52:44 2003
+++ b/arch/i386/kernel/setup.c Fri Dec 19 12:52:44 2003
@@ -423,6 +423,12 @@
#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
unsigned char eddnr;
struct edd_info edd[EDDMAXNR];
+unsigned int edd_disk80_sig;
+#ifdef CONFIG_EDD_MODULE
+EXPORT_SYMBOL(eddnr);
+EXPORT_SYMBOL(edd);
+EXPORT_SYMBOL(edd_disk80_sig);
+#endif
/**
* copy_edd() - Copy the BIOS EDD information
* from empty_zero_page into a safe place.
@@ -432,6 +438,7 @@
{
eddnr = EDD_NR;
memcpy(edd, EDD_BUF, sizeof(edd));
+ edd_disk80_sig = DISK80_SIGNATURE;
}
#else
#define copy_edd() do {} while (0)
diff -Nru a/include/asm-i386/edd.h b/include/asm-i386/edd.h
--- a/include/asm-i386/edd.h Fri Dec 19 12:52:44 2003
+++ b/include/asm-i386/edd.h Fri Dec 19 12:52:44 2003
@@ -1,6 +1,6 @@
/*
* linux/include/asm-i386/edd.h
- * Copyright (C) 2002 Dell Inc.
+ * Copyright (C) 2002, 2003 Dell Inc.
* by Matt Domsch <Matt_Domsch@xxxxxxxx>
*
* structures and definitions for the int 13h, ax={41,48}h
@@ -41,6 +41,9 @@
#define EDDMAGIC1 0x55AA
#define EDDMAGIC2 0xAA55
+#define READ_SECTORS 0x02
+#define MBR_SIG_OFFSET 0x1B8
+#define DISK80_SIG_BUFFER 0x2cc
#ifndef __ASSEMBLY__
#define EDD_EXT_FIXED_DISK_ACCESS (1 << 0)
@@ -167,6 +170,7 @@
extern struct edd_info edd[EDDMAXNR];
extern unsigned char eddnr;
+extern unsigned int edd_disk80_sig;
#endif /*!__ASSEMBLY__ */
#endif /* _ASM_I386_EDD_H */
diff -Nru a/include/asm-i386/setup.h b/include/asm-i386/setup.h
--- a/include/asm-i386/setup.h Fri Dec 19 12:52:44 2003
+++ b/include/asm-i386/setup.h Fri Dec 19 12:52:44 2003
@@ -39,6 +39,7 @@
#define INITRD_START (*(unsigned long *) (PARAM+0x218))
#define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
#define EDID_INFO (*(struct edid_info *) (PARAM+0x440))
+#define DISK80_SIGNATURE (*(unsigned int*) (PARAM+DISK80_SIG_BUFFER))
#define EDD_NR (*(unsigned char *) (PARAM+EDDNR))
#define EDD_BUF ((struct edd_info *) (PARAM+EDDBUF))
#define COMMAND_LINE ((char *) (PARAM+2048))
===================================================================
This BitKeeper patch contains the following changesets:
1.1532.1.1
## Wrapped with gzip_uu ##
M'XL( /Q(XS\ [59^7,:.1;^F?XKWL0S.]CAD/K&&:=\@&>I'':!,[M;28H2
MW6K3<1],J[%-EOW?]TD-&# VQHD))K2.3^]]>I?$#GP2/-LO?6!YWFNFL? &
MV@[\,Q7Y?LGG453STA@;.FF*#?5!&O-Z[*MA]?Y5G?M^/0J3T6U5KUE5?-)P
M[#G+O0%<\TSLEVC-F+?DXR'?+W5:?WYZ?]31M(,#.!FPY))W>0X'!UJ>9M<L
M\L4ARP=1FM3RC"4BYCF3(DSF0R<Z(3K^LZAC$,N>4)N8SL2C/J7,I-PGNNG:
MIO:-BT-$"!/N5^,TN>+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6B&Q3WSIN/B5.-GF2%=N 6Z)T9YK[QHH7N[4#X_ZAQ]>'T_
=T>W>_7[M#;AWA;7# =5UUT*%M?\#,' W/"L?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/