summaryrefslogtreecommitdiff
path: root/stand/uboot
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-03-12 21:39:49 +0000
committerWarner Losh <imp@FreeBSD.org>2018-03-12 21:39:49 +0000
commitde04d704a98a7d2e9e57ebd83d2dd7a19fc11dab (patch)
tree8b2a7c70182f66162f89a183d74cd3d07bb9ffa6 /stand/uboot
parentf264386b3233a7eba03e0afe0e01e39c509d597d (diff)
downloadsrc-test-de04d704a98a7d2e9e57ebd83d2dd7a19fc11dab.tar.gz
src-test-de04d704a98a7d2e9e57ebd83d2dd7a19fc11dab.zip
Use the actual struct devdesc at the start of all *_devdesc structs
The current system is fragile and requires very careful layout of all *_devdesc structures. It also makes it hard to change the base devdesc. Take a page from CAM and put the 'header' in all the derived classes and adjust the code to match. For OFW, move the iHandle h_handle out of a slot conflicting with d_opendata. Due to quirks in the alignment rules, this worked. However changing the code to use d_opendata storage now that it's a pointer is hard, so just have a separate field for it. All other cleanups were to make the *_devdesc structures match where they'd taken some liberties that were none-the-less compatible enough to work.
Notes
Notes: svn path=/head/; revision=330809
Diffstat (limited to 'stand/uboot')
-rw-r--r--stand/uboot/common/main.c18
-rw-r--r--stand/uboot/lib/devicename.c10
-rw-r--r--stand/uboot/lib/disk.c10
-rw-r--r--stand/uboot/lib/libuboot.h5
4 files changed, 20 insertions, 23 deletions
diff --git a/stand/uboot/common/main.c b/stand/uboot/common/main.c
index a88a8bd0ae468..ffc76cae537dc 100644
--- a/stand/uboot/common/main.c
+++ b/stand/uboot/common/main.c
@@ -318,7 +318,7 @@ print_disk_probe_info()
strcpy(partition, "<auto>");
printf(" Checking unit=%d slice=%s partition=%s...",
- currdev.d_unit, slice, partition);
+ currdev.dd.d_unit, slice, partition);
}
@@ -338,8 +338,8 @@ probe_disks(int devidx, int load_type, int load_unit, int load_slice,
if (load_type == -1) {
printf(" Probing all disk devices...\n");
/* Try each disk in succession until one works. */
- for (currdev.d_unit = 0; currdev.d_unit < UB_MAX_DEV;
- currdev.d_unit++) {
+ for (currdev.dd.d_unit = 0; currdev.dd.d_unit < UB_MAX_DEV;
+ currdev.dd.d_unit++) {
print_disk_probe_info();
open_result = devsw[devidx]->dv_open(&f, &currdev);
if (open_result == 0) {
@@ -355,8 +355,8 @@ probe_disks(int devidx, int load_type, int load_unit, int load_slice,
printf(" Probing all %s devices...\n", device_typename(load_type));
/* Try each disk of given type in succession until one works. */
for (unit = 0; unit < UB_MAX_DEV; unit++) {
- currdev.d_unit = uboot_diskgetunit(load_type, unit);
- if (currdev.d_unit == -1)
+ currdev.dd.d_unit = uboot_diskgetunit(load_type, unit);
+ if (currdev.dd.d_unit == -1)
break;
print_disk_probe_info();
open_result = devsw[devidx]->dv_open(&f, &currdev);
@@ -369,7 +369,7 @@ probe_disks(int devidx, int load_type, int load_unit, int load_slice,
return (-1);
}
- if ((currdev.d_unit = uboot_diskgetunit(load_type, load_unit)) != -1) {
+ if ((currdev.dd.d_unit = uboot_diskgetunit(load_type, load_unit)) != -1) {
print_disk_probe_info();
open_result = devsw[devidx]->dv_open(&f,&currdev);
if (open_result == 0) {
@@ -459,9 +459,9 @@ main(int argc, char **argv)
printf("Found U-Boot device: %s\n", devsw[i]->dv_name);
- currdev.d_dev = devsw[i];
- currdev.d_type = currdev.d_dev->dv_type;
- currdev.d_unit = 0;
+ currdev.dd.d_dev = devsw[i];
+ currdev.dd.d_type = currdev.dd.d_dev->dv_type;
+ currdev.dd.d_unit = 0;
if ((load_type == -1 || (load_type & DEV_TYP_STOR)) &&
strcmp(devsw[i]->dv_name, "disk") == 0) {
diff --git a/stand/uboot/lib/devicename.c b/stand/uboot/lib/devicename.c
index 9e68f9df9eb84..095a57f3dcc46 100644
--- a/stand/uboot/lib/devicename.c
+++ b/stand/uboot/lib/devicename.c
@@ -136,7 +136,7 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
err = EINVAL;
goto fail;
}
- idev->d_unit = unit;
+ idev->dd.d_unit = unit;
if (path != NULL)
*path = (*cp == 0) ? cp : cp + 1;
@@ -146,8 +146,8 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
err = EINVAL;
goto fail;
}
- idev->d_dev = dv;
- idev->d_type = dv->dv_type;
+ idev->dd.d_dev = dv;
+ idev->dd.d_type = dv->dv_type;
if (dev == NULL) {
free(idev);
} else {
@@ -167,7 +167,7 @@ uboot_fmtdev(void *vdev)
struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev;
static char buf[128];
- switch(dev->d_type) {
+ switch(dev->dd.d_type) {
case DEVT_NONE:
strcpy(buf, "(no device)");
break;
@@ -178,7 +178,7 @@ uboot_fmtdev(void *vdev)
#endif
case DEVT_NET:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
+ sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit);
break;
}
return(buf);
diff --git a/stand/uboot/lib/disk.c b/stand/uboot/lib/disk.c
index f5e44c749ba3e..bf07d04f7e369 100644
--- a/stand/uboot/lib/disk.c
+++ b/stand/uboot/lib/disk.c
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
#include "libuboot.h"
#define stor_printf(fmt, args...) do { \
- printf("%s%d: ", dev->d_dev->dv_name, dev->d_unit); \
+ printf("%s%d: ", dev->dd.d_dev->dv_name, dev->dd.d_unit); \
printf(fmt, ##args); \
} while (0)
@@ -65,7 +65,7 @@ static struct {
u_int bsize; /* block size */
} stor_info[UB_MAX_DEV];
-#define SI(dev) (stor_info[(dev)->d_unit])
+#define SI(dev) (stor_info[(dev)->dd.d_unit])
static int stor_info_no = 0;
static int stor_opendev(struct disk_devdesc *);
@@ -190,7 +190,7 @@ stor_opendev(struct disk_devdesc *dev)
{
int err;
- if (dev->d_unit < 0 || dev->d_unit >= stor_info_no)
+ if (dev->dd.d_unit < 0 || dev->dd.d_unit >= stor_info_no)
return (EIO);
if (SI(dev).opened == 0) {
@@ -252,8 +252,8 @@ stor_print(int verbose)
return (ret);
for (i = 0; i < stor_info_no; i++) {
- dev.d_dev = &uboot_storage;
- dev.d_unit = i;
+ dev.dd.d_dev = &uboot_storage;
+ dev.dd.d_unit = i;
dev.d_slice = -1;
dev.d_partition = -1;
snprintf(line, sizeof(line), "\tdisk%d (%s)\n", i,
diff --git a/stand/uboot/lib/libuboot.h b/stand/uboot/lib/libuboot.h
index efb789099e467..221f48f787848 100644
--- a/stand/uboot/lib/libuboot.h
+++ b/stand/uboot/lib/libuboot.h
@@ -29,10 +29,7 @@
/* Note: Must match the 'struct devdesc' in stand.h */
struct uboot_devdesc {
- struct devsw *d_dev;
- int d_type;
- int d_unit;
- void *d_opendata;
+ struct devdesc dd;
union {
struct {
int slice;