mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
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@
This commit is contained in:
parent
c668ff330e
commit
e01c6f329a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=254015
@ -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));
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user