Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcmips sync with i386 (MBR)
details: https://anonhg.NetBSD.org/src/rev/a395630fcce3
branches: trunk
changeset: 477101:a395630fcce3
user: shin <shin%NetBSD.org@localhost>
date: Mon Oct 11 05:29:04 1999 +0000
description:
sync with i386 (MBR)
diffstat:
sys/arch/hpcmips/hpcmips/disksubr.c | 108 +++++++++++++++++-----------------
sys/arch/hpcmips/include/disklabel.h | 40 +-----------
2 files changed, 59 insertions(+), 89 deletions(-)
diffs (292 lines):
diff -r 22610a0d4b5d -r a395630fcce3 sys/arch/hpcmips/hpcmips/disksubr.c
--- a/sys/arch/hpcmips/hpcmips/disksubr.c Mon Oct 11 05:28:04 1999 +0000
+++ b/sys/arch/hpcmips/hpcmips/disksubr.c Mon Oct 11 05:29:04 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disksubr.c,v 1.1.1.1 1999/09/16 12:23:20 takemura Exp $ */
+/* $NetBSD: disksubr.c,v 1.2 1999/10/11 05:29:04 shin Exp $ */
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -39,34 +39,22 @@
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/disklabel.h>
-#include <sys/disk.h>
#include <sys/syslog.h>
#include "opt_mbr.h"
#define b_cylin b_resid
-#define MBRSIGOFS 0x1fe
-static char mbrsig[2] = {0x55, 0xaa};
-
-int fat_types[] = { DOSPTYP_FAT12, DOSPTYP_FAT16S,
- DOSPTYP_FAT16B, DOSPTYP_FAT32,
- DOSPTYP_FAT32L, DOSPTYP_FAT16L,
+int fat_types[] = { MBR_PTYPE_FAT12, MBR_PTYPE_FAT16S,
+ MBR_PTYPE_FAT16B, MBR_PTYPE_FAT32,
+ MBR_PTYPE_FAT32L, MBR_PTYPE_FAT16L,
-1 };
-#define NO_MBR_SIGNATURE ((struct dos_partition *) -1)
-
-static struct dos_partition *
-mbr_findslice __P((struct dos_partition* dp, struct buf *bp));
+#define NO_MBR_SIGNATURE ((struct mbr_partition *) -1)
-/* For bootstrapping / device */
-void
-dk_establish(dk, dev)
- struct disk *dk;
- struct device *dev;
-{
- return;
-}
+static struct mbr_partition *
+mbr_findslice __P((struct mbr_partition* dp, struct buf *bp));
+
/*
* Scan MBR for NetBSD partittion. Return NO_MBR_SIGNATURE if no MBR found
@@ -74,24 +62,26 @@
* partition is found, return a pointer to it; else return NULL.
*/
static
-struct dos_partition*
+struct mbr_partition *
mbr_findslice(dp, bp)
- struct dos_partition *dp;
+ struct mbr_partition *dp;
struct buf *bp;
{
- struct dos_partition *ourdp = NULL;
+ struct mbr_partition *ourdp = NULL;
+ u_int16_t *mbrmagicp;
int i;
- /* XXX "there has to be a better check than this." */
- if (memcmp(bp->b_data + MBRSIGOFS, mbrsig, sizeof(mbrsig)))
+ /* Note: Magic number is little-endian. */
+ mbrmagicp = (u_int16_t *)(bp->b_data + MBR_MAGICOFF);
+ if (*mbrmagicp != MBR_MAGIC)
return (NO_MBR_SIGNATURE);
/* XXX how do we check veracity/bounds of this? */
- memcpy(dp, bp->b_data + DOSPARTOFF, NDOSPART * sizeof(*dp));
+ memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp));
/* look for NetBSD partition */
- for (i = 0; i < NDOSPART; i++) {
- if (dp[i].dp_typ == DOSPTYP_NETBSD) {
+ for (i = 0; i < NMBRPART; i++) {
+ if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) {
ourdp = &dp[i];
break;
}
@@ -100,8 +90,8 @@
#ifdef COMPAT_386BSD_MBRPART
/* didn't find it -- look for 386BSD partition */
if (!ourdp) {
- for (i = 0; i < NDOSPART; i++) {
- if (dp[i].dp_typ == DOSPTYP_386BSD) {
+ for (i = 0; i < NMBRPART; i++) {
+ if (dp[i].mbrp_typ == MBR_PTYPE_386BSD) {
printf("WARNING: old BSD partition ID!\n");
ourdp = &dp[i];
/*
@@ -142,7 +132,7 @@
struct disklabel *lp;
struct cpu_disklabel *osdep;
{
- struct dos_partition *dp;
+ struct mbr_partition *dp;
struct partition *pp;
struct dkbad *bdp;
struct buf *bp;
@@ -185,10 +175,10 @@
dp = osdep->dosparts;
/* read master boot record */
- bp->b_blkno = DOSBBSECTOR;
+ bp->b_blkno = MBR_BBSECTOR;
bp->b_bcount = lp->d_secsize;
bp->b_flags = B_BUSY | B_READ;
- bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
+ bp->b_cylin = MBR_BBSECTOR / lp->d_secpercyl;
(*strat)(bp);
/* if successful, wander through dos partition table */
@@ -196,44 +186,47 @@
msg = "dos partition I/O error";
goto done;
} else {
- struct dos_partition *ourdp = NULL;
+ struct mbr_partition *ourdp = NULL;
ourdp = mbr_findslice(dp, bp);
if (ourdp == NO_MBR_SIGNATURE)
goto nombrpart;
- for (i = 0; i < NDOSPART; i++, dp++) {
+ for (i = 0; i < NMBRPART; i++, dp++) {
/* Install in partition e, f, g, or h. */
pp = &lp->d_partitions[RAW_PART + 1 + i];
- pp->p_offset = dp->dp_start;
- pp->p_size = dp->dp_size;
+ pp->p_offset = dp->mbrp_start;
+ pp->p_size = dp->mbrp_size;
for (ip = fat_types; *ip != -1; ip++) {
- if (dp->dp_typ == *ip)
+ if (dp->mbrp_typ == *ip)
pp->p_fstype = FS_MSDOS;
}
- if (dp->dp_typ == DOSPTYP_LNXEXT2)
+ if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2)
pp->p_fstype = FS_EX2FS;
+ if (dp->mbrp_typ == MBR_PTYPE_NTFS)
+ pp->p_fstype = FS_NTFS;
+
/* is this ours? */
if (dp == ourdp) {
/* need sector address for SCSI/IDE,
cylinder for ESDI/ST506/RLL */
- dospartoff = dp->dp_start;
- cyl = DPCYL(dp->dp_scyl, dp->dp_ssect);
+ dospartoff = dp->mbrp_start;
+ cyl = MBR_PCYL(dp->mbrp_scyl, dp->mbrp_ssect);
/* update disklabel with details */
lp->d_partitions[2].p_size =
- dp->dp_size;
+ dp->mbrp_size;
lp->d_partitions[2].p_offset =
- dp->dp_start;
+ dp->mbrp_start;
#if 0
- if (lp->d_ntracks != dp->dp_ehd + 1 ||
- lp->d_nsectors != DPSECT(dp->dp_esect)) {
+ if (lp->d_ntracks != dp->mbrp_ehd + 1 ||
+ lp->d_nsectors != DPSECT(dp->mbrp_esect)) {
printf("disklabel: BIOS sees chs %d/%d/%d as ",
lp->d_ncylinders, lp->d_ntracks,
lp->d_nsectors);
- lp->d_ntracks = dp->dp_ehd + 1;
- lp->d_nsectors = DPSECT(dp->dp_esect);
+ lp->d_ntracks = dp->mbrp_ehd + 1;
+ lp->d_nsectors = DPSECT(dp->mbrp_esect);
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
lp->d_ncylinders = lp->d_secperunit / lp->d_secpercyl;
if (! lp->d_ncylinders)
@@ -389,7 +382,7 @@
struct disklabel *lp;
struct cpu_disklabel *osdep;
{
- struct dos_partition *dp;
+ struct mbr_partition *dp;
struct buf *bp;
struct disklabel *dlp;
int error, dospartoff, cyl;
@@ -406,14 +399,14 @@
dp = osdep->dosparts;
/* read master boot record */
- bp->b_blkno = DOSBBSECTOR;
+ bp->b_blkno = MBR_BBSECTOR;
bp->b_bcount = lp->d_secsize;
bp->b_flags = B_BUSY | B_READ;
- bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
+ bp->b_cylin = MBR_BBSECTOR / lp->d_secpercyl;
(*strat)(bp);
if ((error = biowait(bp)) == 0) {
- struct dos_partition *ourdp = NULL;
+ struct mbr_partition *ourdp = NULL;
ourdp = mbr_findslice(dp, bp);
if (ourdp == NO_MBR_SIGNATURE)
@@ -422,8 +415,8 @@
if (ourdp) {
/* need sector address for SCSI/IDE,
cylinder for ESDI/ST506/RLL */
- dospartoff = ourdp->dp_start;
- cyl = DPCYL(ourdp->dp_scyl, ourdp->dp_ssect);
+ dospartoff = ourdp->mbrp_start;
+ cyl = MBR_PCYL(ourdp->mbrp_scyl, ourdp->mbrp_ssect);
}
}
@@ -520,3 +513,12 @@
done:
return (0);
}
+
+/* For bootstrapping / device */
+void
+dk_establish(dk, dev)
+ struct disk *dk;
+ struct device *dev;
+{
+ return;
+}
diff -r 22610a0d4b5d -r a395630fcce3 sys/arch/hpcmips/include/disklabel.h
--- a/sys/arch/hpcmips/include/disklabel.h Mon Oct 11 05:28:04 1999 +0000
+++ b/sys/arch/hpcmips/include/disklabel.h Mon Oct 11 05:29:04 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disklabel.h,v 1.1.1.1 1999/09/16 12:23:22 takemura Exp $ */
+/* $NetBSD: disklabel.h,v 1.2 1999/10/11 05:29:05 shin Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@@ -38,47 +38,15 @@
#define MAXPARTITIONS 8 /* number of partitions */
#define RAW_PART 3 /* raw partition: XX?d (XXX) */
-/* DOS partition table -- located in boot block */
-#define DOSBBSECTOR 0 /* DOS boot block relative sector # */
-#define DOSPARTOFF 446
-#define NDOSPART 4
-
-#ifndef __ASSEMBLER__
-struct dos_partition {
- u_int8_t dp_flag; /* bootstrap flags */
- u_int8_t dp_shd; /* starting head */
- u_int8_t dp_ssect; /* starting sector */
- u_int8_t dp_scyl; /* starting cylinder */
- u_int8_t dp_typ; /* partition type (see below) */
- u_int8_t dp_ehd; /* end head */
- u_int8_t dp_esect; /* end sector */
- u_int8_t dp_ecyl; /* end cylinder */
- u_int32_t dp_start; /* absolute starting sector number */
- u_int32_t dp_size; /* partition size in sectors */
-};
-#endif
-
-/* Known DOS partition types. */
-#define DOSPTYP_NETBSD 0xa9 /* NetBSD partition type */
-#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
-#define DOSPTYP_FAT12 0x01 /* 12-bit FAT */
-#define DOSPTYP_FAT16S 0x04 /* 16-bit FAT, less than 32M */
-#define DOSPTYP_FAT16B 0x06 /* 16-bit FAT, more than 32M */
-#define DOSPTYP_FAT32 0x0b /* 32-bit FAT */
-#define DOSPTYP_FAT32L 0x0c /* 32-bit FAT, LBA-mapped */
-#define DOSPTYP_FAT16L 0x0e /* 16-bit FAT, LBA-mapped */
-#define DOSPTYP_LNXEXT2 0x83 /* Linux native */
+/* Pull in MBR partition definitions. */
+#include <sys/disklabel_mbr.h>
#ifndef __ASSEMBLER__
#include <sys/dkbad.h>
struct cpu_disklabel {
- struct dos_partition dosparts[NDOSPART];
+ struct mbr_partition dosparts[NMBRPART];
struct dkbad bad;
};
-
-/* Isolate the relevant bits to get sector and cylinder. */
-#define DPSECT(s) ((s) & 0x3f)
-#define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2))
#endif
#ifdef _KERNEL
Home |
Main Index |
Thread Index |
Old Index