asm-offsets.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * This program is used to generate definitions needed by
  4. * assembly language modules.
  5. *
  6. * We use the technique used in the OSF Mach kernel code:
  7. * generate asm statements containing #defines,
  8. * compile this file to assembler, and then extract the
  9. * #defines from the assembly-language output.
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/sched.h>
  13. #include <linux/kernel_stat.h>
  14. #include <linux/ptrace.h>
  15. #include <linux/hardirq.h>
  16. #include <linux/kbuild.h>
  17. #include <asm/irq.h>
  18. #include <asm/ptrace.h>
  19. int main(void)
  20. {
  21. /* offsets into the task struct */
  22. OFFSET(TASK_STATE, task_struct, state);
  23. OFFSET(TASK_FLAGS, task_struct, flags);
  24. OFFSET(TASK_PTRACE, task_struct, ptrace);
  25. OFFSET(TASK_BLOCKED, task_struct, blocked);
  26. OFFSET(TASK_THREAD, task_struct, thread);
  27. OFFSET(TASK_THREAD_INFO, task_struct, stack);
  28. OFFSET(TASK_MM, task_struct, mm);
  29. OFFSET(TASK_ACTIVE_MM, task_struct, active_mm);
  30. /* offsets into the irq_cpustat_t struct */
  31. DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t,
  32. __softirq_pending));
  33. /* offsets into the thread struct */
  34. OFFSET(THREAD_KSP, thread_struct, ksp);
  35. OFFSET(THREAD_USP, thread_struct, usp);
  36. OFFSET(THREAD_CCR, thread_struct, ccr);
  37. /* offsets into the pt_regs struct */
  38. DEFINE(LER0, offsetof(struct pt_regs, er0) - sizeof(long));
  39. DEFINE(LER1, offsetof(struct pt_regs, er1) - sizeof(long));
  40. DEFINE(LER2, offsetof(struct pt_regs, er2) - sizeof(long));
  41. DEFINE(LER3, offsetof(struct pt_regs, er3) - sizeof(long));
  42. DEFINE(LER4, offsetof(struct pt_regs, er4) - sizeof(long));
  43. DEFINE(LER5, offsetof(struct pt_regs, er5) - sizeof(long));
  44. DEFINE(LER6, offsetof(struct pt_regs, er6) - sizeof(long));
  45. DEFINE(LORIG, offsetof(struct pt_regs, orig_er0) - sizeof(long));
  46. DEFINE(LSP, offsetof(struct pt_regs, sp) - sizeof(long));
  47. DEFINE(LCCR, offsetof(struct pt_regs, ccr) - sizeof(long));
  48. DEFINE(LVEC, offsetof(struct pt_regs, vector) - sizeof(long));
  49. #if defined(CONFIG_CPU_H8S)
  50. DEFINE(LEXR, offsetof(struct pt_regs, exr) - sizeof(long));
  51. #endif
  52. DEFINE(LRET, offsetof(struct pt_regs, pc) - sizeof(long));
  53. DEFINE(PT_PTRACED, PT_PTRACED);
  54. /* offsets in thread_info structure */
  55. OFFSET(TI_TASK, thread_info, task);
  56. OFFSET(TI_FLAGS, thread_info, flags);
  57. OFFSET(TI_CPU, thread_info, cpu);
  58. OFFSET(TI_PRE, thread_info, preempt_count);
  59. #ifdef CONFIG_PREEMPTION
  60. DEFINE(TI_PRE_COUNT, offsetof(struct thread_info, preempt_count));
  61. #endif
  62. return 0;
  63. }