summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2006-10-17 23:20:13 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2006-10-17 23:20:13 +0000
commit504633b3eac97c77e073af15b877798f75a45588 (patch)
treebd788cadc010c249e3e39c84b00514de29862de0 /sys
parenta4de7aa4833c26ca1dd050309f0f32d2f091a689 (diff)
For non-CPU_BIOS architectures calculate the number of cylinders on
a disk rather than accepting the cylinder count provided by the disk or controller. This cylinder count will be '16383' for any disk >8.4G according to the ATA spec. CPU_BIOS on i386/amd64 has magic to deal with this, but other archs do not need to be restricted by the needs of PC BIOS. Fixes the default MBR OpenBSD partition size and disklabel on non-CPU_BIOS archtitectures. No change to behaviour on i386/amd64 machines. Noted by Stuart Henderson on his Thecus. Testing by various, including 'old i386 machines' nick@ ok tom@ pedro@ weingart@ deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ata/wd.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c
index f4e68197bf2..c44dd26ffca 100644
--- a/sys/dev/ata/wd.c
+++ b/sys/dev/ata/wd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wd.c,v 1.50 2006/10/04 00:52:55 krw Exp $ */
+/* $OpenBSD: wd.c,v 1.51 2006/10/17 23:20:12 krw Exp $ */
/* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */
/*
@@ -783,10 +783,21 @@ wdgetdefaultlabel(struct wd_softc *wd, struct disklabel *lp)
bzero(lp, sizeof(struct disklabel));
lp->d_secsize = DEV_BSIZE;
+ lp->d_secperunit = wd->sc_capacity;
lp->d_ntracks = wd->sc_params.atap_heads;
lp->d_nsectors = wd->sc_params.atap_sectors;
- lp->d_ncylinders = wd->sc_params.atap_cylinders;
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+#ifdef CPU_BIOS
+ /*
+ * Stick to what the controller says for BIOS compatibility. Let the
+ * CPU_BIOS logic on i386 and friends deal with any mismatch to actual
+ * size.
+ */
+ lp->d_ncylinders = wd->sc_params.atap_cylinders;
+#else
+ /* We are not constrained by BIOS concerns. Calculate cylinder count. */
+ lp->d_ncylinders = lp->d_secperunit / lp->d_secpercyl;
+#endif
if (wd->drvp->ata_vers == -1) {
lp->d_type = DTYPE_ST506;
strncpy(lp->d_typename, "ST506/MFM/RLL", sizeof lp->d_typename);
@@ -796,7 +807,6 @@ wdgetdefaultlabel(struct wd_softc *wd, struct disklabel *lp)
}
/* XXX - user viscopy() like sd.c */
strncpy(lp->d_packname, wd->sc_params.atap_model, sizeof lp->d_packname);
- lp->d_secperunit = wd->sc_capacity;
lp->d_rpm = 3600;
lp->d_interleave = 1;
lp->d_flags = 0;