public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* EDD enhanchement patch
@ 2004-07-06 16:53 Frediano Ziglio
  2004-07-07 17:40 ` Andries Brouwer
  0 siblings, 1 reply; 6+ messages in thread
From: Frediano Ziglio @ 2004-07-06 16:53 UTC (permalink / raw)
  To: Andries Brouwer
  Cc: linux-kernel, Bartlomiej Zolnierkiewicz, Patrick J. LoPresti

[-- Attachment #1: Type: text/plain, Size: 172 bytes --]

This patch add support for DTPE data in EDD and mbr_signature. This
patch do not solve fdisk problems but can help these programs to compute
correct head count.

freddy77


[-- Attachment #2: edd.diff.gz --]
[-- Type: application/x-gzip, Size: 5206 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: EDD enhanchement patch
  2004-07-07  4:45 Fw: " Matt Domsch
@ 2004-07-07 10:05 ` Frediano Ziglio
  2004-07-08 12:56   ` Matt Domsch
  0 siblings, 1 reply; 6+ messages in thread
From: Frediano Ziglio @ 2004-07-07 10:05 UTC (permalink / raw)
  To: Matt Domsch
  Cc: Andrew Morton, linux-kernel, Bartlomiej Zolnierkiewicz,
	Patrick J. LoPresti

Il mer, 2004-07-07 alle 06:45, Matt Domsch ha scritto:
> > Date: Tue, 06 Jul 2004 18:53:28 +0200
> > From: Frediano Ziglio <freddyz77@tin.it>
> > 
> > This patch add support for DTPE data in EDD and mbr_signature. This
> > patch do not solve fdisk problems but can help these programs to compute
> > correct head count.
> 
> Thanks Frediano.  I don't think this is quite ready to include yet,
> but I'm not philosophically opposed to it, so let's work it out.
> 

Here you are, inlined (with your change it's quite smaller)
Fixed a stupid bug too (I'm used to code in Intel asm, not GNU asm...)
It seems that some BIOS (like mine) fill with an invalid pointer using
USB disks, add code to test DPTE data (using checksum).

diff -U10 -r linux-2.6.7.orig/arch/i386/boot/edd.S linux-2.6.7/arch/i386/boot/edd.S
--- linux-2.6.7.orig/arch/i386/boot/edd.S	2004-07-07 08:57:35.000000000 +0200
+++ linux-2.6.7/arch/i386/boot/edd.S	2004-07-07 11:50:55.000000000 +0200
@@ -45,27 +45,28 @@
 	cmpb	$EDD_MBR_SIG_MAX, (EDD_MBR_SIG_NR_BUF)	# Out of space?
 	jb	edd_mbr_sig_read		# keep looping
 edd_mbr_sig_done:
 
 # Do the BIOS Enhanced Disk Drive calls
 # This consists of two calls:
 #    int 13h ah=41h "Check Extensions Present"
 #    int 13h ah=48h "Get Device Parameters"
 #    int 13h ah=08h "Legacy Get Device Parameters"
 #
-# A buffer of size EDDMAXNR*(EDDEXTSIZE+EDDPARMSIZE) is reserved for our use
-# in the boot_params at EDDBUF.  The first four bytes of which are
+# A buffer of size EDDMAXNR*(EDDEXTSIZE+EDDPARMSIZE+DPTESIZE) is reserved 
+# for our use in the boot_params at EDDBUF.  The first four bytes of which are
 # used to store the device number, interface support map and version
 # results from fn41.  The next four bytes are used to store the legacy
 # cylinders, heads, and sectors from fn08. The following 74 bytes are used to
 # store the results from fn48.  Starting from device 80h, fn41, then fn48
-# are called and their results stored in EDDBUF+n*(EDDEXTSIZE+EDDPARMIZE).
+# are called and their results stored
+# in EDDBUF+n*(EDDEXTSIZE+EDDPARMIZE+DPTESIZE).
 # Then the pointer is incremented to store the data for the next call.
 # This repeats until either a device doesn't exist, or until EDDMAXNR
 # devices have been stored.
 # The one tricky part is that ds:si always points EDDEXTSIZE bytes into
 # the structure, and the fn41 and fn08 results are stored at offsets
 # from there.  This removes the need to increment the pointer for
 # every store, and leaves it ready for the fn48 call.
 # A second one-byte buffer, EDDNR, in the boot_params stores
 # the number of BIOS devices which exist, up to EDDMAXNR.
 # In setup.c, copy_edd() stores both boot_params buffers away
@@ -91,22 +92,58 @@
 	movb	%dl, %ds:-8(%si)		# store device number
 	movb	%ah, %ds:-7(%si)		# store version
 	movw	%cx, %ds:-6(%si)		# store extensions
 	incb	(EDDNR)				# note that we stored something
 
 edd_get_device_params:
 	movw	$EDDPARMSIZE, %ds:(%si)		# put size
 	movw	$0x0, %ds:2(%si)		# work around buggy BIOSes
 	movb	$GETDEVICEPARAMETERS, %ah	# Function 48
 	int	$0x13				# make the call
-						# Don't check for fail return
-						# it doesn't matter.
+	jc	edd_get_legacy_chs
+
+	cmpw	$0x1e, %ds:(%si)		# check if EDD 2.0 present
+	jb	edd_get_legacy_chs
+
+	movl	%ds:0x1a(%si), %eax		# check pointer
+	incl	%eax				# no ffff:ffff
+	jz	bad_dpte_data
+	decl	%eax				# or 0000:0000
+	jz	bad_dpte_data
+
+	# copy EDD 2.0 informations
+	pushw	%ds
+	pushw	%es
+	pushw	%ds
+	popw	%es
+	pushw	%si
+	leaw	EDDPARMSIZE(%si), %di
+	ldsw	%ds:0x1a(%si), %si
+	movw	$16, %cx
+	xorw	%ax, %ax
+	cld
+check_dpte:
+	lodsb
+	addb	%al, %ah
+	stosb
+	loop	check_dpte
+	popw	%si
+	popw	%es
+	popw	%ds
+	cmp	$0, %ah
+	je	edd_get_legacy_chs
+
+	# DPTE data invalid, bad BIOS, reset dpte_pointer
+bad_dpte_data:
+	movl	$-1, %ds:0x1a(%si)
+check_edd2_ok:
+
 edd_get_legacy_chs:
 	xorw    %ax, %ax
 	movw    %ax, %ds:-4(%si)
 	movw    %ax, %ds:-2(%si)
         # Ralf Brown's Interrupt List says to set ES:DI to
 	# 0000h:0000h "to guard against BIOS bugs"
 	pushw   %es
 	movw    %ax, %es
 	movw    %ax, %di
 	pushw   %dx                             # legacy call clobbers %dl
@@ -118,21 +155,19 @@
 	movb	%al, %ds:-1(%si)                # Record max sect
 	movb    %dh, %ds:-2(%si)                # Record max head number
 	movb    %ch, %al                        # Low 8 bits of max cyl
 	shr     $6, %cl
 	movb    %cl, %ah                        # High 2 bits of max cyl
 	movw    %ax, %ds:-4(%si)
 
 edd_legacy_done:
 	popw    %dx
 	popw    %es
-	movw	%si, %ax			# increment si
-	addw	$EDDPARMSIZE+EDDEXTSIZE, %ax
-	movw	%ax, %si
+	addw	$EDDPARMSIZE+EDDEXTSIZE+DPTESIZE, %si	# increment si
 
 edd_next:
 	incb	%dl				# increment to next device
 	cmpb	$EDDMAXNR, (EDDNR) 		# Out of space?
 	jb	edd_check_ext			# keep looping
 
 edd_done:
 #endif
diff -U10 -r linux-2.6.7.orig/Documentation/i386/zero-page.txt linux-2.6.7/Documentation/i386/zero-page.txt
--- linux-2.6.7.orig/Documentation/i386/zero-page.txt	2004-07-07 08:57:33.000000000 +0200
+++ linux-2.6.7/Documentation/i386/zero-page.txt	2004-07-07 10:57:54.000000000 +0200
@@ -69,11 +69,11 @@
 				  loader.
 0x212	unsigned short	(setup.S)
 0x214	unsigned long	KERNEL_START, where the loader started the kernel
 0x218	unsigned long	INITRD_START, address of loaded ramdisk image
 0x21c	unsigned long	INITRD_SIZE, size in bytes of ramdisk image
 0x220	4 bytes		(setup.S)
 0x224	unsigned short	setup.S heap end pointer
 0x290 - 0x2cf		EDD_MBR_SIG_BUFFER (edd.S)
 0x2d0 - 0x600		E820MAP
 0x600 - 0x7ff		EDDBUF (edd.S) for disk signature read sector
-0x600 - 0x7eb		EDDBUF (edd.S) for edd data
+0x600 - 0x7e9		EDDBUF (edd.S) for edd data
diff -U10 -r linux-2.6.7.orig/drivers/firmware/edd.c linux-2.6.7/drivers/firmware/edd.c
--- linux-2.6.7.orig/drivers/firmware/edd.c	2004-07-07 08:57:46.000000000 +0200
+++ linux-2.6.7/drivers/firmware/edd.c	2004-07-07 11:38:16.000000000 +0200
@@ -436,20 +436,34 @@
 		return -EINVAL;
 	info = edd_dev_get_info(edev);
 	if (!info || !buf)
 		return -EINVAL;
 
 	p += scnprintf(p, left, "%llu\n", info->params.number_of_sectors);
 	return (p - buf);
 }
 
 
+static ssize_t
+edd_show_raw_dpte(struct edd_device *edev, char *buf)
+{
+	struct edd_info *info;
+	if (!edev)
+		return -EINVAL;
+	info = edd_dev_get_info(edev);
+	if (!info || !buf)
+		return -EINVAL;
+
+	memcpy(buf, &info->dpte, sizeof(struct edd_dpte));
+	return sizeof(struct edd_dpte);
+}
+
 /*
  * Some device instances may not have all the above attributes,
  * or the attribute values may be meaningless (i.e. if
  * the device is < EDD 3.0, it won't have host_bus and interface
  * information), so don't bother making files for them.  Likewise
  * if the default_{cylinders,heads,sectors_per_track} values
  * are zero, the BIOS doesn't provide sane values, don't bother
  * creating files for them either.
  */
 
@@ -549,20 +563,36 @@
 			break;
 		}
 	}
 	if (!nonzero_path) {
 		return 0;
 	}
 
 	return 1;
 }
 
+static int
+edd_has_dpte(struct edd_device *edev)
+{
+	struct edd_info *info;
+	if (!edev)
+		return 0;
+	info = edd_dev_get_info(edev);
+	if (!info || info->params.length < 0x1e)
+		return 0;
+
+	if (info->params.dpte_ptr == 0xffffffffu)
+		return 0;
+
+	return 1;
+}
+
 
 static EDD_DEVICE_ATTR(raw_data, 0444, edd_show_raw_data, edd_has_edd_info);
 static EDD_DEVICE_ATTR(version, 0444, edd_show_version, edd_has_edd_info);
 static EDD_DEVICE_ATTR(extensions, 0444, edd_show_extensions, edd_has_edd_info);
 static EDD_DEVICE_ATTR(info_flags, 0444, edd_show_info_flags, edd_has_edd_info);
 static EDD_DEVICE_ATTR(sectors, 0444, edd_show_sectors, edd_has_edd_info);
 static EDD_DEVICE_ATTR(legacy_max_cylinder, 0444,
                        edd_show_legacy_max_cylinder,
 		       edd_has_legacy_max_cylinder);
 static EDD_DEVICE_ATTR(legacy_max_head, 0444, edd_show_legacy_max_head,
@@ -573,20 +603,21 @@
 static EDD_DEVICE_ATTR(default_cylinders, 0444, edd_show_default_cylinders,
 		       edd_has_default_cylinders);
 static EDD_DEVICE_ATTR(default_heads, 0444, edd_show_default_heads,
 		       edd_has_default_heads);
 static EDD_DEVICE_ATTR(default_sectors_per_track, 0444,
 		       edd_show_default_sectors_per_track,
 		       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_mbr_signature, edd_has_mbr_signature);
+static EDD_DEVICE_ATTR(raw_dpte, 0444, edd_show_raw_dpte, edd_has_dpte);
 
 
 /* These are default attributes that are added for every edd
  * device discovered.  There are none.
  */
 static struct attribute * def_attrs[] = {
 	NULL,
 };
 
 /* These attributes are conditional and only added for some devices. */
@@ -598,20 +629,21 @@
 	&edd_attr_sectors,
 	&edd_attr_legacy_max_cylinder,
 	&edd_attr_legacy_max_head,
 	&edd_attr_legacy_sectors_per_track,
 	&edd_attr_default_cylinders,
 	&edd_attr_default_heads,
 	&edd_attr_default_sectors_per_track,
 	&edd_attr_interface,
 	&edd_attr_host_bus,
 	&edd_attr_mbr_signature,
+	&edd_attr_raw_dpte,
 	NULL,
 };
 
 /**
  *	edd_release - free edd structure
  *	@kobj:	kobject of edd structure
  *
  *	This is called when the refcount of the edd structure
  *	reaches 0. This should happen right after we unregister,
  *	but just in case, we use the release callback anyway.
diff -U10 -r linux-2.6.7.orig/include/linux/edd.h linux-2.6.7/include/linux/edd.h
--- linux-2.6.7.orig/include/linux/edd.h	2004-07-07 08:58:10.000000000 +0200
+++ linux-2.6.7/include/linux/edd.h	2004-07-07 10:57:54.000000000 +0200
@@ -26,23 +26,24 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  */
 #ifndef _LINUX_EDD_H
 #define _LINUX_EDD_H
 
 #define EDDNR 0x1e9		/* addr of number of edd_info structs at EDDBUF
 				   in boot_params - treat this as 1 byte  */
 #define EDDBUF	0x600		/* addr of edd_info structs in boot_params */
-#define EDDMAXNR 6		/* number of edd_info structs starting at EDDBUF  */
+#define EDDMAXNR 5		/* number of edd_info structs starting at EDDBUF  */
 #define EDDEXTSIZE 8		/* change these if you muck with the structures */
 #define EDDPARMSIZE 74
+#define DPTESIZE 16
 #define CHECKEXTENSIONSPRESENT 0x41
 #define GETDEVICEPARAMETERS 0x48
 #define LEGACYGETDEVICEPARAMETERS 0x08
 #define EDDMAGIC1 0x55AA
 #define EDDMAGIC2 0xAA55
 
 
 #define READ_SECTORS 0x02         /* int13 AH=0x02 is READ_SECTORS command */
 #define EDD_MBR_SIG_OFFSET 0x1B8  /* offset of signature in the MBR */
 #define EDD_MBR_SIG_BUF    0x290  /* addr in boot params */
@@ -58,20 +59,22 @@
 
 #define EDD_INFO_DMA_BOUNDARY_ERROR_TRANSPARENT (1 << 0)
 #define EDD_INFO_GEOMETRY_VALID                (1 << 1)
 #define EDD_INFO_REMOVABLE                     (1 << 2)
 #define EDD_INFO_WRITE_VERIFY                  (1 << 3)
 #define EDD_INFO_MEDIA_CHANGE_NOTIFICATION     (1 << 4)
 #define EDD_INFO_LOCKABLE                      (1 << 5)
 #define EDD_INFO_NO_MEDIA_PRESENT              (1 << 6)
 #define EDD_INFO_USE_INT13_FN50                (1 << 7)
 
+#define EDD2_DRIVE_IS_SLAVE                    (1 << 4)
+
 struct edd_device_params {
 	u16 length;
 	u16 info_flags;
 	u32 num_default_cylinders;
 	u32 num_default_heads;
 	u32 sectors_per_track;
 	u64 number_of_sectors;
 	u16 bytes_per_sector;
 	u32 dpte_ptr;		/* 0xFFFFFFFF for our purposes */
 	u16 key;		/* = 0xBEDD */
@@ -159,28 +162,44 @@
 		} __attribute__ ((packed)) sata;
 		struct {
 			u64 reserved1;
 			u64 reserved2;
 		} __attribute__ ((packed)) unknown;
 	} device_path;
 	u8 reserved4;
 	u8 checksum;
 } __attribute__ ((packed));
 
+struct edd_dpte {
+	u16 port_base;
+	u16 port_command;
+	u8 drive_flags;
+	u8 proprietary_informations;
+	u8 irq;
+	u8 multi_sector_count;
+	u8 dma_control;
+	u8 programmed_io;
+	u16 drive_options;
+	u16 reserved5;
+	u8 extension_level;
+	u8 edd2_checksum;
+} __attribute__ ((packed));
+
 struct edd_info {
 	u8 device;
 	u8 version;
 	u16 interface_support;
 	u16 legacy_max_cylinder;
 	u8 legacy_max_head;
 	u8 legacy_sectors_per_track;
 	struct edd_device_params params;
+	struct edd_dpte dpte;
 } __attribute__ ((packed));
 
 struct edd {
 	unsigned int mbr_signature[EDD_MBR_SIG_MAX];
 	struct edd_info edd_info[EDDMAXNR];
 	unsigned char mbr_signature_nr;
 	unsigned char edd_info_nr;
 };
 
 extern struct edd edd;

freddy77



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: EDD enhanchement patch
  2004-07-06 16:53 EDD enhanchement patch Frediano Ziglio
@ 2004-07-07 17:40 ` Andries Brouwer
  2004-07-07 20:48   ` Frediano Ziglio
  0 siblings, 1 reply; 6+ messages in thread
From: Andries Brouwer @ 2004-07-07 17:40 UTC (permalink / raw)
  To: Frediano Ziglio
  Cc: Andries Brouwer, linux-kernel, Bartlomiej Zolnierkiewicz,
	Patrick J. LoPresti

On Tue, Jul 06, 2004 at 06:53:28PM +0200, Frediano Ziglio wrote:

> This patch add support for DTPE data in EDD and mbr_signature. This
> patch do not solve fdisk problems but can help these programs to compute
> correct head count.


Thanks!

(Please, do not gzip - it is much easier to look at the patch
when it is not gzipped, and not hidden in an attachment.
Also for later, for searching things with Google or so, simple
letters are preferable.)

See that Matt Domsch looked at the code. Good. He wrote
 "I don't think this is quite ready to include yet,
  but I'm not philosophically opposed to it, so let's work it out.
  First, I want to understand what information in the DPTE you need.
  I assume byte offset 4, bit 6 (LBA enable), and bytes 10-11 bit 3
  (CHS translation enabled) and bit 4 (LBA translation enabled), yes?
  How are you expecting tools like fdisk to use this information?"

Let me give my answers. No I am not opposed to it, philosophically
or otherwise. It is easiest not to think about what parts might be useful -
next week you might think of some other use. Just fetch all available
information and make it available to user space without looking at it.
(There is a checksum. A revision number. A bit "removable". A Master/Slave bit...)

All this stuff is not very useful. But in some cases it helps.

Long ago I did something similar. Let me see whether I can retrieve that.
Ah, yes. "Collection of BIOS disk info, aeb, Feb 1999"
See http://ftp.cwi.nl/aeb/getbios/2.2.2.patch-HDIO_GETBIOS

+! Try to collect all disk information the BIOS can give us.
+! Such information is difficult to interpret:
+! We don't know whether hd0, hd1, ... are IDE or SCSI disks.
+! Some disks may not be mentioned in the BIOS setup and will
+! probably not be seen here.
+! So, instead of trying to make sense of this, we make the
+! collected information available by ioctl to user space.
+!
+! Layout collected disk data (where DD stands for disk_data)
+! 0x0080-0x008f: hd0 data, from int 41
+! 0x0090-0x009f: hd1 data, from int 46
+! DD[0x000-0x02f]: data following int 41 table, possibly hd1..3
+! DD[0x030-0x0af]: hd0..15 geometry, from int 13, fn 15, 8
+! DD[0x0b0-0x1f8]: hd0..3 Phoenix data, from int 13, fn 41,48
+! Phoenix data has extensive info but takes a lot of space
+! For the moment for 4 disks only

It looks like this is about what Matt and Patrick and you have.
Matt also has something new and very useful: these 4-byte disk signatures.
As additional info I had this "data following int 41 table".
Marginally useful, but it sometimes helps.

There is a difference in philosophy: I made all of the garbage
extracted from the BIOS available to user space without any attempt
at validating or interpreting it in the kernel. A user space routine
sniffed the data and tried to construct the BIOS-Linux disk correspondence,
using ordering and sizes and geometry of the disks.

I never pushed this - had hoped for something that would identify
the correspondence with high probability, but the results were disappointing.

Not many BIOSes implemented Phoenix 3.0, so the much better data provided
by that did not help so much.

I saw mail by Matt Domsch two weeks ago or so, saying "I've got a huge number of
reports, and virtually all show that EDD 3.0 is not supported, or if supported,
is likely implemented in ways contrary to the spec."
So, it seems things have not improved much in these five years.

Of course, one can do a much better job when disk I/O is allowed.
For example, read the first 256 sectors and compute an md5sum.
Reading the MBR signature falls into this category.

There are complications for RAID, even when EDD 3.0 is supported.


Andries


An example.
------------------------------------------------------------------------------------
hd0:  C/H/S= 1020/200/62
hd1:  C/H/S= 1024/255/63
hd00: C/H/S= 1024/255/63
hd01: garbage
hd02: garbage
disk 0: len=0
disk 1: len=0
disk 2: len=0
disk 3: len=0


Found 7 Linux disks

hda: Size  33750864 LinuxCHS=2721/200/62 FdiskCHS=-/16/63
  LBASize  33750864 CurSize  33750864  RawCHS=33483/16/63 CurCHS=2721/200/62
hdb: Size  23547888 LinuxCHS=23361/16/63 FdiskCHS=-/16/63
  LBASize  23547888 CurSize  23547888  RawCHS=23361/16/63 CurCHS=23361/16/63
hdc: Size    417792 LinuxCHS=1024/12/34 FdiskCHS=-/12/34
  LBASize         0 CurSize    417792  RawCHS=1024/12/34 CurCHS=1024/12/34
sda: Size  12657717 LinuxCHS=1020/200/62 FdiskCHS=-/200/62
sdb: Size  17755792 LinuxCHS=8669/64/32 FdiskCHS=-/0/0
sdc: Size   4226725 LinuxCHS=2063/64/32 FdiskCHS=-/64/32
sdd: Size   3517856 LinuxCHS=1717/64/32 FdiskCHS=-/64/32


Found 5 BIOS disks

0 of 5:   12648000 sectors, C/H/S 1020 / 200 / 62 OK
1 of 5:   16450560 sectors, C/H/S 1024 / 255 / 63 OK
2 of 5:    2097152 sectors, C/H/S 1024 / 64 / 32 OK
3 of 5:    2097152 sectors, C/H/S 1024 / 64 / 32 OK
4 of 5: 4292876420 sectors, C/H/S 1023 / 16 / 63 C*H*S=1031184


hda: 0x84?
hdb: 0x84?
hdc:not in BIOS
sda: 0x80
sdb: 0x81
sdc: 0x82
sdd: 0x83

This is a machine booted from SCSI with

hda: Maxtor 91728D8, 16479MB w/512kB Cache, CHS=2721/200/62, (U)DMA
        RawCHS=16383/16/63, CurCHS=16383/16/63, CurSects=16514064, LBAsects=33750864
hdb: QUANTUM Bigfoot TX12.0AT, 11497MB w/69kB Cache, CHS=23361/16/63, (U)DMA
        RawCHS=16383/16/63, CurCHS=16383/16/63, CurSects=16514064, LBAsects=23547888
hdc: ST3243A, 204MB w/32kB Cache, CHS=1024/12/34
        RawCHS=1024/12/34, LBA=no.

hd0 reports sda (and the kernel mistakes it for hda)
hd1 reports sdb, I suppose
------------------------------------------------------------------------------------

This was an example without INT 13 extensions. One with:

------------------------------------------------------------------------------------
disk 0: len=26
  flags 0, phys CHS 0/0/0, totsecs 12594960, seclen 512
  disk 1: len=26
  flags 0, phys CHS 0/0/0, totsecs 6306048, seclen 512
  disk 2: len=26
  flags 0, phys CHS 0/0/0, totsecs 13269690, seclen 512
  disk 3: len=26
  flags 0, phys CHS 0/0/0, totsecs 13269690, seclen 512

Found 5 Linux disks

hda: Size  12594960 LinuxCHS=13328/15/63 FdiskCHS=-/0/63
  LBASize  12594960 CurSize  12594960  RawCHS=13328/15/63 CurCHS=13328/15/63
hdb: Size   6306048 LinuxCHS=782/128/63 FdiskCHS=-/128/63
  LBASize   6306048 CurSize   6306048  RawCHS=6256/16/63 CurCHS=782/128/63
hdc: Size  13281408 LinuxCHS=13176/16/63 FdiskCHS=-/0/63
  LBASize  13281408 CurSize  13281408  RawCHS=13176/16/63 CurCHS=13176/16/63
hdd: Size  13281408 LinuxCHS=13176/16/63 FdiskCHS=-/0/0
  LBASize  13281408 CurSize  13281408  RawCHS=13176/16/63 CurCHS=13176/16/63
hdh: Size    196608 LinuxCHS=32/64/96 FdiskCHS=-/0/0
  LBASize         0 CurSize         0  RawCHS=0/0/0 CurCHS=0/0/0

Found 8 BIOS disks

0 of 4:   12578895 sectors, C/H/S 783 / 255 / 63 OK
1 of 4:    6297984 sectors, C/H/S 781 / 128 / 63 OK
2 of 4:   13253625 sectors, C/H/S 825 / 255 / 63 OK
3 of 4:   13253625 sectors, C/H/S 825 / 255 / 63 OK
4 of 4:      20740 sectors, C/H/S 305 / 4 / 17 OK
5 of 4:      20740 sectors, C/H/S 305 / 4 / 17 OK
6 of 4:      20740 sectors, C/H/S 305 / 4 / 17 OK
7 of 4:      20740 sectors, C/H/S 305 / 4 / 17 OK

hda: 0x80?
hdb: 0x81
hdc: 0x80? 0x82? 0x83?
hdd: 0x80? 0x82? 0x83?
hdh:not in BIOS

Here the IBM extensions report the same size as Linux does
for the Quantum Fireballs, but for the Maxtors we have:
Linux 13281408, IBM extensions 13269690, BIOS 13253625.
The BIOS value is derived from 825*255*63, the IBM extensions value from
826*255*63, so that the BIOS here decides that the last cylinder is a
test cylinder.
The BIOS did not return an error when we asked for disks 4-7 but says
that there are only 4 disks (0-3), and the data for 4-7 is not meaningful.
Thus, Ralf Brown (INT 13, AH=8) is incomplete when he suggests to use
INT 13, AH=15 to check on INT 13, AH=8: in this case both succeeded.
--------------------------------------------------------------------------------

I can imagine that we sooner or later would like to have a preinitrd,
configurable, describing all things that should be done in real mode
before actually starting the kernel. The main problem would be how to
communicate.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: EDD enhanchement patch
  2004-07-07 17:40 ` Andries Brouwer
@ 2004-07-07 20:48   ` Frediano Ziglio
  2004-07-07 23:24     ` Andries Brouwer
  0 siblings, 1 reply; 6+ messages in thread
From: Frediano Ziglio @ 2004-07-07 20:48 UTC (permalink / raw)
  To: Andries Brouwer
  Cc: linux-kernel, Bartlomiej Zolnierkiewicz, Patrick J. LoPresti

Il mer, 2004-07-07 alle 19:40, Andries Brouwer ha scritto:
> On Tue, Jul 06, 2004 at 06:53:28PM +0200, Frediano Ziglio wrote:
> 
> > This patch add support for DTPE data in EDD and mbr_signature. This
> > patch do not solve fdisk problems but can help these programs to compute
> > correct head count.
> 
> 
> Thanks!
> 
> (Please, do not gzip - it is much easier to look at the patch
> when it is not gzipped, and not hidden in an attachment.
> Also for later, for searching things with Google or so, simple
> letters are preferable.)
> 

Updated online patch sent.

> See that Matt Domsch looked at the code. Good. He wrote
>  "I don't think this is quite ready to include yet,
>   but I'm not philosophically opposed to it, so let's work it out.
>   First, I want to understand what information in the DPTE you need.
>   I assume byte offset 4, bit 6 (LBA enable), and bytes 10-11 bit 3
>   (CHS translation enabled) and bit 4 (LBA translation enabled), yes?
>   How are you expecting tools like fdisk to use this information?"
> 
> Let me give my answers. No I am not opposed to it, philosophically
> or otherwise. It is easiest not to think about what parts might be useful -
> next week you might think of some other use. Just fetch all available
> information and make it available to user space without looking at it.
> (There is a checksum. A revision number. A bit "removable". A Master/Slave bit...)
> 
> All this stuff is not very useful. But in some cases it helps.
> 

Did anyone forget about first fields? base-port and control-port ? It
you have an IDE disks they correspond with IDE port and with slave bit
you can know exactly witch disk is. EDD 3.0 it's not required cause it's
EDD 2.0 (supported by most recent BIOSes).

> Long ago I did something similar. Let me see whether I can retrieve that.
> Ah, yes. "Collection of BIOS disk info, aeb, Feb 1999"
> See http://ftp.cwi.nl/aeb/getbios/2.2.2.patch-HDIO_GETBIOS
> 
> +! Try to collect all disk information the BIOS can give us.
> +! Such information is difficult to interpret:
> +! We don't know whether hd0, hd1, ... are IDE or SCSI disks.
> +! Some disks may not be mentioned in the BIOS setup and will
> +! probably not be seen here.
> +! So, instead of trying to make sense of this, we make the
> +! collected information available by ioctl to user space.
> +!
> +! Layout collected disk data (where DD stands for disk_data)
> +! 0x0080-0x008f: hd0 data, from int 41
> +! 0x0090-0x009f: hd1 data, from int 46
> +! DD[0x000-0x02f]: data following int 41 table, possibly hd1..3
> +! DD[0x030-0x0af]: hd0..15 geometry, from int 13, fn 15, 8
> +! DD[0x0b0-0x1f8]: hd0..3 Phoenix data, from int 13, fn 41,48
> +! Phoenix data has extensive info but takes a lot of space
> +! For the moment for 4 disks only
> 
> It looks like this is about what Matt and Patrick and you have.
> Matt also has something new and very useful: these 4-byte disk signatures.
> As additional info I had this "data following int 41 table".
> Marginally useful, but it sometimes helps.
> 

2.4 read also CMOS. Just a bit of story: first BIOSes only support fixed
disks settings. Later on they introduced dynamic settings (manually
enter physical C/H/S values). EIDE introduce C/H/S detection. When disks
raise in size BIOSes introduced C/H/S translation. Newer BIOS introduced
setting to select if init first SCSI or IDE, which IDE disk to start,
cdrom, USB, LS-120 and even pcmcia!! SCSI it's always a BIOS extension
(another peace of code) even if integrated on motherboard. Usually BIOS
assign disk number in order (hda that hdb and so on).

> There is a difference in philosophy: I made all of the garbage
> extracted from the BIOS available to user space without any attempt
> at validating or interpreting it in the kernel. A user space routine
> sniffed the data and tried to construct the BIOS-Linux disk correspondence,
> using ordering and sizes and geometry of the disks.
> 

Good. However HDIO_GETGEO still report a type of information that Linux
do not prefer..

> I never pushed this - had hoped for something that would identify
> the correspondence with high probability, but the results were disappointing.
> 
> Not many BIOSes implemented Phoenix 3.0, so the much better data provided
> by that did not help so much.
> 
> I saw mail by Matt Domsch two weeks ago or so, saying "I've got a huge number of
> reports, and virtually all show that EDD 3.0 is not supported, or if supported,
> is likely implemented in ways contrary to the spec."
> So, it seems things have not improved much in these five years.
> 
> Of course, one can do a much better job when disk I/O is allowed.
> For example, read the first 256 sectors and compute an md5sum.
> Reading the MBR signature falls into this category.
> 
> There are complications for RAID, even when EDD 3.0 is supported.
> 

Did you refer to RAID IDE where the controller store informations on
disks??

> 
> Andries
> 
> 
> An example.
> ------------------------------------------------------------------------------------
> hd0:  C/H/S= 1020/200/62
> hd1:  C/H/S= 1024/255/63
> hd00: C/H/S= 1024/255/63
> hd01: garbage
> hd02: garbage
> disk 0: len=0
> disk 1: len=0
> disk 2: len=0
> disk 3: len=0
> 
> 
> Found 7 Linux disks
> 
> hda: Size  33750864 LinuxCHS=2721/200/62 FdiskCHS=-/16/63
>   LBASize  33750864 CurSize  33750864  RawCHS=33483/16/63 CurCHS=2721/200/62
> hdb: Size  23547888 LinuxCHS=23361/16/63 FdiskCHS=-/16/63
>   LBASize  23547888 CurSize  23547888  RawCHS=23361/16/63 CurCHS=23361/16/63
> hdc: Size    417792 LinuxCHS=1024/12/34 FdiskCHS=-/12/34
>   LBASize         0 CurSize    417792  RawCHS=1024/12/34 CurCHS=1024/12/34
> sda: Size  12657717 LinuxCHS=1020/200/62 FdiskCHS=-/200/62
> sdb: Size  17755792 LinuxCHS=8669/64/32 FdiskCHS=-/0/0
> sdc: Size   4226725 LinuxCHS=2063/64/32 FdiskCHS=-/64/32
> sdd: Size   3517856 LinuxCHS=1717/64/32 FdiskCHS=-/64/32
> 
> 
> Found 5 BIOS disks
> 
> 0 of 5:   12648000 sectors, C/H/S 1020 / 200 / 62 OK
> 1 of 5:   16450560 sectors, C/H/S 1024 / 255 / 63 OK
> 2 of 5:    2097152 sectors, C/H/S 1024 / 64 / 32 OK
> 3 of 5:    2097152 sectors, C/H/S 1024 / 64 / 32 OK
> 4 of 5: 4292876420 sectors, C/H/S 1023 / 16 / 63 C*H*S=1031184
> 
> 
> hda: 0x84?
> hdb: 0x84?
> hdc:not in BIOS
> sda: 0x80
> sdb: 0x81
> sdc: 0x82
> sdd: 0x83
> 
> This is a machine booted from SCSI with
> 
> hda: Maxtor 91728D8, 16479MB w/512kB Cache, CHS=2721/200/62, (U)DMA
>         RawCHS=16383/16/63, CurCHS=16383/16/63, CurSects=16514064, LBAsects=33750864
> hdb: QUANTUM Bigfoot TX12.0AT, 11497MB w/69kB Cache, CHS=23361/16/63, (U)DMA
>         RawCHS=16383/16/63, CurCHS=16383/16/63, CurSects=16514064, LBAsects=23547888
> hdc: ST3243A, 204MB w/32kB Cache, CHS=1024/12/34
>         RawCHS=1024/12/34, LBA=no.
> 
> hd0 reports sda (and the kernel mistakes it for hda)
> hd1 reports sdb, I suppose

1020/200/62 matches exactly so it's
sda <-> 0x80
For order we should continue with SCSI. Also 0x82 and 0x83 match exactly
with sdc and sdd and you can exclude IDE (translation always use higher
values), so it's
sdb <-> 0x81
sdc <-> 0x82
sdd <-> 0x83

For 0x84 it must be  cause it's the first IDE.
I know that some boot loader can however change disk order. Does anyone
know how they can do this? Is there a BIOS interface for this purpose?

> ------------------------------------------------------------------------------------
> 
> This was an example without INT 13 extensions. One with:
> 
> ------------------------------------------------------------------------------------
> disk 0: len=26
>   flags 0, phys CHS 0/0/0, totsecs 12594960, seclen 512
>   disk 1: len=26
>   flags 0, phys CHS 0/0/0, totsecs 6306048, seclen 512
>   disk 2: len=26
>   flags 0, phys CHS 0/0/0, totsecs 13269690, seclen 512
>   disk 3: len=26
>   flags 0, phys CHS 0/0/0, totsecs 13269690, seclen 512
> 
> Found 5 Linux disks
> 
> hda: Size  12594960 LinuxCHS=13328/15/63 FdiskCHS=-/0/63
>   LBASize  12594960 CurSize  12594960  RawCHS=13328/15/63 CurCHS=13328/15/63
> hdb: Size   6306048 LinuxCHS=782/128/63 FdiskCHS=-/128/63
>   LBASize   6306048 CurSize   6306048  RawCHS=6256/16/63 CurCHS=782/128/63
> hdc: Size  13281408 LinuxCHS=13176/16/63 FdiskCHS=-/0/63
>   LBASize  13281408 CurSize  13281408  RawCHS=13176/16/63 CurCHS=13176/16/63
> hdd: Size  13281408 LinuxCHS=13176/16/63 FdiskCHS=-/0/0
>   LBASize  13281408 CurSize  13281408  RawCHS=13176/16/63 CurCHS=13176/16/63
> hdh: Size    196608 LinuxCHS=32/64/96 FdiskCHS=-/0/0
>   LBASize         0 CurSize         0  RawCHS=0/0/0 CurCHS=0/0/0
> 
> Found 8 BIOS disks
> 
> 0 of 4:   12578895 sectors, C/H/S 783 / 255 / 63 OK
> 1 of 4:    6297984 sectors, C/H/S 781 / 128 / 63 OK
> 2 of 4:   13253625 sectors, C/H/S 825 / 255 / 63 OK
> 3 of 4:   13253625 sectors, C/H/S 825 / 255 / 63 OK
> 4 of 4:      20740 sectors, C/H/S 305 / 4 / 17 OK
> 5 of 4:      20740 sectors, C/H/S 305 / 4 / 17 OK
> 6 of 4:      20740 sectors, C/H/S 305 / 4 / 17 OK
> 7 of 4:      20740 sectors, C/H/S 305 / 4 / 17 OK
> 
> hda: 0x80?
> hdb: 0x81
> hdc: 0x80? 0x82? 0x83?
> hdd: 0x80? 0x82? 0x83?
> hdh:not in BIOS
> 
> Here the IBM extensions report the same size as Linux does
> for the Quantum Fireballs, but for the Maxtors we have:
> Linux 13281408, IBM extensions 13269690, BIOS 13253625.
> The BIOS value is derived from 825*255*63, the IBM extensions value from
> 826*255*63, so that the BIOS here decides that the last cylinder is a
> test cylinder.
> The BIOS did not return an error when we asked for disks 4-7 but says
> that there are only 4 disks (0-3), and the data for 4-7 is not meaningful.
> Thus, Ralf Brown (INT 13, AH=8) is incomplete when he suggests to use
> INT 13, AH=15 to check on INT 13, AH=8: in this case both succeeded.

I know Ralf Brown's list is remembered as a bible however I don't think
Ralf can collect all BIOSes bug in PC story :)

I already see this "test cylinder" before..

Here Linux has some problem with hdh..
hdh: Size    196608 LinuxCHS=32/64/96 FdiskCHS=-/0/0
  LBASize         0 CurSize         0  RawCHS=0/0/0 CurCHS=0/0/0
lba 0 ?? cursize 0 ?? sector > 63 ??
IMHO this disk doesn't exist...

hdb must be 0x81 (no 1024 limit and LBA match)
hda must be 0x80 (LBA size and 825 / 255 / 63 can't fit)
hdc 0x82 and hdd 0x83 just for order...

A good way would be to call int13 from Linux a emulated real-mode and
catch port used (not that easy however...).

> --------------------------------------------------------------------------------
> 
> I can imagine that we sooner or later would like to have a preinitrd,
> configurable, describing all things that should be done in real mode
> before actually starting the kernel. The main problem would be how to
> communicate.
> 

Here I really don't catch you...
initrd it's executed after kernel init, before real mode there is only
setup.S code (and it starts before kernel).

freddy77



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: EDD enhanchement patch
  2004-07-07 20:48   ` Frediano Ziglio
@ 2004-07-07 23:24     ` Andries Brouwer
  0 siblings, 0 replies; 6+ messages in thread
From: Andries Brouwer @ 2004-07-07 23:24 UTC (permalink / raw)
  To: Frediano Ziglio
  Cc: Andries Brouwer, linux-kernel, Bartlomiej Zolnierkiewicz,
	Patrick J. LoPresti

On Wed, Jul 07, 2004 at 10:48:51PM +0200, Frediano Ziglio wrote:

> Did anyone forget about first fields? base-port and control-port ? If
> you have an IDE disk they correspond with IDE port and with slave bit
> you can know exactly which disk is. EDD 3.0 it's not required cause it's
> EDD 2.0 (supported by most recent BIOSes).

True. Below a simple example for hda and hdb.
Yes, having EDD 2.0 helps.

> lba 0 ?? cursize 0 ?? sector > 63 ??
> IMHO this disk doesn't exist...

It was hdh: IOMEGA ZIP 100 ATAPI, ATAPI FLOPPY drive, with geometry
(probably 96/64/32, don't know why C and S are interchanged)
obtained from HDIO_GET_IDENTITY.

> For 0x84 it must be hda cause it's the first IDE.

hda or hdb. Since that system boots from SCSI there is no reason to
prefer seeing the first or second IDE disk in the BIOS setup.
(Don't know anymore what the truth was.)

> I know that some boot loader can however change disk order.

Also Linux can change disk order with boot option "ide=reverse".

Andries

----------------------------------------------------------------------------------------
disk 0: len=30 api=0x1
  flags 2, phys CHS 2100/255/63, totsecs 33736500, seclen 512
iobase 0x1f0  controlport 0x3f6 irq 14 sector_count 16 dma 32 pio 4
flags: 0xe0: LBA, Master; revision 1.1

disk 1: len=30 api=0x1
  flags 2, phys CHS 2100/255/63, totsecs 33736500, seclen 512
iobase 0x1f0  controlport 0x3f6 irq 14 sector_count 16 dma 32 pio 4
flags: 0xf0: LBA, Slave; revision 1.1

Found 2 Linux disks

hda: Size  33750864 LinuxCHS=2100/255/63 FdiskCHS=*/0/63
  LBASize  33750864 CurSize  33750864  RawCHS=33483/16/63 CurCHS=2100/255/63
hdb: Size  33750864 LinuxCHS=2100/255/63 FdiskCHS=*/255/63
  LBASize  33750864 CurSize  33750864  RawCHS=33483/16/63 CurCHS=2100/255/63

Found 2 BIOS disks

0 of 2:   33720435 sectors, C/H/S 1024 / 255 / 63 C*H*S=16450560
1 of 2:   33720435 sectors, C/H/S 1024 / 255 / 63 C*H*S=16450560


hda: 0x80
hdb: 0x81
----------------------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: EDD enhanchement patch
  2004-07-07 10:05 ` Frediano Ziglio
@ 2004-07-08 12:56   ` Matt Domsch
  0 siblings, 0 replies; 6+ messages in thread
From: Matt Domsch @ 2004-07-08 12:56 UTC (permalink / raw)
  To: Frediano Ziglio
  Cc: Andrew Morton, linux-kernel, Bartlomiej Zolnierkiewicz,
	Patrick J. LoPresti

On Wed, 7 Jul 2004, Frediano Ziglio wrote:

> Here you are, inlined (with your change it's quite smaller)
> Fixed a stupid bug too (I'm used to code in Intel asm, not GNU asm...)
> It seems that some BIOS (like mine) fill with an invalid pointer using
> USB disks, add code to test DPTE data (using checksum).

At a glance this looks good, but I won't be able to test it myself for a 
few weeks.  If others can do so, I encourage it.

Thanks,
Matt

-- 
Matt Domsch
Sr. Software Engineer, Lead Engineer
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-07-08 12:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-06 16:53 EDD enhanchement patch Frediano Ziglio
2004-07-07 17:40 ` Andries Brouwer
2004-07-07 20:48   ` Frediano Ziglio
2004-07-07 23:24     ` Andries Brouwer
  -- strict thread matches above, loose matches on Subject: below --
2004-07-07  4:45 Fw: " Matt Domsch
2004-07-07 10:05 ` Frediano Ziglio
2004-07-08 12:56   ` Matt Domsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox