asm-offsets.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*
  2. * offset.c: Calculate pt_regs and task_struct offsets.
  3. *
  4. * Copyright (C) 1996 David S. Miller
  5. * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Ralf Baechle
  6. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  7. *
  8. * Kevin Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  9. * Copyright (C) 2000 MIPS Technologies, Inc.
  10. */
  11. #include <linux/compat.h>
  12. #include <linux/types.h>
  13. #include <linux/sched.h>
  14. #include <linux/mm.h>
  15. #include <linux/interrupt.h>
  16. #include <asm/ptrace.h>
  17. #include <asm/processor.h>
  18. #define text(t) __asm__("\n->#" t)
  19. #define _offset(type, member) (&(((type *)NULL)->member))
  20. #define offset(string, ptr, member) \
  21. __asm__("\n->" string " %0" : : "i" (_offset(ptr, member)))
  22. #define constant(string, member) \
  23. __asm__("\n->" string " %0" : : "ri" (member))
  24. #define size(string, size) \
  25. __asm__("\n->" string " %0" : : "i" (sizeof(size)))
  26. #define linefeed text("")
  27. void output_ptreg_defines(void)
  28. {
  29. text("MIPS pt_regs offsets.");
  30. offset("PT_R0", struct pt_regs, regs[0]);
  31. offset("PT_R1", struct pt_regs, regs[1]);
  32. offset("PT_R2", struct pt_regs, regs[2]);
  33. offset("PT_R3", struct pt_regs, regs[3]);
  34. offset("PT_R4", struct pt_regs, regs[4]);
  35. offset("PT_R5", struct pt_regs, regs[5]);
  36. offset("PT_R6", struct pt_regs, regs[6]);
  37. offset("PT_R7", struct pt_regs, regs[7]);
  38. offset("PT_R8", struct pt_regs, regs[8]);
  39. offset("PT_R9", struct pt_regs, regs[9]);
  40. offset("PT_R10", struct pt_regs, regs[10]);
  41. offset("PT_R11", struct pt_regs, regs[11]);
  42. offset("PT_R12", struct pt_regs, regs[12]);
  43. offset("PT_R13", struct pt_regs, regs[13]);
  44. offset("PT_R14", struct pt_regs, regs[14]);
  45. offset("PT_R15", struct pt_regs, regs[15]);
  46. offset("PT_R16", struct pt_regs, regs[16]);
  47. offset("PT_R17", struct pt_regs, regs[17]);
  48. offset("PT_R18", struct pt_regs, regs[18]);
  49. offset("PT_R19", struct pt_regs, regs[19]);
  50. offset("PT_R20", struct pt_regs, regs[20]);
  51. offset("PT_R21", struct pt_regs, regs[21]);
  52. offset("PT_R22", struct pt_regs, regs[22]);
  53. offset("PT_R23", struct pt_regs, regs[23]);
  54. offset("PT_R24", struct pt_regs, regs[24]);
  55. offset("PT_R25", struct pt_regs, regs[25]);
  56. offset("PT_R26", struct pt_regs, regs[26]);
  57. offset("PT_R27", struct pt_regs, regs[27]);
  58. offset("PT_R28", struct pt_regs, regs[28]);
  59. offset("PT_R29", struct pt_regs, regs[29]);
  60. offset("PT_R30", struct pt_regs, regs[30]);
  61. offset("PT_R31", struct pt_regs, regs[31]);
  62. offset("PT_LO", struct pt_regs, lo);
  63. offset("PT_HI", struct pt_regs, hi);
  64. #ifdef CONFIG_CPU_HAS_SMARTMIPS
  65. offset("PT_ACX", struct pt_regs, acx);
  66. #endif
  67. offset("PT_EPC", struct pt_regs, cp0_epc);
  68. offset("PT_BVADDR", struct pt_regs, cp0_badvaddr);
  69. offset("PT_STATUS", struct pt_regs, cp0_status);
  70. offset("PT_CAUSE", struct pt_regs, cp0_cause);
  71. #ifdef CONFIG_MIPS_MT_SMTC
  72. offset("PT_TCSTATUS", struct pt_regs, cp0_tcstatus);
  73. #endif /* CONFIG_MIPS_MT_SMTC */
  74. size("PT_SIZE", struct pt_regs);
  75. linefeed;
  76. }
  77. void output_task_defines(void)
  78. {
  79. text("MIPS task_struct offsets.");
  80. offset("TASK_STATE", struct task_struct, state);
  81. offset("TASK_THREAD_INFO", struct task_struct, stack);
  82. offset("TASK_FLAGS", struct task_struct, flags);
  83. offset("TASK_MM", struct task_struct, mm);
  84. offset("TASK_PID", struct task_struct, pid);
  85. size( "TASK_STRUCT_SIZE", struct task_struct);
  86. linefeed;
  87. }
  88. void output_thread_info_defines(void)
  89. {
  90. text("MIPS thread_info offsets.");
  91. offset("TI_TASK", struct thread_info, task);
  92. offset("TI_EXEC_DOMAIN", struct thread_info, exec_domain);
  93. offset("TI_FLAGS", struct thread_info, flags);
  94. offset("TI_TP_VALUE", struct thread_info, tp_value);
  95. offset("TI_CPU", struct thread_info, cpu);
  96. offset("TI_PRE_COUNT", struct thread_info, preempt_count);
  97. offset("TI_ADDR_LIMIT", struct thread_info, addr_limit);
  98. offset("TI_RESTART_BLOCK", struct thread_info, restart_block);
  99. offset("TI_REGS", struct thread_info, regs);
  100. constant("_THREAD_SIZE", THREAD_SIZE);
  101. constant("_THREAD_MASK", THREAD_MASK);
  102. linefeed;
  103. }
  104. void output_thread_defines(void)
  105. {
  106. text("MIPS specific thread_struct offsets.");
  107. offset("THREAD_REG16", struct task_struct, thread.reg16);
  108. offset("THREAD_REG17", struct task_struct, thread.reg17);
  109. offset("THREAD_REG18", struct task_struct, thread.reg18);
  110. offset("THREAD_REG19", struct task_struct, thread.reg19);
  111. offset("THREAD_REG20", struct task_struct, thread.reg20);
  112. offset("THREAD_REG21", struct task_struct, thread.reg21);
  113. offset("THREAD_REG22", struct task_struct, thread.reg22);
  114. offset("THREAD_REG23", struct task_struct, thread.reg23);
  115. offset("THREAD_REG29", struct task_struct, thread.reg29);
  116. offset("THREAD_REG30", struct task_struct, thread.reg30);
  117. offset("THREAD_REG31", struct task_struct, thread.reg31);
  118. offset("THREAD_STATUS", struct task_struct,
  119. thread.cp0_status);
  120. offset("THREAD_FPU", struct task_struct, thread.fpu);
  121. offset("THREAD_BVADDR", struct task_struct, \
  122. thread.cp0_badvaddr);
  123. offset("THREAD_BUADDR", struct task_struct, \
  124. thread.cp0_baduaddr);
  125. offset("THREAD_ECODE", struct task_struct, \
  126. thread.error_code);
  127. offset("THREAD_TRAPNO", struct task_struct, thread.trap_no);
  128. offset("THREAD_TRAMP", struct task_struct, \
  129. thread.irix_trampoline);
  130. offset("THREAD_OLDCTX", struct task_struct, \
  131. thread.irix_oldctx);
  132. linefeed;
  133. }
  134. void output_thread_fpu_defines(void)
  135. {
  136. offset("THREAD_FPR0",
  137. struct task_struct, thread.fpu.fpr[0]);
  138. offset("THREAD_FPR1",
  139. struct task_struct, thread.fpu.fpr[1]);
  140. offset("THREAD_FPR2",
  141. struct task_struct, thread.fpu.fpr[2]);
  142. offset("THREAD_FPR3",
  143. struct task_struct, thread.fpu.fpr[3]);
  144. offset("THREAD_FPR4",
  145. struct task_struct, thread.fpu.fpr[4]);
  146. offset("THREAD_FPR5",
  147. struct task_struct, thread.fpu.fpr[5]);
  148. offset("THREAD_FPR6",
  149. struct task_struct, thread.fpu.fpr[6]);
  150. offset("THREAD_FPR7",
  151. struct task_struct, thread.fpu.fpr[7]);
  152. offset("THREAD_FPR8",
  153. struct task_struct, thread.fpu.fpr[8]);
  154. offset("THREAD_FPR9",
  155. struct task_struct, thread.fpu.fpr[9]);
  156. offset("THREAD_FPR10",
  157. struct task_struct, thread.fpu.fpr[10]);
  158. offset("THREAD_FPR11",
  159. struct task_struct, thread.fpu.fpr[11]);
  160. offset("THREAD_FPR12",
  161. struct task_struct, thread.fpu.fpr[12]);
  162. offset("THREAD_FPR13",
  163. struct task_struct, thread.fpu.fpr[13]);
  164. offset("THREAD_FPR14",
  165. struct task_struct, thread.fpu.fpr[14]);
  166. offset("THREAD_FPR15",
  167. struct task_struct, thread.fpu.fpr[15]);
  168. offset("THREAD_FPR16",
  169. struct task_struct, thread.fpu.fpr[16]);
  170. offset("THREAD_FPR17",
  171. struct task_struct, thread.fpu.fpr[17]);
  172. offset("THREAD_FPR18",
  173. struct task_struct, thread.fpu.fpr[18]);
  174. offset("THREAD_FPR19",
  175. struct task_struct, thread.fpu.fpr[19]);
  176. offset("THREAD_FPR20",
  177. struct task_struct, thread.fpu.fpr[20]);
  178. offset("THREAD_FPR21",
  179. struct task_struct, thread.fpu.fpr[21]);
  180. offset("THREAD_FPR22",
  181. struct task_struct, thread.fpu.fpr[22]);
  182. offset("THREAD_FPR23",
  183. struct task_struct, thread.fpu.fpr[23]);
  184. offset("THREAD_FPR24",
  185. struct task_struct, thread.fpu.fpr[24]);
  186. offset("THREAD_FPR25",
  187. struct task_struct, thread.fpu.fpr[25]);
  188. offset("THREAD_FPR26",
  189. struct task_struct, thread.fpu.fpr[26]);
  190. offset("THREAD_FPR27",
  191. struct task_struct, thread.fpu.fpr[27]);
  192. offset("THREAD_FPR28",
  193. struct task_struct, thread.fpu.fpr[28]);
  194. offset("THREAD_FPR29",
  195. struct task_struct, thread.fpu.fpr[29]);
  196. offset("THREAD_FPR30",
  197. struct task_struct, thread.fpu.fpr[30]);
  198. offset("THREAD_FPR31",
  199. struct task_struct, thread.fpu.fpr[31]);
  200. offset("THREAD_FCR31",
  201. struct task_struct, thread.fpu.fcr31);
  202. linefeed;
  203. }
  204. void output_mm_defines(void)
  205. {
  206. text("Size of struct page");
  207. size("STRUCT_PAGE_SIZE", struct page);
  208. linefeed;
  209. text("Linux mm_struct offsets.");
  210. offset("MM_USERS", struct mm_struct, mm_users);
  211. offset("MM_PGD", struct mm_struct, pgd);
  212. offset("MM_CONTEXT", struct mm_struct, context);
  213. linefeed;
  214. constant("_PAGE_SIZE", PAGE_SIZE);
  215. constant("_PAGE_SHIFT", PAGE_SHIFT);
  216. linefeed;
  217. constant("_PGD_T_SIZE", sizeof(pgd_t));
  218. constant("_PMD_T_SIZE", sizeof(pmd_t));
  219. constant("_PTE_T_SIZE", sizeof(pte_t));
  220. linefeed;
  221. constant("_PGD_T_LOG2", PGD_T_LOG2);
  222. constant("_PMD_T_LOG2", PMD_T_LOG2);
  223. constant("_PTE_T_LOG2", PTE_T_LOG2);
  224. linefeed;
  225. constant("_PGD_ORDER", PGD_ORDER);
  226. constant("_PMD_ORDER", PMD_ORDER);
  227. constant("_PTE_ORDER", PTE_ORDER);
  228. linefeed;
  229. constant("_PMD_SHIFT", PMD_SHIFT);
  230. constant("_PGDIR_SHIFT", PGDIR_SHIFT);
  231. linefeed;
  232. constant("_PTRS_PER_PGD", PTRS_PER_PGD);
  233. constant("_PTRS_PER_PMD", PTRS_PER_PMD);
  234. constant("_PTRS_PER_PTE", PTRS_PER_PTE);
  235. linefeed;
  236. }
  237. #ifdef CONFIG_32BIT
  238. void output_sc_defines(void)
  239. {
  240. text("Linux sigcontext offsets.");
  241. offset("SC_REGS", struct sigcontext, sc_regs);
  242. offset("SC_FPREGS", struct sigcontext, sc_fpregs);
  243. offset("SC_ACX", struct sigcontext, sc_acx);
  244. offset("SC_MDHI", struct sigcontext, sc_mdhi);
  245. offset("SC_MDLO", struct sigcontext, sc_mdlo);
  246. offset("SC_PC", struct sigcontext, sc_pc);
  247. offset("SC_FPC_CSR", struct sigcontext, sc_fpc_csr);
  248. offset("SC_FPC_EIR", struct sigcontext, sc_fpc_eir);
  249. offset("SC_HI1", struct sigcontext, sc_hi1);
  250. offset("SC_LO1", struct sigcontext, sc_lo1);
  251. offset("SC_HI2", struct sigcontext, sc_hi2);
  252. offset("SC_LO2", struct sigcontext, sc_lo2);
  253. offset("SC_HI3", struct sigcontext, sc_hi3);
  254. offset("SC_LO3", struct sigcontext, sc_lo3);
  255. linefeed;
  256. }
  257. #endif
  258. #ifdef CONFIG_64BIT
  259. void output_sc_defines(void)
  260. {
  261. text("Linux sigcontext offsets.");
  262. offset("SC_REGS", struct sigcontext, sc_regs);
  263. offset("SC_FPREGS", struct sigcontext, sc_fpregs);
  264. offset("SC_MDHI", struct sigcontext, sc_mdhi);
  265. offset("SC_MDLO", struct sigcontext, sc_mdlo);
  266. offset("SC_PC", struct sigcontext, sc_pc);
  267. offset("SC_FPC_CSR", struct sigcontext, sc_fpc_csr);
  268. linefeed;
  269. }
  270. #endif
  271. #ifdef CONFIG_MIPS32_COMPAT
  272. void output_sc32_defines(void)
  273. {
  274. text("Linux 32-bit sigcontext offsets.");
  275. offset("SC32_FPREGS", struct sigcontext32, sc_fpregs);
  276. offset("SC32_FPC_CSR", struct sigcontext32, sc_fpc_csr);
  277. offset("SC32_FPC_EIR", struct sigcontext32, sc_fpc_eir);
  278. linefeed;
  279. }
  280. #endif
  281. void output_signal_defined(void)
  282. {
  283. text("Linux signal numbers.");
  284. constant("_SIGHUP", SIGHUP);
  285. constant("_SIGINT", SIGINT);
  286. constant("_SIGQUIT", SIGQUIT);
  287. constant("_SIGILL", SIGILL);
  288. constant("_SIGTRAP", SIGTRAP);
  289. constant("_SIGIOT", SIGIOT);
  290. constant("_SIGABRT", SIGABRT);
  291. constant("_SIGEMT", SIGEMT);
  292. constant("_SIGFPE", SIGFPE);
  293. constant("_SIGKILL", SIGKILL);
  294. constant("_SIGBUS", SIGBUS);
  295. constant("_SIGSEGV", SIGSEGV);
  296. constant("_SIGSYS", SIGSYS);
  297. constant("_SIGPIPE", SIGPIPE);
  298. constant("_SIGALRM", SIGALRM);
  299. constant("_SIGTERM", SIGTERM);
  300. constant("_SIGUSR1", SIGUSR1);
  301. constant("_SIGUSR2", SIGUSR2);
  302. constant("_SIGCHLD", SIGCHLD);
  303. constant("_SIGPWR", SIGPWR);
  304. constant("_SIGWINCH", SIGWINCH);
  305. constant("_SIGURG", SIGURG);
  306. constant("_SIGIO", SIGIO);
  307. constant("_SIGSTOP", SIGSTOP);
  308. constant("_SIGTSTP", SIGTSTP);
  309. constant("_SIGCONT", SIGCONT);
  310. constant("_SIGTTIN", SIGTTIN);
  311. constant("_SIGTTOU", SIGTTOU);
  312. constant("_SIGVTALRM", SIGVTALRM);
  313. constant("_SIGPROF", SIGPROF);
  314. constant("_SIGXCPU", SIGXCPU);
  315. constant("_SIGXFSZ", SIGXFSZ);
  316. linefeed;
  317. }
  318. void output_irq_cpustat_t_defines(void)
  319. {
  320. text("Linux irq_cpustat_t offsets.");
  321. offset("IC_SOFTIRQ_PENDING", irq_cpustat_t, __softirq_pending);
  322. size("IC_IRQ_CPUSTAT_T", irq_cpustat_t);
  323. linefeed;
  324. }