summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2006-10-17 23:20:12 +0000
committerkrw <krw@openbsd.org>2006-10-17 23:20:12 +0000
commitf0dbaa42765a84461347ef9d1e0b414fb571e3c3 (patch)
tree9c3c240ee619ca4ef0fa38711b0762c3bbc5e63d
parentdisable the firmware fastboot feature on 5752/5755 and 5787 ASICs, (diff)
downloadwireguard-openbsd-f0dbaa42765a84461347ef9d1e0b414fb571e3c3.tar.xz
wireguard-openbsd-f0dbaa42765a84461347ef9d1e0b414fb571e3c3.zip
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@
-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;