asm-offsets.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * This program is used to generate definitions needed by
  3. * assembly language modules.
  4. *
  5. * We use the technique used in the OSF Mach kernel code:
  6. * generate asm statements containing #defines,
  7. * compile this file to assembler, and then extract the
  8. * #defines from the assembly-language output.
  9. */
  10. #include <linux/config.h>
  11. #include <linux/signal.h>
  12. #include <linux/sched.h>
  13. #include <linux/kernel.h>
  14. #include <linux/errno.h>
  15. #include <linux/string.h>
  16. #include <linux/types.h>
  17. #include <linux/ptrace.h>
  18. #include <linux/suspend.h>
  19. #include <linux/mman.h>
  20. #include <linux/mm.h>
  21. #include <asm/io.h>
  22. #include <asm/page.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/processor.h>
  25. #include <asm/cputable.h>
  26. #include <asm/thread_info.h>
  27. #define DEFINE(sym, val) \
  28. asm volatile("\n->" #sym " %0 " #val : : "i" (val))
  29. #define BLANK() asm volatile("\n->" : : )
  30. int
  31. main(void)
  32. {
  33. DEFINE(THREAD, offsetof(struct task_struct, thread));
  34. DEFINE(THREAD_INFO, offsetof(struct task_struct, thread_info));
  35. DEFINE(MM, offsetof(struct task_struct, mm));
  36. DEFINE(PTRACE, offsetof(struct task_struct, ptrace));
  37. DEFINE(KSP, offsetof(struct thread_struct, ksp));
  38. DEFINE(PGDIR, offsetof(struct thread_struct, pgdir));
  39. DEFINE(LAST_SYSCALL, offsetof(struct thread_struct, last_syscall));
  40. DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
  41. DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode));
  42. DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0]));
  43. DEFINE(THREAD_FPSCR, offsetof(struct thread_struct, fpscr));
  44. #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
  45. DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0));
  46. DEFINE(PT_PTRACED, PT_PTRACED);
  47. #endif
  48. #ifdef CONFIG_ALTIVEC
  49. DEFINE(THREAD_VR0, offsetof(struct thread_struct, vr[0]));
  50. DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave));
  51. DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr));
  52. DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr));
  53. #endif /* CONFIG_ALTIVEC */
  54. #ifdef CONFIG_SPE
  55. DEFINE(THREAD_EVR0, offsetof(struct thread_struct, evr[0]));
  56. DEFINE(THREAD_ACC, offsetof(struct thread_struct, acc));
  57. DEFINE(THREAD_SPEFSCR, offsetof(struct thread_struct, spefscr));
  58. DEFINE(THREAD_USED_SPE, offsetof(struct thread_struct, used_spe));
  59. #endif /* CONFIG_SPE */
  60. /* Interrupt register frame */
  61. DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD);
  62. DEFINE(INT_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs));
  63. /* in fact we only use gpr0 - gpr9 and gpr20 - gpr23 */
  64. DEFINE(GPR0, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[0]));
  65. DEFINE(GPR1, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[1]));
  66. DEFINE(GPR2, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[2]));
  67. DEFINE(GPR3, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[3]));
  68. DEFINE(GPR4, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[4]));
  69. DEFINE(GPR5, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[5]));
  70. DEFINE(GPR6, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[6]));
  71. DEFINE(GPR7, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[7]));
  72. DEFINE(GPR8, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[8]));
  73. DEFINE(GPR9, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[9]));
  74. DEFINE(GPR10, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[10]));
  75. DEFINE(GPR11, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[11]));
  76. DEFINE(GPR12, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[12]));
  77. DEFINE(GPR13, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[13]));
  78. DEFINE(GPR14, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[14]));
  79. DEFINE(GPR15, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[15]));
  80. DEFINE(GPR16, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[16]));
  81. DEFINE(GPR17, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[17]));
  82. DEFINE(GPR18, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[18]));
  83. DEFINE(GPR19, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[19]));
  84. DEFINE(GPR20, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[20]));
  85. DEFINE(GPR21, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[21]));
  86. DEFINE(GPR22, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[22]));
  87. DEFINE(GPR23, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[23]));
  88. DEFINE(GPR24, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[24]));
  89. DEFINE(GPR25, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[25]));
  90. DEFINE(GPR26, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[26]));
  91. DEFINE(GPR27, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[27]));
  92. DEFINE(GPR28, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[28]));
  93. DEFINE(GPR29, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[29]));
  94. DEFINE(GPR30, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[30]));
  95. DEFINE(GPR31, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[31]));
  96. /* Note: these symbols include _ because they overlap with special
  97. * register names
  98. */
  99. DEFINE(_NIP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, nip));
  100. DEFINE(_MSR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, msr));
  101. DEFINE(_CTR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, ctr));
  102. DEFINE(_LINK, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, link));
  103. DEFINE(_CCR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, ccr));
  104. DEFINE(_MQ, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, mq));
  105. DEFINE(_XER, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, xer));
  106. DEFINE(_DAR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dar));
  107. DEFINE(_DSISR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dsisr));
  108. /* The PowerPC 400-class & Book-E processors have neither the DAR nor the DSISR
  109. * SPRs. Hence, we overload them to hold the similar DEAR and ESR SPRs
  110. * for such processors. For critical interrupts we use them to
  111. * hold SRR0 and SRR1.
  112. */
  113. DEFINE(_DEAR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dar));
  114. DEFINE(_ESR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dsisr));
  115. DEFINE(ORIG_GPR3, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, orig_gpr3));
  116. DEFINE(RESULT, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, result));
  117. DEFINE(TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap));
  118. DEFINE(CLONE_VM, CLONE_VM);
  119. DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
  120. DEFINE(MM_PGD, offsetof(struct mm_struct, pgd));
  121. /* About the CPU features table */
  122. DEFINE(CPU_SPEC_ENTRY_SIZE, sizeof(struct cpu_spec));
  123. DEFINE(CPU_SPEC_PVR_MASK, offsetof(struct cpu_spec, pvr_mask));
  124. DEFINE(CPU_SPEC_PVR_VALUE, offsetof(struct cpu_spec, pvr_value));
  125. DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features));
  126. DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
  127. DEFINE(TI_TASK, offsetof(struct thread_info, task));
  128. DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
  129. DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
  130. DEFINE(TI_LOCAL_FLAGS, offsetof(struct thread_info, local_flags));
  131. DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
  132. DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
  133. DEFINE(pbe_address, offsetof(struct pbe, address));
  134. DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
  135. DEFINE(pbe_next, offsetof(struct pbe, next));
  136. DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28);
  137. return 0;
  138. }