home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 May / pcp151c.iso / misc / src / install / modutils / include / module.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-06  |  5.1 KB  |  194 lines

  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.  
  23. #ifndef MODUTILS_MODULE_H
  24. #define MODUTILS_MODULE_H 1
  25.  
  26. #ident "$Id: module.h,v 1.1.1.1 1998/01/06 20:51:07 ewt Exp $"
  27.  
  28. /* This file contains the structures used by the 2.0 and 2.1 kernels.
  29.    We do not use the kernel headers directly because we do not wish
  30.    to be dependant on a particular kernel version to compile insmod.  */
  31.  
  32.  
  33. /*======================================================================*/
  34. /* The structures used by Linux 2.0.  */
  35.  
  36. /* The symbol format used by get_kernel_syms(2).  */
  37. struct old_kernel_sym
  38. {
  39.   unsigned long value;
  40.   char name[60];
  41. };
  42.  
  43. struct old_module_ref
  44. {
  45.   unsigned long module;        /* kernel addresses */
  46.   unsigned long next;
  47. };
  48.  
  49. struct old_module_symbol
  50. {
  51.   unsigned long addr;
  52.   unsigned long name;
  53. };
  54.  
  55. struct old_symbol_table
  56. {
  57.   int size;            /* total, including string table!!! */
  58.   int n_symbols;
  59.   int n_refs;
  60.   struct old_module_symbol symbol[0]; /* actual size defined by n_symbols */
  61.   struct old_module_ref ref[0];    /* actual size defined by n_refs */
  62. };
  63.  
  64. struct old_mod_routines
  65. {
  66.   unsigned long init;
  67.   unsigned long cleanup;
  68. };
  69.  
  70. struct old_module
  71. {
  72.   unsigned long next;
  73.   unsigned long ref;        /* the list of modules that refer to me */
  74.   unsigned long symtab;
  75.   unsigned long name;
  76.   int size;            /* size of module in pages */
  77.   unsigned long addr;        /* address of module */
  78.   int state;
  79.   unsigned long cleanup;    /* cleanup routine */
  80. };
  81.  
  82. /* Sent to init_module(2) or'ed into the code size parameter.  */
  83. #define OLD_MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */
  84.  
  85. int get_kernel_syms(struct old_kernel_sym *);
  86. int old_sys_init_module(const char *name, char *code, unsigned codesize,
  87.             struct old_mod_routines *, struct old_symbol_table *);
  88.  
  89. /*======================================================================*/
  90. /* For sizeof() which are related to the module platform and not to the
  91.    environment isnmod is running in, use sizeof_xx instead of sizeof(xx).  */
  92.  
  93. #define tgt_sizeof_char        sizeof(char)
  94. #define tgt_sizeof_short    sizeof(short)
  95. #define tgt_sizeof_int        sizeof(int)
  96. #define tgt_sizeof_long        sizeof(long)
  97. #define tgt_sizeof_char_p    sizeof(char *)
  98. #define tgt_sizeof_void_p    sizeof(void *)
  99. #define tgt_long        long
  100.  
  101. #if defined(__sparc__) && !defined(__sparc_v9__) && defined(ARCH_sparc64)
  102. #undef tgt_sizeof_long
  103. #undef tgt_sizeof_char_p
  104. #undef tgt_sizeof_void_p
  105. #undef tgt_long
  106. #define tgt_sizeof_long        8
  107. #define tgt_sizeof_char_p    8
  108. #define tgt_sizeof_void_p    8
  109. #define tgt_long        long long
  110. #endif
  111.  
  112. /*======================================================================*/
  113. /* The structures used in Linux 2.1.  */
  114.  
  115. struct new_module_symbol
  116. {
  117.   unsigned tgt_long value;
  118.   unsigned tgt_long name;
  119. };
  120.  
  121. struct new_module_persist;
  122.  
  123. struct new_module_ref
  124. {
  125.   unsigned tgt_long dep;        /* kernel addresses */
  126.   unsigned tgt_long ref;
  127.   unsigned tgt_long next_ref;
  128. };
  129.  
  130. struct new_module
  131. {
  132.   unsigned tgt_long size_of_struct;    /* == sizeof(module) */
  133.   unsigned tgt_long next;
  134.   unsigned tgt_long name;
  135.   unsigned tgt_long size;
  136.  
  137.   tgt_long usecount;
  138.   unsigned tgt_long flags;        /* AUTOCLEAN et al */
  139.  
  140.   unsigned nsyms;
  141.   unsigned ndeps;
  142.  
  143.   unsigned tgt_long syms;
  144.   unsigned tgt_long deps;
  145.   unsigned tgt_long refs;
  146.   unsigned tgt_long init;
  147.   unsigned tgt_long cleanup;
  148.   unsigned tgt_long ex_table_start;
  149.   unsigned tgt_long ex_table_end;
  150. #ifdef __alpha__
  151.   unsigned tgt_long gp;
  152. #endif
  153.   /* Everything after here is extension.  */
  154.   unsigned tgt_long persist_start;
  155.   unsigned tgt_long persist_end;
  156.   unsigned tgt_long can_unload;
  157. };
  158.  
  159. struct new_module_info
  160. {
  161.   unsigned tgt_long addr;
  162.   unsigned tgt_long size;
  163.   unsigned tgt_long flags;
  164.          tgt_long usecount;
  165. };
  166.  
  167. /* Bits of module.flags.  */
  168. #define NEW_MOD_RUNNING        1
  169. #define NEW_MOD_DELETED        2
  170. #define NEW_MOD_AUTOCLEAN    4
  171. #define NEW_MOD_VISITED        8
  172. #define NEW_MOD_USED_ONCE    16
  173.  
  174. int new_sys_init_module(const char *name, const struct new_module *);
  175. int query_module(const char *name, int which, void *buf, size_t bufsize,
  176.          size_t *ret);
  177.  
  178. /* Values for query_module's which.  */
  179.  
  180. #define QM_MODULES    1
  181. #define QM_DEPS        2
  182. #define QM_REFS        3
  183. #define QM_SYMBOLS    4
  184. #define QM_INFO        5
  185.  
  186. /*======================================================================*/
  187. /* The system calls unchanged between 2.0 and 2.1.  */
  188.  
  189. unsigned long create_module(const char *, size_t);
  190. int delete_module(const char *);
  191.  
  192.  
  193. #endif /* module.h */
  194.