asm-offsets.c 3.7 KB

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