asm-offsets.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/kbuild.h>
  10. #include <asm/registers.h>
  11. #include <asm/ucontext.h>
  12. #include <asm/processor.h>
  13. #include <asm/thread_info.h>
  14. #include <asm/gdb-stub.h>
  15. #define DEF_PTREG(sym, reg) \
  16. asm volatile("\n->" #sym " %0 offsetof(struct pt_regs, " #reg ")" \
  17. : : "i" (offsetof(struct pt_regs, reg)))
  18. #define DEF_IREG(sym, reg) \
  19. asm volatile("\n->" #sym " %0 offsetof(struct user_context, " #reg ")" \
  20. : : "i" (offsetof(struct user_context, reg)))
  21. #define DEF_FREG(sym, reg) \
  22. asm volatile("\n->" #sym " %0 offsetof(struct user_context, " #reg ")" \
  23. : : "i" (offsetof(struct user_context, reg)))
  24. #define DEF_0REG(sym, reg) \
  25. asm volatile("\n->" #sym " %0 offsetof(struct frv_frame0, " #reg ")" \
  26. : : "i" (offsetof(struct frv_frame0, reg)))
  27. void foo(void)
  28. {
  29. /* offsets into the thread_info structure */
  30. OFFSET(TI_TASK, thread_info, task);
  31. OFFSET(TI_FLAGS, thread_info, flags);
  32. OFFSET(TI_STATUS, thread_info, status);
  33. OFFSET(TI_CPU, thread_info, cpu);
  34. OFFSET(TI_PREEMPT_COUNT, thread_info, preempt_count);
  35. OFFSET(TI_ADDR_LIMIT, thread_info, addr_limit);
  36. BLANK();
  37. /* offsets into register file storage */
  38. DEF_PTREG(REG_PSR, psr);
  39. DEF_PTREG(REG_ISR, isr);
  40. DEF_PTREG(REG_CCR, ccr);
  41. DEF_PTREG(REG_CCCR, cccr);
  42. DEF_PTREG(REG_LR, lr);
  43. DEF_PTREG(REG_LCR, lcr);
  44. DEF_PTREG(REG_PC, pc);
  45. DEF_PTREG(REG__STATUS, __status);
  46. DEF_PTREG(REG_SYSCALLNO, syscallno);
  47. DEF_PTREG(REG_ORIG_GR8, orig_gr8);
  48. DEF_PTREG(REG_GNER0, gner0);
  49. DEF_PTREG(REG_GNER1, gner1);
  50. DEF_PTREG(REG_IACC0, iacc0);
  51. DEF_PTREG(REG_TBR, tbr);
  52. DEF_PTREG(REG_GR0, tbr);
  53. DEFINE(REG__END, sizeof(struct pt_regs));
  54. BLANK();
  55. DEF_0REG(REG_DCR, debug.dcr);
  56. DEF_0REG(REG_IBAR0, debug.ibar[0]);
  57. DEF_0REG(REG_DBAR0, debug.dbar[0]);
  58. DEF_0REG(REG_DBDR00, debug.dbdr[0][0]);
  59. DEF_0REG(REG_DBMR00, debug.dbmr[0][0]);
  60. BLANK();
  61. DEF_IREG(__INT_GR0, i.gr[0]);
  62. DEF_FREG(__USER_FPMEDIA, f);
  63. DEF_FREG(__FPMEDIA_FR0, f.fr[0]);
  64. DEF_FREG(__FPMEDIA_FNER0, f.fner[0]);
  65. DEF_FREG(__FPMEDIA_MSR0, f.msr[0]);
  66. DEF_FREG(__FPMEDIA_ACC0, f.acc[0]);
  67. DEF_FREG(__FPMEDIA_ACCG0, f.accg[0]);
  68. DEF_FREG(__FPMEDIA_FSR0, f.fsr[0]);
  69. BLANK();
  70. DEFINE(NR_PT_REGS, sizeof(struct pt_regs) / 4);
  71. DEFINE(NR_USER_INT_REGS, sizeof(struct user_int_regs) / 4);
  72. DEFINE(NR_USER_FPMEDIA_REGS, sizeof(struct user_fpmedia_regs) / 4);
  73. DEFINE(NR_USER_CONTEXT, sizeof(struct user_context) / 4);
  74. DEFINE(FRV_FRAME0_SIZE, sizeof(struct frv_frame0));
  75. BLANK();
  76. /* offsets into thread_struct */
  77. OFFSET(__THREAD_FRAME, thread_struct, frame);
  78. OFFSET(__THREAD_CURR, thread_struct, curr);
  79. OFFSET(__THREAD_SP, thread_struct, sp);
  80. OFFSET(__THREAD_FP, thread_struct, fp);
  81. OFFSET(__THREAD_LR, thread_struct, lr);
  82. OFFSET(__THREAD_PC, thread_struct, pc);
  83. OFFSET(__THREAD_GR16, thread_struct, gr[0]);
  84. OFFSET(__THREAD_SCHED_LR, thread_struct, sched_lr);
  85. OFFSET(__THREAD_FRAME0, thread_struct, frame0);
  86. OFFSET(__THREAD_USER, thread_struct, user);
  87. BLANK();
  88. /* offsets into frv_debug_status */
  89. OFFSET(DEBUG_BPSR, frv_debug_status, bpsr);
  90. OFFSET(DEBUG_DCR, frv_debug_status, dcr);
  91. OFFSET(DEBUG_BRR, frv_debug_status, brr);
  92. OFFSET(DEBUG_NMAR, frv_debug_status, nmar);
  93. BLANK();
  94. }