Upstream | cc2ee17 | 1970-01-12 13:46:40 +0000 | [diff] [blame^] | 1 | /* Definitions for the Linux module syscall interface. |
| 2 | Copyright 1996, 1997 Linux International. |
| 3 | |
| 4 | Contributed by Richard Henderson <rth@tamu.edu> |
| 5 | |
| 6 | This file is part of the Linux modutils. |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify it |
| 9 | under the terms of the GNU General Public License as published by the |
| 10 | Free Software Foundation; either version 2 of the License, or (at your |
| 11 | option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, but |
| 14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software Foundation, |
| 20 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 21 | |
| 22 | #ifndef MODUTILS_MODULE_H |
| 23 | #define MODUTILS_MODULE_H 1 |
| 24 | |
| 25 | /* This file contains the structures used by the 2.0 and 2.1 kernels. |
| 26 | We do not use the kernel headers directly because we do not wish |
| 27 | to be dependant on a particular kernel version to compile insmod. */ |
| 28 | |
| 29 | |
| 30 | /*======================================================================*/ |
| 31 | /* The structures used by Linux 2.0. */ |
| 32 | |
| 33 | /* The symbol format used by get_kernel_syms(2). */ |
| 34 | struct old_kernel_sym |
| 35 | { |
| 36 | unsigned long value; |
| 37 | char name[60]; |
| 38 | }; |
| 39 | |
| 40 | struct old_module_ref |
| 41 | { |
| 42 | unsigned long module; /* kernel addresses */ |
| 43 | unsigned long next; |
| 44 | }; |
| 45 | |
| 46 | struct old_module_symbol |
| 47 | { |
| 48 | unsigned long addr; |
| 49 | unsigned long name; |
| 50 | }; |
| 51 | |
| 52 | struct old_symbol_table |
| 53 | { |
| 54 | int size; /* total, including string table!!! */ |
| 55 | int n_symbols; |
| 56 | int n_refs; |
| 57 | struct old_module_symbol symbol[0]; /* actual size defined by n_symbols */ |
| 58 | struct old_module_ref ref[0]; /* actual size defined by n_refs */ |
| 59 | }; |
| 60 | |
| 61 | struct old_mod_routines |
| 62 | { |
| 63 | unsigned long init; |
| 64 | unsigned long cleanup; |
| 65 | }; |
| 66 | |
| 67 | struct old_module |
| 68 | { |
| 69 | unsigned long next; |
| 70 | unsigned long ref; /* the list of modules that refer to me */ |
| 71 | unsigned long symtab; |
| 72 | unsigned long name; |
| 73 | int size; /* size of module in pages */ |
| 74 | unsigned long addr; /* address of module */ |
| 75 | int state; |
| 76 | unsigned long cleanup; /* cleanup routine */ |
| 77 | }; |
| 78 | |
| 79 | /* Sent to init_module(2) or'ed into the code size parameter. */ |
| 80 | #define OLD_MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */ |
| 81 | |
| 82 | int get_kernel_syms(struct old_kernel_sym *); |
| 83 | int old_sys_init_module(char const * name, char *code, unsigned codesize, |
| 84 | struct old_mod_routines *, struct old_symbol_table *); |
| 85 | |
| 86 | /*======================================================================*/ |
| 87 | /* For sizeof() which are related to the module platform and not to the |
| 88 | environment isnmod is running in, use sizeof_xx instead of sizeof(xx). */ |
| 89 | |
| 90 | #define tgt_sizeof_char sizeof(char) |
| 91 | #define tgt_sizeof_short sizeof(short) |
| 92 | #define tgt_sizeof_int sizeof(int) |
| 93 | #define tgt_sizeof_long sizeof(long) |
| 94 | #define tgt_sizeof_char_p sizeof(char *) |
| 95 | #define tgt_sizeof_void_p sizeof(void *) |
| 96 | #define tgt_long long |
| 97 | #define tgt_long_fmt "l" |
| 98 | |
| 99 | /* This assumes that long long on a 32 bit system is equivalent to long on the |
| 100 | * equivalent 64 bit system. Also that void and char pointers are 8 bytes on |
| 101 | * all 64 bit systems. Add per system tweaks if it ever becomes necessary. |
| 102 | */ |
| 103 | #if defined(COMMON_3264) && defined(ONLY_64) |
| 104 | #undef tgt_long |
| 105 | #undef tgt_long_fmt |
| 106 | #undef tgt_sizeof_long |
| 107 | #undef tgt_sizeof_char_p |
| 108 | #undef tgt_sizeof_void_p |
| 109 | #define tgt_long long long |
| 110 | #define tgt_long_fmt "ll" |
| 111 | #define tgt_sizeof_long 8 |
| 112 | #define tgt_sizeof_char_p 8 |
| 113 | #define tgt_sizeof_void_p 8 |
| 114 | #endif |
| 115 | |
| 116 | /*======================================================================*/ |
| 117 | /* The structures used in Linux 2.1 onwards. */ |
| 118 | |
| 119 | /* Note: module_symbol does not use tgt_long intentionally */ |
| 120 | struct module_symbol |
| 121 | { |
| 122 | unsigned long value; |
| 123 | unsigned long name; |
| 124 | }; |
| 125 | |
| 126 | struct module_ref |
| 127 | { |
| 128 | unsigned tgt_long dep; /* kernel addresses */ |
| 129 | unsigned tgt_long ref; |
| 130 | unsigned tgt_long next_ref; |
| 131 | }; |
| 132 | |
| 133 | struct module |
| 134 | { |
| 135 | unsigned tgt_long size_of_struct; /* == sizeof(module) */ |
| 136 | unsigned tgt_long next; |
| 137 | unsigned tgt_long name; |
| 138 | unsigned tgt_long size; |
| 139 | |
| 140 | tgt_long usecount; |
| 141 | unsigned tgt_long flags; /* AUTOCLEAN et al */ |
| 142 | |
| 143 | unsigned nsyms; |
| 144 | unsigned ndeps; |
| 145 | |
| 146 | unsigned tgt_long syms; |
| 147 | unsigned tgt_long deps; |
| 148 | unsigned tgt_long refs; |
| 149 | unsigned tgt_long init; |
| 150 | unsigned tgt_long cleanup; |
| 151 | unsigned tgt_long ex_table_start; |
| 152 | unsigned tgt_long ex_table_end; |
| 153 | #ifdef __alpha__ |
| 154 | unsigned tgt_long gp; |
| 155 | #endif |
| 156 | /* Everything after here is extension. */ |
| 157 | unsigned tgt_long read_start; /* Read data from existing module */ |
| 158 | unsigned tgt_long read_end; |
| 159 | unsigned tgt_long can_unload; |
| 160 | unsigned tgt_long runsize; |
| 161 | unsigned tgt_long kallsyms_start; |
| 162 | unsigned tgt_long kallsyms_end; |
| 163 | unsigned tgt_long archdata_start; |
| 164 | unsigned tgt_long archdata_end; |
| 165 | unsigned tgt_long kernel_data; |
| 166 | }; |
| 167 | |
| 168 | struct module_info |
| 169 | { |
| 170 | unsigned long addr; |
| 171 | unsigned long size; |
| 172 | unsigned long flags; |
| 173 | long usecount; |
| 174 | }; |
| 175 | |
| 176 | /* Bits of module.flags. */ |
| 177 | #define NEW_MOD_RUNNING 1 |
| 178 | #define NEW_MOD_DELETED 2 |
| 179 | #define NEW_MOD_AUTOCLEAN 4 |
| 180 | #define NEW_MOD_VISITED 8 |
| 181 | #define NEW_MOD_USED_ONCE 16 |
| 182 | #define NEW_MOD_INITIALIZING 64 |
| 183 | |
| 184 | int sys_init_module(char const * name, const struct module *); |
| 185 | int query_module(char const * name, int which, void *buf, size_t bufsize, |
| 186 | size_t *ret); |
| 187 | |
| 188 | /* Values for query_module's which. */ |
| 189 | |
| 190 | #define QM_MODULES 1 |
| 191 | #define QM_DEPS 2 |
| 192 | #define QM_REFS 3 |
| 193 | #define QM_SYMBOLS 4 |
| 194 | #define QM_INFO 5 |
| 195 | |
| 196 | /*======================================================================*/ |
| 197 | /* The system calls unchanged between 2.0 and 2.1. */ |
| 198 | |
| 199 | unsigned long create_module(const char *, size_t); |
| 200 | int delete_module(const char *); |
| 201 | |
| 202 | /* In safe mode the last parameter is forced to be a module name and meta |
| 203 | * expansion is not allowed on that name. |
| 204 | */ |
| 205 | extern unsigned int safemode; |
| 206 | |
| 207 | #endif /* module.h */ |