summaryrefslogtreecommitdiff
path: root/usr/src/uts/sparc
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/sparc')
-rw-r--r--usr/src/uts/sparc/Makefile.files6
-rw-r--r--usr/src/uts/sparc/Makefile.rules9
-rw-r--r--usr/src/uts/sparc/ml/modstubs.s9
-rw-r--r--usr/src/uts/sparc/specfs/Makefile8
-rw-r--r--usr/src/uts/sparc/zfs/Makefile4
-rw-r--r--usr/src/uts/sparc/zfs/spa_boot.c123
6 files changed, 151 insertions, 8 deletions
diff --git a/usr/src/uts/sparc/Makefile.files b/usr/src/uts/sparc/Makefile.files
index fccd7341e3..cfca9e03ba 100644
--- a/usr/src/uts/sparc/Makefile.files
+++ b/usr/src/uts/sparc/Makefile.files
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
@@ -76,6 +76,10 @@ FCODE_OBJS += fcode.o
#PROC_OBJS +=
CORE_OBJS += prmachdep.o
+# ZFS file system module
+ZFS_OBJS += \
+ spa_boot.o
+
#
# misc modules
#
diff --git a/usr/src/uts/sparc/Makefile.rules b/usr/src/uts/sparc/Makefile.rules
index b7978200ad..a9ab9e0dba 100644
--- a/usr/src/uts/sparc/Makefile.rules
+++ b/usr/src/uts/sparc/Makefile.rules
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -62,6 +62,10 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/sparc/krtld/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
+$(OBJS_DIR)/%.o: $(UTSBASE)/sparc/zfs/%.c
+ $(COMPILE.c) -o $@ $<
+ $(CTFCONVERT_O)
+
#
# _RELSEG indicates that the dynamic syms are put in a separate ELF
# section so they can be freed later.
@@ -99,6 +103,9 @@ $(LINTS_DIR)/%.ln: $(UTSBASE)/sparc/io/%.c
$(LINTS_DIR)/%.ln: $(UTSBASE)/sparc/fpu/%.c
@($(LHEAD) $(LINT.c) $< $(LTAIL))
+$(LINTS_DIR)/%.ln: $(UTSBASE)/sparc/zfs/%.c
+ @($(LHEAD) $(LINT.c) $< $(LTAIL))
+
$(LINTS_DIR)/%.ln: $(UTSBASE)/sparc/fs/proc/%.c
@($(LHEAD) $(LINT.c) $< $(LTAIL))
diff --git a/usr/src/uts/sparc/ml/modstubs.s b/usr/src/uts/sparc/ml/modstubs.s
index 22be0e8a44..8e4e06a008 100644
--- a/usr/src/uts/sparc/ml/modstubs.s
+++ b/usr/src/uts/sparc/ml/modstubs.s
@@ -627,6 +627,15 @@ stubs_base:
#endif
/*
+ * Stubs for zfs
+ */
+#ifndef ZFS_MODULE
+ MODULE(zfs,fs);
+ STUB(zfs, spa_boot_init, nomod_minus_one);
+ END_MODULE(zfs);
+#endif
+
+/*
* Stubs for dcfs
*/
#ifndef DCFS_MODULE
diff --git a/usr/src/uts/sparc/specfs/Makefile b/usr/src/uts/sparc/specfs/Makefile
index 6c5344719b..d19a549d3f 100644
--- a/usr/src/uts/sparc/specfs/Makefile
+++ b/usr/src/uts/sparc/specfs/Makefile
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -21,7 +20,7 @@
#
#
# uts/sparc/specfs/Makefile
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
@@ -64,6 +63,7 @@ MODSTUBS_DIR = $(OBJS_DIR)
$(MODSTUBS_O) := AS_CPPFLAGS += -DSPEC_MODULE
CLEANFILES += $(MODSTUBS_O)
CFLAGS += $(CCVERBOSE)
+LDFLAGS += -dy -Nfs/fifofs
#
# Default build targets.
diff --git a/usr/src/uts/sparc/zfs/Makefile b/usr/src/uts/sparc/zfs/Makefile
index c9596a4eef..05ab541d5d 100644
--- a/usr/src/uts/sparc/zfs/Makefile
+++ b/usr/src/uts/sparc/zfs/Makefile
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
@@ -60,7 +60,7 @@ INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOTLINK) $(ROOT_CONFFILE)
# Overrides and depends_on
#
MODSTUBS_DIR = $(OBJS_DIR)
-LDFLAGS += -dy -Nfs/specfs -Ndrv/random -Nmisc/idmap
+LDFLAGS += -dy -Nfs/specfs -Ncrypto/swrand -Nmisc/idmap
INC_PATH += -I$(UTSBASE)/common/fs/zfs
INC_PATH += -I$(SRC)/common
diff --git a/usr/src/uts/sparc/zfs/spa_boot.c b/usr/src/uts/sparc/zfs/spa_boot.c
new file mode 100644
index 0000000000..6a20081bd6
--- /dev/null
+++ b/usr/src/uts/sparc/zfs/spa_boot.c
@@ -0,0 +1,123 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/spa.h>
+#include <sys/bootconf.h>
+
+char *
+spa_get_bootfs()
+{
+ int proplen;
+ char *zfs_bp;
+
+ proplen = BOP_GETPROPLEN(bootops, "zfs-bootfs");
+ if (proplen == 0)
+ return (NULL);
+
+ zfs_bp = kmem_zalloc(proplen, KM_SLEEP);
+ if (BOP_GETPROP(bootops, "zfs-bootfs", zfs_bp) == -1) {
+ kmem_free(zfs_bp, proplen);
+ return (NULL);
+ }
+
+ return (zfs_bp);
+}
+
+void
+spa_free_bootfs(char *bootfs)
+{
+ kmem_free(bootfs, strlen(bootfs) + 1);
+}
+
+/*
+ * Given the boot device physpath, check if the device is in a valid state.
+ * If so, return the configuration from the vdev label.
+ */
+int
+spa_get_rootconf(char *devpath, char **bestdev, nvlist_t **bestconf)
+{
+ nvlist_t *conf = NULL;
+ char *dev = NULL;
+ uint64_t txg = 0;
+ nvlist_t *nvtop, **child;
+ char *type;
+ uint_t children, c;
+
+ spa_check_rootconf(devpath, &dev, &conf, &txg);
+ if (txg == 0 || conf == NULL)
+ return (EINVAL);
+
+ VERIFY(nvlist_lookup_nvlist(conf, ZPOOL_CONFIG_VDEV_TREE,
+ &nvtop) == 0);
+ VERIFY(nvlist_lookup_string(nvtop, ZPOOL_CONFIG_TYPE, &type) == 0);
+
+ if (strcmp(type, VDEV_TYPE_DISK) == 0) {
+ if (spa_rootdev_validate(nvtop))
+ goto out;
+ else
+ return (EINVAL);
+ }
+
+ ASSERT(strcmp(type, VDEV_TYPE_MIRROR) == 0);
+
+ VERIFY(nvlist_lookup_nvlist_array(nvtop, ZPOOL_CONFIG_CHILDREN,
+ &child, &children) == 0);
+
+ /*
+ * Go thru vdevs in the mirror to see if the given device (devpath)
+ * is in a healthy state. Also check if the given device has the most
+ * recent txg. Only the device with the most recent txg has valid
+ * information and can be booted.
+ */
+ for (c = 0; c < children; c++) {
+ char *physpath;
+
+ if (nvlist_lookup_string(child[c], ZPOOL_CONFIG_PHYS_PATH,
+ &physpath) != 0)
+ return (EINVAL);
+
+ if (strcmp(devpath, physpath) == 0) {
+ if (!spa_rootdev_validate(child[c]))
+ return (EINVAL);
+ } else {
+ /* get dev with the highest txg */
+ if (spa_rootdev_validate(child[c])) {
+ spa_check_rootconf(physpath, &dev,
+ &conf, &txg);
+ }
+ }
+ }
+
+ /* Does the given device have the most recent txg? */
+ if (strcmp(devpath, dev) != 0)
+ return (EINVAL);
+out:
+ *bestdev = dev;
+ *bestconf = conf;
+ return (0);
+}