xref: /titanic_51/usr/src/uts/common/sys/modctl.h (revision c9cc1492d5b27b76cf77300ab3aafd0857f38228)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5facf4a8dSllai1  * Common Development and Distribution License (the "License").
6facf4a8dSllai1  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
226532b960SJerry Gilliam  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_MODCTL_H
277c478bd9Sstevel@tonic-gate #define	_SYS_MODCTL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * loadable module support.
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate #include <sys/ioccom.h>
357c478bd9Sstevel@tonic-gate #include <sys/nexusdefs.h>
367c478bd9Sstevel@tonic-gate #include <sys/thread.h>
377c478bd9Sstevel@tonic-gate #include <sys/t_lock.h>
387c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
397c478bd9Sstevel@tonic-gate #include <sys/hwconf.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
427c478bd9Sstevel@tonic-gate extern "C" {
437c478bd9Sstevel@tonic-gate #endif
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * The following structure defines the operations used by modctl
477c478bd9Sstevel@tonic-gate  * to load and unload modules.  Each supported loadable module type
487c478bd9Sstevel@tonic-gate  * requires a set of mod_ops.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate struct mod_ops {
517c478bd9Sstevel@tonic-gate 	int		(*modm_install)();	/* install module in kernel */
527c478bd9Sstevel@tonic-gate 	int		(*modm_remove)();	/* remove from kernel */
537c478bd9Sstevel@tonic-gate 	int		(*modm_info)();		/* module info */
547c478bd9Sstevel@tonic-gate };
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #ifdef _KERNEL
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate  * The defined set of mod_ops structures for each loadable module type
607c478bd9Sstevel@tonic-gate  * Defined in modctl.c
617c478bd9Sstevel@tonic-gate  */
629acbbeafSnn35248 extern struct mod_ops mod_brandops;
637aec1d6eScindi #if defined(__i386) || defined(__amd64)
647aec1d6eScindi extern struct mod_ops mod_cpuops;
657aec1d6eScindi #endif
667c478bd9Sstevel@tonic-gate extern struct mod_ops mod_cryptoops;
677c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops;
687c478bd9Sstevel@tonic-gate extern struct mod_ops mod_execops;
697c478bd9Sstevel@tonic-gate extern struct mod_ops mod_fsops;
707c478bd9Sstevel@tonic-gate extern struct mod_ops mod_miscops;
717c478bd9Sstevel@tonic-gate extern struct mod_ops mod_schedops;
727c478bd9Sstevel@tonic-gate extern struct mod_ops mod_strmodops;
737c478bd9Sstevel@tonic-gate extern struct mod_ops mod_syscallops;
740f1702c5SYu Xiangning extern struct mod_ops mod_sockmodops;
757c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL
767c478bd9Sstevel@tonic-gate extern struct mod_ops mod_syscallops32;
777c478bd9Sstevel@tonic-gate #endif
787c478bd9Sstevel@tonic-gate extern struct mod_ops mod_dacfops;
797c478bd9Sstevel@tonic-gate extern struct mod_ops mod_ippops;
807c478bd9Sstevel@tonic-gate extern struct mod_ops mod_pcbeops;
81d14d7d31Sis extern struct mod_ops mod_kiconvops;
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate  * Definitions for the module specific linkage structures.
877c478bd9Sstevel@tonic-gate  * The first two fields are the same in all of the structures.
887c478bd9Sstevel@tonic-gate  * The linkinfo is for informational purposes only and is returned by
897c478bd9Sstevel@tonic-gate  * modctl with the MODINFO cmd.
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /* For drivers */
937c478bd9Sstevel@tonic-gate struct modldrv {
947c478bd9Sstevel@tonic-gate 	struct mod_ops		*drv_modops;
957c478bd9Sstevel@tonic-gate 	char			*drv_linkinfo;
967c478bd9Sstevel@tonic-gate 	struct dev_ops		*drv_dev_ops;
977c478bd9Sstevel@tonic-gate };
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /* For system calls */
1007c478bd9Sstevel@tonic-gate struct modlsys {
1017c478bd9Sstevel@tonic-gate 	struct mod_ops		*sys_modops;
1027c478bd9Sstevel@tonic-gate 	char			*sys_linkinfo;
1037c478bd9Sstevel@tonic-gate 	struct sysent		*sys_sysent;
1047c478bd9Sstevel@tonic-gate };
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /* For filesystems */
1077c478bd9Sstevel@tonic-gate struct modlfs {
1087c478bd9Sstevel@tonic-gate 	struct mod_ops		*fs_modops;
1097c478bd9Sstevel@tonic-gate 	char			*fs_linkinfo;
110d7334e51Srm15945 	struct vfsdef_v5	*fs_vfsdef;	/* version may actually vary */
1117c478bd9Sstevel@tonic-gate };
1127c478bd9Sstevel@tonic-gate 
1137aec1d6eScindi #if defined(__i386) || defined(__amd64)
1147aec1d6eScindi struct cmi_ops;
1157aec1d6eScindi 
1167aec1d6eScindi /* For CPU modules */
1177aec1d6eScindi struct modlcpu {
1187aec1d6eScindi 	struct mod_ops		*cpu_modops;
1197aec1d6eScindi 	char			*cpu_linkinfo;
1207aec1d6eScindi 	struct cmi_ops		*cpu_cmiops;
1217aec1d6eScindi };
1227aec1d6eScindi #endif
1237aec1d6eScindi 
1247c478bd9Sstevel@tonic-gate /* For cryptographic providers */
1257c478bd9Sstevel@tonic-gate struct modlcrypto {
1267c478bd9Sstevel@tonic-gate 	struct mod_ops		*crypto_modops;
1277c478bd9Sstevel@tonic-gate 	char			*crypto_linkinfo;
1287c478bd9Sstevel@tonic-gate };
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /* For misc */
1317c478bd9Sstevel@tonic-gate struct modlmisc {
1327c478bd9Sstevel@tonic-gate 	struct mod_ops		*misc_modops;
1337c478bd9Sstevel@tonic-gate 	char			*misc_linkinfo;
1347c478bd9Sstevel@tonic-gate };
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate /* For IP Modules */
1377c478bd9Sstevel@tonic-gate struct modlipp {
1387c478bd9Sstevel@tonic-gate 	struct mod_ops		*ipp_modops;
1397c478bd9Sstevel@tonic-gate 	char			*ipp_linkinfo;
1407c478bd9Sstevel@tonic-gate 	struct ipp_ops		*ipp_ops;
1417c478bd9Sstevel@tonic-gate };
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate /* For Streams Modules. */
1447c478bd9Sstevel@tonic-gate struct modlstrmod {
1457c478bd9Sstevel@tonic-gate 	struct mod_ops		*strmod_modops;
1467c478bd9Sstevel@tonic-gate 	char			*strmod_linkinfo;
1477c478bd9Sstevel@tonic-gate 	struct fmodsw		*strmod_fmodsw;
1487c478bd9Sstevel@tonic-gate };
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate /* For Scheduling classes */
1517c478bd9Sstevel@tonic-gate struct modlsched {
1527c478bd9Sstevel@tonic-gate 	struct mod_ops		*sched_modops;
1537c478bd9Sstevel@tonic-gate 	char			*sched_linkinfo;
1547c478bd9Sstevel@tonic-gate 	struct sclass		*sched_class;
1557c478bd9Sstevel@tonic-gate };
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate /* For Exec file type (like ELF, ...) */
1587c478bd9Sstevel@tonic-gate struct modlexec {
1597c478bd9Sstevel@tonic-gate 	struct mod_ops		*exec_modops;
1607c478bd9Sstevel@tonic-gate 	char			*exec_linkinfo;
1617c478bd9Sstevel@tonic-gate 	struct execsw		*exec_execsw;
1627c478bd9Sstevel@tonic-gate };
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate /* For dacf modules */
1657c478bd9Sstevel@tonic-gate struct modldacf {
1667c478bd9Sstevel@tonic-gate 	struct mod_ops		*dacf_modops;
1677c478bd9Sstevel@tonic-gate 	char			*dacf_linkinfo;
1687c478bd9Sstevel@tonic-gate 	struct dacfsw		*dacf_dacfsw;
1697c478bd9Sstevel@tonic-gate };
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /* For PCBE modules */
1727c478bd9Sstevel@tonic-gate struct modlpcbe {
1737c478bd9Sstevel@tonic-gate 	struct mod_ops		*pcbe_modops;
1747c478bd9Sstevel@tonic-gate 	char			*pcbe_linkinfo;
1757c478bd9Sstevel@tonic-gate 	struct __pcbe_ops	*pcbe_ops;
1767c478bd9Sstevel@tonic-gate };
1777c478bd9Sstevel@tonic-gate 
1789acbbeafSnn35248 /* For Brand modules */
1799acbbeafSnn35248 struct modlbrand {
1809acbbeafSnn35248 	struct mod_ops		*brand_modops;
1819acbbeafSnn35248 	char			*brand_linkinfo;
1829acbbeafSnn35248 	struct brand		*brand_branddef;
1839acbbeafSnn35248 };
1849acbbeafSnn35248 
1850f1702c5SYu Xiangning /* For socket Modules. */
1860f1702c5SYu Xiangning struct modlsockmod {
1870f1702c5SYu Xiangning 	struct mod_ops		*sockmod_modops;
1880f1702c5SYu Xiangning 	char			*sockmod_linkinfo;
1890f1702c5SYu Xiangning 	struct smod_reg_s	*sockmod_reg_info;
1900f1702c5SYu Xiangning };
1910f1702c5SYu Xiangning 
192d14d7d31Sis /* For kiconv modules */
193d14d7d31Sis struct modlkiconv {
194d14d7d31Sis 	struct mod_ops		*kiconv_modops;
195d14d7d31Sis 	char			*kiconv_linkinfo;
196d14d7d31Sis 	struct kiconv_mod_info	*kiconv_moddef;
197d14d7d31Sis };
198d14d7d31Sis 
1997c478bd9Sstevel@tonic-gate /*
2007c478bd9Sstevel@tonic-gate  * Revision number of loadable modules support.  This is the value
2017c478bd9Sstevel@tonic-gate  * that must be used in the modlinkage structure.
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate #define	MODREV_1		1
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate /*
2067c478bd9Sstevel@tonic-gate  * The modlinkage structure is the structure that the module writer
2077c478bd9Sstevel@tonic-gate  * provides to the routines to install, remove, and stat a module.
2087c478bd9Sstevel@tonic-gate  * The ml_linkage element is an array of pointers to linkage structures.
2097c478bd9Sstevel@tonic-gate  * For most modules there is only one linkage structure.  We allocate
2107c478bd9Sstevel@tonic-gate  * enough space for 3 linkage structures which happens to be the most
2117c478bd9Sstevel@tonic-gate  * we have in any sun supplied module.  For those modules with more
2127c478bd9Sstevel@tonic-gate  * than 3 linkage structures (which is very unlikely), a modlinkage
2137c478bd9Sstevel@tonic-gate  * structure must be kmem_alloc'd in the module wrapper to be big enough
2147c478bd9Sstevel@tonic-gate  * for all of the linkage structures.
2157c478bd9Sstevel@tonic-gate  */
2167c478bd9Sstevel@tonic-gate struct modlinkage {
2177c478bd9Sstevel@tonic-gate 	int		ml_rev;		/* rev of loadable modules system */
2187c478bd9Sstevel@tonic-gate #ifdef _LP64
2197c478bd9Sstevel@tonic-gate 	void		*ml_linkage[7];	/* more space in 64-bit OS */
2207c478bd9Sstevel@tonic-gate #else
2217c478bd9Sstevel@tonic-gate 	void		*ml_linkage[4];	/* NULL terminated list of */
2227c478bd9Sstevel@tonic-gate 					/* linkage structures */
2237c478bd9Sstevel@tonic-gate #endif
2247c478bd9Sstevel@tonic-gate };
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate /*
2277c478bd9Sstevel@tonic-gate  * commands.  These are the commands supported by the modctl system call.
2287c478bd9Sstevel@tonic-gate  */
2297c478bd9Sstevel@tonic-gate #define	MODLOAD			0
2307c478bd9Sstevel@tonic-gate #define	MODUNLOAD		1
2317c478bd9Sstevel@tonic-gate #define	MODINFO			2
2327c478bd9Sstevel@tonic-gate #define	MODRESERVED		3
2337c478bd9Sstevel@tonic-gate #define	MODSETMINIROOT		4
2347c478bd9Sstevel@tonic-gate #define	MODADDMAJBIND		5
2357c478bd9Sstevel@tonic-gate #define	MODGETPATH		6
2367c478bd9Sstevel@tonic-gate #define	MODREADSYSBIND		7
2377c478bd9Sstevel@tonic-gate #define	MODGETMAJBIND		8
2387c478bd9Sstevel@tonic-gate #define	MODGETNAME		9
2397c478bd9Sstevel@tonic-gate #define	MODSIZEOF_DEVID		10
2407c478bd9Sstevel@tonic-gate #define	MODGETDEVID		11
2417c478bd9Sstevel@tonic-gate #define	MODSIZEOF_MINORNAME	12
2427c478bd9Sstevel@tonic-gate #define	MODGETMINORNAME		13
2437c478bd9Sstevel@tonic-gate #define	MODGETPATHLEN		14
2447c478bd9Sstevel@tonic-gate #define	MODEVENTS		15
2457c478bd9Sstevel@tonic-gate #define	MODGETFBNAME		16
2467c478bd9Sstevel@tonic-gate #define	MODREREADDACF		17
2477c478bd9Sstevel@tonic-gate #define	MODLOADDRVCONF		18
2487c478bd9Sstevel@tonic-gate #define	MODUNLOADDRVCONF	19
2497c478bd9Sstevel@tonic-gate #define	MODREMMAJBIND		20
2507c478bd9Sstevel@tonic-gate #define	MODDEVT2INSTANCE	21
2517c478bd9Sstevel@tonic-gate #define	MODGETDEVFSPATH_LEN	22
2527c478bd9Sstevel@tonic-gate #define	MODGETDEVFSPATH		23
2537c478bd9Sstevel@tonic-gate #define	MODDEVID2PATHS		24
2547c478bd9Sstevel@tonic-gate #define	MODSETDEVPOLICY		26
2557c478bd9Sstevel@tonic-gate #define	MODGETDEVPOLICY		27
2567c478bd9Sstevel@tonic-gate #define	MODALLOCPRIV		28
2577c478bd9Sstevel@tonic-gate #define	MODGETDEVPOLICYBYNAME	29
2587c478bd9Sstevel@tonic-gate #define	MODLOADMINORPERM	31
2597c478bd9Sstevel@tonic-gate #define	MODADDMINORPERM		32
2607c478bd9Sstevel@tonic-gate #define	MODREMMINORPERM		33
2617c478bd9Sstevel@tonic-gate #define	MODREMDRVCLEANUP	34
262facf4a8dSllai1 #define	MODDEVEXISTS		35
263facf4a8dSllai1 #define	MODDEVREADDIR		36
264facf4a8dSllai1 #define	MODDEVNAME		37
265a08731ecScth #define	MODGETDEVFSPATH_MI_LEN	38
266a08731ecScth #define	MODGETDEVFSPATH_MI	39
26725e8c5aaSvikram #define	MODRETIRE		40
26825e8c5aaSvikram #define	MODUNRETIRE		41
26925e8c5aaSvikram #define	MODISRETIRED		42
270e37c6c37Scth #define	MODDEVEMPTYDIR		43
2716532b960SJerry Gilliam #define	MODREMDRVALIAS		44
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate /*
2747c478bd9Sstevel@tonic-gate  * sub cmds for MODEVENTS
2757c478bd9Sstevel@tonic-gate  */
2767c478bd9Sstevel@tonic-gate #define	MODEVENTS_FLUSH				0
2777c478bd9Sstevel@tonic-gate #define	MODEVENTS_FLUSH_DUMP			1
2787c478bd9Sstevel@tonic-gate #define	MODEVENTS_SET_DOOR_UPCALL_FILENAME	2
2797c478bd9Sstevel@tonic-gate #define	MODEVENTS_GETDATA			3
2807c478bd9Sstevel@tonic-gate #define	MODEVENTS_FREEDATA			4
2817c478bd9Sstevel@tonic-gate #define	MODEVENTS_POST_EVENT			5
2827c478bd9Sstevel@tonic-gate #define	MODEVENTS_REGISTER_EVENT		6
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate /*
285facf4a8dSllai1  * devname subcmds for MODDEVNAME
286facf4a8dSllai1  */
287facf4a8dSllai1 #define	MODDEVNAME_LOOKUPDOOR	0
288facf4a8dSllai1 #define	MODDEVNAME_PROFILE	3
289facf4a8dSllai1 #define	MODDEVNAME_RECONFIG	4
290facf4a8dSllai1 #define	MODDEVNAME_SYSAVAIL	5
291facf4a8dSllai1 
292facf4a8dSllai1 
293facf4a8dSllai1 /*
2947c478bd9Sstevel@tonic-gate  * Data structure passed to modconfig command in kernel to build devfs tree
2957c478bd9Sstevel@tonic-gate  */
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate struct aliases {
2987c478bd9Sstevel@tonic-gate 	struct aliases *a_next;
2997c478bd9Sstevel@tonic-gate 	char *a_name;
3007c478bd9Sstevel@tonic-gate 	int a_len;
3017c478bd9Sstevel@tonic-gate };
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate #define	MAXMODCONFNAME	256
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate struct modconfig {
3067c478bd9Sstevel@tonic-gate 	char drvname[MAXMODCONFNAME];
3077c478bd9Sstevel@tonic-gate 	char drvclass[MAXMODCONFNAME];
3087c478bd9Sstevel@tonic-gate 	int major;
3096532b960SJerry Gilliam 	int flags;
3107c478bd9Sstevel@tonic-gate 	int num_aliases;
3117c478bd9Sstevel@tonic-gate 	struct aliases *ap;
3127c478bd9Sstevel@tonic-gate };
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate struct aliases32 {
3177c478bd9Sstevel@tonic-gate 	caddr32_t a_next;
3187c478bd9Sstevel@tonic-gate 	caddr32_t a_name;
3197c478bd9Sstevel@tonic-gate 	int32_t a_len;
3207c478bd9Sstevel@tonic-gate };
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate struct modconfig32 {
3237c478bd9Sstevel@tonic-gate 	char drvname[MAXMODCONFNAME];
3247c478bd9Sstevel@tonic-gate 	char drvclass[MAXMODCONFNAME];
3257c478bd9Sstevel@tonic-gate 	int32_t major;
3266532b960SJerry Gilliam 	int32_t flags;
3277c478bd9Sstevel@tonic-gate 	int32_t num_aliases;
3287c478bd9Sstevel@tonic-gate 	caddr32_t ap;
3297c478bd9Sstevel@tonic-gate };
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
3327c478bd9Sstevel@tonic-gate 
3336532b960SJerry Gilliam /* flags for modconfig */
3346532b960SJerry Gilliam #define	MOD_UNBIND_OVERRIDE	0x01		/* fail unbind if in use */
335*c9cc1492SJerry Gilliam #define	MOD_ADDMAJBIND_UPDATE	0x02		/* update only, do not load */
336*c9cc1492SJerry Gilliam 
337*c9cc1492SJerry Gilliam /* flags for MODLOADDRVCONF - modctl_load_drvconf() */
338*c9cc1492SJerry Gilliam #define	MOD_LOADDRVCONF_RECONF	0x01		/* complete configuration */
339*c9cc1492SJerry Gilliam 						/* after update-only */
3406532b960SJerry Gilliam 
3417c478bd9Sstevel@tonic-gate /*
3427c478bd9Sstevel@tonic-gate  * Max module path length
3437c478bd9Sstevel@tonic-gate  */
3447c478bd9Sstevel@tonic-gate #define	MOD_MAXPATH	256
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate /*
3477c478bd9Sstevel@tonic-gate  * Default search path for modules ADDITIONAL to the directory
3487c478bd9Sstevel@tonic-gate  * where the kernel components we booted from are.
3497c478bd9Sstevel@tonic-gate  *
3507c478bd9Sstevel@tonic-gate  * Most often, this will be "/platform/{platform}/kernel /kernel /usr/kernel",
3517c478bd9Sstevel@tonic-gate  * but we don't wire it down here.
3527c478bd9Sstevel@tonic-gate  */
3537c478bd9Sstevel@tonic-gate #define	MOD_DEFPATH	"/kernel /usr/kernel"
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate /*
3567c478bd9Sstevel@tonic-gate  * Default file name extension for autoloading modules.
3577c478bd9Sstevel@tonic-gate  */
3587c478bd9Sstevel@tonic-gate #define	MOD_DEFEXT	""
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate /*
3617c478bd9Sstevel@tonic-gate  * Parameters for modinfo
3627c478bd9Sstevel@tonic-gate  */
3637c478bd9Sstevel@tonic-gate #define	MODMAXNAMELEN 32		/* max module name length */
3647c478bd9Sstevel@tonic-gate #define	MODMAXLINKINFOLEN 32		/* max link info length */
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate /*
3677c478bd9Sstevel@tonic-gate  * Module specific information.
3687c478bd9Sstevel@tonic-gate  */
3697c478bd9Sstevel@tonic-gate struct modspecific_info {
3707c478bd9Sstevel@tonic-gate 	char	msi_linkinfo[MODMAXLINKINFOLEN]; /* name in linkage struct */
3717c478bd9Sstevel@tonic-gate 	int	msi_p0;			/* module specific information */
3727c478bd9Sstevel@tonic-gate };
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate /*
3757c478bd9Sstevel@tonic-gate  * Structure returned by modctl with MODINFO command.
3767c478bd9Sstevel@tonic-gate  */
3777c478bd9Sstevel@tonic-gate #define	MODMAXLINK 10			/* max linkages modinfo can handle */
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate struct modinfo {
3807c478bd9Sstevel@tonic-gate 	int		   mi_info;		/* Flags for info wanted */
3817c478bd9Sstevel@tonic-gate 	int		   mi_state;		/* Flags for module state */
3827c478bd9Sstevel@tonic-gate 	int		   mi_id;		/* id of this loaded module */
3837c478bd9Sstevel@tonic-gate 	int		   mi_nextid;		/* id of next module or -1 */
3847c478bd9Sstevel@tonic-gate 	caddr_t		   mi_base;		/* virtual addr of text */
3857c478bd9Sstevel@tonic-gate 	size_t		   mi_size;		/* size of module in bytes */
3867c478bd9Sstevel@tonic-gate 	int		   mi_rev;		/* loadable modules rev */
3877c478bd9Sstevel@tonic-gate 	int		   mi_loadcnt;		/* # of times loaded */
3887c478bd9Sstevel@tonic-gate 	char		   mi_name[MODMAXNAMELEN]; /* name of module */
3897c478bd9Sstevel@tonic-gate 	struct modspecific_info mi_msinfo[MODMAXLINK];
3907c478bd9Sstevel@tonic-gate 						/* mod specific info */
3917c478bd9Sstevel@tonic-gate };
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate #define	MODMAXNAMELEN32 32		/* max module name length */
3977c478bd9Sstevel@tonic-gate #define	MODMAXLINKINFOLEN32 32		/* max link info length */
3987c478bd9Sstevel@tonic-gate #define	MODMAXLINK32 10			/* max linkages modinfo can handle */
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate struct modspecific_info32 {
4017c478bd9Sstevel@tonic-gate 	char	msi_linkinfo[MODMAXLINKINFOLEN32]; /* name in linkage struct */
4027c478bd9Sstevel@tonic-gate 	int32_t	msi_p0;			/* module specific information */
4037c478bd9Sstevel@tonic-gate };
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate struct modinfo32 {
4067c478bd9Sstevel@tonic-gate 	int32_t		   mi_info;		/* Flags for info wanted */
4077c478bd9Sstevel@tonic-gate 	int32_t		   mi_state;		/* Flags for module state */
4087c478bd9Sstevel@tonic-gate 	int32_t		   mi_id;		/* id of this loaded module */
4097c478bd9Sstevel@tonic-gate 	int32_t		   mi_nextid;		/* id of next module or -1 */
4107c478bd9Sstevel@tonic-gate 	caddr32_t	   mi_base;		/* virtual addr of text */
4117c478bd9Sstevel@tonic-gate 	uint32_t	   mi_size;		/* size of module in bytes */
4127c478bd9Sstevel@tonic-gate 	int32_t		   mi_rev;		/* loadable modules rev */
4137c478bd9Sstevel@tonic-gate 	int32_t		   mi_loadcnt;		/* # of times loaded */
4147c478bd9Sstevel@tonic-gate 	char		   mi_name[MODMAXNAMELEN32]; /* name of module */
4157c478bd9Sstevel@tonic-gate 	struct modspecific_info32 mi_msinfo[MODMAXLINK32];
4167c478bd9Sstevel@tonic-gate 						/* mod specific info */
4177c478bd9Sstevel@tonic-gate };
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
4207c478bd9Sstevel@tonic-gate 
4217c478bd9Sstevel@tonic-gate /* Values for mi_info flags */
4227c478bd9Sstevel@tonic-gate #define	MI_INFO_ONE	1
4237c478bd9Sstevel@tonic-gate #define	MI_INFO_ALL	2
4247c478bd9Sstevel@tonic-gate #define	MI_INFO_CNT	4
4257c478bd9Sstevel@tonic-gate #ifdef _KERNEL
4267c478bd9Sstevel@tonic-gate #define	MI_INFO_LINKAGE	8	/* used internally to extract modlinkage */
4277c478bd9Sstevel@tonic-gate #endif
4287c478bd9Sstevel@tonic-gate /*
4297c478bd9Sstevel@tonic-gate  * MI_INFO_NOBASE indicates caller does not need mi_base. Failure to use this
4307c478bd9Sstevel@tonic-gate  * flag may lead 32-bit apps to receive an EOVERFLOW error from modctl(MODINFO)
4317c478bd9Sstevel@tonic-gate  * when used with a 64-bit kernel.
4327c478bd9Sstevel@tonic-gate  */
4337c478bd9Sstevel@tonic-gate #define	MI_INFO_NOBASE	16
4347c478bd9Sstevel@tonic-gate 
4357c478bd9Sstevel@tonic-gate /* Values for mi_state */
4367c478bd9Sstevel@tonic-gate #define	MI_LOADED	1
4377c478bd9Sstevel@tonic-gate #define	MI_INSTALLED	2
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate /*
4407c478bd9Sstevel@tonic-gate  * Macros to vector to the appropriate module specific routine.
4417c478bd9Sstevel@tonic-gate  */
4427c478bd9Sstevel@tonic-gate #define	MODL_INSTALL(MODL, MODLP) \
4437c478bd9Sstevel@tonic-gate 	(*(MODL)->misc_modops->modm_install)(MODL, MODLP)
4447c478bd9Sstevel@tonic-gate #define	MODL_REMOVE(MODL, MODLP) \
4457c478bd9Sstevel@tonic-gate 	(*(MODL)->misc_modops->modm_remove)(MODL, MODLP)
4467c478bd9Sstevel@tonic-gate #define	MODL_INFO(MODL, MODLP, P0) \
4477c478bd9Sstevel@tonic-gate 	(*(MODL)->misc_modops->modm_info)(MODL, MODLP, P0)
4487c478bd9Sstevel@tonic-gate 
4497c478bd9Sstevel@tonic-gate /*
4507c478bd9Sstevel@tonic-gate  * Definitions for stubs
4517c478bd9Sstevel@tonic-gate  */
4527c478bd9Sstevel@tonic-gate struct mod_stub_info {
4537c478bd9Sstevel@tonic-gate 	uintptr_t mods_func_adr;
4547c478bd9Sstevel@tonic-gate 	struct mod_modinfo *mods_modinfo;
4557c478bd9Sstevel@tonic-gate 	uintptr_t mods_stub_adr;
4567c478bd9Sstevel@tonic-gate 	int (*mods_errfcn)();
4577c478bd9Sstevel@tonic-gate 	int mods_flag;			/* flags defined below */
4587c478bd9Sstevel@tonic-gate };
4597c478bd9Sstevel@tonic-gate 
4607c478bd9Sstevel@tonic-gate /*
4617c478bd9Sstevel@tonic-gate  * Definitions for mods_flag.
4627c478bd9Sstevel@tonic-gate  */
4637c478bd9Sstevel@tonic-gate #define	MODS_WEAK	0x01		/* weak stub (not loaded if called) */
4647c478bd9Sstevel@tonic-gate #define	MODS_NOUNLOAD	0x02		/* module not unloadable (no _fini()) */
4657c478bd9Sstevel@tonic-gate #define	MODS_INSTALLED	0x10		/* module installed */
4667c478bd9Sstevel@tonic-gate 
4677c478bd9Sstevel@tonic-gate struct mod_modinfo {
4687c478bd9Sstevel@tonic-gate 	char *modm_module_name;
4697c478bd9Sstevel@tonic-gate 	struct modctl *mp;
4707c478bd9Sstevel@tonic-gate 	struct mod_stub_info modm_stubs[1];
4717c478bd9Sstevel@tonic-gate };
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate struct modctl_list {
4747c478bd9Sstevel@tonic-gate 	struct modctl_list *modl_next;
4757c478bd9Sstevel@tonic-gate 	struct modctl *modl_modp;
4767c478bd9Sstevel@tonic-gate };
4777c478bd9Sstevel@tonic-gate 
4787c478bd9Sstevel@tonic-gate /*
4797c478bd9Sstevel@tonic-gate  * Structure to manage a loadable module.
4807c478bd9Sstevel@tonic-gate  * Note: the module (mod_mp) structure's "text" and "text_size" information
4817c478bd9Sstevel@tonic-gate  * are replicated in the modctl structure so that mod_containing_pc()
4827c478bd9Sstevel@tonic-gate  * doesn't have to grab any locks (modctls are persistent; modules are not.)
4837c478bd9Sstevel@tonic-gate  */
4847aec1d6eScindi typedef struct modctl {
4857c478bd9Sstevel@tonic-gate 	struct modctl	*mod_next;	/* &modules based list */
4867c478bd9Sstevel@tonic-gate 	struct modctl	*mod_prev;
4877c478bd9Sstevel@tonic-gate 	int		mod_id;
4887c478bd9Sstevel@tonic-gate 	void		*mod_mp;
4897c478bd9Sstevel@tonic-gate 	kthread_t	*mod_inprogress_thread;
4907c478bd9Sstevel@tonic-gate 	struct mod_modinfo *mod_modinfo;
4917c478bd9Sstevel@tonic-gate 	struct modlinkage *mod_linkage;
4927c478bd9Sstevel@tonic-gate 	char		*mod_filename;
4937c478bd9Sstevel@tonic-gate 	char		*mod_modname;
4947c478bd9Sstevel@tonic-gate 
4957c478bd9Sstevel@tonic-gate 	char		mod_busy;	/* inprogress_thread has locked */
4967c478bd9Sstevel@tonic-gate 	char		mod_want;	/* someone waiting for unlock */
4977c478bd9Sstevel@tonic-gate 	char		mod_prim;	/* primary module */
4987c478bd9Sstevel@tonic-gate 
4997c478bd9Sstevel@tonic-gate 	int		mod_ref;	/* ref count - from dependent or stub */
5007c478bd9Sstevel@tonic-gate 
5017c478bd9Sstevel@tonic-gate 	char		mod_loaded;	/* module in memory */
5027c478bd9Sstevel@tonic-gate 	char		mod_installed;	/* post _init pre _fini */
5037c478bd9Sstevel@tonic-gate 	char		mod_loadflags;
5047c478bd9Sstevel@tonic-gate 	char		mod_delay_unload;	/* deferred unload */
5057c478bd9Sstevel@tonic-gate 
5067c478bd9Sstevel@tonic-gate 	struct modctl_list *mod_requisites;	/* mods this one depends on. */
5077c478bd9Sstevel@tonic-gate 	void		*__unused;	/* NOTE: reuse (same size) is OK, */
5087c478bd9Sstevel@tonic-gate 					/* deletion causes mdb.vs.core issues */
5097c478bd9Sstevel@tonic-gate 	int		mod_loadcnt;	/* number of times mod was loaded */
5107c478bd9Sstevel@tonic-gate 	int		mod_nenabled;	/* # of enabled DTrace probes in mod */
5117c478bd9Sstevel@tonic-gate 	char		*mod_text;
5127c478bd9Sstevel@tonic-gate 	size_t		mod_text_size;
5137c478bd9Sstevel@tonic-gate 
5147c478bd9Sstevel@tonic-gate 	int		mod_gencount;	/* # times loaded/unloaded */
5157c478bd9Sstevel@tonic-gate 	struct modctl	*mod_requisite_loading;	/* mod circular dependency */
5167aec1d6eScindi } modctl_t;
5177c478bd9Sstevel@tonic-gate 
5187c478bd9Sstevel@tonic-gate /*
5197c478bd9Sstevel@tonic-gate  * mod_loadflags
5207c478bd9Sstevel@tonic-gate  */
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate #define	MOD_NOAUTOUNLOAD	0x1	/* Auto mod-unloader skips this mod */
5237c478bd9Sstevel@tonic-gate #define	MOD_NONOTIFY		0x2	/* No krtld notifications on (un)load */
5247c478bd9Sstevel@tonic-gate #define	MOD_NOUNLOAD		0x4	/* Assume EBUSY for all _fini's */
5257c478bd9Sstevel@tonic-gate 
526facf4a8dSllai1 
5277c478bd9Sstevel@tonic-gate #ifdef _KERNEL
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate #define	MOD_BIND_HASHSIZE	64
5307c478bd9Sstevel@tonic-gate #define	MOD_BIND_HASHMASK	(MOD_BIND_HASHSIZE-1)
5317c478bd9Sstevel@tonic-gate 
5327c478bd9Sstevel@tonic-gate typedef int modid_t;
5337c478bd9Sstevel@tonic-gate 
5347c478bd9Sstevel@tonic-gate /*
5357c478bd9Sstevel@tonic-gate  * global function and data declarations
5367c478bd9Sstevel@tonic-gate  */
5377c478bd9Sstevel@tonic-gate extern kmutex_t mod_lock;
5387c478bd9Sstevel@tonic-gate 
5397c478bd9Sstevel@tonic-gate extern char *systemfile;
5407c478bd9Sstevel@tonic-gate extern char **syscallnames;
5417c478bd9Sstevel@tonic-gate extern int moddebug;
5427c478bd9Sstevel@tonic-gate 
5437c478bd9Sstevel@tonic-gate /*
5447c478bd9Sstevel@tonic-gate  * this is the head of a doubly linked list.  Only the next and prev
5457c478bd9Sstevel@tonic-gate  * pointers are used
5467c478bd9Sstevel@tonic-gate  */
5477aec1d6eScindi extern modctl_t modules;
5487aec1d6eScindi 
5497aec1d6eScindi extern int modload_qualified(const char *,
55020c794b3Sgavinm     const char *, const char *, const char *, uint_t[], int, int *);
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate extern void	mod_setup(void);
55343d5cd3dSjohnlev extern int	modload(const char *, const char *);
55443d5cd3dSjohnlev extern int	modloadonly(const char *, const char *);
5557c478bd9Sstevel@tonic-gate extern int	modunload(int);
5567c478bd9Sstevel@tonic-gate extern int	mod_hold_stub(struct mod_stub_info *);
5577c478bd9Sstevel@tonic-gate extern void	modunload_disable(void);
5587c478bd9Sstevel@tonic-gate extern void	modunload_enable(void);
559a7aa4df7Scth extern void	modunload_begin(void);
560a7aa4df7Scth extern void	modunload_end(void);
5617c478bd9Sstevel@tonic-gate extern int	mod_remove_by_name(char *);
5627c478bd9Sstevel@tonic-gate extern int	mod_sysvar(const char *, const char *, u_longlong_t *);
5637c478bd9Sstevel@tonic-gate extern int	mod_sysctl(int, void *);
5647c478bd9Sstevel@tonic-gate struct sysparam;
5657aec1d6eScindi extern int	mod_hold_by_modctl(modctl_t *, int);
5667c478bd9Sstevel@tonic-gate #define		MOD_WAIT_ONCE		0x01
5677c478bd9Sstevel@tonic-gate #define		MOD_WAIT_FOREVER	0x02
5687c478bd9Sstevel@tonic-gate #define		MOD_LOCK_HELD		0x04
5697c478bd9Sstevel@tonic-gate #define		MOD_LOCK_NOT_HELD	0x08
5707c478bd9Sstevel@tonic-gate extern int	mod_sysctl_type(int, int (*)(struct sysparam *, void *),
5717c478bd9Sstevel@tonic-gate     void *);
5727c478bd9Sstevel@tonic-gate extern void	mod_read_system_file(int);
5737c478bd9Sstevel@tonic-gate extern void	mod_release_stub(struct mod_stub_info *);
5747c478bd9Sstevel@tonic-gate extern void	mod_askparams(void);
5757c478bd9Sstevel@tonic-gate extern void	mod_uninstall_daemon(void);
5767c478bd9Sstevel@tonic-gate extern void	modreap(void);
5777aec1d6eScindi extern modctl_t *mod_hold_by_id(modid_t);
5787aec1d6eScindi extern modctl_t *mod_hold_by_name(const char *);
5797aec1d6eScindi extern void	mod_release_mod(modctl_t *);
5807aec1d6eScindi extern uintptr_t modlookup(const char *, const char *);
5817aec1d6eScindi extern uintptr_t modlookup_by_modctl(modctl_t *, const char *);
5827c478bd9Sstevel@tonic-gate extern char	*modgetsymname(uintptr_t, unsigned long *);
5837aec1d6eScindi extern void	mod_release_requisites(modctl_t *);
5847aec1d6eScindi extern modctl_t *mod_load_requisite(modctl_t *, char *);
5857aec1d6eScindi extern modctl_t *mod_find_by_filename(char *, char *);
5867c478bd9Sstevel@tonic-gate extern uintptr_t	modgetsymvalue(char *, int);
5877c478bd9Sstevel@tonic-gate 
588*c9cc1492SJerry Gilliam extern int	driver_installed(major_t);
5897c478bd9Sstevel@tonic-gate extern void	mod_rele_dev_by_major(major_t);
5907c478bd9Sstevel@tonic-gate extern struct dev_ops *mod_hold_dev_by_major(major_t);
5917c478bd9Sstevel@tonic-gate extern struct dev_ops *mod_hold_dev_by_devi(dev_info_t *);
5927c478bd9Sstevel@tonic-gate extern void	mod_rele_dev_by_devi(dev_info_t *);
5937c478bd9Sstevel@tonic-gate 
594*c9cc1492SJerry Gilliam extern int make_devname(char *, major_t, int);
595facf4a8dSllai1 extern int gmatch(const char *, const char *);
5967c478bd9Sstevel@tonic-gate 
5977c478bd9Sstevel@tonic-gate extern void make_aliases(struct bind **);
5987c478bd9Sstevel@tonic-gate extern int read_binding_file(char *, struct bind **,
5997c478bd9Sstevel@tonic-gate     int (*line_parser)(char *, int, char *, struct bind **));
6007c478bd9Sstevel@tonic-gate extern void clear_binding_hash(struct bind **);
6017c478bd9Sstevel@tonic-gate 
6027c478bd9Sstevel@tonic-gate extern void read_class_file(void);
6037c478bd9Sstevel@tonic-gate extern void setbootpath(char *);
6047c478bd9Sstevel@tonic-gate extern void setbootfstype(char *);
6057c478bd9Sstevel@tonic-gate 
6067aec1d6eScindi extern int install_stubs_by_name(modctl_t *, char *);
6077aec1d6eScindi extern void install_stubs(modctl_t *);
6087aec1d6eScindi extern void uninstall_stubs(modctl_t *);
6097aec1d6eScindi extern void reset_stubs(modctl_t *);
6107aec1d6eScindi extern modctl_t *mod_getctl(struct modlinkage *);
6117c478bd9Sstevel@tonic-gate extern major_t mod_name_to_major(char *);
6127c478bd9Sstevel@tonic-gate extern modid_t mod_name_to_modid(char *);
6137c478bd9Sstevel@tonic-gate extern char *mod_major_to_name(major_t);
6147c478bd9Sstevel@tonic-gate extern void init_devnamesp(int);
6157c478bd9Sstevel@tonic-gate extern void init_syscallnames(int);
6167c478bd9Sstevel@tonic-gate 
6177c478bd9Sstevel@tonic-gate extern char *mod_getsysname(int);
6187c478bd9Sstevel@tonic-gate extern int mod_getsysnum(char *);
6197c478bd9Sstevel@tonic-gate 
6207c478bd9Sstevel@tonic-gate extern char *mod_containing_pc(caddr_t);
6217c478bd9Sstevel@tonic-gate extern int mod_in_autounload(void);
622a204de77Scth extern const char *mod_modname(struct modlinkage *);
6237c478bd9Sstevel@tonic-gate 
6247aec1d6eScindi extern int dev_minorperm(dev_info_t *, char *, mperm_t *);
6251aef0e11Sjg extern void dev_devices_cleanup(void);
6267c478bd9Sstevel@tonic-gate 
6277c478bd9Sstevel@tonic-gate /*
6287c478bd9Sstevel@tonic-gate  * Declarations used for dynamic linking support routines.  Interfaces
6297c478bd9Sstevel@tonic-gate  * are marked with the pragma "unknown_control_flow" to prevent tail call
6307c478bd9Sstevel@tonic-gate  * optimization, so that implementations can reliably use caller() to
6317c478bd9Sstevel@tonic-gate  * determine initiating module.
6327c478bd9Sstevel@tonic-gate  */
6337c478bd9Sstevel@tonic-gate #define	KRTLD_MODE_FIRST	0x0001
6347c478bd9Sstevel@tonic-gate typedef	struct __ddi_modhandle	*ddi_modhandle_t;
6357c478bd9Sstevel@tonic-gate extern ddi_modhandle_t		ddi_modopen(const char *,
6367c478bd9Sstevel@tonic-gate 				    int, int *);
6377c478bd9Sstevel@tonic-gate extern void			*ddi_modsym(ddi_modhandle_t,
6387c478bd9Sstevel@tonic-gate 				    const char *, int *);
6397c478bd9Sstevel@tonic-gate extern int			ddi_modclose(ddi_modhandle_t);
6407c478bd9Sstevel@tonic-gate #pragma	unknown_control_flow(ddi_modopen, ddi_modsym, ddi_modclose)
6417c478bd9Sstevel@tonic-gate 
6427c478bd9Sstevel@tonic-gate /*
6437c478bd9Sstevel@tonic-gate  * Only the following are part of the DDI/DKI
6447c478bd9Sstevel@tonic-gate  */
6457c478bd9Sstevel@tonic-gate extern int	_init(void);
6467c478bd9Sstevel@tonic-gate extern int	_fini(void);
6477c478bd9Sstevel@tonic-gate extern int	_info(struct modinfo *);
6487c478bd9Sstevel@tonic-gate extern int	mod_install(struct modlinkage *);
6497c478bd9Sstevel@tonic-gate extern int	mod_remove(struct modlinkage *);
6507c478bd9Sstevel@tonic-gate extern int	mod_info(struct modlinkage *, struct modinfo *);
6517c478bd9Sstevel@tonic-gate 
6527c478bd9Sstevel@tonic-gate #else	/* _KERNEL */
6537c478bd9Sstevel@tonic-gate 
6547c478bd9Sstevel@tonic-gate extern int modctl(int, ...);
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
6577c478bd9Sstevel@tonic-gate 
6587c478bd9Sstevel@tonic-gate /*
6597c478bd9Sstevel@tonic-gate  * bit definitions for moddebug.
6607c478bd9Sstevel@tonic-gate  */
6617c478bd9Sstevel@tonic-gate #define	MODDEBUG_LOADMSG	0x80000000	/* print "[un]loading..." msg */
6627c478bd9Sstevel@tonic-gate #define	MODDEBUG_ERRMSG		0x40000000	/* print detailed error msgs */
6637c478bd9Sstevel@tonic-gate #define	MODDEBUG_LOADMSG2	0x20000000	/* print 2nd level msgs */
66425e8c5aaSvikram #define	MODDEBUG_RETIRE		0x10000000	/* print retire msgs */
6656532b960SJerry Gilliam #define	MODDEBUG_BINDING	0x00040000	/* driver/alias binding */
6667c478bd9Sstevel@tonic-gate #define	MODDEBUG_FINI_EBUSY	0x00020000	/* pretend fini returns EBUSY */
6677c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_IPP	0x00010000	/* no Autounloading ipp mods */
6687c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_DACF	0x00008000	/* no Autounloading dacf mods */
6697c478bd9Sstevel@tonic-gate #define	MODDEBUG_KEEPTEXT	0x00004000	/* keep text after unloading */
6707c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_DRV	0x00001000	/* no Autounloading Drivers */
6717c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_EXEC	0x00000800	/* no Autounloading Execs */
6727c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_FS	0x00000400	/* no Autounloading File sys */
6737c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_MISC	0x00000200	/* no Autounloading misc */
6747c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_SCHED	0x00000100	/* no Autounloading scheds */
6757c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_STR	0x00000080	/* no Autounloading streams */
6767c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUL_SYS	0x00000040	/* no Autounloading syscalls */
6777c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOCTF		0x00000020	/* do not load CTF debug data */
6787c478bd9Sstevel@tonic-gate #define	MODDEBUG_NOAUTOUNLOAD	0x00000010	/* no autounloading at all */
6797c478bd9Sstevel@tonic-gate #define	MODDEBUG_DDI_MOD	0x00000008	/* ddi_mod{open,sym,close} */
6807c478bd9Sstevel@tonic-gate #define	MODDEBUG_MP_MATCH	0x00000004	/* dev_minorperm */
6817c478bd9Sstevel@tonic-gate #define	MODDEBUG_MINORPERM	0x00000002	/* minor perm modctls */
6827c478bd9Sstevel@tonic-gate #define	MODDEBUG_USERDEBUG	0x00000001	/* bpt after init_module() */
6837c478bd9Sstevel@tonic-gate 
6847c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6857c478bd9Sstevel@tonic-gate }
6867c478bd9Sstevel@tonic-gate #endif
6877c478bd9Sstevel@tonic-gate 
6887c478bd9Sstevel@tonic-gate #endif	/* _SYS_MODCTL_H */
689