asm-offsets.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/stddef.h>
  11. #include <linux/sched.h>
  12. #include <linux/kernel_stat.h>
  13. #include <linux/ptrace.h>
  14. #include <linux/hardirq.h>
  15. #include <linux/kbuild.h>
  16. #include <asm/irq.h>
  17. #include <asm/ptrace.h>
  18. int main(void)
  19. {
  20. /* offsets into the task struct */
  21. OFFSET(TASK_STATE, task_struct, state);
  22. OFFSET(TASK_FLAGS, task_struct, flags);
  23. OFFSET(TASK_PTRACE, task_struct, ptrace);
  24. OFFSET(TASK_BLOCKED, task_struct, blocked);
  25. OFFSET(TASK_THREAD, task_struct, thread);
  26. OFFSET(TASK_THREAD_INFO, task_struct, stack);
  27. OFFSET(TASK_MM, task_struct, mm);
  28. OFFSET(TASK_ACTIVE_MM, task_struct, active_mm);
  29. /* offsets into the irq_cpustat_t struct */
  30. DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t,
  31. __softirq_pending));
  32. /* offsets into the thread struct */
  33. OFFSET(THREAD_KSP, thread_struct, ksp);
  34. OFFSET(THREAD_USP, thread_struct, usp);
  35. OFFSET(THREAD_CCR, thread_struct, ccr);
  36. /* offsets into the pt_regs struct */
  37. DEFINE(LER0, offsetof(struct pt_regs, er0) - sizeof(long));
  38. DEFINE(LER1, offsetof(struct pt_regs, er1) - sizeof(long));
  39. DEFINE(LER2, offsetof(struct pt_regs, er2) - sizeof(long));
  40. DEFINE(LER3, offsetof(struct pt_regs, er3) - sizeof(long));
  41. DEFINE(LER4, offsetof(struct pt_regs, er4) - sizeof(long));
  42. DEFINE(LER5, offsetof(struct pt_regs, er5) - sizeof(long));
  43. DEFINE(LER6, offsetof(struct pt_regs, er6) - sizeof(long));
  44. DEFINE(LORIG, offsetof(struct pt_regs, orig_er0) - sizeof(long));
  45. DEFINE(LSP, offsetof(struct pt_regs, sp) - sizeof(long));
  46. DEFINE(LCCR, offsetof(struct pt_regs, ccr) - sizeof(long));
  47. DEFINE(LVEC, offsetof(struct pt_regs, vector) - sizeof(long));
  48. #if defined(CONFIG_CPU_H8S)
  49. DEFINE(LEXR, offsetof(struct pt_regs, exr) - sizeof(long));
  50. #endif
  51. DEFINE(LRET, offsetof(struct pt_regs, pc) - sizeof(long));
  52. DEFINE(PT_PTRACED, PT_PTRACED);
  53. /* offsets in thread_info structure */
  54. OFFSET(TI_TASK, thread_info, task);
  55. OFFSET(TI_FLAGS, thread_info, flags);
  56. OFFSET(TI_CPU, thread_info, cpu);
  57. OFFSET(TI_PRE, thread_info, preempt_count);
  58. return 0;
  59. }