summaryrefslogtreecommitdiff
path: root/sys/arch/hppa
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2006-07-03 20:00:23 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2006-07-03 20:00:23 +0000
commit141511f529dd014f1123943b675252f612002909 (patch)
tree34678c11938563da654bf6f33425fd39d76dee5c /sys/arch/hppa
parentdd326d0b747ea6e80c64b072ac3845516fd575ab (diff)
Eliminate most of the #if/#endif maze in alpha, hppa, hppa64, and mips64
disklabel code that was intended to support cross-endian and cross-architecture use of disklabels. Never actually used except for Alpha<->Amiga moves that now can't happen anyway. Leave native and DOS MBR disklabel code. Tested on alpha and hppa. No functional change.
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r--sys/arch/hppa/hppa/disksubr.c146
-rw-r--r--sys/arch/hppa/include/disklabel.h10
2 files changed, 16 insertions, 140 deletions
diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c
index bfb6e703016..d835103c18e 100644
--- a/sys/arch/hppa/hppa/disksubr.c
+++ b/sys/arch/hppa/hppa/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.25 2006/07/01 16:50:32 krw Exp $ */
+/* $OpenBSD: disksubr.c,v 1.26 2006/07/03 20:00:22 krw Exp $ */
/*
* Copyright (c) 1999 Michael Shalayeff
@@ -39,9 +39,6 @@
* but it was always thought it should be made completely MI and not need to
* be in that alpha-specific tree at all.
*
- * XXX The DOS partitioning code is not endian-independent, only native
- * endian DOS partition tables can be parsed yet.
- *
* XXX HPUX disklabel is not understood yet.
*/
@@ -54,97 +51,35 @@
#include <sys/disk.h>
/* The native defaults... */
-#if defined(alpha) && !defined(DISKLABEL_ALPHA)
-#define DISKLABEL_ALPHA
-#elif (defined(i386) || defined(arc)) && !defined(DISKLABEL_I386)
+#if defined(DISKLABEL_ALL) && !defined(DISKLABEL_I386)
#define DISKLABEL_I386
-#elif (defined(hppa) || defined(hppa64)) && !defined(DISKLABEL_HPPA)
-#define DISKLABEL_HPPA
#endif
-#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL)
-void swapdisklabel(struct disklabel *d);
char *readbsdlabel(struct buf *, void (*)(struct buf *), int, int,
- int, int, struct disklabel *, int);
-#endif
-#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL)
+ int, struct disklabel *, int);
+#if defined(DISKLABEL_I386)
char *readdoslabel(struct buf *, void (*)(struct buf *),
struct disklabel *, struct cpu_disklabel *, int *, int *, int);
#endif
-#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL)
char *readliflabel(struct buf *, void (*)(struct buf *),
struct disklabel *, struct cpu_disklabel *, int *, int *, int);
-#endif
static enum disklabel_tag probe_order[] = { LABELPROBES, -1 };
-#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALPHA) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL)
-
-/*
- * Byteswap all the fields that might be swapped.
- */
-void
-swapdisklabel(dlp)
- struct disklabel *dlp;
-{
- int i;
- struct partition *pp;
-
- swap32(dlp->d_magic);
- swap16(dlp->d_type);
- swap16(dlp->d_subtype);
- swap32(dlp->d_secsize);
- swap32(dlp->d_nsectors);
- swap32(dlp->d_ntracks);
- swap32(dlp->d_ncylinders);
- swap32(dlp->d_secpercyl);
- swap32(dlp->d_secperunit);
- swap16(dlp->d_sparespertrack);
- swap16(dlp->d_sparespercyl);
- swap32(dlp->d_acylinders);
- swap16(dlp->d_rpm);
- swap16(dlp->d_interleave);
- swap16(dlp->d_trackskew);
- swap16(dlp->d_cylskew);
- swap32(dlp->d_headswitch);
- swap32(dlp->d_trkseek);
- swap32(dlp->d_flags);
- for (i = 0; i < NDDATA; i++)
- swap32(dlp->d_drivedata[i]);
- for (i = 0; i < NSPARE; i++)
- swap32(dlp->d_spare[i]);
- swap32(dlp->d_magic2);
- swap16(dlp->d_checksum);
- swap16(dlp->d_npartitions);
- swap32(dlp->d_bbsize);
- swap32(dlp->d_sbsize);
- for (i = 0; i < MAXPARTITIONS; i++) {
- pp = &dlp->d_partitions[i];
- swap32(pp->p_size);
- swap32(pp->p_offset);
- swap32(pp->p_fsize);
- swap16(pp->p_cpg);
- }
-}
-
/*
* Try to read a standard BSD disklabel at a certain sector.
*/
char *
-readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly)
+readbsdlabel(bp, strat, cyl, sec, off, lp, spoofonly)
struct buf *bp;
void (*strat)(struct buf *);
- int cyl, sec, off, endian;
+ int cyl, sec, off;
struct disklabel *lp;
int spoofonly;
{
struct disklabel *dlp;
char *msg = NULL;
u_int16_t cksum;
- u_int32_t magic;
-
- if (endian != LITTLE_ENDIAN && endian != BIG_ENDIAN)
- panic("readbsdlabel: unsupported byteorder %d", endian);
/* don't read the on-disk label if we are in spoofed-only mode */
if (spoofonly)
@@ -163,8 +98,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly)
return (msg);
}
- magic = endian == BIG_ENDIAN ? htobe32(DISKMAGIC) : htole32(DISKMAGIC);
-
/*
* If off is negative, search until the end of the sector for
* the label, otherwise, just look at the specific location
@@ -172,25 +105,15 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly)
*/
dlp = (struct disklabel *)(bp->b_data + (off >= 0 ? off : 0));
do {
- if (dlp->d_magic != magic || dlp->d_magic2 != magic) {
+ if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
if (msg == NULL)
msg = "no disk label";
} else {
cksum = dkcksum(dlp);
- if (endian != BYTE_ORDER)
- swapdisklabel(dlp);
if (dlp->d_npartitions > MAXPARTITIONS || cksum != 0) {
msg = "disk label corrupted";
- /* swap back if necessary. */
- if (off < 0 && endian != BYTE_ORDER)
- swapdisklabel(dlp);
} else {
*lp = *dlp;
- /* Recalc magic on foreign labels */
- if (endian != BYTE_ORDER) {
- lp->d_checksum = 0;
- lp->d_checksum = dkcksum(lp);
- }
msg = NULL;
break;
}
@@ -202,7 +125,6 @@ readbsdlabel(bp, strat, cyl, sec, off, endian, lp, spoofonly)
sizeof(*dlp)));
return (msg);
}
-#endif
/*
* Attempt to read a disk label from a device
@@ -253,15 +175,8 @@ readdisklabel(dev, strat, lp, osdep, spoofonly)
for (tp = probe_order; msg && *tp != -1; tp++) {
switch (*tp) {
- case DLT_ALPHA:
-#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL)
- msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR,
- ALPHA_LABELOFFSET, LITTLE_ENDIAN, lp, spoofonly);
-#endif
- break;
-
case DLT_I386:
-#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL)
+#if defined(DISKLABEL_I386)
msg = readdoslabel(bp, strat, lp, osdep, 0, 0, spoofonly);
if (msg)
/* Fallback alternative */
@@ -270,9 +185,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly)
break;
case DLT_HPPA:
-#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL)
msg = readliflabel(bp, strat, lp, osdep, 0, 0, spoofonly);
-#endif
break;
default:
@@ -309,7 +222,7 @@ done:
return (msg);
}
-#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL)
+#if defined(DISKLABEL_I386)
/*
* If dos partition table requested, attempt to load it and
* find disklabel inside a DOS partition. Also, if bad block
@@ -499,7 +412,7 @@ donot:
/* next, dig out disk label */
msg = readbsdlabel(bp, strat, cyl, dospartoff + I386_LABELSECTOR, -1,
- LITTLE_ENDIAN, lp, spoofonly);
+ lp, spoofonly);
if (msg)
return (msg);
@@ -551,7 +464,6 @@ donot:
}
#endif
-#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL)
char *
readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly)
struct buf *bp;
@@ -711,9 +623,8 @@ readliflabel (bp, strat, lp, osdep, partoffp, cylp, spoofonly)
*partoffp = fsoff;
return readbsdlabel(bp, strat, 0, fsoff + HPPA_LABELSECTOR,
- HPPA_LABELOFFSET, BIG_ENDIAN, lp, spoofonly);
+ HPPA_LABELOFFSET, lp, spoofonly);
}
-#endif
/*
* Check new disk label for sensibility
@@ -794,11 +705,8 @@ writedisklabel(dev, strat, lp, osdep)
char *msg = "no disk label";
struct buf *bp;
struct disklabel dl;
-#if defined(DISKLABEL_I386) || defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL)
struct cpu_disklabel cdl;
-#endif
- int labeloffset, error, i, endian, partoff = 0, cyl = 0;
- u_int64_t csum, *p;
+ int labeloffset, error, partoff = 0, cyl = 0;
/* get a buffer and initialize it */
bp = geteblk((int)lp->d_secsize);
@@ -813,31 +721,18 @@ writedisklabel(dev, strat, lp, osdep)
for (tp = probe_order; msg && *tp != -1; tp++) {
dl = *lp;
switch (*tp) {
- case DLT_ALPHA:
-#if defined(DISKLABEL_ALPHA) || defined(DISKLABEL_ALL)
- msg = readbsdlabel(bp, strat, 0, ALPHA_LABELSECTOR,
- ALPHA_LABELOFFSET, LITTLE_ENDIAN, &dl, 0);
- labeloffset = ALPHA_LABELOFFSET;
- endian = LITTLE_ENDIAN;
-#endif
- break;
-
case DLT_I386:
-#if defined(DISKLABEL_I386) || defined(DISKLABEL_ALL)
+#if defined(DISKLABEL_I386)
msg = readdoslabel(bp, strat, &dl, &cdl, &partoff,
&cyl, 0);
labeloffset = I386_LABELOFFSET;
- endian = LITTLE_ENDIAN;
#endif
break;
case DLT_HPPA:
-#if defined(DISKLABEL_HPPA) || defined(DISKLABEL_ALL)
msg = readliflabel(bp, strat, &dl, &cdl, &partoff,
&cyl, 0);
labeloffset = HPPA_LABELOFFSET;
- endian = BIG_ENDIAN;
-#endif
break;
default:
@@ -851,28 +746,13 @@ writedisklabel(dev, strat, lp, osdep)
/* Write it in the regular place with native byte order. */
labeloffset = LABELOFFSET;
- endian = BYTE_ORDER;
bp->b_blkno = partoff + LABELSECTOR;
bp->b_cylinder = cyl;
bp->b_bcount = lp->d_secsize;
}
- if (endian != BYTE_ORDER) {
- swapdisklabel(lp);
- /* recalc checksum */
- lp->d_checksum = 0;
- lp->d_checksum = dkcksum(lp);
- }
-
*(struct disklabel *)(bp->b_data + labeloffset) = *lp;
- /* Alpha bootblocks are checksummed. */
- if (*tp == DLT_ALPHA) {
- for (csum = i = 0, p = (u_int64_t *)bp->b_data; i < 63; i++)
- csum += *p++;
- *p = csum;
- }
-
bp->b_flags = B_BUSY | B_WRITE;
(*strat)(bp);
error = biowait(bp);
diff --git a/sys/arch/hppa/include/disklabel.h b/sys/arch/hppa/include/disklabel.h
index e73efe8b578..a3e5b90e628 100644
--- a/sys/arch/hppa/include/disklabel.h
+++ b/sys/arch/hppa/include/disklabel.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.h,v 1.10 2006/06/26 23:11:31 krw Exp $ */
+/* $OpenBSD: disklabel.h,v 1.11 2006/07/03 20:00:22 krw Exp $ */
/* $NetBSD: disklabel.h,v 1.1 1995/02/13 23:07:34 cgd Exp $ */
/*
@@ -34,17 +34,15 @@
#ifndef _MACHINE_DISKLABEL_H_
#define _MACHINE_DISKLABEL_H_
-enum disklabel_tag { DLT_ALPHA, DLT_I386, DLT_HPPA };
+enum disklabel_tag { DLT_I386, DLT_HPPA };
/*
* What disklabels are we probing for, and in which order?
*/
#ifndef LABELPROBES
-#define LABELPROBES DLT_ALPHA, DLT_I386, DLT_HPPA
+#define LABELPROBES DLT_I386, DLT_HPPA
#endif
-#define ALPHA_LABELSECTOR 0 /* sector containing label */
-#define ALPHA_LABELOFFSET 64 /* offset of label in sector */
#define I386_LABELSECTOR 1 /* sector containing label */
#define I386_LABELOFFSET 0 /* offset of label in sector */
#define HPPA_LABELSECTOR 1 /* sector containing label */
@@ -192,8 +190,6 @@ struct cpu_disklabel {
int labelsector;
union {
struct {
- } _alpha;
- struct {
struct dos_partition dosparts[NDOSPART];
struct dkbad bad;
} _i386;