1 /*
2 * arch/xtensa/kernel/asm-offsets.c
3 *
4 * Generates definitions from c-type structures used by assembly sources.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 2005 Tensilica Inc.
11 *
12 * Chris Zankel <chris@zankel.net>
13 */
14
15 #include <asm/processor.h>
16 #include <asm/coprocessor.h>
17
18 #include <linux/types.h>
19 #include <linux/stddef.h>
20 #include <linux/thread_info.h>
21 #include <linux/ptrace.h>
22 #include <linux/mm.h>
23 #include <linux/kbuild.h>
24 #include <linux/suspend.h>
25
26 #include <asm/ptrace.h>
27 #include <asm/traps.h>
28 #include <linux/uaccess.h>
29
main(void)30 int main(void)
31 {
32 /* struct pt_regs */
33 DEFINE(PT_PC, offsetof (struct pt_regs, pc));
34 DEFINE(PT_PS, offsetof (struct pt_regs, ps));
35 DEFINE(PT_DEPC, offsetof (struct pt_regs, depc));
36 DEFINE(PT_EXCCAUSE, offsetof (struct pt_regs, exccause));
37 DEFINE(PT_EXCVADDR, offsetof (struct pt_regs, excvaddr));
38 DEFINE(PT_DEBUGCAUSE, offsetof (struct pt_regs, debugcause));
39 DEFINE(PT_WMASK, offsetof (struct pt_regs, wmask));
40 DEFINE(PT_LBEG, offsetof (struct pt_regs, lbeg));
41 DEFINE(PT_LEND, offsetof (struct pt_regs, lend));
42 DEFINE(PT_LCOUNT, offsetof (struct pt_regs, lcount));
43 DEFINE(PT_SAR, offsetof (struct pt_regs, sar));
44 DEFINE(PT_ICOUNTLEVEL, offsetof (struct pt_regs, icountlevel));
45 DEFINE(PT_SYSCALL, offsetof (struct pt_regs, syscall));
46 DEFINE(PT_SCOMPARE1, offsetof(struct pt_regs, scompare1));
47 DEFINE(PT_THREADPTR, offsetof(struct pt_regs, threadptr));
48 DEFINE(PT_AREG, offsetof (struct pt_regs, areg[0]));
49 DEFINE(PT_AREG0, offsetof (struct pt_regs, areg[0]));
50 DEFINE(PT_AREG1, offsetof (struct pt_regs, areg[1]));
51 DEFINE(PT_AREG2, offsetof (struct pt_regs, areg[2]));
52 DEFINE(PT_AREG3, offsetof (struct pt_regs, areg[3]));
53 DEFINE(PT_AREG4, offsetof (struct pt_regs, areg[4]));
54 DEFINE(PT_AREG5, offsetof (struct pt_regs, areg[5]));
55 DEFINE(PT_AREG6, offsetof (struct pt_regs, areg[6]));
56 DEFINE(PT_AREG7, offsetof (struct pt_regs, areg[7]));
57 DEFINE(PT_AREG8, offsetof (struct pt_regs, areg[8]));
58 DEFINE(PT_AREG9, offsetof (struct pt_regs, areg[9]));
59 DEFINE(PT_AREG10, offsetof (struct pt_regs, areg[10]));
60 DEFINE(PT_AREG11, offsetof (struct pt_regs, areg[11]));
61 DEFINE(PT_AREG12, offsetof (struct pt_regs, areg[12]));
62 DEFINE(PT_AREG13, offsetof (struct pt_regs, areg[13]));
63 DEFINE(PT_AREG14, offsetof (struct pt_regs, areg[14]));
64 DEFINE(PT_AREG15, offsetof (struct pt_regs, areg[15]));
65 DEFINE(PT_WINDOWBASE, offsetof (struct pt_regs, windowbase));
66 DEFINE(PT_WINDOWSTART, offsetof(struct pt_regs, windowstart));
67 DEFINE(PT_KERNEL_SIZE, offsetof(struct pt_regs, areg[16]));
68 DEFINE(PT_AREG_END, offsetof (struct pt_regs, areg[XCHAL_NUM_AREGS]));
69 DEFINE(PT_USER_SIZE, offsetof(struct pt_regs, areg[XCHAL_NUM_AREGS]));
70 DEFINE(PT_XTREGS_OPT, offsetof(struct pt_regs, xtregs_opt));
71 DEFINE(XTREGS_OPT_SIZE, sizeof(xtregs_opt_t));
72
73 /* struct task_struct */
74 DEFINE(TASK_PTRACE, offsetof (struct task_struct, ptrace));
75 DEFINE(TASK_MM, offsetof (struct task_struct, mm));
76 DEFINE(TASK_ACTIVE_MM, offsetof (struct task_struct, active_mm));
77 DEFINE(TASK_PID, offsetof (struct task_struct, pid));
78 DEFINE(TASK_THREAD, offsetof (struct task_struct, thread));
79 DEFINE(TASK_THREAD_INFO, offsetof (struct task_struct, stack));
80 #ifdef CONFIG_STACKPROTECTOR
81 DEFINE(TASK_STACK_CANARY, offsetof(struct task_struct, stack_canary));
82 #endif
83 DEFINE(TASK_STRUCT_SIZE, sizeof (struct task_struct));
84
85 /* offsets in thread_info struct */
86 OFFSET(TI_TASK, thread_info, task);
87 OFFSET(TI_FLAGS, thread_info, flags);
88 OFFSET(TI_STSTUS, thread_info, status);
89 OFFSET(TI_CPU, thread_info, cpu);
90 OFFSET(TI_PRE_COUNT, thread_info, preempt_count);
91 #ifdef CONFIG_USER_ABI_CALL0_PROBE
92 OFFSET(TI_PS_WOE_FIX_ADDR, thread_info, ps_woe_fix_addr);
93 #endif
94
95 /* struct thread_info (offset from start_struct) */
96 DEFINE(THREAD_RA, offsetof (struct task_struct, thread.ra));
97 DEFINE(THREAD_SP, offsetof (struct task_struct, thread.sp));
98 #if XCHAL_HAVE_EXCLUSIVE
99 DEFINE(THREAD_ATOMCTL8, offsetof (struct thread_info, atomctl8));
100 #endif
101 DEFINE(THREAD_CPENABLE, offsetof(struct thread_info, cpenable));
102 DEFINE(THREAD_CPU, offsetof(struct thread_info, cpu));
103 DEFINE(THREAD_CP_OWNER_CPU, offsetof(struct thread_info, cp_owner_cpu));
104 #if XTENSA_HAVE_COPROCESSORS
105 DEFINE(THREAD_XTREGS_CP0, offsetof(struct thread_info, xtregs_cp.cp0));
106 DEFINE(THREAD_XTREGS_CP1, offsetof(struct thread_info, xtregs_cp.cp1));
107 DEFINE(THREAD_XTREGS_CP2, offsetof(struct thread_info, xtregs_cp.cp2));
108 DEFINE(THREAD_XTREGS_CP3, offsetof(struct thread_info, xtregs_cp.cp3));
109 DEFINE(THREAD_XTREGS_CP4, offsetof(struct thread_info, xtregs_cp.cp4));
110 DEFINE(THREAD_XTREGS_CP5, offsetof(struct thread_info, xtregs_cp.cp5));
111 DEFINE(THREAD_XTREGS_CP6, offsetof(struct thread_info, xtregs_cp.cp6));
112 DEFINE(THREAD_XTREGS_CP7, offsetof(struct thread_info, xtregs_cp.cp7));
113 #endif
114 DEFINE(THREAD_XTREGS_USER, offsetof (struct thread_info, xtregs_user));
115 DEFINE(XTREGS_USER_SIZE, sizeof(xtregs_user_t));
116
117 /* struct mm_struct */
118 DEFINE(MM_USERS, offsetof(struct mm_struct, mm_users));
119 DEFINE(MM_PGD, offsetof (struct mm_struct, pgd));
120 DEFINE(MM_CONTEXT, offsetof (struct mm_struct, context));
121
122 /* struct page */
123 DEFINE(PAGE_FLAGS, offsetof(struct page, flags));
124
125 /* constants */
126 DEFINE(_CLONE_VM, CLONE_VM);
127 DEFINE(_CLONE_UNTRACED, CLONE_UNTRACED);
128 DEFINE(PG_ARCH_1, PG_arch_1);
129
130 /* struct debug_table */
131 DEFINE(DT_DEBUG_EXCEPTION,
132 offsetof(struct debug_table, debug_exception));
133 DEFINE(DT_DEBUG_SAVE, offsetof(struct debug_table, debug_save));
134 #ifdef CONFIG_HAVE_HW_BREAKPOINT
135 DEFINE(DT_DBREAKC_SAVE, offsetof(struct debug_table, dbreakc_save));
136 DEFINE(DT_ICOUNT_SAVE, offsetof(struct debug_table, icount_save));
137 DEFINE(DT_ICOUNT_LEVEL_SAVE,
138 offsetof(struct debug_table, icount_level_save));
139 #endif
140
141 /* struct exc_table */
142 DEFINE(EXC_TABLE_KSTK, offsetof(struct exc_table, kstk));
143 DEFINE(EXC_TABLE_DOUBLE_SAVE, offsetof(struct exc_table, double_save));
144 DEFINE(EXC_TABLE_FIXUP, offsetof(struct exc_table, fixup));
145 DEFINE(EXC_TABLE_PARAM, offsetof(struct exc_table, fixup_param));
146 #if XTENSA_HAVE_COPROCESSORS
147 DEFINE(EXC_TABLE_COPROCESSOR_OWNER,
148 offsetof(struct exc_table, coprocessor_owner));
149 #endif
150 DEFINE(EXC_TABLE_FAST_USER,
151 offsetof(struct exc_table, fast_user_handler));
152 DEFINE(EXC_TABLE_FAST_KERNEL,
153 offsetof(struct exc_table, fast_kernel_handler));
154 DEFINE(EXC_TABLE_DEFAULT, offsetof(struct exc_table, default_handler));
155
156 #ifdef CONFIG_HIBERNATION
157 DEFINE(PBE_ADDRESS, offsetof(struct pbe, address));
158 DEFINE(PBE_ORIG_ADDRESS, offsetof(struct pbe, orig_address));
159 DEFINE(PBE_NEXT, offsetof(struct pbe, next));
160 DEFINE(PBE_SIZE, sizeof(struct pbe));
161 #endif
162
163 return 0;
164 }
165