diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-07-01 16:50:34 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-07-01 16:50:34 +0000 |
commit | b545b1cfa11001abb9631403bb55140b333a62e9 (patch) | |
tree | 62374e5b8097be1d763970a98ab9a508b60343da /sys/arch | |
parent | 7937c561d78b712d86ccecc567ac3775851bb59d (diff) |
Eliminate redundant get_le() in favour of letoh32(). Add letoh32()
calls in alpha, hppa, hppa64 and mips63 when accessing the two DOS MBR
u_int32_t fields dp_size and dp_start.
No functional change.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/alpha/alpha/disksubr.c | 53 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/disksubr.c | 36 | ||||
-rw-r--r-- | sys/arch/amd64/include/disklabel.h | 16 | ||||
-rw-r--r-- | sys/arch/arm/arm/disksubr.c | 36 | ||||
-rw-r--r-- | sys/arch/arm/include/disklabel.h | 22 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/disksubr.c | 28 | ||||
-rw-r--r-- | sys/arch/aviion/include/disklabel.h | 16 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/disksubr.c | 46 | ||||
-rw-r--r-- | sys/arch/hppa64/hppa64/disksubr.c | 46 | ||||
-rw-r--r-- | sys/arch/i386/i386/disksubr.c | 36 | ||||
-rw-r--r-- | sys/arch/i386/include/disklabel.h | 16 | ||||
-rw-r--r-- | sys/arch/macppc/include/disklabel.h | 16 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/disksubr.c | 36 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/disksubr.c | 46 | ||||
-rw-r--r-- | sys/arch/mvmeppc/include/disklabel.h | 16 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/disksubr.c | 36 |
16 files changed, 215 insertions, 286 deletions
diff --git a/sys/arch/alpha/alpha/disksubr.c b/sys/arch/alpha/alpha/disksubr.c index 82b7687c203..ad31b6d365a 100644 --- a/sys/arch/alpha/alpha/disksubr.c +++ b/sys/arch/alpha/alpha/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.44 2006/06/11 21:15:35 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.45 2006/07/01 16:50:32 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -335,7 +335,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) dospartoff = 0; cyl = I386_LABELSECTOR / lp->d_secpercyl; if (dp) { - daddr_t part_blkno = DOSBBSECTOR; + daddr_t part_blkno = DOSBBSECTOR; unsigned long extoff = 0; int wander = 1, n = 0, loop = 0; @@ -344,7 +344,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) * Map the partitions to disklabel entries i-p */ while (wander && n < 8 && loop < 8) { - loop++; + loop++; wander = 0; if (part_blkno < extoff) part_blkno = extoff; @@ -355,7 +355,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) bp->b_flags = B_BUSY | B_READ; bp->b_cylinder = part_blkno / lp->d_secpercyl; (*strat)(bp); - + /* if successful, wander through dos partition table */ if (biowait(bp)) { msg = "dos partition I/O error"; @@ -368,19 +368,19 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) if (ourpart == -1) { /* Search for our MBR partition */ - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -391,13 +391,13 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) * ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = dp2->dp_start + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = dp2->dp_size; - lp->d_partitions[0].p_offset = dp2->dp_start + - part_blkno; + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); + lp->d_partitions[0].p_offset = + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -416,11 +416,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (dp2->dp_size) - pp->p_size = dp2->dp_size; - if (dp2->dp_start) + if (letoh32(dp2->dp_size) > lp->d_secperunit) + continue; + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - dp2->dp_start + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -455,9 +457,12 @@ donot: break; case DOSPTYP_EXTEND: case DOSPTYP_EXTENDL: - part_blkno = dp2->dp_start + extoff; - if (!extoff) - extoff = dp2->dp_start; + part_blkno = + letoh32(dp2->dp_start) + extoff; + if (!extoff) { + extoff = letoh32(dp2->dp_start); + part_blkno = 0; + } wander = 1; break; default: diff --git a/sys/arch/amd64/amd64/disksubr.c b/sys/arch/amd64/amd64/disksubr.c index a599596444b..29b0b067163 100644 --- a/sys/arch/amd64/amd64/disksubr.c +++ b/sys/arch/amd64/amd64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.8 2006/03/15 20:20:38 miod Exp $ */ +/* $OpenBSD: disksubr.c,v 1.9 2006/07/01 16:50:32 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -133,17 +133,17 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) /* Search for our MBR partition */ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -153,13 +153,13 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) * for SCSI/IDE, cylinder for ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = get_le(&dp2->dp_start) + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = get_le(&dp2->dp_size); + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); lp->d_partitions[0].p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -178,13 +178,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (get_le(&dp2->dp_size) > lp->d_secperunit) + if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (get_le(&dp2->dp_size)) - pp->p_size = get_le(&dp2->dp_size); - if (get_le(&dp2->dp_start)) + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -219,9 +219,9 @@ donot: break; case DOSPTYP_EXTEND: case DOSPTYP_EXTENDL: - part_blkno = get_le(&dp2->dp_start) + extoff; + part_blkno = letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = get_le(&dp2->dp_start); + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; @@ -423,13 +423,13 @@ writedisklabel(dev, strat, lp, osdep) NDOSPART * sizeof(*dp)); for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart != -1) { @@ -439,7 +439,7 @@ writedisklabel(dev, strat, lp, osdep) * need sector address for SCSI/IDE, * cylinder for ESDI/ST506/RLL */ - dospartoff = get_le(&dp2->dp_start); + dospartoff = letoh32(dp2->dp_start); cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); } } diff --git a/sys/arch/amd64/include/disklabel.h b/sys/arch/amd64/include/disklabel.h index d312d90b226..f325b8048a6 100644 --- a/sys/arch/amd64/include/disklabel.h +++ b/sys/arch/amd64/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.3 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.4 2006/07/01 16:50:32 krw Exp $ */ /* $NetBSD: disklabel.h,v 1.3 1996/03/09 20:52:54 ghudson Exp $ */ /* @@ -96,18 +96,4 @@ struct cpu_disklabel { #define DPSECT(s) ((s) & 0x3f) #define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) -static __inline u_int32_t get_le(void *); - -static __inline u_int32_t -get_le(void *p) -{ - u_int8_t *_p = (u_int8_t *)p; - u_int32_t x; - x = _p[0]; - x |= _p[1] << 8; - x |= _p[2] << 16; - x |= _p[3] << 24; - return x; -} - #endif /* _MACHINE_DISKLABEL_H_ */ diff --git a/sys/arch/arm/arm/disksubr.c b/sys/arch/arm/arm/disksubr.c index ed3913170a5..e9612677767 100644 --- a/sys/arch/arm/arm/disksubr.c +++ b/sys/arch/arm/arm/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.8 2006/03/15 20:20:39 miod Exp $ */ +/* $OpenBSD: disksubr.c,v 1.9 2006/07/01 16:50:32 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -132,17 +132,17 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) /* Search for our MBR partition */ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -152,13 +152,13 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) * for SCSI/IDE, cylinder for ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = get_le(&dp2->dp_start) + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = get_le(&dp2->dp_size); + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); lp->d_partitions[0].p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -177,13 +177,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (get_le(&dp2->dp_size) > lp->d_secperunit) + if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (get_le(&dp2->dp_size)) - pp->p_size = get_le(&dp2->dp_size); - if (get_le(&dp2->dp_start)) + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -217,9 +217,9 @@ donot: break; case DOSPTYP_EXTEND: case DOSPTYP_EXTENDL: - part_blkno = get_le(&dp2->dp_start) + extoff; + part_blkno = letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = get_le(&dp2->dp_start); + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; @@ -388,13 +388,13 @@ writedisklabel(dev, strat, lp, osdep) NDOSPART * sizeof(*dp)); for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart != -1) { @@ -404,7 +404,7 @@ writedisklabel(dev, strat, lp, osdep) * need sector address for SCSI/IDE, * cylinder for ESDI/ST506/RLL */ - dospartoff = get_le(&dp2->dp_start); + dospartoff = letoh32(dp2->dp_start); cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); } } diff --git a/sys/arch/arm/include/disklabel.h b/sys/arch/arm/include/disklabel.h index d21c578ba61..d58b9d71461 100644 --- a/sys/arch/arm/include/disklabel.h +++ b/sys/arch/arm/include/disklabel.h @@ -1,5 +1,5 @@ -/* $OpenBSD: disklabel.h,v 1.6 2006/06/26 23:11:31 krw Exp $ */ -/* $OpenBSD: disklabel.h,v 1.6 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.7 2006/07/01 16:50:32 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.7 2006/07/01 16:50:32 krw Exp $ */ /* $NetBSD: disklabel.h,v 1.2 2001/11/25 19:02:03 thorpej Exp $ */ /* @@ -105,24 +105,6 @@ struct dos_partition { #define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) -#ifdef __ARMEL__ -#define get_le(x) (*((u_int32_t *)x)) -#else -static __inline u_int32_t get_le(void *); -static __inline u_int32_t -get_le(void *p) -{ - u_int8_t *_p = (u_int8_t *)p; - u_int32_t x; - x = _p[0]; - x |= _p[1] << 8; - x |= _p[2] << 16; - x |= _p[3] << 24; - return x; -} -#endif - - struct cpu_disklabel { struct dos_partition dosparts[NDOSPART]; struct dkbad bad; diff --git a/sys/arch/aviion/aviion/disksubr.c b/sys/arch/aviion/aviion/disksubr.c index 26819e77b0a..44dd2c6e85e 100644 --- a/sys/arch/aviion/aviion/disksubr.c +++ b/sys/arch/aviion/aviion/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.1 2006/05/09 18:28:55 miod Exp $ */ +/* $OpenBSD: disksubr.c,v 1.2 2006/07/01 16:50:33 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -132,7 +132,7 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) /* Search for our MBR partition */ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; if (ourpart == -1) @@ -142,13 +142,13 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) * for SCSI/IDE, cylinder for ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = get_le(&dp2->dp_start) + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = get_le(&dp2->dp_size); + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); lp->d_partitions[0].p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -167,13 +167,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (get_le(&dp2->dp_size) > lp->d_secperunit) + if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (get_le(&dp2->dp_size)) - pp->p_size = get_le(&dp2->dp_size); - if (get_le(&dp2->dp_start)) + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -207,9 +207,9 @@ donot: break; case DOSPTYP_EXTEND: case DOSPTYP_EXTENDL: - part_blkno = get_le(&dp2->dp_start) + extoff; + part_blkno = letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = get_le(&dp2->dp_start); + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; @@ -378,7 +378,7 @@ writedisklabel(dev, strat, lp, osdep) NDOSPART * sizeof(*dp)); for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; if (ourpart != -1) { @@ -388,7 +388,7 @@ writedisklabel(dev, strat, lp, osdep) * need sector address for SCSI/IDE, * cylinder for ESDI/ST506/RLL */ - dospartoff = get_le(&dp2->dp_start); + dospartoff = letoh32(dp2->dp_start); cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); } } diff --git a/sys/arch/aviion/include/disklabel.h b/sys/arch/aviion/include/disklabel.h index 46a012aee4c..c5ae83c7559 100644 --- a/sys/arch/aviion/include/disklabel.h +++ b/sys/arch/aviion/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.2 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.3 2006/07/01 16:50:33 krw Exp $ */ /* $NetBSD: disklabel.h,v 1.2 2001/11/25 19:02:03 thorpej Exp $ */ /* @@ -97,20 +97,6 @@ struct dos_partition { #define DPSECT(s) ((s) & 0x3f) #define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) - -static __inline u_int32_t get_le(void *); -static __inline u_int32_t -get_le(void *p) -{ - u_int8_t *_p = (u_int8_t *)p; - u_int32_t x; - x = _p[0]; - x |= _p[1] << 8; - x |= _p[2] << 16; - x |= _p[3] << 24; - return x; -} - struct cpu_disklabel { struct dos_partition dosparts[NDOSPART]; struct dkbad bad; diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c index 7d13ed0f261..bfb6e703016 100644 --- a/sys/arch/hppa/hppa/disksubr.c +++ b/sys/arch/hppa/hppa/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.24 2006/06/11 21:15:35 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.25 2006/07/01 16:50:32 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -369,7 +369,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) bp->b_flags = B_BUSY | B_READ; bp->b_cylinder = part_blkno / lp->d_secpercyl; (*strat)(bp); - + /* if successful, wander through dos partition table */ if (biowait(bp)) { msg = "dos partition I/O error"; @@ -382,19 +382,19 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) if (ourpart == -1) { /* Search for our MBR partition */ - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -405,13 +405,13 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) * ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = dp2->dp_start + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = dp2->dp_size; - lp->d_partitions[0].p_offset = dp2->dp_start + - part_blkno; + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); + lp->d_partitions[0].p_offset = + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -430,11 +430,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (dp2->dp_size) - pp->p_size = dp2->dp_size; - if (dp2->dp_start) + if (letoh32(dp2->dp_size) > lp->d_secperunit) + continue; + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - dp2->dp_start + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -468,9 +470,11 @@ donot: n++; break; case DOSPTYP_EXTEND: - part_blkno = dp2->dp_start + extoff; + case DOSPTYP_EXTENDL: + part_blkno = + letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = dp2->dp_start; + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; diff --git a/sys/arch/hppa64/hppa64/disksubr.c b/sys/arch/hppa64/hppa64/disksubr.c index 7dc23974450..28747a2b886 100644 --- a/sys/arch/hppa64/hppa64/disksubr.c +++ b/sys/arch/hppa64/hppa64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.7 2006/06/11 21:15:35 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.8 2006/07/01 16:50:32 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -365,7 +365,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) bp->b_flags = B_BUSY | B_READ; bp->b_cylinder = part_blkno / lp->d_secpercyl; (*strat)(bp); - + /* if successful, wander through dos partition table */ if (biowait(bp)) { msg = "dos partition I/O error"; @@ -378,19 +378,19 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) if (ourpart == -1) { /* Search for our MBR partition */ - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -401,13 +401,13 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) * ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = dp2->dp_start + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = dp2->dp_size; - lp->d_partitions[0].p_offset = dp2->dp_start + - part_blkno; + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); + lp->d_partitions[0].p_offset = + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -426,11 +426,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (dp2->dp_size) - pp->p_size = dp2->dp_size; - if (dp2->dp_start) + if (letoh32(dp2->dp_size) > lp->d_secperunit) + continue; + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - dp2->dp_start + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -464,9 +466,11 @@ donot: n++; break; case DOSPTYP_EXTEND: - part_blkno = dp2->dp_start + extoff; + case DOSPTYP_EXTENDL: + part_blkno = + letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = dp2->dp_start; + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; diff --git a/sys/arch/i386/i386/disksubr.c b/sys/arch/i386/i386/disksubr.c index 8f6309f0360..90dfec56555 100644 --- a/sys/arch/i386/i386/disksubr.c +++ b/sys/arch/i386/i386/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.50 2006/05/11 13:21:11 mickey Exp $ */ +/* $OpenBSD: disksubr.c,v 1.51 2006/07/01 16:50:33 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -133,17 +133,17 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) /* Search for our MBR partition */ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -153,13 +153,13 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) * for SCSI/IDE, cylinder for ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = get_le(&dp2->dp_start) + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = get_le(&dp2->dp_size); + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); lp->d_partitions[0].p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -178,13 +178,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (get_le(&dp2->dp_size) > lp->d_secperunit) + if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (get_le(&dp2->dp_size)) - pp->p_size = get_le(&dp2->dp_size); - if (get_le(&dp2->dp_start)) + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -219,9 +219,9 @@ donot: break; case DOSPTYP_EXTEND: case DOSPTYP_EXTENDL: - part_blkno = get_le(&dp2->dp_start) + extoff; + part_blkno = letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = get_le(&dp2->dp_start); + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; @@ -423,13 +423,13 @@ writedisklabel(dev, strat, lp, osdep) NDOSPART * sizeof(*dp)); for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart != -1) { @@ -439,7 +439,7 @@ writedisklabel(dev, strat, lp, osdep) * need sector address for SCSI/IDE, * cylinder for ESDI/ST506/RLL */ - dospartoff = get_le(&dp2->dp_start); + dospartoff = letoh32(dp2->dp_start); cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); } } diff --git a/sys/arch/i386/include/disklabel.h b/sys/arch/i386/include/disklabel.h index 7b7e39e3762..7510dde1d35 100644 --- a/sys/arch/i386/include/disklabel.h +++ b/sys/arch/i386/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.27 2004/11/10 10:36:12 grange Exp $ */ +/* $OpenBSD: disklabel.h,v 1.28 2006/07/01 16:50:33 krw Exp $ */ /* $NetBSD: disklabel.h,v 1.3 1996/03/09 20:52:54 ghudson Exp $ */ /* @@ -96,18 +96,4 @@ struct cpu_disklabel { #define DPSECT(s) ((s) & 0x3f) #define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) -static __inline u_int32_t get_le(void *); - -static __inline u_int32_t -get_le(void *p) -{ - u_int8_t *_p = (u_int8_t *)p; - u_int32_t x; - x = _p[0]; - x |= _p[1] << 8; - x |= _p[2] << 16; - x |= _p[3] << 24; - return x; -} - #endif /* _MACHINE_DISKLABEL_H_ */ diff --git a/sys/arch/macppc/include/disklabel.h b/sys/arch/macppc/include/disklabel.h index 07ae6dc615b..c6b3e749b29 100644 --- a/sys/arch/macppc/include/disklabel.h +++ b/sys/arch/macppc/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.6 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.7 2006/07/01 16:50:33 krw Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -84,20 +84,6 @@ struct dos_partition { #define DPSECT(s) ((s) & 0x3f) #define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) -static __inline u_int32_t get_le(void *); - -static __inline u_int32_t -get_le(void *p) -{ - u_int8_t *_p = (u_int8_t *)p; - u_int32_t x; - x = _p[0]; - x |= _p[1] << 8; - x |= _p[2] << 16; - x |= _p[3] << 24; - return x; -} - /* HFS/DPME */ /* partition map structure from Inside Macintosh: Devices, SCSI Manager diff --git a/sys/arch/macppc/macppc/disksubr.c b/sys/arch/macppc/macppc/disksubr.c index 9b564f34062..e6906a918ca 100644 --- a/sys/arch/macppc/macppc/disksubr.c +++ b/sys/arch/macppc/macppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.17 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.18 2006/07/01 16:50:33 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -213,17 +213,17 @@ hfs_done: /* Search for our MBR partition */ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -234,15 +234,15 @@ hfs_done: * cylinder for ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = get_le(&dp2->dp_start) + + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ lp->d_partitions[0].p_size = - get_le(&dp2->dp_size); + letoh32(dp2->dp_size); lp->d_partitions[0].p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -261,13 +261,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (get_le(&dp2->dp_size) > lp->d_secperunit) + if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (get_le(&dp2->dp_size)) - pp->p_size = get_le(&dp2->dp_size); - if (get_le(&dp2->dp_start)) + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -301,9 +301,9 @@ donot: break; case DOSPTYP_EXTEND: case DOSPTYP_EXTENDL: - part_blkno = get_le(&dp2->dp_start) + extoff; + part_blkno = letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = get_le(&dp2->dp_start); + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; @@ -522,15 +522,15 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, NDOSPART * sizeof(*dp)); for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; @@ -541,7 +541,7 @@ writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp, * need sector address for SCSI/IDE, * cylinder for ESDI/ST506/RLL */ - dospartoff = get_le(&dp2->dp_start); + dospartoff = letoh32(dp2->dp_start); cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); } } diff --git a/sys/arch/mips64/mips64/disksubr.c b/sys/arch/mips64/mips64/disksubr.c index cef48a1ddc0..1ba80434cd4 100644 --- a/sys/arch/mips64/mips64/disksubr.c +++ b/sys/arch/mips64/mips64/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.13 2006/06/11 21:15:35 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.14 2006/07/01 16:50:33 krw Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -385,7 +385,7 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) bp->b_flags = B_BUSY | B_READ; bp->b_cylinder = part_blkno / lp->d_secpercyl; (*strat)(bp); - + /* if successful, wander through dos partition table */ if (biowait(bp)) { msg = "dos partition I/O error"; @@ -398,19 +398,19 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) if (ourpart == -1) { /* Search for our MBR partition */ - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; - for (dp2=dp, i=0; - i < NDOSPART && ourpart == -1; i++, dp2++) - if (dp2->dp_size && + for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; + i++, dp2++) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -421,13 +421,13 @@ readdoslabel(bp, strat, lp, osdep, partoffp, cylp, spoofonly) * ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = dp2->dp_start + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = dp2->dp_size; - lp->d_partitions[0].p_offset = dp2->dp_start + - part_blkno; + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); + lp->d_partitions[0].p_offset = + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -446,11 +446,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (dp2->dp_size) - pp->p_size = dp2->dp_size; - if (dp2->dp_start) + if (letoh32(dp2->dp_size) > lp->d_secperunit) + continue; + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - dp2->dp_start + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -484,9 +486,11 @@ donot: n++; break; case DOSPTYP_EXTEND: - part_blkno = dp2->dp_start + extoff; + case DOSPTYP_EXTENDL: + part_blkno = + letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = dp2->dp_start; + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; diff --git a/sys/arch/mvmeppc/include/disklabel.h b/sys/arch/mvmeppc/include/disklabel.h index 4b4632835a8..f5cdc205ec5 100644 --- a/sys/arch/mvmeppc/include/disklabel.h +++ b/sys/arch/mvmeppc/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.5 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disklabel.h,v 1.6 2006/07/01 16:50:33 krw Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -90,18 +90,4 @@ struct cpu_disklabel { #define DPSECT(s) ((s) & 0x3f) #define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2)) -static __inline u_int32_t get_le(void *); - -static __inline u_int32_t -get_le(void *p) -{ - u_int8_t *_p = (u_int8_t *)p; - u_int32_t x; - x = _p[0]; - x |= _p[1] << 8; - x |= _p[2] << 16; - x |= _p[3] << 24; - return x; -} - #endif /* _MACHINE_DISKLABEL_H_ */ diff --git a/sys/arch/mvmeppc/mvmeppc/disksubr.c b/sys/arch/mvmeppc/mvmeppc/disksubr.c index 51e0b90dfc2..e42c1d41535 100644 --- a/sys/arch/mvmeppc/mvmeppc/disksubr.c +++ b/sys/arch/mvmeppc/mvmeppc/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.13 2006/06/26 23:11:31 krw Exp $ */ +/* $OpenBSD: disksubr.c,v 1.14 2006/07/01 16:50:33 krw Exp $ */ /* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */ /* @@ -132,17 +132,17 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) /* Search for our MBR partition */ for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart == -1) @@ -152,13 +152,13 @@ readdisklabel(dev, strat, lp, osdep, spoofonly) * for SCSI/IDE, cylinder for ESDI/ST506/RLL */ dp2 = &dp[ourpart]; - dospartoff = get_le(&dp2->dp_start) + part_blkno; + dospartoff = letoh32(dp2->dp_start) + part_blkno; cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); /* XXX build a temporary disklabel */ - lp->d_partitions[0].p_size = get_le(&dp2->dp_size); + lp->d_partitions[0].p_size = letoh32(dp2->dp_size); lp->d_partitions[0].p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; if (lp->d_ntracks == 0) lp->d_ntracks = dp2->dp_ehd + 1; if (lp->d_nsectors == 0) @@ -177,13 +177,13 @@ donot: if (dp2->dp_typ == DOSPTYP_OPENBSD) continue; - if (get_le(&dp2->dp_size) > lp->d_secperunit) + if (letoh32(dp2->dp_size) > lp->d_secperunit) continue; - if (get_le(&dp2->dp_size)) - pp->p_size = get_le(&dp2->dp_size); - if (get_le(&dp2->dp_start)) + if (letoh32(dp2->dp_size)) + pp->p_size = letoh32(dp2->dp_size); + if (letoh32(dp2->dp_start)) pp->p_offset = - get_le(&dp2->dp_start) + part_blkno; + letoh32(dp2->dp_start) + part_blkno; switch (dp2->dp_typ) { case DOSPTYP_UNUSED: @@ -217,9 +217,9 @@ donot: break; case DOSPTYP_EXTEND: case DOSPTYP_EXTENDL: - part_blkno = get_le(&dp2->dp_start) + extoff; + part_blkno = letoh32(dp2->dp_start) + extoff; if (!extoff) { - extoff = get_le(&dp2->dp_start); + extoff = letoh32(dp2->dp_start); part_blkno = 0; } wander = 1; @@ -419,13 +419,13 @@ writedisklabel(dev, strat, lp, osdep) NDOSPART * sizeof(*dp)); for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_OPENBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_FREEBSD) ourpart = i; for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++) - if (get_le(&dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) + if (letoh32(dp2->dp_size) && dp2->dp_typ == DOSPTYP_NETBSD) ourpart = i; if (ourpart != -1) { @@ -435,7 +435,7 @@ writedisklabel(dev, strat, lp, osdep) * need sector address for SCSI/IDE, * cylinder for ESDI/ST506/RLL */ - dospartoff = get_le(&dp2->dp_start); + dospartoff = letoh32(dp2->dp_start); cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect); } } |