p_module.h

Go to the documentation of this file.
00001 /* Definitions for the Linux module syscall interface.
00002    Copyright 1996, 1997 Linux International.
00003 
00004    Contributed by Richard Henderson <rth@tamu.edu>
00005 
00006    This file is part of the Linux modutils.
00007 
00008    This program is free software; you can redistribute it and/or modify it
00009    under the terms of the GNU General Public License as published by the
00010    Free Software Foundation; either version 2 of the License, or (at your
00011    option) any later version.
00012 
00013    This program is distributed in the hope that it will be useful, but
00014    WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software Foundation,
00020    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00021 
00022 #ifndef MODUTILS_MODULE_H
00023 #define MODUTILS_MODULE_H 1
00024 
00025 /* This file contains the structures used by the 2.0 and 2.1 kernels.
00026    We do not use the kernel headers directly because we do not wish
00027    to be dependant on a particular kernel version to compile insmod.  */
00028 
00029 
00030 /*======================================================================*/
00031 /* The structures used by Linux 2.0.  */
00032 
00033 /* The symbol format used by get_kernel_syms(2).  */
00034 struct old_kernel_sym
00035 {
00036   unsigned long value;
00037   char name[60];
00038 };
00039 
00040 struct old_module_ref
00041 {
00042   unsigned long module;     /* kernel addresses */
00043   unsigned long next;
00044 };
00045 
00046 struct old_module_symbol
00047 {
00048   unsigned long addr;
00049   unsigned long name;
00050 };
00051 
00052 struct old_symbol_table
00053 {
00054   int size;         /* total, including string table!!! */
00055   int n_symbols;
00056   int n_refs;
00057   struct old_module_symbol symbol[0]; /* actual size defined by n_symbols */
00058   struct old_module_ref ref[0]; /* actual size defined by n_refs */
00059 };
00060 
00061 struct old_mod_routines
00062 {
00063   unsigned long init;
00064   unsigned long cleanup;
00065 };
00066 
00067 struct old_module
00068 {
00069   unsigned long next;
00070   unsigned long ref;        /* the list of modules that refer to me */
00071   unsigned long symtab;
00072   unsigned long name;
00073   int size;         /* size of module in pages */
00074   unsigned long addr;       /* address of module */
00075   int state;
00076   unsigned long cleanup;    /* cleanup routine */
00077 };
00078 
00079 /* Sent to init_module(2) or'ed into the code size parameter.  */
00080 #define OLD_MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */
00081 
00082 int get_kernel_syms(struct old_kernel_sym *);
00083 int old_sys_init_module(char const * name, char *code, unsigned codesize,
00084             struct old_mod_routines *, struct old_symbol_table *);
00085 
00086 /*======================================================================*/
00087 /* For sizeof() which are related to the module platform and not to the
00088    environment isnmod is running in, use sizeof_xx instead of sizeof(xx).  */
00089 
00090 #define tgt_sizeof_char     sizeof(char)
00091 #define tgt_sizeof_short    sizeof(short)
00092 #define tgt_sizeof_int      sizeof(int)
00093 #define tgt_sizeof_long     sizeof(long)
00094 #define tgt_sizeof_char_p   sizeof(char *)
00095 #define tgt_sizeof_void_p   sizeof(void *)
00096 #define tgt_long        long
00097 #define tgt_long_fmt        "l"
00098 
00099 /* This assumes that long long on a 32 bit system is equivalent to long on the
00100  * equivalent 64 bit system.  Also that void and char pointers are 8 bytes on
00101  * all 64 bit systems.  Add per system tweaks if it ever becomes necessary.
00102  */
00103 #if defined(COMMON_3264) && defined(ONLY_64)
00104 #undef tgt_long
00105 #undef tgt_long_fmt
00106 #undef tgt_sizeof_long
00107 #undef tgt_sizeof_char_p
00108 #undef tgt_sizeof_void_p
00109 #define tgt_long                long long
00110 #define tgt_long_fmt        "ll"
00111 #define tgt_sizeof_long         8
00112 #define tgt_sizeof_char_p       8
00113 #define tgt_sizeof_void_p       8
00114 #endif
00115 
00116 /*======================================================================*/
00117 /* The structures used in Linux 2.1 onwards.  */
00118 
00119 /* Note: module_symbol does not use tgt_long intentionally */
00120 struct module_symbol
00121 {
00122   unsigned long value;
00123   unsigned long name;
00124 };
00125 
00126 struct module_ref
00127 {
00128   unsigned tgt_long dep;        /* kernel addresses */
00129   unsigned tgt_long ref;
00130   unsigned tgt_long next_ref;
00131 };
00132 
00133 struct module
00134 {
00135   unsigned tgt_long size_of_struct; /* == sizeof(module) */
00136   unsigned tgt_long next;
00137   unsigned tgt_long name;
00138   unsigned tgt_long size;
00139 
00140   tgt_long usecount;
00141   unsigned tgt_long flags;      /* AUTOCLEAN et al */
00142 
00143   unsigned nsyms;
00144   unsigned ndeps;
00145 
00146   unsigned tgt_long syms;
00147   unsigned tgt_long deps;
00148   unsigned tgt_long refs;
00149   unsigned tgt_long init;
00150   unsigned tgt_long cleanup;
00151   unsigned tgt_long ex_table_start;
00152   unsigned tgt_long ex_table_end;
00153 #ifdef __alpha__
00154   unsigned tgt_long gp;
00155 #endif
00156   /* Everything after here is extension.  */
00157   unsigned tgt_long read_start;     /* Read data from existing module */
00158   unsigned tgt_long read_end;
00159   unsigned tgt_long can_unload;
00160   unsigned tgt_long runsize;
00161   unsigned tgt_long kallsyms_start;
00162   unsigned tgt_long kallsyms_end;
00163   unsigned tgt_long archdata_start;
00164   unsigned tgt_long archdata_end;
00165   unsigned tgt_long kernel_data;
00166 };
00167 
00168 struct module_info
00169 {
00170   unsigned long addr;
00171   unsigned long size;
00172   unsigned long flags;
00173        long usecount;
00174 };
00175 
00176 /* Bits of module.flags.  */
00177 #define NEW_MOD_RUNNING     1
00178 #define NEW_MOD_DELETED     2
00179 #define NEW_MOD_AUTOCLEAN   4
00180 #define NEW_MOD_VISITED     8
00181 #define NEW_MOD_USED_ONCE   16
00182 #define NEW_MOD_INITIALIZING    64
00183 
00184 int sys_init_module(char const * name, const struct module *);
00185 int query_module(char const * name, int which, void *buf, size_t bufsize,
00186          size_t *ret);
00187 
00188 /* Values for query_module's which.  */
00189 
00190 #define QM_MODULES  1
00191 #define QM_DEPS     2
00192 #define QM_REFS     3
00193 #define QM_SYMBOLS  4
00194 #define QM_INFO     5
00195 
00196 /*======================================================================*/
00197 /* The system calls unchanged between 2.0 and 2.1.  */
00198 
00199 unsigned long create_module(const char *, size_t);
00200 int delete_module(const char *);
00201 
00202 /* In safe mode the last parameter is forced to be a module name and meta
00203  * expansion is not allowed on that name.
00204  */
00205 extern unsigned int safemode;
00206 
00207 #endif /* module.h */

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1