4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <sys/zfs_context.h>
27 #include <sys/modctl.h>
30 * Null operations; used for uninitialized and "misc" modules.
32 static int mod_null(struct modlmisc *, struct modlinkage *);
33 static int mod_infonull(void *, struct modlinkage *, int *);
36 * Cryptographic Modules
38 struct mod_ops mod_cryptoops = {
39 .modm_install = mod_null,
40 .modm_remove = mod_null,
41 .modm_info = mod_infonull
45 * Null operation; return 0.
48 mod_null(struct modlmisc *modl, struct modlinkage *modlp)
54 * Status for User modules.
57 mod_infonull(void *modl, struct modlinkage *modlp, int *p0)
59 *p0 = -1; /* for modinfo display */
65 * (This routine is in the Solaris SPARC DDI/DKI)
68 mod_install(struct modlinkage *modlp)
70 int retval = -1; /* No linkage structures */
71 struct modlmisc **linkpp;
72 struct modlmisc **linkpp1;
74 if (modlp->ml_rev != MODREV_1) {
75 cmn_err(CE_WARN, "mod_install: "
76 "modlinkage structure is not MODREV_1\n");
79 linkpp = (struct modlmisc **)&modlp->ml_linkage[0];
81 while (*linkpp != NULL) {
82 if ((retval = MODL_INSTALL(*linkpp, modlp)) != 0) {
83 linkpp1 = (struct modlmisc **)&modlp->ml_linkage[0];
85 while (linkpp1 != linkpp) {
86 MODL_REMOVE(*linkpp1, modlp); /* clean up */
96 static char *reins_err =
97 "Could not reinstall %s\nReboot to correct the problem";
100 * Remove a module. This is called by the module wrapper routine.
101 * (This routine is in the Solaris SPARC DDI/DKI)
104 mod_remove(struct modlinkage *modlp)
107 struct modlmisc **linkpp, *last_linkp;
109 linkpp = (struct modlmisc **)&modlp->ml_linkage[0];
111 while (*linkpp != NULL) {
112 if ((retval = MODL_REMOVE(*linkpp, modlp)) != 0) {
113 last_linkp = *linkpp;
114 linkpp = (struct modlmisc **)&modlp->ml_linkage[0];
115 while (*linkpp != last_linkp) {
116 if (MODL_INSTALL(*linkpp, modlp) != 0) {
117 cmn_err(CE_WARN, reins_err,
118 (*linkpp)->misc_linkinfo);
132 * (This routine is in the Solaris SPARC DDI/DKI)
135 mod_info(struct modlinkage *modlp, struct modinfo *modinfop)
139 struct modspecific_info *msip;
140 struct modlmisc **linkpp;
142 modinfop->mi_rev = modlp->ml_rev;
144 linkpp = (struct modlmisc **)modlp->ml_linkage;
145 msip = &modinfop->mi_msinfo[0];
147 for (i = 0; i < MODMAXLINK; i++) {
148 if (*linkpp == NULL) {
149 msip->msi_linkinfo[0] = '\0';
151 (void) strlcpy(msip->msi_linkinfo,
152 (*linkpp)->misc_linkinfo, MODMAXLINKINFOLEN);
153 retval = MODL_INFO(*linkpp, modlp, &msip->msi_p0);
161 if (modinfop->mi_info == MI_INFO_LINKAGE) {
163 * Slight kludge used to extract the address of the
164 * modlinkage structure from the module (just after
165 * loading a module for the very first time)
167 modinfop->mi_base = (void *)modlp;