module.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. #ifndef _ASM_IA64_MODULE_H
  2. #define _ASM_IA64_MODULE_H
  3. /*
  4.  * This file contains the ia64 architecture specific module code.
  5.  *
  6.  * Copyright (C) 2000 Intel Corporation.
  7.  * Copyright (C) 2000 Mike Stephens <mike.stephens@intel.com>
  8.  */
  9. #include <linux/module.h>
  10. #include <linux/vmalloc.h>
  11. #include <asm/unwind.h>
  12. #define module_map(x) vmalloc(x)
  13. #define module_unmap(x) ia64_module_unmap(x)
  14. #define module_arch_init(x) ia64_module_init(x)
  15. /*
  16.  * This must match in size and layout the data created by
  17.  * modutils/obj/obj-ia64.c
  18.  */
  19. struct archdata {
  20. const char *unw_table;
  21. const char *segment_base;
  22. const char *unw_start;
  23. const char *unw_end;
  24. const char *gp;
  25. };
  26. static inline void
  27. arch_init_modules (struct module *kmod)
  28. {
  29. static struct archdata archdata;
  30. register char *kernel_gp asm ("gp");
  31. archdata.gp = kernel_gp;
  32. kmod->archdata_start = (const char *) &archdata;
  33. kmod->archdata_end   = (const char *) (&archdata + 1);
  34. }
  35. /*
  36.  * functions to add/remove a modules unwind info when
  37.  * it is loaded or unloaded.
  38.  */
  39. static inline int
  40. ia64_module_init (struct module *mod)
  41. {
  42. struct archdata *archdata;
  43. if (!mod_member_present(mod, archdata_start) || !mod->archdata_start)
  44. return 0;
  45. archdata = (struct archdata *)(mod->archdata_start);
  46. /*
  47.  * Make sure the unwind pointers are sane.
  48.  */
  49. if (archdata->unw_table) {
  50. printk(KERN_ERR "module_arch_init: archdata->unw_table must be zero.n");
  51. return 1;
  52. }
  53. if (!mod_bound(archdata->gp, 0, mod)) {
  54. printk(KERN_ERR "module_arch_init: archdata->gp out of bounds.n");
  55. return 1;
  56. }
  57. if (!mod_bound(archdata->unw_start, 0, mod)) {
  58. printk(KERN_ERR "module_arch_init: archdata->unw_start out of bounds.n");
  59. return 1;
  60. }
  61. if (!mod_bound(archdata->unw_end, 0, mod)) {
  62. printk(KERN_ERR "module_arch_init: archdata->unw_end out of bounds.n");
  63. return 1;
  64. }
  65. if (!mod_bound(archdata->segment_base, 0, mod)) {
  66. printk(KERN_ERR "module_arch_init: archdata->unw_table out of bounds.n");
  67. return 1;
  68. }
  69. /*
  70.  * Pointers are reasonable, add the module unwind table
  71.  */
  72. archdata->unw_table = unw_add_unwind_table(mod->name,
  73.    (unsigned long) archdata->segment_base,
  74.    (unsigned long) archdata->gp,
  75.    archdata->unw_start, archdata->unw_end);
  76. return 0;
  77. }
  78. static inline void
  79. ia64_module_unmap (void * addr)
  80. {
  81. struct module *mod = (struct module *) addr;
  82. struct archdata *archdata;
  83. /*
  84.  * Before freeing the module memory remove the unwind table entry
  85.  */
  86. if (mod_member_present(mod, archdata_start) && mod->archdata_start) {
  87. archdata = (struct archdata *)(mod->archdata_start);
  88. if (archdata->unw_table != NULL)
  89. unw_remove_unwind_table((void *) archdata->unw_table);
  90. }
  91. vfree(addr);
  92. }
  93. #endif /* _ASM_IA64_MODULE_H */