Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149061625
D20773.1789469758.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
26 KB
Referenced Files
None
Subscribers
None
D20773.1789469758.diff
View Options
Index: stand/common/dev_net.c
===================================================================
--- stand/common/dev_net.c
+++ stand/common/dev_net.c
@@ -77,7 +77,7 @@
static int netdev_opens;
static int net_init(void);
-static int net_open(struct open_file *, ...);
+static int net_open(struct open_file *, struct devdesc *);
static int net_close(struct open_file *);
static void net_cleanup(void);
static int net_strategy(void *, int, daddr_t, size_t, char *, size_t *);
@@ -115,21 +115,14 @@
/*
* Called by devopen after it sets f->f_dev to our devsw entry.
* This opens the low-level device and sets f->f_devdata.
- * This is declared with variable arguments...
*/
static int
-net_open(struct open_file *f, ...)
+net_open(struct open_file *f, struct devdesc *dev)
{
struct iodesc *d;
- va_list args;
- struct devdesc *dev;
const char *devname; /* Device part of file name (or NULL). */
int error = 0;
- va_start(args, f);
- dev = va_arg(args, struct devdesc *);
- va_end(args);
-
devname = dev->d_dev->dv_name;
/* Before opening another interface, close the previous one first. */
if (netdev_sock >= 0 && strcmp(devname, netdev_name) != 0)
Index: stand/common/devopen.c
===================================================================
--- stand/common/devopen.c
+++ stand/common/devopen.c
@@ -49,7 +49,7 @@
/* point to device-specific data so that device open can use it */
f->f_dev = dev->d_dev;
f->f_devdata = dev;
- result = dev->d_dev->dv_open(f, dev);
+ result = dv_open(dev->d_dev, f, dev);
if (result != 0) {
f->f_devdata = NULL;
free(dev);
Index: stand/common/md.c
===================================================================
--- stand/common/md.c
+++ stand/common/md.c
@@ -61,7 +61,7 @@
/* devsw I/F */
static int md_init(void);
static int md_strategy(void *, int, daddr_t, size_t, char *, size_t *);
-static int md_open(struct open_file *, ...);
+static int md_open(struct open_file *, struct devdesc *);
static int md_close(struct open_file *);
static int md_print(int);
@@ -120,14 +120,8 @@
}
static int
-md_open(struct open_file *f, ...)
+md_open(struct open_file *f, struct devdesc *dev)
{
- va_list ap;
- struct devdesc *dev;
-
- va_start(ap, f);
- dev = va_arg(ap, struct devdesc *);
- va_end(ap);
if (dev->d_unit != 0)
return (ENXIO);
Index: stand/common/vdisk.c
===================================================================
--- stand/common/vdisk.c
+++ stand/common/vdisk.c
@@ -38,7 +38,7 @@
static int vdisk_init(void);
static int vdisk_strategy(void *, int, daddr_t, size_t, char *, size_t *);
-static int vdisk_open(struct open_file *, ...);
+static int vdisk_open(struct open_file *, struct devdesc *);
static int vdisk_close(struct open_file *);
static int vdisk_ioctl(struct open_file *, u_long, void *);
static int vdisk_print(int);
@@ -291,24 +291,18 @@
}
static int
-vdisk_open(struct open_file *f, ...)
+vdisk_open(struct open_file *f, struct devdesc *dev)
{
- va_list args;
- struct disk_devdesc *dev;
vdisk_info_t *vd;
int rc = 0;
- va_start(args, f);
- dev = va_arg(args, struct disk_devdesc *);
- va_end(args);
- if (dev == NULL)
- return (EINVAL);
- vd = vdisk_get_info((struct devdesc *)dev);
+ vd = vdisk_get_info(dev);
if (vd == NULL)
return (EINVAL);
- if (dev->dd.d_dev->dv_type == DEVT_DISK) {
- rc = disk_open(dev, vd->vdisk_size, vd->vdisk_sectorsz);
+ if (dev->d_dev->dv_type == DEVT_DISK) {
+ rc = disk_open((struct disk_devdesc *)dev, vd->vdisk_size,
+ vd->vdisk_sectorsz);
}
if (rc == 0)
vd->vdisk_open++;
Index: stand/efi/libefi/efihttp.c
===================================================================
--- stand/efi/libefi/efihttp.c
+++ stand/efi/libefi/efihttp.c
@@ -57,7 +57,7 @@
static int efihttp_dev_init(void);
static int efihttp_dev_strategy(void *devdata, int rw, daddr_t blk, size_t size,
char *buf, size_t *rsize);
-static int efihttp_dev_open(struct open_file *f, ...);
+static int efihttp_dev_open(struct open_file *f, struct devdesc *dev);
static int efihttp_dev_close(struct open_file *f);
static int efihttp_fs_open(const char *path, struct open_file *f);
@@ -224,7 +224,7 @@
}
static int
-efihttp_dev_open(struct open_file *f, ...)
+efihttp_dev_open(struct open_file *f, struct devdesc *dev)
{
EFI_HTTP_CONFIG_DATA config;
EFI_HTTPv4_ACCESS_POINT config_access;
@@ -234,7 +234,6 @@
IPv4_DEVICE_PATH *ipv4;
MAC_ADDR_DEVICE_PATH *mac;
URI_DEVICE_PATH *uri;
- struct devdesc *dev;
struct open_efihttp *oh;
char *c;
EFI_HANDLE handle;
@@ -287,7 +286,6 @@
if (!oh)
return (ENOMEM);
oh->dev_handle = handle;
- dev = (struct devdesc *)f->f_devdata;
dev->d_opendata = oh;
status = BS->OpenProtocol(handle, &httpsb_guid, (void **)&sb, IH, NULL,
Index: stand/efi/libefi/efipart.c
===================================================================
--- stand/efi/libefi/efipart.c
+++ stand/efi/libefi/efipart.c
@@ -51,7 +51,7 @@
static int efipart_strategy(void *, int, daddr_t, size_t, char *, size_t *);
static int efipart_realstrategy(void *, int, daddr_t, size_t, char *, size_t *);
-static int efipart_open(struct open_file *, ...);
+static int efipart_open(struct open_file *, struct devdesc *);
static int efipart_close(struct open_file *);
static int efipart_ioctl(struct open_file *, u_long, void *);
@@ -843,21 +843,13 @@
}
static int
-efipart_open(struct open_file *f, ...)
+efipart_open(struct open_file *f, struct devdesc *dev)
{
- va_list args;
- struct disk_devdesc *dev;
pdinfo_t *pd;
EFI_BLOCK_IO *blkio;
EFI_STATUS status;
- va_start(args, f);
- dev = va_arg(args, struct disk_devdesc*);
- va_end(args);
- if (dev == NULL)
- return (EINVAL);
-
- pd = efiblk_get_pdinfo((struct devdesc *)dev);
+ pd = efiblk_get_pdinfo(dev);
if (pd == NULL)
return (EIO);
@@ -876,10 +868,10 @@
if (pd->pd_bcache == NULL)
pd->pd_bcache = bcache_allocate();
- if (dev->dd.d_dev->dv_type == DEVT_DISK) {
+ if (dev->d_dev->dv_type == DEVT_DISK) {
int rc;
- rc = disk_open(dev,
+ rc = disk_open((struct disk_devdesc *)dev,
blkio->Media->BlockSize * (blkio->Media->LastBlock + 1),
blkio->Media->BlockSize);
if (rc != 0) {
Index: stand/efi/loader/main.c
===================================================================
--- stand/efi/loader/main.c
+++ stand/efi/loader/main.c
@@ -895,9 +895,7 @@
"failures\n", i);
}
- for (i = 0; devsw[i] != NULL; i++)
- if (devsw[i]->dv_init != NULL)
- (devsw[i]->dv_init)();
+ devsw_init();
/*
* Detect console settings two different ways: one via the command
Index: stand/i386/libfirewire/firewire.c
===================================================================
--- stand/i386/libfirewire/firewire.c
+++ stand/i386/libfirewire/firewire.c
@@ -68,7 +68,7 @@
static int fw_init(void);
static int fw_strategy(void *devdata, int flag, daddr_t dblk,
size_t size, char *buf, size_t *rsize);
-static int fw_open(struct open_file *f, ...);
+static int fw_open(struct open_file *f, struct devdesc *dev);
static int fw_close(struct open_file *f);
static int fw_print(int verbose);
static void fw_cleanup(void);
@@ -176,18 +176,8 @@
}
static int
-fw_open(struct open_file *f, ...)
+fw_open(struct open_file *f, struct devdesc *dev)
{
-#if 0
- va_list ap;
- struct i386_devdesc *dev;
- struct open_disk *od;
- int error;
-
- va_start(ap, f);
- dev = va_arg(ap, struct i386_devdesc *);
- va_end(ap);
-#endif
return (ENXIO);
}
Index: stand/i386/libi386/biosdisk.c
===================================================================
--- stand/i386/libi386/biosdisk.c
+++ stand/i386/libi386/biosdisk.c
@@ -130,7 +130,7 @@
char *buf, size_t *rsize);
static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size,
char *buf, size_t *rsize);
-static int bd_open(struct open_file *f, ...);
+static int bd_open(struct open_file *f, struct devdesc *dev);
static int bd_close(struct open_file *f);
static int bd_ioctl(struct open_file *f, u_long cmd, void *data);
static int bd_print(int verbose);
@@ -768,18 +768,12 @@
* slice before it?)
*/
static int
-bd_open(struct open_file *f, ...)
+bd_open(struct open_file *f, struct devdesc *dev)
{
bdinfo_t *bd;
- struct disk_devdesc *dev;
- va_list ap;
int rc;
- va_start(ap, f);
- dev = va_arg(ap, struct disk_devdesc *);
- va_end(ap);
-
- bd = bd_get_bdinfo(&dev->dd);
+ bd = bd_get_bdinfo(dev);
if (bd == NULL)
return (EIO);
@@ -793,13 +787,13 @@
bd->bd_bcache = bcache_allocate();
if (bd->bd_open == 0)
- bd->bd_sectors = bd_disk_get_sectors(dev);
+ bd->bd_sectors = bd_disk_get_sectors((struct disk_devdesc *)dev);
bd->bd_open++;
rc = 0;
- if (dev->dd.d_dev->dv_type == DEVT_DISK) {
- rc = disk_open(dev, bd->bd_sectors * bd->bd_sectorsize,
- bd->bd_sectorsize);
+ if (dev->d_dev->dv_type == DEVT_DISK) {
+ rc = disk_open((struct disk_devdesc *)dev,
+ bd->bd_sectors * bd->bd_sectorsize, bd->bd_sectorsize);
if (rc != 0) {
bd->bd_open--;
if (bd->bd_open == 0) {
Index: stand/i386/loader/main.c
===================================================================
--- stand/i386/loader/main.c
+++ stand/i386/loader/main.c
@@ -89,7 +89,6 @@
int
main(void)
{
- int i;
/* Pick up arguments */
kargs = (void *)__args;
@@ -217,9 +216,7 @@
/*
* March through the device switch probing for things.
*/
- for (i = 0; devsw[i] != NULL; i++)
- if (devsw[i]->dv_init != NULL)
- (devsw[i]->dv_init)();
+ devsw_init();
printf("BIOS %dkB/%dkB available memory\n", bios_basemem / 1024, bios_extmem / 1024);
if (initial_bootinfo != NULL) {
initial_bootinfo->bi_basemem = bios_basemem / 1024;
Index: stand/libsa/Makefile
===================================================================
--- stand/libsa/Makefile
+++ stand/libsa/Makefile
@@ -145,6 +145,7 @@
SRCS+= dosfs.c ext2fs.c
SRCS+= splitfs.c
SRCS+= pkgfs.c
+SRCS+= devsw.c
# kernel ufs support
.PATH: ${SRCTOP}/sys/ufs/ffs
Index: stand/libsa/devsw.c
===================================================================
--- /dev/null
+++ stand/libsa/devsw.c
@@ -0,0 +1,60 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "stand.h"
+
+void
+devsw_init(void)
+{
+ struct devsw **dp, *dev;
+
+ for (dp = devsw; *dp != NULL; ++dp) {
+ dev = *dp;
+ /*
+ * No init must mean that the devsw is usable without any
+ * setup.
+ */
+ if (dev->dv_init == NULL || dev->dv_init() == 0)
+ dev->dv_flags |= DV_FLAG_INIT_DONE;
+ }
+}
+
+int
+dv_open(struct devsw *devsw, struct open_file *f, struct devdesc *dev)
+{
+
+ if (dev == NULL)
+ return (EINVAL);
+ /* Device not configured */
+ if ((devsw->dv_flags & DV_FLAG_INIT_DONE) == 0)
+ return (ENXIO);
+
+ return (devsw->dv_open(f, dev));
+}
Index: stand/libsa/geli/gelidev.c
===================================================================
--- stand/libsa/geli/gelidev.c
+++ stand/libsa/geli/gelidev.c
@@ -37,7 +37,7 @@
static int geli_dev_init(void);
static int geli_dev_strategy(void *, int, daddr_t, size_t, char *, size_t *);
-static int geli_dev_open(struct open_file *f, ...);
+static int geli_dev_open(struct open_file *f, struct devdesc *d);
static int geli_dev_close(struct open_file *f);
static int geli_dev_ioctl(struct open_file *, u_long, void *);
static int geli_dev_print(int);
@@ -175,7 +175,7 @@
}
static int
-geli_dev_open(struct open_file *f, ...)
+geli_dev_open(struct open_file *f, struct devdesc *d)
{
/*
Index: stand/libsa/stand.h
===================================================================
--- stand/libsa/stand.h
+++ stand/libsa/stand.h
@@ -66,6 +66,8 @@
#include <sys/stat.h>
#include <sys/dirent.h>
+#include <stdbool.h>
+
/* this header intentionally exports NULL from <string.h> */
#include <string.h>
#define strcoll(a, b) strcmp((a), (b))
@@ -132,6 +134,8 @@
#define SEEK_CUR 1 /* set file offset to current plus offset */
#define SEEK_END 2 /* set file offset to EOF plus offset */
+struct devdesc;
+
/*
* Device switch
*/
@@ -147,11 +151,13 @@
int (*dv_init)(void); /* early probe call */
int (*dv_strategy)(void *devdata, int rw, daddr_t blk,
size_t size, char *buf, size_t *rsize);
- int (*dv_open)(struct open_file *f, ...);
+ int (*dv_open)(struct open_file *f, struct devdesc *desc);
int (*dv_close)(struct open_file *f);
int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data);
int (*dv_print)(int verbose); /* print device information */
void (*dv_cleanup)(void);
+ bool dv_flags;
+#define DV_FLAG_INIT_DONE 0x0001 /* dv_init was successful */
};
/*
@@ -410,6 +416,9 @@
extern struct fs_ops *exclusive_file_system;
extern struct devsw *devsw[];
+void devsw_init(void);
+int dv_open(struct devsw *devsw, struct open_file *f, struct devdesc *dev);
+
/*
* Expose byteorder(3) functions.
*/
Index: stand/libsa/zfs/zfs.c
===================================================================
--- stand/libsa/zfs/zfs.c
+++ stand/libsa/zfs/zfs.c
@@ -650,18 +650,14 @@
* Attempt to open the pool described by (dev) for use by (f).
*/
static int
-zfs_dev_open(struct open_file *f, ...)
+zfs_dev_open(struct open_file *f, struct devdesc *d)
{
- va_list args;
struct zfs_devdesc *dev;
struct zfsmount *mount;
spa_t *spa;
int rv;
- va_start(args, f);
- dev = va_arg(args, struct zfs_devdesc *);
- va_end(args);
-
+ dev = (struct zfs_devdesc *)d;
if (dev->pool_guid == 0)
spa = STAILQ_FIRST(&zfs_pools);
else
Index: stand/mips/beri/loader/beri_disk_cfi.c
===================================================================
--- stand/mips/beri/loader/beri_disk_cfi.c
+++ stand/mips/beri/loader/beri_disk_cfi.c
@@ -42,7 +42,7 @@
#include <cfi.h>
static int beri_cfi_disk_init(void);
-static int beri_cfi_disk_open(struct open_file *, ...);
+static int beri_cfi_disk_open(struct open_file *, struct devdesc *);
static int beri_cfi_disk_close(struct open_file *);
static int beri_cfi_disk_strategy(void *, int, daddr_t, size_t,
char *, size_t *);
@@ -89,18 +89,13 @@
}
static int
-beri_cfi_disk_open(struct open_file *f, ...)
+beri_cfi_disk_open(struct open_file *f, struct devdesc *dev)
{
- va_list ap;
- struct disk_devdesc *dev;
-
- va_start(ap, f);
- dev = va_arg(ap, struct disk_devdesc *);
- va_end(ap);
- if (dev->dd.d_unit != 0)
+ if (dev->d_unit != 0)
return (EIO);
- return (disk_open(dev, cfi_get_mediasize(), cfi_get_sectorsize()));
+ return (disk_open((struct disk_devdesc *)dev, cfi_get_mediasize(),
+ cfi_get_sectorsize()));
}
static int
Index: stand/mips/beri/loader/beri_disk_sdcard.c
===================================================================
--- stand/mips/beri/loader/beri_disk_sdcard.c
+++ stand/mips/beri/loader/beri_disk_sdcard.c
@@ -42,7 +42,7 @@
#include <sdcard.h>
static int beri_sdcard_disk_init(void);
-static int beri_sdcard_disk_open(struct open_file *, ...);
+static int beri_sdcard_disk_open(struct open_file *, struct devdesc *);
static int beri_sdcard_disk_close(struct open_file *);
static int beri_sdcard_disk_strategy(void *, int, daddr_t, size_t,
char *, size_t *);
@@ -89,24 +89,18 @@
}
static int
-beri_sdcard_disk_open(struct open_file *f, ...)
+beri_sdcard_disk_open(struct open_file *f, struct devdesc *dev)
{
- va_list ap;
- struct disk_devdesc *dev;
-
- va_start(ap, f);
- dev = va_arg(ap, struct disk_devdesc *);
- va_end(ap);
if (!(altera_sdcard_get_present())) {
printf("SD card not present or not supported\n");
return (ENXIO);
}
- if (dev->dd.d_unit != 0)
+ if (dev->d_unit != 0)
return (EIO);
- return (disk_open(dev, altera_sdcard_get_mediasize(),
- altera_sdcard_get_sectorsize()));
+ return (disk_open((struct disk_devdesc *)dev,
+ altera_sdcard_get_mediasize(), altera_sdcard_get_sectorsize()));
}
static int
Index: stand/mips/beri/loader/main.c
===================================================================
--- stand/mips/beri/loader/main.c
+++ stand/mips/beri/loader/main.c
@@ -105,7 +105,6 @@
int
main(int argc, char *argv[], char *envv[], struct bootinfo *bootinfop)
{
- struct devsw **dp;
/* NB: Must be sure to bzero() before using any globals. */
bzero(&__bss_start, &__bss_end - &__bss_start);
@@ -138,10 +137,7 @@
/*
* Initialise devices.
*/
- for (dp = devsw; *dp != NULL; dp++) {
- if ((*dp)->dv_init != NULL)
- (*dp)->dv_init();
- }
+ devsw_init();
extract_currdev(bootinfop);
printf("\n%s", bootprog_info);
Index: stand/ofw/libofw/ofw_disk.c
===================================================================
--- stand/ofw/libofw/ofw_disk.c
+++ stand/ofw/libofw/ofw_disk.c
@@ -45,7 +45,7 @@
static int ofwd_init(void);
static int ofwd_strategy(void *devdata, int flag, daddr_t dblk,
size_t size, char *buf, size_t *rsize);
-static int ofwd_open(struct open_file *f, ...);
+static int ofwd_open(struct open_file *f, struct devdesc *d);
static int ofwd_close(struct open_file *f);
static int ofwd_ioctl(struct open_file *f, u_long cmd, void *data);
static int ofwd_print(int verbose);
@@ -116,15 +116,11 @@
}
static int
-ofwd_open(struct open_file *f, ...)
+ofwd_open(struct open_file *f, struct devdesc *d)
{
struct ofw_devdesc *dp;
- va_list vl;
-
- va_start(vl, f);
- dp = va_arg(vl, struct ofw_devdesc *);
- va_end(vl);
+ dp = (struct ofw_devdesc *)d;
if (dp != kdp) {
if (kdp != NULL) {
OF_close(kdp->d_handle);
Index: stand/powerpc/kboot/hostdisk.c
===================================================================
--- stand/powerpc/kboot/hostdisk.c
+++ stand/powerpc/kboot/hostdisk.c
@@ -34,7 +34,7 @@
static int hostdisk_init(void);
static int hostdisk_strategy(void *devdata, int flag, daddr_t dblk,
size_t size, char *buf, size_t *rsize);
-static int hostdisk_open(struct open_file *f, ...);
+static int hostdisk_open(struct open_file *f, struct devdesc *);
static int hostdisk_close(struct open_file *f);
static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data);
static int hostdisk_print(int verbose);
@@ -85,14 +85,8 @@
}
static int
-hostdisk_open(struct open_file *f, ...)
+hostdisk_open(struct open_file *f, struct devdesc *desc)
{
- struct devdesc *desc;
- va_list vl;
-
- va_start(vl, f);
- desc = va_arg(vl, struct devdesc *);
- va_end(vl);
desc->d_unit = host_open(desc->d_opendata, O_RDONLY, 0);
Index: stand/powerpc/ofw/main.c
===================================================================
--- stand/powerpc/ofw/main.c
+++ stand/powerpc/ofw/main.c
@@ -93,7 +93,6 @@
main(int (*openfirm)(void *))
{
phandle_t root;
- int i;
char bootpath[64];
char *ch;
int bargc;
@@ -125,9 +124,7 @@
/*
* March through the device switch probing for things.
*/
- for (i = 0; devsw[i] != NULL; i++)
- if (devsw[i]->dv_init != NULL)
- (devsw[i]->dv_init)();
+ devsw_init();
printf("\n%s", bootprog_info);
printf("Memory: %lldKB\n", memsize() / 1024);
Index: stand/sparc64/loader/main.c
===================================================================
--- stand/sparc64/loader/main.c
+++ stand/sparc64/loader/main.c
@@ -813,7 +813,6 @@
main(int (*openfirm)(void *))
{
char compatible[32];
- struct devsw **dp;
/*
* Tell the Open Firmware functions where they find the OFW gate.
@@ -853,9 +852,7 @@
/*
* Initialize devices.
*/
- for (dp = devsw; *dp != NULL; dp++)
- if ((*dp)->dv_init != 0)
- (*dp)->dv_init();
+ devsw_init();
#ifdef LOADER_ZFS_SUPPORT
if (zfs_currdev.pool_guid != 0) {
Index: stand/uboot/common/main.c
===================================================================
--- stand/uboot/common/main.c
+++ stand/uboot/common/main.c
@@ -378,7 +378,8 @@
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);
+ open_result = dv_open(devsw[devidx], &f,
+ (struct devdesc *)&currdev);
if (open_result == 0) {
printf(" good.\n");
return (0);
@@ -396,7 +397,8 @@
if (currdev.dd.d_unit == -1)
break;
print_disk_probe_info();
- open_result = devsw[devidx]->dv_open(&f, &currdev);
+ open_result = dv_open(devsw[devidx], &f,
+ (struct devdesc *)&currdev);
if (open_result == 0) {
printf(" good.\n");
return (0);
@@ -408,7 +410,8 @@
if ((currdev.dd.d_unit = uboot_diskgetunit(load_type, load_unit)) != -1) {
print_disk_probe_info();
- open_result = devsw[devidx]->dv_open(&f,&currdev);
+ open_result = dv_open(devsw[devidx], &f,
+ (struct devdesc *)&currdev);
if (open_result == 0) {
printf(" good.\n");
return (0);
@@ -489,11 +492,10 @@
/*
* March through the device switch probing for things.
*/
- for (i = 0; devsw[i] != NULL; i++) {
+ devsw_init();
- if (devsw[i]->dv_init == NULL)
- continue;
- if ((devsw[i]->dv_init)() != 0)
+ for (i = 0; devsw[i] != NULL; i++) {
+ if ((devsw[i]->dv_flags & DV_FLAG_INIT_DONE) == 0)
continue;
printf("Found U-Boot device: %s\n", devsw[i]->dv_name);
Index: stand/uboot/lib/disk.c
===================================================================
--- stand/uboot/lib/disk.c
+++ stand/uboot/lib/disk.c
@@ -74,7 +74,7 @@
/* devsw I/F */
static int stor_init(void);
static int stor_strategy(void *, int, daddr_t, size_t, char *, size_t *);
-static int stor_open(struct open_file *, ...);
+static int stor_open(struct open_file *, struct devdesc *);
static int stor_close(struct open_file *);
static int stor_ioctl(struct open_file *f, u_long cmd, void *data);
static int stor_print(int);
@@ -173,16 +173,10 @@
}
static int
-stor_open(struct open_file *f, ...)
+stor_open(struct open_file *f, struct devdesc *dev)
{
- va_list ap;
- struct disk_devdesc *dev;
-
- va_start(ap, f);
- dev = va_arg(ap, struct disk_devdesc *);
- va_end(ap);
- return (stor_opendev(dev));
+ return (stor_opendev((struct disk_devdesc *)dev));
}
static int
Index: stand/usb/storage/umass_loader.c
===================================================================
--- stand/usb/storage/umass_loader.c
+++ stand/usb/storage/umass_loader.c
@@ -44,7 +44,7 @@
#include "umass_common.h"
static int umass_disk_init(void);
-static int umass_disk_open(struct open_file *,...);
+static int umass_disk_open(struct open_file *, struct devdesc *);
static int umass_disk_close(struct open_file *);
static void umass_disk_cleanup(void);
static int umass_disk_ioctl(struct open_file *, u_long, void *);
@@ -121,20 +121,14 @@
}
static int
-umass_disk_open(struct open_file *f,...)
+umass_disk_open(struct open_file *f, struct devdesc *dev)
{
- va_list ap;
- struct disk_devdesc *dev;
-
- va_start(ap, f);
- dev = va_arg(ap, struct disk_devdesc *);
- va_end(ap);
if (umass_uaa.device == NULL)
return (ENXIO);
if (dev->d_unit != 0)
return (EIO);
- return (umass_disk_open_sub(dev));
+ return (umass_disk_open_sub((struct disk_devdesc *)dev));
}
static int
Index: stand/userboot/userboot/host.c
===================================================================
--- stand/userboot/userboot/host.c
+++ stand/userboot/userboot/host.c
@@ -141,14 +141,8 @@
* 'Open' the host device.
*/
static int
-host_dev_open(struct open_file *f, ...)
+host_dev_open(struct open_file *f, struct devdesc *dev)
{
- va_list args;
- struct devdesc *dev;
-
- va_start(args, f);
- dev = va_arg(args, struct devdesc*);
- va_end(args);
return (0);
}
Index: stand/userboot/userboot/main.c
===================================================================
--- stand/userboot/userboot/main.c
+++ stand/userboot/userboot/main.c
@@ -192,9 +192,7 @@
/*
* March through the device switch probing for things.
*/
- for (i = 0; devsw[i] != NULL; i++)
- if (devsw[i]->dv_init != NULL)
- (devsw[i]->dv_init)();
+ devsw_init();
extract_currdev();
@@ -246,7 +244,7 @@
* If we cannot auto-detect the partition type then
* access the disk as a raw device.
*/
- if (dev.dd.d_dev->dv_open(NULL, &dev)) {
+ if (dv_open(dev.dd.d_dev, NULL, (struct devdesc *)&dev)) {
dev.d_slice = D_SLICENONE;
dev.d_partition = D_PARTNONE;
}
Index: stand/userboot/userboot/userboot_disk.c
===================================================================
--- stand/userboot/userboot/userboot_disk.c
+++ stand/userboot/userboot/userboot_disk.c
@@ -57,7 +57,7 @@
size_t size, char *buf, size_t *rsize);
static int userdisk_realstrategy(void *devdata, int flag, daddr_t dblk,
size_t size, char *buf, size_t *rsize);
-static int userdisk_open(struct open_file *f, ...);
+static int userdisk_open(struct open_file *f, struct devdesc *dev);
static int userdisk_close(struct open_file *f);
static int userdisk_ioctl(struct open_file *f, u_long cmd, void *data);
static int userdisk_print(int verbose);
@@ -155,22 +155,16 @@
* Attempt to open the disk described by (dev) for use by (f).
*/
static int
-userdisk_open(struct open_file *f, ...)
+userdisk_open(struct open_file *f, struct devdesc *dev)
{
- va_list ap;
- struct disk_devdesc *dev;
- va_start(ap, f);
- dev = va_arg(ap, struct disk_devdesc *);
- va_end(ap);
-
- if (dev->dd.d_unit < 0 || dev->dd.d_unit >= userdisk_maxunit)
+ if (dev->d_unit < 0 || dev->d_unit >= userdisk_maxunit)
return (EIO);
- ud_info[dev->dd.d_unit].ud_open++;
- if (ud_info[dev->dd.d_unit].ud_bcache == NULL)
- ud_info[dev->dd.d_unit].ud_bcache = bcache_allocate();
- return (disk_open(dev, ud_info[dev->dd.d_unit].mediasize,
- ud_info[dev->dd.d_unit].sectorsize));
+ ud_info[dev->d_unit].ud_open++;
+ if (ud_info[dev->d_unit].ud_bcache == NULL)
+ ud_info[dev->d_unit].ud_bcache = bcache_allocate();
+ return (disk_open((struct disk_devdesc *)dev,
+ ud_info[dev->d_unit].mediasize, ud_info[dev->d_unit].sectorsize));
}
static int
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Sep 15, 10:55 AM (16 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29650115
Default Alt Text
D20773.1789469758.diff (26 KB)
Attached To
Mode
D20773: stand: shuffle dv_open/dv_init bits around
Attached
Detach File
Event Timeline
Log In to Comment