/*
* 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
* 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
*/
/*
*/
#ifndef _SYS_MODCTL_H
#define _SYS_MODCTL_H
/*
* loadable module support.
*/
#include <sys/nexusdefs.h>
#include <sys/dditypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The following structure defines the operations used by modctl
* to load and unload modules. Each supported loadable module type
* requires a set of mod_ops.
*/
struct mod_ops {
};
#ifdef _KERNEL
/*
* The defined set of mod_ops structures for each loadable module type
* Defined in modctl.c
*/
extern struct mod_ops mod_brandops;
extern struct mod_ops mod_cpuops;
#endif
extern struct mod_ops mod_cryptoops;
extern struct mod_ops mod_driverops;
extern struct mod_ops mod_execops;
extern struct mod_ops mod_miscops;
extern struct mod_ops mod_schedops;
extern struct mod_ops mod_strmodops;
extern struct mod_ops mod_syscallops;
extern struct mod_ops mod_sockmodops;
#ifdef _SYSCALL32_IMPL
extern struct mod_ops mod_syscallops32;
#endif
extern struct mod_ops mod_dacfops;
extern struct mod_ops mod_ippops;
extern struct mod_ops mod_pcbeops;
extern struct mod_ops mod_kiconvops;
#endif /* _KERNEL */
/*
* Definitions for the module specific linkage structures.
* The first two fields are the same in all of the structures.
* The linkinfo is for informational purposes only and is returned by
* modctl with the MODINFO cmd.
*/
/* For drivers */
struct modldrv {
char *drv_linkinfo;
};
/* For system calls */
struct modlsys {
char *sys_linkinfo;
};
/* For filesystems */
struct modlfs {
char *fs_linkinfo;
};
struct cmi_ops;
/* For CPU modules */
struct modlcpu {
char *cpu_linkinfo;
};
#endif
/* For cryptographic providers */
struct modlcrypto {
char *crypto_linkinfo;
};
/* For misc */
struct modlmisc {
char *misc_linkinfo;
};
/* For IP Modules */
struct modlipp {
char *ipp_linkinfo;
};
/* For Streams Modules. */
struct modlstrmod {
char *strmod_linkinfo;
};
/* For Scheduling classes */
struct modlsched {
char *sched_linkinfo;
};
/* For Exec file type (like ELF, ...) */
struct modlexec {
char *exec_linkinfo;
};
/* For dacf modules */
struct modldacf {
char *dacf_linkinfo;
};
/* For PCBE modules */
struct modlpcbe {
char *pcbe_linkinfo;
};
/* For Brand modules */
struct modlbrand {
char *brand_linkinfo;
};
/* For socket Modules. */
struct modlsockmod {
char *sockmod_linkinfo;
};
/* For kiconv modules */
struct modlkiconv {
char *kiconv_linkinfo;
};
/*
* Revision number of loadable modules support. This is the value
* that must be used in the modlinkage structure.
*/
/*
* The modlinkage structure is the structure that the module writer
* provides to the routines to install, remove, and stat a module.
* The ml_linkage element is an array of pointers to linkage structures.
* For most modules there is only one linkage structure. We allocate
* enough space for 3 linkage structures which happens to be the most
* we have in any sun supplied module. For those modules with more
* than 3 linkage structures (which is very unlikely), a modlinkage
* structure must be kmem_alloc'd in the module wrapper to be big enough
* for all of the linkage structures.
*/
struct modlinkage {
#ifdef _LP64
#else
/* linkage structures */
#endif
};
/*
* commands. These are the commands supported by the modctl system call.
*/
#define MODLOAD 0
/*
* sub cmds for MODEVENTS
*/
#define MODEVENTS_FLUSH 0
/*
* devname subcmds for MODDEVNAME
*/
#define MODDEVNAME_LOOKUPDOOR 0
/*
* subcmds for MODHPOPS
*/
#define MODHPOPS_CHANGE_STATE 0
/*
* Data structure passed to modconfig command in kernel to build devfs tree
*/
struct aliases {
char *a_name;
int a_len;
};
struct modconfig {
int major;
int flags;
int num_aliases;
};
#if defined(_SYSCALL32)
struct aliases32 {
};
struct modconfig32 {
};
#endif /* _SYSCALL32 */
/* flags for modconfig */
/* flags for MODLOADDRVCONF - modctl_load_drvconf() */
/* after update-only */
/*
* Max module path length
*/
/*
* Default search path for modules ADDITIONAL to the directory
* where the kernel components we booted from are.
*
* but we don't wire it down here.
*/
/*
* Default file name extension for autoloading modules.
*/
/*
* Parameters for modinfo
*/
/*
* Module specific information.
*/
struct modspecific_info {
};
/*
* Structure returned by modctl with MODINFO command.
*/
struct modinfo {
/* mod specific info */
};
#if defined(_SYSCALL32)
struct modspecific_info32 {
};
struct modinfo32 {
/* mod specific info */
};
#endif /* _SYSCALL32 */
/* Values for mi_info flags */
#ifdef _KERNEL
#endif
/*
* MI_INFO_NOBASE indicates caller does not need mi_base. Failure to use this
* flag may lead 32-bit apps to receive an EOVERFLOW error from modctl(MODINFO)
* when used with a 64-bit kernel.
*/
/* Values for mi_state */
/*
* Macros to vector to the appropriate module specific routine.
*/
/*
* Definitions for stubs
*/
struct mod_stub_info {
int (*mods_errfcn)();
};
/*
* Definitions for mods_flag.
*/
struct mod_modinfo {
char *modm_module_name;
};
struct modctl_list {
};
/*
* Structure to manage a loadable module.
* Note: the module (mod_mp) structure's "text" and "text_size" information
* are replicated in the modctl structure so that mod_containing_pc()
* doesn't have to grab any locks (modctls are persistent; modules are not.)
*/
typedef struct modctl {
int mod_id;
void *mod_mp;
char *mod_filename;
char *mod_modname;
char mod_loadflags;
/* deletion causes mdb.vs.core issues */
char *mod_text;
} modctl_t;
/*
* mod_loadflags
*/
#ifdef _KERNEL
typedef int modid_t;
/*
* global function and data declarations
*/
extern char *systemfile;
extern char **syscallnames;
extern int moddebug;
/*
* this is the head of a doubly linked list. Only the next and prev
* pointers are used
*/
extern int modload_qualified(const char *,
const char *, const char *, const char *, uint_t[], int, int *);
extern void mod_setup(void);
extern int modload(const char *, const char *);
extern int modloadonly(const char *, const char *);
extern int modunload(int);
extern int mod_hold_stub(struct mod_stub_info *);
extern void modunload_disable(void);
extern void modunload_enable(void);
extern void modunload_begin(void);
extern void modunload_end(void);
extern int mod_remove_by_name(char *);
extern int mod_sysvar(const char *, const char *, u_longlong_t *);
extern int mod_sysctl(int, void *);
struct sysparam;
extern int mod_hold_by_modctl(modctl_t *, int);
extern int mod_sysctl_type(int, int (*)(struct sysparam *, void *),
void *);
extern void mod_read_system_file(int);
extern void mod_release_stub(struct mod_stub_info *);
extern void mod_askparams(void);
extern void mod_uninstall_daemon(void);
extern void modreap(void);
extern modctl_t *mod_hold_by_name(const char *);
extern void mod_release_mod(modctl_t *);
extern char *modgetsymname(uintptr_t, unsigned long *);
extern void mod_release_requisites(modctl_t *);
extern modctl_t *mod_find_by_filename(char *, char *);
extern uintptr_t modgetsymvalue(char *, int);
extern int major_valid(major_t);
extern int driver_installed(major_t);
extern int driver_active(major_t);
extern void mod_rele_dev_by_major(major_t);
extern void mod_rele_dev_by_devi(dev_info_t *);
extern int make_devname(char *, major_t, int);
extern int gmatch(const char *, const char *);
extern void make_aliases(struct bind **);
extern int read_binding_file(char *, struct bind **,
int (*line_parser)(char *, int, char *, struct bind **));
extern void clear_binding_hash(struct bind **);
extern void read_class_file(void);
extern void setbootpath(char *);
extern void setbootfstype(char *);
extern int install_stubs_by_name(modctl_t *, char *);
extern void install_stubs(modctl_t *);
extern void uninstall_stubs(modctl_t *);
extern void reset_stubs(modctl_t *);
extern major_t mod_name_to_major(char *);
extern modid_t mod_name_to_modid(char *);
extern char *mod_major_to_name(major_t);
extern void init_devnamesp(int);
extern void init_syscallnames(int);
extern char *mod_getsysname(int);
extern int mod_getsysnum(char *);
extern char *mod_containing_pc(caddr_t);
extern int mod_in_autounload(void);
extern const char *mod_modname(struct modlinkage *);
extern void dev_devices_cleanup(void);
/*
* Declarations used for dynamic linking support routines. Interfaces
* are marked with the pragma "unknown_control_flow" to prevent tail call
* optimization, so that implementations can reliably use caller() to
* determine initiating module.
*/
extern ddi_modhandle_t ddi_modopen(const char *,
int, int *);
extern void *ddi_modsym(ddi_modhandle_t,
const char *, int *);
extern int ddi_modclose(ddi_modhandle_t);
/*
*/
extern int _init(void);
extern int _fini(void);
extern int mod_install(struct modlinkage *);
extern int mod_remove(struct modlinkage *);
#else /* _KERNEL */
extern int modctl(int, ...);
#endif /* _KERNEL */
/*
* bit definitions for moddebug.
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_MODCTL_H */