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