9022 loader.efi: module placement must check memory map
[unleashed.git] / share / man / man9f / mod_install.9f
blob2165166ed4043ea2e7260d70697c3eeafae2366b
1 '\" te
2 .\" Copyright (c) 2008, Sun Microsystems, Inc., All Rights Removed
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH MOD_INSTALL 9F "Jul 8, 2008"
7 .SH NAME
8 mod_install, mod_remove, mod_info, mod_modname \- add, remove or query a
9 loadable module
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/modctl.h>
17 \fBint\fR \fBmod_install\fR(\fBstruct modlinkage *\fR\fImodlinkage\fR);
18 .fi
20 .LP
21 .nf
22 \fBint\fR \fBmod_remove\fR(\fBstruct modlinkage *\fR\fImodlinkage\fR);
23 .fi
25 .LP
26 .nf
27 \fBint\fR \fBmod_info\fR(\fBstruct modlinkage *\fR\fImodlinkage\fR,
28      \fBstruct modinfo *\fR\fImodinfo\fR);
29 .fi
31 .LP
32 .nf
33 \fBconst\fR \fBchar *\fR\fImod_modname\fR(\fBstruct modlinkage *\fR\fImodlinkage\fR);
34 .fi
36 .SH INTERFACE LEVEL
37 .LP
38 Solaris DDI specific (Solaris DDI).
39 .SH PARAMETERS
40 .ne 2
41 .na
42 \fB\fImodlinkage\fR\fR
43 .ad
44 .RS 14n
45 Pointer to the loadable module's \fBmodlinkage\fR structure which describes
46 what type(s) of module elements are included in this loadable module.
47 .RE
49 .sp
50 .ne 2
51 .na
52 \fB\fImodinfo\fR\fR
53 .ad
54 .RS 14n
55 Pointer to the \fBmodinfo\fR structure passed to \fB_info\fR(9E).
56 .RE
58 .SH DESCRIPTION
59 .LP
60 \fBmod_install()\fR must be called from a module's \fB_init\fR(9E) routine.
61 .sp
62 .LP
63 \fBmod_remove()\fR must be called from a module's \fB_fini\fR(9E) routine.
64 .sp
65 .LP
66 \fBmod_info()\fR must be called from a module's \fB_info\fR(9E) routine.
67 .sp
68 .LP
69 \fBmod_modname()\fR can be called from any module routine.
70 .sp
71 .LP
72 When \fB_init\fR(9E) is executing, its call to \fBmod_install()\fR enables
73 other threads to call \fBattach\fR(9E) even prior to \fBmod_install()\fR
74 returning and \fB_init\fR(9E) completion. From a programming standpoint this
75 means that all \fB_init\fR(9E) initialization must occur prior to
76 \fB_init\fR(9E) calling \fBmod_install()\fR. If \fBmod_install()\fR fails
77 (non-zero return value), any initialization must be undone.
78 .sp
79 .LP
80 When \fB_fini\fR(9E) is executing, another thread may call \fBattach\fR(9E)
81 prior to \fB_fini\fR(9E) calling \fBmod_remove()\fR. If this occurs, the
82 \fBmod_remove()\fR fails (non-zero return). From a programming standpoint, this
83 means that \fB_init\fR(9E) initializations should only be undone after a
84 successful return from \fBmod_remove()\fR.
85 .sp
86 .LP
87 To query the name of a module, use \fBmod_modname()\fR. If the module is a
88 driver, the module name is the same as the driver name. This function can be
89 used to avoid compiled-in knowledge of the module name, and is of particular
90 use when \fB_init\fR(9E) needs to call a function like \fBkstat_create\fR(9F).
91 .SH RETURN VALUES
92 .LP
93 \fBmod_install()\fR and \fBmod_remove()\fR return \fB0\fR upon success and
94 non-zero on failure.
95 .sp
96 .LP
97 \fBmod_info()\fR returns a non-zero value on success and  \fB0\fR upon failure.
98 .sp
99 .LP
100 \fBmod_modname()\fR returns the name of the module. The returned name remains
101 valid as long as the module remains loaded.
102 .SH EXAMPLES
104 See \fB_init\fR(9E) for an example that uses these functions.
105 .SH SEE ALSO
107 \fB_fini\fR(9E), \fB_info\fR(9E), \fB_init\fR(9E), \fBkstat_create\fR(9F),
108 \fBmodldrv\fR(9S), \fBmodlinkage\fR(9S), \fBmodlstrmod\fR(9S)
111 \fIWriting Device Drivers\fR