summaryrefslogtreecommitdiffstats
path: root/sys/boot/sparc64/loader/main.c
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2012-05-12 20:27:33 +0000
committeravg <avg@FreeBSD.org>2012-05-12 20:27:33 +0000
commit5a967fbfcc6f8df911a59020f191a5953d53c3a3 (patch)
tree9bd0cc8d4dee80f534d8942657f2f4fd2a5a37f0 /sys/boot/sparc64/loader/main.c
parentee127d5890a3679e20c7cd055ab00cc78d4cb5e8 (diff)
downloadFreeBSD-src-5a967fbfcc6f8df911a59020f191a5953d53c3a3.zip
FreeBSD-src-5a967fbfcc6f8df911a59020f191a5953d53c3a3.tar.gz
sparc64/zfs boot: take advantage of new libzfsboot capabilities
Also drop the now unneeded compatibility shims. Tested by: marius MFC after: 1 month
Diffstat (limited to 'sys/boot/sparc64/loader/main.c')
-rw-r--r--sys/boot/sparc64/loader/main.c79
1 files changed, 23 insertions, 56 deletions
diff --git a/sys/boot/sparc64/loader/main.c b/sys/boot/sparc64/loader/main.c
index 14cf6d6..3da7ea5 100644
--- a/sys/boot/sparc64/loader/main.c
+++ b/sys/boot/sparc64/loader/main.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#ifdef LOADER_ZFS_SUPPORT
#include <sys/vtoc.h>
+#include "../zfs/libzfs.h"
#endif
#include <vm/vm.h>
@@ -74,7 +75,7 @@ __FBSDID("$FreeBSD$");
#include "libofw.h"
#include "dev_net.h"
-#define MAXBDDEV 31
+#define MAXDEV 31
extern char bootprog_name[], bootprog_rev[], bootprog_date[], bootprog_maker[];
@@ -142,11 +143,6 @@ static vm_offset_t heapva;
static phandle_t root;
-#ifdef LOADER_ZFS_SUPPORT
-static int sparc64_zfs_dev_init(void);
-#include "zfs.c"
-#endif
-
/*
* Machine dependent structures that the machine independent
* loader part uses.
@@ -159,7 +155,7 @@ struct devsw *devsw[] = {
&netdev,
#endif
#ifdef LOADER_ZFS_SUPPORT
- &zfs_dev_compat,
+ &zfs_dev,
#endif
0
};
@@ -733,39 +729,20 @@ tlb_init_sun4u(void)
}
#ifdef LOADER_ZFS_SUPPORT
-
-static int
-sparc64_zfs_dev_init(void)
+static void
+sparc64_zfs_probe(void)
{
struct vtoc8 vtoc;
- char devname[512];
- spa_t *spa;
- vdev_t *vdev;
+ struct zfs_devdesc zfs_currdev;
+ char devname[32];
uint64_t guid;
int fd, part, unit;
- zfs_init();
-
- guid = 0;
/* Get the GUID of the ZFS pool on the boot device. */
- fd = open(getenv("currdev"), O_RDONLY);
- if (fd != -1) {
- if (vdev_probe(vdev_read, (void *)(uintptr_t) fd, &spa) == 0)
- guid = spa->spa_guid;
- close(fd);
- }
-
- /* Clean up the environment to let ZFS work. */
- while ((vdev = STAILQ_FIRST(&zfs_vdevs)) != NULL) {
- STAILQ_REMOVE_HEAD(&zfs_vdevs, v_alllink);
- free(vdev);
- }
- while ((spa = STAILQ_FIRST(&zfs_pools)) != NULL) {
- STAILQ_REMOVE_HEAD(&zfs_pools, spa_link);
- free(spa);
- }
+ guid = 0;
+ zfs_probe_dev(getenv("currdev"), &guid);
- for (unit = 0; unit < MAXBDDEV; unit++) {
+ for (unit = 0; unit < MAXDEV; unit++) {
/* Find freebsd-zfs slices in the VTOC. */
sprintf(devname, "disk%d:", unit);
fd = open(devname, O_RDONLY);
@@ -783,29 +760,23 @@ sparc64_zfs_dev_init(void)
VTOC_TAG_FREEBSD_ZFS)
continue;
sprintf(devname, "disk%d:%c", unit, part + 'a');
- fd = open(devname, O_RDONLY);
- if (fd == -1)
+ if (zfs_probe_dev(devname, NULL) == ENXIO)
break;
-
- if (vdev_probe(vdev_read, (void*)(uintptr_t) fd, 0))
- close(fd);
}
}
if (guid != 0) {
- unit = zfs_guid_to_unit(guid);
- if (unit >= 0) {
- /* Update the environment for ZFS. */
- sprintf(devname, "zfs%d", unit);
- env_setenv("currdev", EV_VOLATILE, devname,
- ofw_setcurrdev, env_nounset);
- env_setenv("loaddev", EV_VOLATILE, devname,
- env_noset, env_nounset);
- }
+ zfs_currdev.pool_guid = guid;
+ zfs_currdev.root_guid = 0;
+ zfs_currdev.d_dev = &zfs_dev;
+ zfs_currdev.d_type = zfs_currdev.d_dev->dv_type;
+ /* Update the environment for ZFS. */
+ env_setenv("currdev", EV_VOLATILE, zfs_fmtdev(&zfs_currdev),
+ ofw_setcurrdev, env_nounset);
+ env_setenv("loaddev", EV_VOLATILE, zfs_fmtdev(&zfs_currdev),
+ env_noset, env_nounset);
}
- return (0);
}
-
#endif /* LOADER_ZFS_SUPPORT */
int
@@ -825,6 +796,9 @@ main(int (*openfirm)(void *))
archsw.arch_copyout = ofw_copyout;
archsw.arch_readin = sparc64_readin;
archsw.arch_autoload = sparc64_autoload;
+#ifdef LOADER_ZFS_SUPPORT
+ archsw.arch_zfs_probe = sparc64_zfs_probe;
+#endif
if (init_heap() == (vm_offset_t)-1)
OF_exit();
@@ -870,13 +844,6 @@ main(int (*openfirm)(void *))
env_setenv("loaddev", EV_VOLATILE, bootpath,
env_noset, env_nounset);
-#ifdef LOADER_ZFS_SUPPORT
- /*
- * Patch up ZFS.
- */
- zfs_dev_compat.dv_init = sparc64_zfs_dev_init;
-#endif
-
/*
* Initialize devices.
*/
OpenPOWER on IntegriCloud