author | llai1 |
Fri, 25 Aug 2006 17:24:25 -0700 | |
changeset 2621 | 4ea88858d952 |
parent 1414 | b4126407ac5b |
child 2712 | f74a135872bc |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
2621 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
0 | 7 |
* |
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. |
|
12 |
* |
|
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] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
1218
da9792769ae8
4988141 modunload(1M) can race with di_ioctl(DINFOLODRV)
cth
parents:
878
diff
changeset
|
22 |
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
0 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#ifndef _SYS_MODCTL_H |
|
27 |
#define _SYS_MODCTL_H |
|
28 |
||
29 |
#pragma ident "%Z%%M% %I% %E% SMI" |
|
30 |
||
31 |
/* |
|
32 |
* loadable module support. |
|
33 |
*/ |
|
34 |
||
35 |
#include <sys/types.h> |
|
36 |
#include <sys/ioccom.h> |
|
37 |
#include <sys/nexusdefs.h> |
|
38 |
#include <sys/thread.h> |
|
39 |
#include <sys/t_lock.h> |
|
40 |
#include <sys/dditypes.h> |
|
41 |
#include <sys/hwconf.h> |
|
42 |
||
43 |
#ifdef __cplusplus |
|
44 |
extern "C" { |
|
45 |
#endif |
|
46 |
||
47 |
/* |
|
48 |
* The following structure defines the operations used by modctl |
|
49 |
* to load and unload modules. Each supported loadable module type |
|
50 |
* requires a set of mod_ops. |
|
51 |
*/ |
|
52 |
struct mod_ops { |
|
53 |
int (*modm_install)(); /* install module in kernel */ |
|
54 |
int (*modm_remove)(); /* remove from kernel */ |
|
55 |
int (*modm_info)(); /* module info */ |
|
56 |
}; |
|
57 |
||
58 |
#ifdef _KERNEL |
|
59 |
||
60 |
/* |
|
61 |
* The defined set of mod_ops structures for each loadable module type |
|
62 |
* Defined in modctl.c |
|
63 |
*/ |
|
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
64 |
#if defined(__i386) || defined(__amd64) |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
65 |
extern struct mod_ops mod_cpuops; |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
66 |
#endif |
0 | 67 |
extern struct mod_ops mod_cryptoops; |
68 |
extern struct mod_ops mod_driverops; |
|
69 |
extern struct mod_ops mod_execops; |
|
70 |
extern struct mod_ops mod_fsops; |
|
71 |
extern struct mod_ops mod_miscops; |
|
72 |
extern struct mod_ops mod_schedops; |
|
73 |
extern struct mod_ops mod_strmodops; |
|
74 |
extern struct mod_ops mod_syscallops; |
|
75 |
#ifdef _SYSCALL32_IMPL |
|
76 |
extern struct mod_ops mod_syscallops32; |
|
77 |
#endif |
|
78 |
extern struct mod_ops mod_dacfops; |
|
79 |
extern struct mod_ops mod_ippops; |
|
80 |
extern struct mod_ops mod_pcbeops; |
|
2621 | 81 |
extern struct mod_ops mod_devfsops; |
0 | 82 |
|
83 |
#endif /* _KERNEL */ |
|
84 |
||
85 |
/* |
|
86 |
* Definitions for the module specific linkage structures. |
|
87 |
* The first two fields are the same in all of the structures. |
|
88 |
* The linkinfo is for informational purposes only and is returned by |
|
89 |
* modctl with the MODINFO cmd. |
|
90 |
*/ |
|
91 |
||
92 |
/* For drivers */ |
|
93 |
struct modldrv { |
|
94 |
struct mod_ops *drv_modops; |
|
95 |
char *drv_linkinfo; |
|
96 |
struct dev_ops *drv_dev_ops; |
|
97 |
}; |
|
98 |
||
99 |
/* For system calls */ |
|
100 |
struct modlsys { |
|
101 |
struct mod_ops *sys_modops; |
|
102 |
char *sys_linkinfo; |
|
103 |
struct sysent *sys_sysent; |
|
104 |
}; |
|
105 |
||
106 |
/* For filesystems */ |
|
107 |
struct modlfs { |
|
108 |
struct mod_ops *fs_modops; |
|
109 |
char *fs_linkinfo; |
|
110 |
struct vfsdef_v3 *fs_vfsdef; /* version may actually vary */ |
|
111 |
}; |
|
112 |
||
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
113 |
#if defined(__i386) || defined(__amd64) |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
114 |
struct cmi_ops; |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
115 |
|
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
116 |
/* For CPU modules */ |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
117 |
struct modlcpu { |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
118 |
struct mod_ops *cpu_modops; |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
119 |
char *cpu_linkinfo; |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
120 |
struct cmi_ops *cpu_cmiops; |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
121 |
}; |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
122 |
#endif |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
123 |
|
0 | 124 |
/* For cryptographic providers */ |
125 |
struct modlcrypto { |
|
126 |
struct mod_ops *crypto_modops; |
|
127 |
char *crypto_linkinfo; |
|
128 |
}; |
|
129 |
||
130 |
/* For misc */ |
|
131 |
struct modlmisc { |
|
132 |
struct mod_ops *misc_modops; |
|
133 |
char *misc_linkinfo; |
|
134 |
}; |
|
135 |
||
136 |
/* For IP Modules */ |
|
137 |
struct modlipp { |
|
138 |
struct mod_ops *ipp_modops; |
|
139 |
char *ipp_linkinfo; |
|
140 |
struct ipp_ops *ipp_ops; |
|
141 |
}; |
|
142 |
||
143 |
/* For Streams Modules. */ |
|
144 |
struct modlstrmod { |
|
145 |
struct mod_ops *strmod_modops; |
|
146 |
char *strmod_linkinfo; |
|
147 |
struct fmodsw *strmod_fmodsw; |
|
148 |
}; |
|
149 |
||
150 |
/* For Scheduling classes */ |
|
151 |
struct modlsched { |
|
152 |
struct mod_ops *sched_modops; |
|
153 |
char *sched_linkinfo; |
|
154 |
struct sclass *sched_class; |
|
155 |
}; |
|
156 |
||
157 |
/* For Exec file type (like ELF, ...) */ |
|
158 |
struct modlexec { |
|
159 |
struct mod_ops *exec_modops; |
|
160 |
char *exec_linkinfo; |
|
161 |
struct execsw *exec_execsw; |
|
162 |
}; |
|
163 |
||
164 |
/* For dacf modules */ |
|
165 |
struct modldacf { |
|
166 |
struct mod_ops *dacf_modops; |
|
167 |
char *dacf_linkinfo; |
|
168 |
struct dacfsw *dacf_dacfsw; |
|
169 |
}; |
|
170 |
||
171 |
/* For PCBE modules */ |
|
172 |
struct modlpcbe { |
|
173 |
struct mod_ops *pcbe_modops; |
|
174 |
char *pcbe_linkinfo; |
|
175 |
struct __pcbe_ops *pcbe_ops; |
|
176 |
}; |
|
177 |
||
2621 | 178 |
/* for devname fs */ |
179 |
struct modldev { |
|
180 |
struct mod_ops *dev_modops; |
|
181 |
char *dev_linkinfo; |
|
182 |
struct devname_ops *dev_ops; |
|
183 |
}; |
|
184 |
||
0 | 185 |
/* |
186 |
* Revision number of loadable modules support. This is the value |
|
187 |
* that must be used in the modlinkage structure. |
|
188 |
*/ |
|
189 |
#define MODREV_1 1 |
|
190 |
||
191 |
/* |
|
192 |
* The modlinkage structure is the structure that the module writer |
|
193 |
* provides to the routines to install, remove, and stat a module. |
|
194 |
* The ml_linkage element is an array of pointers to linkage structures. |
|
195 |
* For most modules there is only one linkage structure. We allocate |
|
196 |
* enough space for 3 linkage structures which happens to be the most |
|
197 |
* we have in any sun supplied module. For those modules with more |
|
198 |
* than 3 linkage structures (which is very unlikely), a modlinkage |
|
199 |
* structure must be kmem_alloc'd in the module wrapper to be big enough |
|
200 |
* for all of the linkage structures. |
|
201 |
*/ |
|
202 |
struct modlinkage { |
|
203 |
int ml_rev; /* rev of loadable modules system */ |
|
204 |
#ifdef _LP64 |
|
205 |
void *ml_linkage[7]; /* more space in 64-bit OS */ |
|
206 |
#else |
|
207 |
void *ml_linkage[4]; /* NULL terminated list of */ |
|
208 |
/* linkage structures */ |
|
209 |
#endif |
|
210 |
}; |
|
211 |
||
212 |
/* |
|
213 |
* commands. These are the commands supported by the modctl system call. |
|
214 |
*/ |
|
215 |
#define MODLOAD 0 |
|
216 |
#define MODUNLOAD 1 |
|
217 |
#define MODINFO 2 |
|
218 |
#define MODRESERVED 3 |
|
219 |
#define MODSETMINIROOT 4 |
|
220 |
#define MODADDMAJBIND 5 |
|
221 |
#define MODGETPATH 6 |
|
222 |
#define MODREADSYSBIND 7 |
|
223 |
#define MODGETMAJBIND 8 |
|
224 |
#define MODGETNAME 9 |
|
225 |
#define MODSIZEOF_DEVID 10 |
|
226 |
#define MODGETDEVID 11 |
|
227 |
#define MODSIZEOF_MINORNAME 12 |
|
228 |
#define MODGETMINORNAME 13 |
|
229 |
#define MODGETPATHLEN 14 |
|
230 |
#define MODEVENTS 15 |
|
231 |
#define MODGETFBNAME 16 |
|
232 |
#define MODREREADDACF 17 |
|
233 |
#define MODLOADDRVCONF 18 |
|
234 |
#define MODUNLOADDRVCONF 19 |
|
235 |
#define MODREMMAJBIND 20 |
|
236 |
#define MODDEVT2INSTANCE 21 |
|
237 |
#define MODGETDEVFSPATH_LEN 22 |
|
238 |
#define MODGETDEVFSPATH 23 |
|
239 |
#define MODDEVID2PATHS 24 |
|
240 |
#define MODSETDEVPOLICY 26 |
|
241 |
#define MODGETDEVPOLICY 27 |
|
242 |
#define MODALLOCPRIV 28 |
|
243 |
#define MODGETDEVPOLICYBYNAME 29 |
|
244 |
#define MODLOADMINORPERM 31 |
|
245 |
#define MODADDMINORPERM 32 |
|
246 |
#define MODREMMINORPERM 33 |
|
247 |
#define MODREMDRVCLEANUP 34 |
|
2621 | 248 |
#define MODDEVEXISTS 35 |
249 |
#define MODDEVREADDIR 36 |
|
250 |
#define MODDEVNAME 37 |
|
0 | 251 |
|
252 |
/* |
|
253 |
* sub cmds for MODEVENTS |
|
254 |
*/ |
|
255 |
#define MODEVENTS_FLUSH 0 |
|
256 |
#define MODEVENTS_FLUSH_DUMP 1 |
|
257 |
#define MODEVENTS_SET_DOOR_UPCALL_FILENAME 2 |
|
258 |
#define MODEVENTS_GETDATA 3 |
|
259 |
#define MODEVENTS_FREEDATA 4 |
|
260 |
#define MODEVENTS_POST_EVENT 5 |
|
261 |
#define MODEVENTS_REGISTER_EVENT 6 |
|
262 |
||
263 |
/* |
|
2621 | 264 |
* devname subcmds for MODDEVNAME |
265 |
*/ |
|
266 |
#define MODDEVNAME_LOOKUPDOOR 0 |
|
267 |
#define MODDEVNAME_DEVFSADMNODE 1 |
|
268 |
#define MODDEVNAME_NSMAPS 2 |
|
269 |
#define MODDEVNAME_PROFILE 3 |
|
270 |
#define MODDEVNAME_RECONFIG 4 |
|
271 |
#define MODDEVNAME_SYSAVAIL 5 |
|
272 |
||
273 |
||
274 |
/* |
|
0 | 275 |
* Data structure passed to modconfig command in kernel to build devfs tree |
276 |
*/ |
|
277 |
||
278 |
struct aliases { |
|
279 |
struct aliases *a_next; |
|
280 |
char *a_name; |
|
281 |
int a_len; |
|
282 |
}; |
|
283 |
||
284 |
#define MAXMODCONFNAME 256 |
|
285 |
||
286 |
struct modconfig { |
|
287 |
char drvname[MAXMODCONFNAME]; |
|
288 |
char drvclass[MAXMODCONFNAME]; |
|
289 |
int major; |
|
290 |
int num_aliases; |
|
291 |
struct aliases *ap; |
|
292 |
}; |
|
293 |
||
294 |
#if defined(_SYSCALL32) |
|
295 |
||
296 |
struct aliases32 { |
|
297 |
caddr32_t a_next; |
|
298 |
caddr32_t a_name; |
|
299 |
int32_t a_len; |
|
300 |
}; |
|
301 |
||
302 |
struct modconfig32 { |
|
303 |
char drvname[MAXMODCONFNAME]; |
|
304 |
char drvclass[MAXMODCONFNAME]; |
|
305 |
int32_t major; |
|
306 |
int32_t num_aliases; |
|
307 |
caddr32_t ap; |
|
308 |
}; |
|
309 |
||
310 |
#endif /* _SYSCALL32 */ |
|
311 |
||
312 |
/* |
|
313 |
* Max module path length |
|
314 |
*/ |
|
315 |
#define MOD_MAXPATH 256 |
|
316 |
||
317 |
/* |
|
318 |
* Default search path for modules ADDITIONAL to the directory |
|
319 |
* where the kernel components we booted from are. |
|
320 |
* |
|
321 |
* Most often, this will be "/platform/{platform}/kernel /kernel /usr/kernel", |
|
322 |
* but we don't wire it down here. |
|
323 |
*/ |
|
324 |
#define MOD_DEFPATH "/kernel /usr/kernel" |
|
325 |
||
326 |
/* |
|
327 |
* Default file name extension for autoloading modules. |
|
328 |
*/ |
|
329 |
#define MOD_DEFEXT "" |
|
330 |
||
331 |
/* |
|
332 |
* Parameters for modinfo |
|
333 |
*/ |
|
334 |
#define MODMAXNAMELEN 32 /* max module name length */ |
|
335 |
#define MODMAXLINKINFOLEN 32 /* max link info length */ |
|
336 |
||
337 |
/* |
|
338 |
* Module specific information. |
|
339 |
*/ |
|
340 |
struct modspecific_info { |
|
341 |
char msi_linkinfo[MODMAXLINKINFOLEN]; /* name in linkage struct */ |
|
342 |
int msi_p0; /* module specific information */ |
|
343 |
}; |
|
344 |
||
345 |
/* |
|
346 |
* Structure returned by modctl with MODINFO command. |
|
347 |
*/ |
|
348 |
#define MODMAXLINK 10 /* max linkages modinfo can handle */ |
|
349 |
||
350 |
struct modinfo { |
|
351 |
int mi_info; /* Flags for info wanted */ |
|
352 |
int mi_state; /* Flags for module state */ |
|
353 |
int mi_id; /* id of this loaded module */ |
|
354 |
int mi_nextid; /* id of next module or -1 */ |
|
355 |
caddr_t mi_base; /* virtual addr of text */ |
|
356 |
size_t mi_size; /* size of module in bytes */ |
|
357 |
int mi_rev; /* loadable modules rev */ |
|
358 |
int mi_loadcnt; /* # of times loaded */ |
|
359 |
char mi_name[MODMAXNAMELEN]; /* name of module */ |
|
360 |
struct modspecific_info mi_msinfo[MODMAXLINK]; |
|
361 |
/* mod specific info */ |
|
362 |
}; |
|
363 |
||
364 |
||
365 |
#if defined(_SYSCALL32) |
|
366 |
||
367 |
#define MODMAXNAMELEN32 32 /* max module name length */ |
|
368 |
#define MODMAXLINKINFOLEN32 32 /* max link info length */ |
|
369 |
#define MODMAXLINK32 10 /* max linkages modinfo can handle */ |
|
370 |
||
371 |
struct modspecific_info32 { |
|
372 |
char msi_linkinfo[MODMAXLINKINFOLEN32]; /* name in linkage struct */ |
|
373 |
int32_t msi_p0; /* module specific information */ |
|
374 |
}; |
|
375 |
||
376 |
struct modinfo32 { |
|
377 |
int32_t mi_info; /* Flags for info wanted */ |
|
378 |
int32_t mi_state; /* Flags for module state */ |
|
379 |
int32_t mi_id; /* id of this loaded module */ |
|
380 |
int32_t mi_nextid; /* id of next module or -1 */ |
|
381 |
caddr32_t mi_base; /* virtual addr of text */ |
|
382 |
uint32_t mi_size; /* size of module in bytes */ |
|
383 |
int32_t mi_rev; /* loadable modules rev */ |
|
384 |
int32_t mi_loadcnt; /* # of times loaded */ |
|
385 |
char mi_name[MODMAXNAMELEN32]; /* name of module */ |
|
386 |
struct modspecific_info32 mi_msinfo[MODMAXLINK32]; |
|
387 |
/* mod specific info */ |
|
388 |
}; |
|
389 |
||
390 |
#endif /* _SYSCALL32 */ |
|
391 |
||
392 |
/* Values for mi_info flags */ |
|
393 |
#define MI_INFO_ONE 1 |
|
394 |
#define MI_INFO_ALL 2 |
|
395 |
#define MI_INFO_CNT 4 |
|
396 |
#ifdef _KERNEL |
|
397 |
#define MI_INFO_LINKAGE 8 /* used internally to extract modlinkage */ |
|
398 |
#endif |
|
399 |
/* |
|
400 |
* MI_INFO_NOBASE indicates caller does not need mi_base. Failure to use this |
|
401 |
* flag may lead 32-bit apps to receive an EOVERFLOW error from modctl(MODINFO) |
|
402 |
* when used with a 64-bit kernel. |
|
403 |
*/ |
|
404 |
#define MI_INFO_NOBASE 16 |
|
405 |
||
406 |
/* Values for mi_state */ |
|
407 |
#define MI_LOADED 1 |
|
408 |
#define MI_INSTALLED 2 |
|
409 |
||
410 |
/* |
|
411 |
* Macros to vector to the appropriate module specific routine. |
|
412 |
*/ |
|
413 |
#define MODL_INSTALL(MODL, MODLP) \ |
|
414 |
(*(MODL)->misc_modops->modm_install)(MODL, MODLP) |
|
415 |
#define MODL_REMOVE(MODL, MODLP) \ |
|
416 |
(*(MODL)->misc_modops->modm_remove)(MODL, MODLP) |
|
417 |
#define MODL_INFO(MODL, MODLP, P0) \ |
|
418 |
(*(MODL)->misc_modops->modm_info)(MODL, MODLP, P0) |
|
419 |
||
420 |
/* |
|
421 |
* Definitions for stubs |
|
422 |
*/ |
|
423 |
struct mod_stub_info { |
|
424 |
uintptr_t mods_func_adr; |
|
425 |
struct mod_modinfo *mods_modinfo; |
|
426 |
uintptr_t mods_stub_adr; |
|
427 |
int (*mods_errfcn)(); |
|
428 |
int mods_flag; /* flags defined below */ |
|
429 |
}; |
|
430 |
||
431 |
/* |
|
432 |
* Definitions for mods_flag. |
|
433 |
*/ |
|
434 |
#define MODS_WEAK 0x01 /* weak stub (not loaded if called) */ |
|
435 |
#define MODS_NOUNLOAD 0x02 /* module not unloadable (no _fini()) */ |
|
436 |
#define MODS_INSTALLED 0x10 /* module installed */ |
|
437 |
||
438 |
struct mod_modinfo { |
|
439 |
char *modm_module_name; |
|
440 |
struct modctl *mp; |
|
441 |
struct mod_stub_info modm_stubs[1]; |
|
442 |
}; |
|
443 |
||
444 |
struct modctl_list { |
|
445 |
struct modctl_list *modl_next; |
|
446 |
struct modctl *modl_modp; |
|
447 |
}; |
|
448 |
||
449 |
/* |
|
450 |
* Structure to manage a loadable module. |
|
451 |
* Note: the module (mod_mp) structure's "text" and "text_size" information |
|
452 |
* are replicated in the modctl structure so that mod_containing_pc() |
|
453 |
* doesn't have to grab any locks (modctls are persistent; modules are not.) |
|
454 |
*/ |
|
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
455 |
typedef struct modctl { |
0 | 456 |
struct modctl *mod_next; /* &modules based list */ |
457 |
struct modctl *mod_prev; |
|
458 |
int mod_id; |
|
459 |
void *mod_mp; |
|
460 |
kthread_t *mod_inprogress_thread; |
|
461 |
struct mod_modinfo *mod_modinfo; |
|
462 |
struct modlinkage *mod_linkage; |
|
463 |
char *mod_filename; |
|
464 |
char *mod_modname; |
|
465 |
||
466 |
char mod_busy; /* inprogress_thread has locked */ |
|
467 |
char mod_want; /* someone waiting for unlock */ |
|
468 |
char mod_prim; /* primary module */ |
|
469 |
||
470 |
int mod_ref; /* ref count - from dependent or stub */ |
|
471 |
||
472 |
char mod_loaded; /* module in memory */ |
|
473 |
char mod_installed; /* post _init pre _fini */ |
|
474 |
char mod_loadflags; |
|
475 |
char mod_delay_unload; /* deferred unload */ |
|
476 |
||
477 |
struct modctl_list *mod_requisites; /* mods this one depends on. */ |
|
478 |
void *__unused; /* NOTE: reuse (same size) is OK, */ |
|
479 |
/* deletion causes mdb.vs.core issues */ |
|
480 |
int mod_loadcnt; /* number of times mod was loaded */ |
|
481 |
int mod_nenabled; /* # of enabled DTrace probes in mod */ |
|
482 |
char *mod_text; |
|
483 |
size_t mod_text_size; |
|
484 |
||
485 |
int mod_gencount; /* # times loaded/unloaded */ |
|
486 |
struct modctl *mod_requisite_loading; /* mod circular dependency */ |
|
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
487 |
} modctl_t; |
0 | 488 |
|
489 |
/* |
|
490 |
* mod_loadflags |
|
491 |
*/ |
|
492 |
||
493 |
#define MOD_NOAUTOUNLOAD 0x1 /* Auto mod-unloader skips this mod */ |
|
494 |
#define MOD_NONOTIFY 0x2 /* No krtld notifications on (un)load */ |
|
495 |
#define MOD_NOUNLOAD 0x4 /* Assume EBUSY for all _fini's */ |
|
496 |
||
2621 | 497 |
|
0 | 498 |
#ifdef _KERNEL |
499 |
||
500 |
#define MOD_BIND_HASHSIZE 64 |
|
501 |
#define MOD_BIND_HASHMASK (MOD_BIND_HASHSIZE-1) |
|
502 |
||
503 |
typedef int modid_t; |
|
504 |
||
505 |
/* |
|
506 |
* global function and data declarations |
|
507 |
*/ |
|
508 |
extern kmutex_t mod_lock; |
|
509 |
||
510 |
extern char *systemfile; |
|
511 |
extern char **syscallnames; |
|
512 |
extern int moddebug; |
|
513 |
||
514 |
/* |
|
515 |
* this is the head of a doubly linked list. Only the next and prev |
|
516 |
* pointers are used |
|
517 |
*/ |
|
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
518 |
extern modctl_t modules; |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
519 |
|
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
520 |
extern int modload_qualified(const char *, |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
521 |
const char *, const char *, const char *, uint_t[], int); |
0 | 522 |
|
523 |
extern void mod_setup(void); |
|
524 |
extern int modload(char *, char *); |
|
525 |
extern int modloadonly(char *, char *); |
|
526 |
extern int modunload(int); |
|
527 |
extern int mod_hold_stub(struct mod_stub_info *); |
|
528 |
extern void modunload_disable(void); |
|
529 |
extern void modunload_enable(void); |
|
1218
da9792769ae8
4988141 modunload(1M) can race with di_ioctl(DINFOLODRV)
cth
parents:
878
diff
changeset
|
530 |
extern void modunload_begin(void); |
da9792769ae8
4988141 modunload(1M) can race with di_ioctl(DINFOLODRV)
cth
parents:
878
diff
changeset
|
531 |
extern void modunload_end(void); |
0 | 532 |
extern int mod_remove_by_name(char *); |
533 |
extern int mod_sysvar(const char *, const char *, u_longlong_t *); |
|
534 |
extern int mod_sysctl(int, void *); |
|
535 |
struct sysparam; |
|
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
536 |
extern int mod_hold_by_modctl(modctl_t *, int); |
0 | 537 |
#define MOD_WAIT_ONCE 0x01 |
538 |
#define MOD_WAIT_FOREVER 0x02 |
|
539 |
#define MOD_LOCK_HELD 0x04 |
|
540 |
#define MOD_LOCK_NOT_HELD 0x08 |
|
541 |
extern int mod_sysctl_type(int, int (*)(struct sysparam *, void *), |
|
542 |
void *); |
|
543 |
extern void mod_read_system_file(int); |
|
544 |
extern void mod_release_stub(struct mod_stub_info *); |
|
545 |
extern void mod_askparams(void); |
|
546 |
extern void mod_uninstall_daemon(void); |
|
547 |
extern void modreap(void); |
|
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
548 |
extern modctl_t *mod_hold_by_id(modid_t); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
549 |
extern modctl_t *mod_hold_by_name(const char *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
550 |
extern void mod_release_mod(modctl_t *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
551 |
extern uintptr_t modlookup(const char *, const char *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
552 |
extern uintptr_t modlookup_by_modctl(modctl_t *, const char *); |
0 | 553 |
extern char *modgetsymname(uintptr_t, unsigned long *); |
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
554 |
extern void mod_release_requisites(modctl_t *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
555 |
extern modctl_t *mod_load_requisite(modctl_t *, char *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
556 |
extern modctl_t *mod_find_by_filename(char *, char *); |
0 | 557 |
extern uintptr_t modgetsymvalue(char *, int); |
558 |
||
559 |
extern void mod_rele_dev_by_major(major_t); |
|
560 |
extern struct dev_ops *mod_hold_dev_by_major(major_t); |
|
561 |
extern struct dev_ops *mod_hold_dev_by_devi(dev_info_t *); |
|
562 |
extern void mod_rele_dev_by_devi(dev_info_t *); |
|
563 |
||
564 |
extern int make_devname(char *, major_t); |
|
2621 | 565 |
extern int gmatch(const char *, const char *); |
0 | 566 |
|
567 |
struct bind; |
|
568 |
extern void make_aliases(struct bind **); |
|
569 |
extern int read_binding_file(char *, struct bind **, |
|
570 |
int (*line_parser)(char *, int, char *, struct bind **)); |
|
571 |
extern void clear_binding_hash(struct bind **); |
|
572 |
||
573 |
extern void read_class_file(void); |
|
574 |
extern void setbootpath(char *); |
|
575 |
extern void setbootfstype(char *); |
|
576 |
||
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
577 |
extern int install_stubs_by_name(modctl_t *, char *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
578 |
extern void install_stubs(modctl_t *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
579 |
extern void uninstall_stubs(modctl_t *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
580 |
extern void reset_stubs(modctl_t *); |
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
581 |
extern modctl_t *mod_getctl(struct modlinkage *); |
0 | 582 |
extern major_t mod_name_to_major(char *); |
583 |
extern modid_t mod_name_to_modid(char *); |
|
584 |
extern char *mod_major_to_name(major_t); |
|
585 |
extern void init_devnamesp(int); |
|
586 |
extern void init_syscallnames(int); |
|
587 |
||
588 |
extern char *mod_getsysname(int); |
|
589 |
extern int mod_getsysnum(char *); |
|
590 |
||
591 |
extern char *mod_containing_pc(caddr_t); |
|
592 |
extern int mod_in_autounload(void); |
|
593 |
extern char *mod_modname(struct modlinkage *); |
|
594 |
||
1414
b4126407ac5b
PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents:
1218
diff
changeset
|
595 |
extern int dev_minorperm(dev_info_t *, char *, mperm_t *); |
0 | 596 |
|
597 |
/* |
|
598 |
* Declarations used for dynamic linking support routines. Interfaces |
|
599 |
* are marked with the pragma "unknown_control_flow" to prevent tail call |
|
600 |
* optimization, so that implementations can reliably use caller() to |
|
601 |
* determine initiating module. |
|
602 |
*/ |
|
603 |
#define KRTLD_MODE_FIRST 0x0001 |
|
604 |
typedef struct __ddi_modhandle *ddi_modhandle_t; |
|
605 |
extern ddi_modhandle_t ddi_modopen(const char *, |
|
606 |
int, int *); |
|
607 |
extern void *ddi_modsym(ddi_modhandle_t, |
|
608 |
const char *, int *); |
|
609 |
extern int ddi_modclose(ddi_modhandle_t); |
|
610 |
#pragma unknown_control_flow(ddi_modopen, ddi_modsym, ddi_modclose) |
|
611 |
||
612 |
/* |
|
613 |
* Only the following are part of the DDI/DKI |
|
614 |
*/ |
|
615 |
extern int _init(void); |
|
616 |
extern int _fini(void); |
|
617 |
extern int _info(struct modinfo *); |
|
618 |
extern int mod_install(struct modlinkage *); |
|
619 |
extern int mod_remove(struct modlinkage *); |
|
620 |
extern int mod_info(struct modlinkage *, struct modinfo *); |
|
621 |
||
622 |
#else /* _KERNEL */ |
|
623 |
||
624 |
extern int modctl(int, ...); |
|
625 |
||
626 |
#endif /* _KERNEL */ |
|
627 |
||
628 |
/* |
|
629 |
* bit definitions for moddebug. |
|
630 |
*/ |
|
631 |
#define MODDEBUG_LOADMSG 0x80000000 /* print "[un]loading..." msg */ |
|
632 |
#define MODDEBUG_ERRMSG 0x40000000 /* print detailed error msgs */ |
|
633 |
#define MODDEBUG_LOADMSG2 0x20000000 /* print 2nd level msgs */ |
|
634 |
#define MODDEBUG_FINI_EBUSY 0x00020000 /* pretend fini returns EBUSY */ |
|
635 |
#define MODDEBUG_NOAUL_IPP 0x00010000 /* no Autounloading ipp mods */ |
|
636 |
#define MODDEBUG_NOAUL_DACF 0x00008000 /* no Autounloading dacf mods */ |
|
637 |
#define MODDEBUG_KEEPTEXT 0x00004000 /* keep text after unloading */ |
|
638 |
#define MODDEBUG_NOAUL_DRV 0x00001000 /* no Autounloading Drivers */ |
|
639 |
#define MODDEBUG_NOAUL_EXEC 0x00000800 /* no Autounloading Execs */ |
|
640 |
#define MODDEBUG_NOAUL_FS 0x00000400 /* no Autounloading File sys */ |
|
641 |
#define MODDEBUG_NOAUL_MISC 0x00000200 /* no Autounloading misc */ |
|
642 |
#define MODDEBUG_NOAUL_SCHED 0x00000100 /* no Autounloading scheds */ |
|
643 |
#define MODDEBUG_NOAUL_STR 0x00000080 /* no Autounloading streams */ |
|
644 |
#define MODDEBUG_NOAUL_SYS 0x00000040 /* no Autounloading syscalls */ |
|
645 |
#define MODDEBUG_NOCTF 0x00000020 /* do not load CTF debug data */ |
|
646 |
#define MODDEBUG_NOAUTOUNLOAD 0x00000010 /* no autounloading at all */ |
|
647 |
#define MODDEBUG_DDI_MOD 0x00000008 /* ddi_mod{open,sym,close} */ |
|
648 |
#define MODDEBUG_MP_MATCH 0x00000004 /* dev_minorperm */ |
|
649 |
#define MODDEBUG_MINORPERM 0x00000002 /* minor perm modctls */ |
|
650 |
#define MODDEBUG_USERDEBUG 0x00000001 /* bpt after init_module() */ |
|
651 |
||
652 |
#ifdef __cplusplus |
|
653 |
} |
|
654 |
#endif |
|
655 |
||
656 |
#endif /* _SYS_MODCTL_H */ |