15a0015d6SChris Zankel /*
25a0015d6SChris Zankel * arch/xtensa/kernel/asm-offsets.c
35a0015d6SChris Zankel *
45a0015d6SChris Zankel * Generates definitions from c-type structures used by assembly sources.
55a0015d6SChris Zankel *
65a0015d6SChris Zankel * This file is subject to the terms and conditions of the GNU General Public
75a0015d6SChris Zankel * License. See the file "COPYING" in the main directory of this archive
85a0015d6SChris Zankel * for more details.
95a0015d6SChris Zankel *
105a0015d6SChris Zankel * Copyright (C) 2005 Tensilica Inc.
115a0015d6SChris Zankel *
125a0015d6SChris Zankel * Chris Zankel <chris@zankel.net>
135a0015d6SChris Zankel */
145a0015d6SChris Zankel
155a0015d6SChris Zankel #include <asm/processor.h>
164573e398SChris Zankel #include <asm/coprocessor.h>
175a0015d6SChris Zankel
185a0015d6SChris Zankel #include <linux/types.h>
195a0015d6SChris Zankel #include <linux/stddef.h>
205a0015d6SChris Zankel #include <linux/thread_info.h>
215a0015d6SChris Zankel #include <linux/ptrace.h>
226656920bSChris Zankel #include <linux/mm.h>
230fcfbb1dSChristoph Lameter #include <linux/kbuild.h>
24733f5c28SMax Filippov #include <linux/suspend.h>
256656920bSChris Zankel
265a0015d6SChris Zankel #include <asm/ptrace.h>
276ec7026aSMax Filippov #include <asm/traps.h>
287c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
295a0015d6SChris Zankel
main(void)305a0015d6SChris Zankel int main(void)
315a0015d6SChris Zankel {
325a0015d6SChris Zankel /* struct pt_regs */
335a0015d6SChris Zankel DEFINE(PT_PC, offsetof (struct pt_regs, pc));
345a0015d6SChris Zankel DEFINE(PT_PS, offsetof (struct pt_regs, ps));
355a0015d6SChris Zankel DEFINE(PT_DEPC, offsetof (struct pt_regs, depc));
365a0015d6SChris Zankel DEFINE(PT_EXCCAUSE, offsetof (struct pt_regs, exccause));
375a0015d6SChris Zankel DEFINE(PT_EXCVADDR, offsetof (struct pt_regs, excvaddr));
385a0015d6SChris Zankel DEFINE(PT_DEBUGCAUSE, offsetof (struct pt_regs, debugcause));
395a0015d6SChris Zankel DEFINE(PT_WMASK, offsetof (struct pt_regs, wmask));
405a0015d6SChris Zankel DEFINE(PT_LBEG, offsetof (struct pt_regs, lbeg));
415a0015d6SChris Zankel DEFINE(PT_LEND, offsetof (struct pt_regs, lend));
425a0015d6SChris Zankel DEFINE(PT_LCOUNT, offsetof (struct pt_regs, lcount));
435a0015d6SChris Zankel DEFINE(PT_SAR, offsetof (struct pt_regs, sar));
4429c4dfd9SChris Zankel DEFINE(PT_ICOUNTLEVEL, offsetof (struct pt_regs, icountlevel));
455a0015d6SChris Zankel DEFINE(PT_SYSCALL, offsetof (struct pt_regs, syscall));
46733536b8SMax Filippov DEFINE(PT_SCOMPARE1, offsetof(struct pt_regs, scompare1));
47c50842dfSChris Zankel DEFINE(PT_THREADPTR, offsetof(struct pt_regs, threadptr));
485a0015d6SChris Zankel DEFINE(PT_AREG, offsetof (struct pt_regs, areg[0]));
495a0015d6SChris Zankel DEFINE(PT_AREG0, offsetof (struct pt_regs, areg[0]));
505a0015d6SChris Zankel DEFINE(PT_AREG1, offsetof (struct pt_regs, areg[1]));
515a0015d6SChris Zankel DEFINE(PT_AREG2, offsetof (struct pt_regs, areg[2]));
525a0015d6SChris Zankel DEFINE(PT_AREG3, offsetof (struct pt_regs, areg[3]));
535a0015d6SChris Zankel DEFINE(PT_AREG4, offsetof (struct pt_regs, areg[4]));
545a0015d6SChris Zankel DEFINE(PT_AREG5, offsetof (struct pt_regs, areg[5]));
555a0015d6SChris Zankel DEFINE(PT_AREG6, offsetof (struct pt_regs, areg[6]));
565a0015d6SChris Zankel DEFINE(PT_AREG7, offsetof (struct pt_regs, areg[7]));
575a0015d6SChris Zankel DEFINE(PT_AREG8, offsetof (struct pt_regs, areg[8]));
585a0015d6SChris Zankel DEFINE(PT_AREG9, offsetof (struct pt_regs, areg[9]));
595a0015d6SChris Zankel DEFINE(PT_AREG10, offsetof (struct pt_regs, areg[10]));
605a0015d6SChris Zankel DEFINE(PT_AREG11, offsetof (struct pt_regs, areg[11]));
615a0015d6SChris Zankel DEFINE(PT_AREG12, offsetof (struct pt_regs, areg[12]));
625a0015d6SChris Zankel DEFINE(PT_AREG13, offsetof (struct pt_regs, areg[13]));
635a0015d6SChris Zankel DEFINE(PT_AREG14, offsetof (struct pt_regs, areg[14]));
645a0015d6SChris Zankel DEFINE(PT_AREG15, offsetof (struct pt_regs, areg[15]));
655a0015d6SChris Zankel DEFINE(PT_WINDOWBASE, offsetof (struct pt_regs, windowbase));
665a0015d6SChris Zankel DEFINE(PT_WINDOWSTART, offsetof(struct pt_regs, windowstart));
676fad9ddcSMax Filippov DEFINE(PT_KERNEL_SIZE, offsetof(struct pt_regs, areg[16]));
685a0015d6SChris Zankel DEFINE(PT_AREG_END, offsetof (struct pt_regs, areg[XCHAL_NUM_AREGS]));
695a0015d6SChris Zankel DEFINE(PT_USER_SIZE, offsetof(struct pt_regs, areg[XCHAL_NUM_AREGS]));
70c658eac6SChris Zankel DEFINE(PT_XTREGS_OPT, offsetof(struct pt_regs, xtregs_opt));
71c658eac6SChris Zankel DEFINE(XTREGS_OPT_SIZE, sizeof(xtregs_opt_t));
725a0015d6SChris Zankel
735a0015d6SChris Zankel /* struct task_struct */
745a0015d6SChris Zankel DEFINE(TASK_PTRACE, offsetof (struct task_struct, ptrace));
755a0015d6SChris Zankel DEFINE(TASK_MM, offsetof (struct task_struct, mm));
765a0015d6SChris Zankel DEFINE(TASK_ACTIVE_MM, offsetof (struct task_struct, active_mm));
775a0015d6SChris Zankel DEFINE(TASK_PID, offsetof (struct task_struct, pid));
785a0015d6SChris Zankel DEFINE(TASK_THREAD, offsetof (struct task_struct, thread));
79f7e4217bSRoman Zippel DEFINE(TASK_THREAD_INFO, offsetof (struct task_struct, stack));
80050e9baaSLinus Torvalds #ifdef CONFIG_STACKPROTECTOR
8140d1a07bSMax Filippov DEFINE(TASK_STACK_CANARY, offsetof(struct task_struct, stack_canary));
8240d1a07bSMax Filippov #endif
835a0015d6SChris Zankel DEFINE(TASK_STRUCT_SIZE, sizeof (struct task_struct));
845a0015d6SChris Zankel
85cb418fdbSRichard Weinberger /* offsets in thread_info struct */
86cb418fdbSRichard Weinberger OFFSET(TI_TASK, thread_info, task);
87cb418fdbSRichard Weinberger OFFSET(TI_FLAGS, thread_info, flags);
88cb418fdbSRichard Weinberger OFFSET(TI_STSTUS, thread_info, status);
89cb418fdbSRichard Weinberger OFFSET(TI_CPU, thread_info, cpu);
90cb418fdbSRichard Weinberger OFFSET(TI_PRE_COUNT, thread_info, preempt_count);
91*5cc5f19fSMax Filippov #ifdef CONFIG_USER_ABI_CALL0_PROBE
92*5cc5f19fSMax Filippov OFFSET(TI_PS_WOE_FIX_ADDR, thread_info, ps_woe_fix_addr);
93*5cc5f19fSMax Filippov #endif
94cb418fdbSRichard Weinberger
955a0015d6SChris Zankel /* struct thread_info (offset from start_struct) */
965a0015d6SChris Zankel DEFINE(THREAD_RA, offsetof (struct task_struct, thread.ra));
975a0015d6SChris Zankel DEFINE(THREAD_SP, offsetof (struct task_struct, thread.sp));
98a0fc1436SMax Filippov #if XCHAL_HAVE_EXCLUSIVE
99a0fc1436SMax Filippov DEFINE(THREAD_ATOMCTL8, offsetof (struct thread_info, atomctl8));
100a0fc1436SMax Filippov #endif
10111e969bcSMax Filippov DEFINE(THREAD_CPENABLE, offsetof(struct thread_info, cpenable));
10211e969bcSMax Filippov DEFINE(THREAD_CPU, offsetof(struct thread_info, cpu));
10311e969bcSMax Filippov DEFINE(THREAD_CP_OWNER_CPU, offsetof(struct thread_info, cp_owner_cpu));
104c658eac6SChris Zankel #if XTENSA_HAVE_COPROCESSORS
10503bc996aSMax Filippov DEFINE(THREAD_XTREGS_CP0, offsetof(struct thread_info, xtregs_cp.cp0));
10603bc996aSMax Filippov DEFINE(THREAD_XTREGS_CP1, offsetof(struct thread_info, xtregs_cp.cp1));
10703bc996aSMax Filippov DEFINE(THREAD_XTREGS_CP2, offsetof(struct thread_info, xtregs_cp.cp2));
10803bc996aSMax Filippov DEFINE(THREAD_XTREGS_CP3, offsetof(struct thread_info, xtregs_cp.cp3));
10903bc996aSMax Filippov DEFINE(THREAD_XTREGS_CP4, offsetof(struct thread_info, xtregs_cp.cp4));
11003bc996aSMax Filippov DEFINE(THREAD_XTREGS_CP5, offsetof(struct thread_info, xtregs_cp.cp5));
11103bc996aSMax Filippov DEFINE(THREAD_XTREGS_CP6, offsetof(struct thread_info, xtregs_cp.cp6));
11203bc996aSMax Filippov DEFINE(THREAD_XTREGS_CP7, offsetof(struct thread_info, xtregs_cp.cp7));
113c658eac6SChris Zankel #endif
114c658eac6SChris Zankel DEFINE(THREAD_XTREGS_USER, offsetof (struct thread_info, xtregs_user));
115c658eac6SChris Zankel DEFINE(XTREGS_USER_SIZE, sizeof(xtregs_user_t));
1165a0015d6SChris Zankel
1175a0015d6SChris Zankel /* struct mm_struct */
1185a0015d6SChris Zankel DEFINE(MM_USERS, offsetof(struct mm_struct, mm_users));
1195a0015d6SChris Zankel DEFINE(MM_PGD, offsetof (struct mm_struct, pgd));
1205a0015d6SChris Zankel DEFINE(MM_CONTEXT, offsetof (struct mm_struct, context));
1216656920bSChris Zankel
1226656920bSChris Zankel /* struct page */
1236656920bSChris Zankel DEFINE(PAGE_FLAGS, offsetof(struct page, flags));
124fc4fb2adSChris Zankel
125fc4fb2adSChris Zankel /* constants */
126fc4fb2adSChris Zankel DEFINE(_CLONE_VM, CLONE_VM);
127fc4fb2adSChris Zankel DEFINE(_CLONE_UNTRACED, CLONE_UNTRACED);
1286656920bSChris Zankel DEFINE(PG_ARCH_1, PG_arch_1);
129fc4fb2adSChris Zankel
1306ec7026aSMax Filippov /* struct debug_table */
1316ec7026aSMax Filippov DEFINE(DT_DEBUG_EXCEPTION,
1326ec7026aSMax Filippov offsetof(struct debug_table, debug_exception));
1336ec7026aSMax Filippov DEFINE(DT_DEBUG_SAVE, offsetof(struct debug_table, debug_save));
134c91e02bdSMax Filippov #ifdef CONFIG_HAVE_HW_BREAKPOINT
135c91e02bdSMax Filippov DEFINE(DT_DBREAKC_SAVE, offsetof(struct debug_table, dbreakc_save));
136c91e02bdSMax Filippov DEFINE(DT_ICOUNT_SAVE, offsetof(struct debug_table, icount_save));
137c91e02bdSMax Filippov DEFINE(DT_ICOUNT_LEVEL_SAVE,
138c91e02bdSMax Filippov offsetof(struct debug_table, icount_level_save));
139c91e02bdSMax Filippov #endif
1406ec7026aSMax Filippov
141f21a79caSMax Filippov /* struct exc_table */
142f21a79caSMax Filippov DEFINE(EXC_TABLE_KSTK, offsetof(struct exc_table, kstk));
143f21a79caSMax Filippov DEFINE(EXC_TABLE_DOUBLE_SAVE, offsetof(struct exc_table, double_save));
144f21a79caSMax Filippov DEFINE(EXC_TABLE_FIXUP, offsetof(struct exc_table, fixup));
145f21a79caSMax Filippov DEFINE(EXC_TABLE_PARAM, offsetof(struct exc_table, fixup_param));
14611e969bcSMax Filippov #if XTENSA_HAVE_COPROCESSORS
14711e969bcSMax Filippov DEFINE(EXC_TABLE_COPROCESSOR_OWNER,
14811e969bcSMax Filippov offsetof(struct exc_table, coprocessor_owner));
14911e969bcSMax Filippov #endif
150f21a79caSMax Filippov DEFINE(EXC_TABLE_FAST_USER,
151f21a79caSMax Filippov offsetof(struct exc_table, fast_user_handler));
152f21a79caSMax Filippov DEFINE(EXC_TABLE_FAST_KERNEL,
153f21a79caSMax Filippov offsetof(struct exc_table, fast_kernel_handler));
154f21a79caSMax Filippov DEFINE(EXC_TABLE_DEFAULT, offsetof(struct exc_table, default_handler));
155f21a79caSMax Filippov
156733f5c28SMax Filippov #ifdef CONFIG_HIBERNATION
157733f5c28SMax Filippov DEFINE(PBE_ADDRESS, offsetof(struct pbe, address));
158733f5c28SMax Filippov DEFINE(PBE_ORIG_ADDRESS, offsetof(struct pbe, orig_address));
159733f5c28SMax Filippov DEFINE(PBE_NEXT, offsetof(struct pbe, next));
160733f5c28SMax Filippov DEFINE(PBE_SIZE, sizeof(struct pbe));
161733f5c28SMax Filippov #endif
162733f5c28SMax Filippov
1635a0015d6SChris Zankel return 0;
1645a0015d6SChris Zankel }
165