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