summaryrefslogtreecommitdiffstats
path: root/sys/boot/i386
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2006-11-02 01:23:18 +0000
committermarcel <marcel@FreeBSD.org>2006-11-02 01:23:18 +0000
commitdc91b1990af7dcb6d36cfccc9756c830cf400108 (patch)
treef6d4e8e00f43cedf707309d12500b41a38fcaaf0 /sys/boot/i386
parent19b599de4af959c5287bac69d61c3810ae390dfe (diff)
downloadFreeBSD-src-dc91b1990af7dcb6d36cfccc9756c830cf400108.zip
FreeBSD-src-dc91b1990af7dcb6d36cfccc9756c830cf400108.tar.gz
Extend struct devdesc with a unit field, called d_unit. Promote the
device (kind) specific unit field to the common field. This change allows a future version of libefi to work without requiring anything more than what is defined in struct devdesc and as such makes it possible to compile said version of libefi for different platforms without requiring that those platforms have identical derivatives of struct devdesc.
Diffstat (limited to 'sys/boot/i386')
-rw-r--r--sys/boot/i386/libi386/bioscd.c6
-rw-r--r--sys/boot/i386/libi386/biosdisk.c14
-rw-r--r--sys/boot/i386/libi386/bootinfo32.c4
-rw-r--r--sys/boot/i386/libi386/devicename.c13
-rw-r--r--sys/boot/i386/libi386/libi386.h9
-rw-r--r--sys/boot/i386/loader/main.c8
6 files changed, 23 insertions, 31 deletions
diff --git a/sys/boot/i386/libi386/bioscd.c b/sys/boot/i386/libi386/bioscd.c
index 5ffcada..42dfbb3 100644
--- a/sys/boot/i386/libi386/bioscd.c
+++ b/sys/boot/i386/libi386/bioscd.c
@@ -195,7 +195,7 @@ bc_open(struct open_file *f, ...)
va_start(ap, f);
dev = va_arg(ap, struct i386_devdesc *);
va_end(ap);
- if (dev->d_kind.bioscd.unit >= nbcinfo) {
+ if (dev->d_unit >= nbcinfo) {
DEBUG("attempt to open nonexistent disk");
return(ENXIO);
}
@@ -230,7 +230,7 @@ bc_strategy(void *devdata, int rw, daddr_t dblk, size_t size, char *buf,
if (rw != F_READ)
return(EROFS);
dev = (struct i386_devdesc *)devdata;
- unit = dev->d_kind.bioscd.unit;
+ unit = dev->d_unit;
blks = size / BIOSCD_SECSIZE;
if (dblk % (BIOSCD_SECSIZE / DEV_BSIZE) != 0)
return (EINVAL);
@@ -331,7 +331,7 @@ bc_getdev(struct i386_devdesc *dev)
int major;
int rootdev;
- unit = dev->d_kind.bioscd.unit;
+ unit = dev->d_unit;
biosdev = bc_unit2bios(unit);
DEBUG("unit %d BIOS device %d", unit, biosdev);
if (biosdev == -1) /* not a BIOS device */
diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c
index 8a1b402..b65ddd8 100644
--- a/sys/boot/i386/libi386/biosdisk.c
+++ b/sys/boot/i386/libi386/biosdisk.c
@@ -251,7 +251,7 @@ bd_print(int verbose)
pager_output(line);
/* try to open the whole disk */
- dev.d_kind.biosdisk.unit = i;
+ dev.d_unit = i;
dev.d_kind.biosdisk.slice = -1;
dev.d_kind.biosdisk.partition = -1;
@@ -454,7 +454,7 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
int error;
char buf[BUFSIZE];
- if (dev->d_kind.biosdisk.unit >= nbdinfo) {
+ if (dev->d_unit >= nbdinfo) {
DEBUG("attempt to open nonexistent disk");
return(ENXIO);
}
@@ -466,14 +466,14 @@ bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev)
}
/* Look up BIOS unit number, intialise open_disk structure */
- od->od_dkunit = dev->d_kind.biosdisk.unit;
+ od->od_dkunit = dev->d_unit;
od->od_unit = bdinfo[od->od_dkunit].bd_unit;
od->od_flags = bdinfo[od->od_dkunit].bd_flags;
od->od_boff = 0;
od->od_nslices = 0;
error = 0;
DEBUG("open '%s', unit 0x%x slice %d partition %c",
- i386_fmtdev(dev), dev->d_kind.biosdisk.unit,
+ i386_fmtdev(dev), dev->d_unit,
dev->d_kind.biosdisk.slice, dev->d_kind.biosdisk.partition + 'a');
/* Get geometry for this open (removable device may have changed) */
@@ -1177,8 +1177,8 @@ bd_getdev(struct i386_devdesc *dev)
char *nip, *cp;
int unitofs = 0, i, unit;
- biosdev = bd_unit2bios(dev->d_kind.biosdisk.unit);
- DEBUG("unit %d BIOS device %d", dev->d_kind.biosdisk.unit, biosdev);
+ biosdev = bd_unit2bios(dev->d_unit);
+ DEBUG("unit %d BIOS device %d", dev->d_unit, biosdev);
if (biosdev == -1) /* not a BIOS device */
return(-1);
if (bd_opendisk(&od, dev) != 0) /* oops, not a viable device */
@@ -1186,7 +1186,7 @@ bd_getdev(struct i386_devdesc *dev)
if (biosdev < 0x80) {
/* floppy (or emulated floppy) or ATAPI device */
- if (bdinfo[dev->d_kind.biosdisk.unit].bd_type == DT_ATAPI) {
+ if (bdinfo[dev->d_unit].bd_type == DT_ATAPI) {
/* is an ATAPI disk */
major = WFDMAJOR;
} else {
diff --git a/sys/boot/i386/libi386/bootinfo32.c b/sys/boot/i386/libi386/bootinfo32.c
index ceb254c..6b517c5 100644
--- a/sys/boot/i386/libi386/bootinfo32.c
+++ b/sys/boot/i386/libi386/bootinfo32.c
@@ -172,13 +172,13 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t
switch(rootdev->d_type) {
case DEVT_CD:
/* Pass in BIOS device number. */
- bi.bi_bios_dev = bc_unit2bios(rootdev->d_kind.bioscd.unit);
+ bi.bi_bios_dev = bc_unit2bios(rootdev->d_unit);
bootdevnr = bc_getdev(rootdev);
break;
case DEVT_DISK:
/* pass in the BIOS device number of the current disk */
- bi.bi_bios_dev = bd_unit2bios(rootdev->d_kind.biosdisk.unit);
+ bi.bi_bios_dev = bd_unit2bios(rootdev->d_unit);
bootdevnr = bd_getdev(rootdev);
break;
diff --git a/sys/boot/i386/libi386/devicename.c b/sys/boot/i386/libi386/devicename.c
index fac0b83..c906a52 100644
--- a/sys/boot/i386/libi386/devicename.c
+++ b/sys/boot/i386/libi386/devicename.c
@@ -142,7 +142,7 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path)
goto fail;
}
- idev->d_kind.biosdisk.unit = unit;
+ idev->d_unit = unit;
idev->d_kind.biosdisk.slice = slice;
idev->d_kind.biosdisk.partition = partition;
if (path != NULL)
@@ -165,10 +165,7 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path)
goto fail;
}
- if (dv->dv_type == DEVT_NET)
- idev->d_kind.netif.unit = unit;
- else
- idev->d_kind.bioscd.unit = unit;
+ idev->d_unit = unit;
if (path != NULL)
*path = (*cp == 0) ? cp : cp + 1;
break;
@@ -205,12 +202,12 @@ i386_fmtdev(void *vdev)
break;
case DEVT_CD:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.bioscd.unit);
+ sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
break;
case DEVT_DISK:
cp = buf;
- cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.biosdisk.unit);
+ cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit);
if (dev->d_kind.biosdisk.slice > 0)
cp += sprintf(cp, "s%d", dev->d_kind.biosdisk.slice);
if (dev->d_kind.biosdisk.partition >= 0)
@@ -219,7 +216,7 @@ i386_fmtdev(void *vdev)
break;
case DEVT_NET:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit);
+ sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
break;
}
return(buf);
diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h
index 412e1b6..ccae099 100644
--- a/sys/boot/i386/libi386/libi386.h
+++ b/sys/boot/i386/libi386/libi386.h
@@ -36,24 +36,19 @@ struct i386_devdesc
{
struct devsw *d_dev;
int d_type;
+ int d_unit;
union
{
struct
{
- int unit;
+ void *data;
int slice;
int partition;
- void *data;
} biosdisk;
struct
{
- int unit;
void *data;
} bioscd;
- struct
- {
- int unit; /* XXX net layer lives over these? */
- } netif;
} d_kind;
};
diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c
index 9dd4a05..daac4d6 100644
--- a/sys/boot/i386/loader/main.c
+++ b/sys/boot/i386/loader/main.c
@@ -201,11 +201,11 @@ extract_currdev(void)
if ((kargs->bootflags & KARGS_FLAGS_CD) != 0) {
/* we are booting from a CD with cdboot */
new_currdev.d_dev = &bioscd;
- new_currdev.d_kind.bioscd.unit = bc_bios2unit(initial_bootdev);
+ new_currdev.d_unit = bc_bios2unit(initial_bootdev);
} else if ((kargs->bootflags & KARGS_FLAGS_PXE) != 0) {
/* we are booting from pxeldr */
new_currdev.d_dev = &pxedisk;
- new_currdev.d_kind.netif.unit = 0;
+ new_currdev.d_unit = 0;
} else {
/* we don't know what our boot device is */
new_currdev.d_kind.biosdisk.slice = -1;
@@ -240,10 +240,10 @@ extract_currdev(void)
* which one we booted off of, just use disk0: as a reasonable default.
*/
if ((new_currdev.d_type == biosdisk.dv_type) &&
- ((new_currdev.d_kind.biosdisk.unit = bd_bios2unit(biosdev)) == -1)) {
+ ((new_currdev.d_unit = bd_bios2unit(biosdev)) == -1)) {
printf("Can't work out which disk we are booting from.\n"
"Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev);
- new_currdev.d_kind.biosdisk.unit = 0;
+ new_currdev.d_unit = 0;
}
env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&new_currdev),
i386_setcurrdev, env_nounset);
OpenPOWER on IntegriCloud