summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2013-08-07 00:00:48 +0000
committermarcel <marcel@FreeBSD.org>2013-08-07 00:00:48 +0000
commit9f2f2e171a6de4c6d713a50366f3572946665fb5 (patch)
treeb8704cff2de99c4cf2da972288c8d1271ec33598
parentf5fd32bca5d6cadbe86d031375653c183adce356 (diff)
downloadFreeBSD-src-9f2f2e171a6de4c6d713a50366f3572946665fb5.zip
FreeBSD-src-9f2f2e171a6de4c6d713a50366f3572946665fb5.tar.gz
Change <sys/diskpc98.h> to not redefine the same symbols that are
being defined in <sys/diskmbr.h>. Instead give the symbols here a "PC98_" prefix. This way, both <sys/diskmbr.h> and <sys/diskpc98.h> can be included in the same C source file. The renaming is trivial. The only gotcha is that DOSBBSECTOR is also redefined from 0 to 1. This because DOSBBSECTOR was always used in conjunction with an addition of 1. The PC98_BBSECTOR symbol is defined as 1 and the expression is simplified. Note: it is not believed that ports are seriously impacted; or at all for that matter. Approved by: nyan@
-rw-r--r--sbin/fdisk_pc98/fdisk.c16
-rw-r--r--sys/boot/pc98/boot2/boot2.c14
-rw-r--r--sys/boot/pc98/libpc98/biosdisk.c10
-rw-r--r--sys/geom/geom_pc98.c15
-rw-r--r--sys/geom/part/g_part_pc98.c24
-rw-r--r--sys/sys/diskpc98.h20
-rw-r--r--usr.sbin/boot98cfg/boot98cfg.c2
7 files changed, 49 insertions, 52 deletions
diff --git a/sbin/fdisk_pc98/fdisk.c b/sbin/fdisk_pc98/fdisk.c
index b66bad4..479e1e4 100644
--- a/sbin/fdisk_pc98/fdisk.c
+++ b/sbin/fdisk_pc98/fdisk.c
@@ -254,7 +254,7 @@ main(int argc, char *argv[])
dos_sectors);
printf("Part %11s %11s %4s %4s %-16s\n", "Start", "Size", "MID",
"SID", "Name");
- for (i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < PC98_NPARTS; i++) {
partp = ((struct pc98_partition *) &mboot.parts) + i;
if (partp->dp_sid == 0)
continue;
@@ -310,7 +310,7 @@ main(int argc, char *argv[])
printf("Warning: BIOS sector numbering starts with sector 1\n");
printf("Information from DOS bootblock is:\n");
if (partition == -1)
- for (i = 1; i <= NDOSPART; i++)
+ for (i = 1; i <= PC98_NPARTS; i++)
change_part(i, v_flag);
else
change_part(partition, 1);
@@ -367,7 +367,7 @@ print_s0(int which)
print_params();
printf("Information from DOS bootblock is:\n");
if (which == -1) {
- for (i = 1; i <= NDOSPART; i++)
+ for (i = 1; i <= PC98_NPARTS; i++)
if (v_flag || !part_unused(i)) {
printf("%d: ", i);
print_part(i);
@@ -414,7 +414,7 @@ static void
init_boot(void)
{
- mboot.signature = DOSMAGIC;
+ mboot.signature = PC98_MAGIC;
}
@@ -517,7 +517,7 @@ change_active(int which)
int active, i, new, tmp;
active = -1;
- for (i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < PC98_NPARTS; i++) {
if ((partp[i].dp_sid & PC98_SID_ACTIVE) == 0)
continue;
printf("Partition %d is marked active\n", i + 1);
@@ -672,7 +672,7 @@ write_disk(off_t sector, void *buf)
if (error == sz)
return (0);
- for (i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < PC98_NPARTS; i++) {
sprintf(fbuf, "%ss%d", disk, i + 1);
fdw = open(fbuf, O_RDWR, 0);
if (fdw < 0)
@@ -731,7 +731,7 @@ read_s0()
warnx("can't read fdisk partition table");
return -1;
}
- if (mboot.signature != DOSMAGIC) {
+ if (mboot.signature != PC98_MAGIC) {
warnx("invalid fdisk partition table found");
/* So should we initialize things */
return -1;
@@ -911,7 +911,7 @@ reset_boot(void)
struct pc98_partition *partp;
init_boot();
- for (i = 1; i <= NDOSPART; i++) {
+ for (i = 1; i <= PC98_NPARTS; i++) {
partp = ((struct pc98_partition *) &mboot.parts) + i - 1;
bzero((char *)partp, sizeof (struct pc98_partition));
}
diff --git a/sys/boot/pc98/boot2/boot2.c b/sys/boot/pc98/boot2/boot2.c
index 296ca55..3d3e5d2 100644
--- a/sys/boot/pc98/boot2/boot2.c
+++ b/sys/boot/pc98/boot2/boot2.c
@@ -330,10 +330,10 @@ check_slice(void)
if (dsk.type == TYPE_FD)
return (WHOLE_DISK_SLICE);
- if (drvread(sec, DOSBBSECTOR + 1))
+ if (drvread(sec, PC98_BBSECTOR))
return (WHOLE_DISK_SLICE); /* Read error */
- dp = (void *)(sec + DOSPARTOFF);
- for (i = 0; i < NDOSPART; i++) {
+ dp = (void *)(sec + PC98_PARTOFF);
+ for (i = 0; i < PC98_NPARTS; i++) {
if (dp[i].dp_mid == DOSMID_386BSD) {
if (dp[i].dp_scyl <= cyl && cyl <= dp[i].dp_ecyl)
return (BASE_SLICE + i);
@@ -583,7 +583,7 @@ parse()
dsk.slice = WHOLE_DISK_SLICE;
if (arg[1] == ',') {
dsk.slice = *arg - '0' + 1;
- if (dsk.slice > NDOSPART + 1)
+ if (dsk.slice > PC98_NPARTS + 1)
return -1;
arg += 2;
}
@@ -626,12 +626,12 @@ dskread(void *buf, unsigned lba, unsigned nblk)
set_dsk();
if (dsk.type == TYPE_FD)
goto unsliced;
- if (drvread(sec, DOSBBSECTOR + 1))
+ if (drvread(sec, PC98_BBSECTOR))
return -1;
- dp = (void *)(sec + DOSPARTOFF);
+ dp = (void *)(sec + PC98_PARTOFF);
sl = dsk.slice;
if (sl < BASE_SLICE) {
- for (i = 0; i < NDOSPART; i++)
+ for (i = 0; i < PC98_NPARTS; i++)
if (dp[i].dp_mid == DOSMID_386BSD) {
sl = BASE_SLICE + i;
break;
diff --git a/sys/boot/pc98/libpc98/biosdisk.c b/sys/boot/pc98/libpc98/biosdisk.c
index 572e90c..96dbd1f 100644
--- a/sys/boot/pc98/libpc98/biosdisk.c
+++ b/sys/boot/pc98/libpc98/biosdisk.c
@@ -83,7 +83,7 @@ struct open_disk {
#define BD_OPTICAL 0x0020
struct disklabel od_disklabel;
int od_nslices; /* slice count */
- struct pc98_partition od_slicetab[NDOSPART];
+ struct pc98_partition od_slicetab[PC98_NPARTS];
};
/*
@@ -528,9 +528,9 @@ bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev)
/*
* copy the partition table, then pick up any extended partitions.
*/
- bcopy(buf + DOSPARTOFF, &od->od_slicetab,
- sizeof(struct pc98_partition) * NDOSPART);
- od->od_nslices = NDOSPART; /* extended slices start here */
+ bcopy(buf + PC98_PARTOFF, &od->od_slicetab,
+ sizeof(struct pc98_partition) * PC98_NPARTS);
+ od->od_nslices = PC98_NPARTS; /* extended slices start here */
od->od_flags |= BD_PARTTABOK;
dptr = &od->od_slicetab[0];
@@ -647,7 +647,7 @@ bd_open_pc98(struct open_disk *od, struct i386_devdesc *dev)
#define PREF_NONE 7
/*
- * slicelimit is in the range 0 .. NDOSPART
+ * slicelimit is in the range 0 .. PC98_NPARTS
*/
static int
bd_bestslice(struct open_disk *od)
diff --git a/sys/geom/geom_pc98.c b/sys/geom/geom_pc98.c
index 8e14f09..42c9962 100644
--- a/sys/geom/geom_pc98.c
+++ b/sys/geom/geom_pc98.c
@@ -56,7 +56,7 @@ FEATURE(geom_pc98, "GEOM NEC PC9800 partitioning support");
struct g_pc98_softc {
u_int fwsectors, fwheads, sectorsize;
- int type[NDOSPART];
+ int type[PC98_NPARTS];
u_char sec[8192];
};
@@ -84,8 +84,8 @@ static int
g_pc98_modify(struct g_geom *gp, struct g_pc98_softc *ms, u_char *sec, int len __unused)
{
int i, error;
- off_t s[NDOSPART], l[NDOSPART];
- struct pc98_partition dp[NDOSPART];
+ off_t s[PC98_NPARTS], l[PC98_NPARTS];
+ struct pc98_partition dp[PC98_NPARTS];
g_topology_assert();
@@ -114,11 +114,11 @@ g_pc98_modify(struct g_geom *gp, struct g_pc98_softc *ms, u_char *sec, int len _
return (EBUSY);
#endif
- for (i = 0; i < NDOSPART; i++)
+ for (i = 0; i < PC98_NPARTS; i++)
pc98_partition_dec(
sec + 512 + i * sizeof(struct pc98_partition), &dp[i]);
- for (i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < PC98_NPARTS; i++) {
/* If start and end are identical it's bogus */
if (dp[i].dp_ssect == dp[i].dp_esect &&
dp[i].dp_shd == dp[i].dp_ehd &&
@@ -146,7 +146,7 @@ g_pc98_modify(struct g_geom *gp, struct g_pc98_softc *ms, u_char *sec, int len _
return (error);
}
- for (i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < PC98_NPARTS; i++) {
ms->type[i] = (dp[i].dp_sid << 8) | dp[i].dp_mid;
g_slice_config(gp, i, G_SLICE_CONFIG_SET, s[i], l[i],
ms->sectorsize, "%ss%d", gp->name, i + 1);
@@ -269,7 +269,8 @@ g_pc98_taste(struct g_class *mp, struct g_provider *pp, int flags)
if (flags == G_TF_NORMAL &&
!strcmp(pp->geom->class->name, PC98_CLASS_NAME))
return (NULL);
- gp = g_slice_new(mp, NDOSPART, pp, &cp, &ms, sizeof *ms, g_pc98_start);
+ gp = g_slice_new(mp, PC98_NPARTS, pp, &cp, &ms, sizeof *ms,
+ g_pc98_start);
if (gp == NULL)
return (NULL);
g_topology_unlock();
diff --git a/sys/geom/part/g_part_pc98.c b/sys/geom/part/g_part_pc98.c
index 4d2b60c..d18d5cf 100644
--- a/sys/geom/part/g_part_pc98.c
+++ b/sys/geom/part/g_part_pc98.c
@@ -109,8 +109,8 @@ static struct g_part_scheme g_part_pc98_scheme = {
g_part_pc98_methods,
sizeof(struct g_part_pc98_table),
.gps_entrysz = sizeof(struct g_part_pc98_entry),
- .gps_minent = NDOSPART,
- .gps_maxent = NDOSPART,
+ .gps_minent = PC98_NPARTS,
+ .gps_maxent = PC98_NPARTS,
.gps_bootcodesz = BOOTSIZE,
};
G_PART_SCHEME_DECLARE(g_part_pc98);
@@ -259,7 +259,7 @@ g_part_pc98_create(struct g_part_table *basetable, struct g_part_parms *gpp)
basetable->gpt_last = MIN(pp->mediasize / SECSIZE, UINT32_MAX) - 1;
table = (struct g_part_pc98_table *)basetable;
- le16enc(table->boot + DOSMAGICOFFSET, DOSMAGIC);
+ le16enc(table->boot + PC98_MAGICOFS, PC98_MAGIC);
return (0);
}
@@ -396,8 +396,8 @@ g_part_pc98_probe(struct g_part_table *table, struct g_consumer *cp)
/* We goto out on mismatch. */
res = ENXIO;
- magic = le16dec(buf + DOSMAGICOFFSET);
- if (magic != DOSMAGIC)
+ magic = le16dec(buf + PC98_MAGICOFS);
+ if (magic != PC98_MAGIC)
goto out;
sum = 0;
@@ -408,8 +408,8 @@ g_part_pc98_probe(struct g_part_table *table, struct g_consumer *cp)
goto out;
}
- for (index = 0; index < NDOSPART; index++) {
- p = buf + SECSIZE + index * DOSPARTSIZE;
+ for (index = 0; index < PC98_NPARTS; index++) {
+ p = buf + SECSIZE + index * PC98_PARTSIZE;
if (p[0] == 0 || p[1] == 0) /* !dp_mid || !dp_sid */
continue;
scyl = le16dec(p + 10);
@@ -456,8 +456,8 @@ g_part_pc98_read(struct g_part_table *basetable, struct g_consumer *cp)
bcopy(buf + SECSIZE, table->table, sizeof(table->table));
bcopy(buf + SECSIZE*2, table->menu, sizeof(table->menu));
- for (index = NDOSPART - 1; index >= 0; index--) {
- p = buf + SECSIZE + index * DOSPARTSIZE;
+ for (index = PC98_NPARTS - 1; index >= 0; index--) {
+ p = buf + SECSIZE + index * PC98_PARTSIZE;
ent.dp_mid = p[0];
ent.dp_sid = p[1];
ent.dp_dum1 = p[2];
@@ -482,7 +482,7 @@ g_part_pc98_read(struct g_part_table *basetable, struct g_consumer *cp)
entry->ent = ent;
}
- basetable->gpt_entries = NDOSPART;
+ basetable->gpt_entries = PC98_NPARTS;
basetable->gpt_first = cyl;
basetable->gpt_last = msize - 1;
@@ -569,7 +569,7 @@ g_part_pc98_write(struct g_part_table *basetable, struct g_consumer *cp)
table = (struct g_part_pc98_table *)basetable;
baseentry = LIST_FIRST(&basetable->gpt_entry);
for (index = 1; index <= basetable->gpt_entries; index++) {
- p = table->table + (index - 1) * DOSPARTSIZE;
+ p = table->table + (index - 1) * PC98_PARTSIZE;
entry = (baseentry != NULL && index == baseentry->gpe_index)
? (struct g_part_pc98_entry *)baseentry : NULL;
if (entry != NULL && !baseentry->gpe_deleted) {
@@ -589,7 +589,7 @@ g_part_pc98_write(struct g_part_table *basetable, struct g_consumer *cp)
bcopy(entry->ent.dp_name, p + 16,
sizeof(entry->ent.dp_name));
} else
- bzero(p, DOSPARTSIZE);
+ bzero(p, PC98_PARTSIZE);
if (entry != NULL)
baseentry = LIST_NEXT(baseentry, gpe_entry);
diff --git a/sys/sys/diskpc98.h b/sys/sys/diskpc98.h
index 66bda90..aa0bb0a 100644
--- a/sys/sys/diskpc98.h
+++ b/sys/sys/diskpc98.h
@@ -35,15 +35,12 @@
#include <sys/ioccom.h>
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#undef DOSPARTOFF
-#define DOSPARTOFF 0
-#undef DOSPARTSIZE
-#define DOSPARTSIZE 32
-#undef NDOSPART
-#define NDOSPART 16
-#define DOSMAGICOFFSET 510
-#define DOSMAGIC 0xAA55
+#define PC98_BBSECTOR 1 /* DOS boot block relative sector number */
+#define PC98_PARTOFF 0
+#define PC98_PARTSIZE 32
+#define PC98_NPARTS 16
+#define PC98_MAGICOFS 510
+#define PC98_MAGIC 0xAA55
#define PC98_MID_BOOTABLE 0x80
#define PC98_MID_MASK 0x7f
@@ -55,8 +52,7 @@
#define DOSMID_386BSD (PC98_MID_386BSD | PC98_MID_BOOTABLE)
#define DOSSID_386BSD (PC98_SID_386BSD | PC98_SID_ACTIVE)
-#undef DOSPTYP_386BSD
-#define DOSPTYP_386BSD (DOSSID_386BSD << 8 | DOSMID_386BSD)
+#define PC98_PTYP_386BSD (DOSSID_386BSD << 8 | DOSMID_386BSD)
struct pc98_partition {
unsigned char dp_mid;
@@ -75,7 +71,7 @@ struct pc98_partition {
unsigned char dp_name[16];
};
#ifdef CTASSERT
-CTASSERT(sizeof (struct pc98_partition) == DOSPARTSIZE);
+CTASSERT(sizeof (struct pc98_partition) == PC98_PARTSIZE);
#endif
void pc98_partition_dec(void const *pp, struct pc98_partition *d);
diff --git a/usr.sbin/boot98cfg/boot98cfg.c b/usr.sbin/boot98cfg/boot98cfg.c
index f1ae8329..0ed1b17 100644
--- a/usr.sbin/boot98cfg/boot98cfg.c
+++ b/usr.sbin/boot98cfg/boot98cfg.c
@@ -271,7 +271,7 @@ write_boot(const char *disk, u_char *boot)
warnx("%s: %s", disk, q);
gctl_free(grq);
- for (i = 0; i < NDOSPART; i++) {
+ for (i = 0; i < PC98_NPARTS; i++) {
snprintf(buf, sizeof(buf), "%ss%d", disk, i + 1);
fd = open(buf, O_RDONLY);
if (fd < 0)
OpenPOWER on IntegriCloud