asm-offsets.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Generate definitions needed by assembly language modules.
  3. * This code generates raw asm output which is post-processed
  4. * to extract and format the required data.
  5. */
  6. #include <linux/sched.h>
  7. #include <linux/signal.h>
  8. #include <linux/personality.h>
  9. #include <linux/suspend.h>
  10. #include <asm/ucontext.h>
  11. #include "sigframe.h"
  12. #include <asm/fixmap.h>
  13. #include <asm/processor.h>
  14. #include <asm/thread_info.h>
  15. #define DEFINE(sym, val) \
  16. asm volatile("\n->" #sym " %0 " #val : : "i" (val))
  17. #define BLANK() asm volatile("\n->" : : )
  18. #define OFFSET(sym, str, mem) \
  19. DEFINE(sym, offsetof(struct str, mem));
  20. void foo(void)
  21. {
  22. OFFSET(SIGCONTEXT_eax, sigcontext, eax);
  23. OFFSET(SIGCONTEXT_ebx, sigcontext, ebx);
  24. OFFSET(SIGCONTEXT_ecx, sigcontext, ecx);
  25. OFFSET(SIGCONTEXT_edx, sigcontext, edx);
  26. OFFSET(SIGCONTEXT_esi, sigcontext, esi);
  27. OFFSET(SIGCONTEXT_edi, sigcontext, edi);
  28. OFFSET(SIGCONTEXT_ebp, sigcontext, ebp);
  29. OFFSET(SIGCONTEXT_esp, sigcontext, esp);
  30. OFFSET(SIGCONTEXT_eip, sigcontext, eip);
  31. BLANK();
  32. OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
  33. OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
  34. OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
  35. OFFSET(CPUINFO_x86_mask, cpuinfo_x86, x86_mask);
  36. OFFSET(CPUINFO_hard_math, cpuinfo_x86, hard_math);
  37. OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
  38. OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
  39. OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
  40. BLANK();
  41. OFFSET(TI_task, thread_info, task);
  42. OFFSET(TI_exec_domain, thread_info, exec_domain);
  43. OFFSET(TI_flags, thread_info, flags);
  44. OFFSET(TI_status, thread_info, status);
  45. OFFSET(TI_cpu, thread_info, cpu);
  46. OFFSET(TI_preempt_count, thread_info, preempt_count);
  47. OFFSET(TI_addr_limit, thread_info, addr_limit);
  48. OFFSET(TI_restart_block, thread_info, restart_block);
  49. BLANK();
  50. OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
  51. OFFSET(RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
  52. BLANK();
  53. OFFSET(pbe_address, pbe, address);
  54. OFFSET(pbe_orig_address, pbe, orig_address);
  55. OFFSET(pbe_next, pbe, next);
  56. /* Offset from the sysenter stack to tss.esp0 */
  57. DEFINE(TSS_sysenter_esp0, offsetof(struct tss_struct, esp0) -
  58. sizeof(struct tss_struct));
  59. DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
  60. DEFINE(VSYSCALL_BASE, __fix_to_virt(FIX_VSYSCALL));
  61. }