Centralise the geometry fudge.

This commit is contained in:
ad 2001-06-10 10:48:42 +00:00
parent 5f1286dfb9
commit bfac43a1c8
6 changed files with 33 additions and 61 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_iop.c,v 1.6 2001/03/20 13:01:49 ad Exp $ */ /* $NetBSD: ld_iop.c,v 1.7 2001/06/10 10:48:43 ad Exp $ */
/*- /*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -216,22 +216,6 @@ ld_iop_attach(struct device *parent, struct device *self, void *aux)
ld->sc_secperunit = (int) ld->sc_secperunit = (int)
(le64toh(param.p.bdi.capacity) / ld->sc_secsize); (le64toh(param.p.bdi.capacity) / ld->sc_secsize);
/* Build synthetic geometry. */
if (ld->sc_secperunit <= 528 * 2048) /* 528MB */
ld->sc_nheads = 16;
else if (ld->sc_secperunit <= 1024 * 2048) /* 1GB */
ld->sc_nheads = 32;
else if (ld->sc_secperunit <= 21504 * 2048) /* 21GB */
ld->sc_nheads = 64;
else if (ld->sc_secperunit <= 43008 * 2048) /* 42GB */
ld->sc_nheads = 128;
else
ld->sc_nheads = 255;
ld->sc_nsectors = 63;
ld->sc_ncylinders = ld->sc_secperunit /
(ld->sc_nheads * ld->sc_nsectors);
switch (param.p.bdi.type) { switch (param.p.bdi.type) {
case I2O_RBS_TYPE_DIRECT: case I2O_RBS_TYPE_DIRECT:
typestr = "direct access"; typestr = "direct access";

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_cac.c,v 1.2 2000/12/11 13:19:51 ad Exp $ */ /* $NetBSD: ld_cac.c,v 1.3 2001/06/10 10:48:43 ad Exp $ */
/*- /*-
* Copyright (c) 2000 The NetBSD Foundation, Inc. * Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -109,14 +109,11 @@ ld_cac_attach(struct device *parent, struct device *self, void *aux)
return; return;
} }
ld->sc_ncylinders = CAC_GET2(dinfo.ncylinders);
ld->sc_nheads = CAC_GET1(dinfo.nheads);
ld->sc_nsectors = CAC_GET1(dinfo.nsectors);
ld->sc_secsize = CAC_GET2(dinfo.secsize); ld->sc_secsize = CAC_GET2(dinfo.secsize);
ld->sc_maxxfer = CAC_MAX_XFER; ld->sc_maxxfer = CAC_MAX_XFER;
ld->sc_maxqueuecnt = CAC_MAX_CCBS / cac->sc_nunits; /* XXX */ ld->sc_maxqueuecnt = CAC_MAX_CCBS / cac->sc_nunits; /* XXX */
ld->sc_secperunit = ld->sc_ncylinders * ld->sc_nheads * ld->sc_secperunit = CAC_GET2(dinfo.ncylinders) *
ld->sc_nsectors; CAC_GET1(dinfo.nheads) * CAC_GET1(dinfo.nsectors);
ld->sc_start = ld_cac_start; ld->sc_start = ld_cac_start;
ld->sc_dump = ld_cac_dump; ld->sc_dump = ld_cac_dump;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_mlx.c,v 1.1 2001/02/04 17:05:12 ad Exp $ */ /* $NetBSD: ld_mlx.c,v 1.2 2001/06/10 10:48:43 ad Exp $ */
/*- /*-
* Copyright (c) 2001 The NetBSD Foundation, Inc. * Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -113,22 +113,8 @@ ld_mlx_attach(struct device *parent, struct device *self, void *aux)
ld->sc_maxqueuecnt = 1; ld->sc_maxqueuecnt = 1;
ld->sc_start = ld_mlx_start; ld->sc_start = ld_mlx_start;
ld->sc_dump = ld_mlx_dump; ld->sc_dump = ld_mlx_dump;
/*
* Build synthetic geometry.
*/
ld->sc_secperunit = ms->ms_size; ld->sc_secperunit = ms->ms_size;
if (ld->sc_secperunit > 0x200000) {
ld->sc_nheads = 255;
ld->sc_nsectors = 63;
ld->sc_ncylinders = ms->ms_size / (255 * 63);
} else {
ld->sc_nheads = 128;
ld->sc_nsectors = 32;
ld->sc_ncylinders = ms->ms_size / (128 * 32);
}
/* /*
* Report on current status, and attach to the ld driver proper. * Report on current status, and attach to the ld driver proper.
*/ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld.c,v 1.8 2001/04/30 02:46:06 lukem Exp $ */ /* $NetBSD: ld.c,v 1.9 2001/06/10 10:48:42 ad Exp $ */
/*- /*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -96,6 +96,22 @@ ldattach(struct ld_softc *sc)
if (sc->sc_maxxfer > MAXPHYS) if (sc->sc_maxxfer > MAXPHYS)
sc->sc_maxxfer = MAXPHYS; sc->sc_maxxfer = MAXPHYS;
/* Build synthetic geometry. */
if (sc->sc_secperunit <= 528 * 2048) /* 528MB */
sc->sc_nheads = 16;
else if (sc->sc_secperunit <= 1024 * 2048) /* 1GB */
sc->sc_nheads = 32;
else if (sc->sc_secperunit <= 21504 * 2048) /* 21GB */
sc->sc_nheads = 64;
else if (sc->sc_secperunit <= 43008 * 2048) /* 42GB */
sc->sc_nheads = 128;
else
sc->sc_nheads = 255;
sc->sc_nsectors = 63;
sc->sc_ncylinders = sc->sc_secperunit /
(sc->sc_nheads * sc->sc_nsectors);
format_bytes(buf, sizeof(buf), (u_int64_t)sc->sc_secperunit * format_bytes(buf, sizeof(buf), (u_int64_t)sc->sc_secperunit *
sc->sc_secsize); sc->sc_secsize);
printf("%s: %s, %d cyl, %d head, %d sec, %d bytes/sect x %d sectors\n", printf("%s: %s, %d cyl, %d head, %d sec, %d bytes/sect x %d sectors\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldvar.h,v 1.4 2001/02/04 17:15:37 ad Exp $ */ /* $NetBSD: ldvar.h,v 1.5 2001/06/10 10:48:42 ad Exp $ */
/*- /*-
* Copyright (c) 2000 The NetBSD Foundation, Inc. * Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -46,19 +46,19 @@ struct ld_softc {
#if NRND > 0 #if NRND > 0
rndsource_element_t sc_rnd_source; rndsource_element_t sc_rnd_source;
#endif #endif
int sc_queuecnt; int sc_queuecnt; /* current h/w queue depth */
int sc_ncylinders; /* # cylinders */
int sc_nheads; /* # heads */
int sc_nsectors; /* # sectors per track */
/* /*
* The following are filled by hardware specific attachment code. * The following are filled by hardware specific attachment code.
*/ */
int sc_flags; /* control flags */ int sc_flags; /* control flags */
int sc_secperunit; /* # sectors in total */ int sc_secperunit; /* # sectors in total */
int sc_ncylinders; /* # cylinders */ int sc_secsize; /* sector size in bytes */
int sc_nheads; /* # heads */ int sc_maxxfer; /* max xfer size in bytes */
int sc_nsectors; /* # sectors per track */ int sc_maxqueuecnt; /* maximum h/w queue depth */
int sc_secsize; /* sector size in bytes */
int sc_maxxfer; /* max xfer size in bytes */
int sc_maxqueuecnt; /* maximum h/w queue count */
int (*sc_dump)(struct ld_softc *, void *, int, int); int (*sc_dump)(struct ld_softc *, void *, int, int);
int (*sc_flush)(struct ld_softc *); int (*sc_flush)(struct ld_softc *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ld_twe.c,v 1.6 2001/01/26 19:53:15 ad Exp $ */ /* $NetBSD: ld_twe.c,v 1.7 2001/06/10 10:48:43 ad Exp $ */
/*- /*-
* Copyright (c) 2000 The NetBSD Foundation, Inc. * Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -107,17 +107,6 @@ ld_twe_attach(struct device *parent, struct device *self, void *aux)
ld->sc_start = ld_twe_start; ld->sc_start = ld_twe_start;
ld->sc_dump = ld_twe_dump; ld->sc_dump = ld_twe_dump;
/* Build synthetic geometry as per controller internal rules. */
if (ld->sc_secperunit > 0x200000) {
ld->sc_nheads = 255;
ld->sc_nsectors = 63;
} else {
ld->sc_nheads = 64;
ld->sc_nsectors = 32;
}
ld->sc_ncylinders = ld->sc_secperunit /
(ld->sc_nheads * ld->sc_nsectors);
printf("\n"); printf("\n");
ldattach(ld); ldattach(ld);
} }