Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This program is used to generate definitions needed by |
| 3 | * assembly language modules. |
| 4 | * |
| 5 | * We use the technique used in the OSF Mach kernel code: |
| 6 | * generate asm statements containing #defines, |
| 7 | * compile this file to assembler, and then extract the |
| 8 | * #defines from the assembly-language output. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/config.h> |
| 12 | #include <linux/signal.h> |
| 13 | #include <linux/sched.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/errno.h> |
| 16 | #include <linux/string.h> |
| 17 | #include <linux/types.h> |
| 18 | #include <linux/ptrace.h> |
| 19 | #include <linux/suspend.h> |
| 20 | #include <linux/mman.h> |
| 21 | #include <linux/mm.h> |
| 22 | #include <asm/io.h> |
| 23 | #include <asm/page.h> |
| 24 | #include <asm/pgtable.h> |
| 25 | #include <asm/processor.h> |
| 26 | #include <asm/cputable.h> |
| 27 | #include <asm/thread_info.h> |
Paul Mackerras | 271c3f3 | 2005-11-11 23:04:40 +1100 | [diff] [blame] | 28 | #include <asm/vdso_datapage.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
| 30 | #define DEFINE(sym, val) \ |
| 31 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
| 32 | |
| 33 | #define BLANK() asm volatile("\n->" : : ) |
| 34 | |
| 35 | int |
| 36 | main(void) |
| 37 | { |
| 38 | DEFINE(THREAD, offsetof(struct task_struct, thread)); |
| 39 | DEFINE(THREAD_INFO, offsetof(struct task_struct, thread_info)); |
| 40 | DEFINE(MM, offsetof(struct task_struct, mm)); |
| 41 | DEFINE(PTRACE, offsetof(struct task_struct, ptrace)); |
| 42 | DEFINE(KSP, offsetof(struct thread_struct, ksp)); |
| 43 | DEFINE(PGDIR, offsetof(struct thread_struct, pgdir)); |
| 44 | DEFINE(LAST_SYSCALL, offsetof(struct thread_struct, last_syscall)); |
| 45 | DEFINE(PT_REGS, offsetof(struct thread_struct, regs)); |
| 46 | DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode)); |
| 47 | DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0])); |
| 48 | DEFINE(THREAD_FPSCR, offsetof(struct thread_struct, fpscr)); |
| 49 | #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) |
| 50 | DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0)); |
| 51 | DEFINE(PT_PTRACED, PT_PTRACED); |
| 52 | #endif |
| 53 | #ifdef CONFIG_ALTIVEC |
| 54 | DEFINE(THREAD_VR0, offsetof(struct thread_struct, vr[0])); |
| 55 | DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave)); |
| 56 | DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr)); |
| 57 | DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr)); |
| 58 | #endif /* CONFIG_ALTIVEC */ |
| 59 | #ifdef CONFIG_SPE |
| 60 | DEFINE(THREAD_EVR0, offsetof(struct thread_struct, evr[0])); |
| 61 | DEFINE(THREAD_ACC, offsetof(struct thread_struct, acc)); |
| 62 | DEFINE(THREAD_SPEFSCR, offsetof(struct thread_struct, spefscr)); |
| 63 | DEFINE(THREAD_USED_SPE, offsetof(struct thread_struct, used_spe)); |
| 64 | #endif /* CONFIG_SPE */ |
| 65 | /* Interrupt register frame */ |
| 66 | DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD); |
| 67 | DEFINE(INT_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs)); |
| 68 | /* in fact we only use gpr0 - gpr9 and gpr20 - gpr23 */ |
| 69 | DEFINE(GPR0, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[0])); |
| 70 | DEFINE(GPR1, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[1])); |
| 71 | DEFINE(GPR2, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[2])); |
| 72 | DEFINE(GPR3, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[3])); |
| 73 | DEFINE(GPR4, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[4])); |
| 74 | DEFINE(GPR5, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[5])); |
| 75 | DEFINE(GPR6, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[6])); |
| 76 | DEFINE(GPR7, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[7])); |
| 77 | DEFINE(GPR8, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[8])); |
| 78 | DEFINE(GPR9, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[9])); |
| 79 | DEFINE(GPR10, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[10])); |
| 80 | DEFINE(GPR11, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[11])); |
| 81 | DEFINE(GPR12, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[12])); |
| 82 | DEFINE(GPR13, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[13])); |
| 83 | DEFINE(GPR14, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[14])); |
| 84 | DEFINE(GPR15, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[15])); |
| 85 | DEFINE(GPR16, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[16])); |
| 86 | DEFINE(GPR17, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[17])); |
| 87 | DEFINE(GPR18, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[18])); |
| 88 | DEFINE(GPR19, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[19])); |
| 89 | DEFINE(GPR20, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[20])); |
| 90 | DEFINE(GPR21, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[21])); |
| 91 | DEFINE(GPR22, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[22])); |
| 92 | DEFINE(GPR23, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[23])); |
| 93 | DEFINE(GPR24, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[24])); |
| 94 | DEFINE(GPR25, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[25])); |
| 95 | DEFINE(GPR26, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[26])); |
| 96 | DEFINE(GPR27, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[27])); |
| 97 | DEFINE(GPR28, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[28])); |
| 98 | DEFINE(GPR29, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[29])); |
| 99 | DEFINE(GPR30, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[30])); |
| 100 | DEFINE(GPR31, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[31])); |
| 101 | /* Note: these symbols include _ because they overlap with special |
| 102 | * register names |
| 103 | */ |
| 104 | DEFINE(_NIP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, nip)); |
| 105 | DEFINE(_MSR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, msr)); |
| 106 | DEFINE(_CTR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, ctr)); |
| 107 | DEFINE(_LINK, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, link)); |
| 108 | DEFINE(_CCR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, ccr)); |
| 109 | DEFINE(_MQ, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, mq)); |
| 110 | DEFINE(_XER, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, xer)); |
| 111 | DEFINE(_DAR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dar)); |
| 112 | DEFINE(_DSISR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dsisr)); |
| 113 | /* The PowerPC 400-class & Book-E processors have neither the DAR nor the DSISR |
| 114 | * SPRs. Hence, we overload them to hold the similar DEAR and ESR SPRs |
| 115 | * for such processors. For critical interrupts we use them to |
| 116 | * hold SRR0 and SRR1. |
| 117 | */ |
| 118 | DEFINE(_DEAR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dar)); |
| 119 | DEFINE(_ESR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dsisr)); |
| 120 | DEFINE(ORIG_GPR3, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, orig_gpr3)); |
| 121 | DEFINE(RESULT, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, result)); |
| 122 | DEFINE(TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap)); |
| 123 | DEFINE(CLONE_VM, CLONE_VM); |
| 124 | DEFINE(CLONE_UNTRACED, CLONE_UNTRACED); |
| 125 | DEFINE(MM_PGD, offsetof(struct mm_struct, pgd)); |
| 126 | |
| 127 | /* About the CPU features table */ |
| 128 | DEFINE(CPU_SPEC_ENTRY_SIZE, sizeof(struct cpu_spec)); |
| 129 | DEFINE(CPU_SPEC_PVR_MASK, offsetof(struct cpu_spec, pvr_mask)); |
| 130 | DEFINE(CPU_SPEC_PVR_VALUE, offsetof(struct cpu_spec, pvr_value)); |
| 131 | DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features)); |
| 132 | DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup)); |
| 133 | |
David Woodhouse | 1c3eb62 | 2005-11-26 14:44:47 +0000 | [diff] [blame] | 134 | DEFINE(TI_SIGFRAME, offsetof(struct thread_info, nvgprs_frame)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | DEFINE(TI_TASK, offsetof(struct thread_info, task)); |
| 136 | DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain)); |
| 137 | DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); |
| 139 | DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count)); |
| 140 | |
| 141 | DEFINE(pbe_address, offsetof(struct pbe, address)); |
| 142 | DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address)); |
| 143 | DEFINE(pbe_next, offsetof(struct pbe, next)); |
| 144 | |
Paul Mackerras | fd582ec | 2005-10-11 22:08:12 +1000 | [diff] [blame] | 145 | DEFINE(TASK_SIZE, TASK_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28); |
Paul Mackerras | 271c3f3 | 2005-11-11 23:04:40 +1100 | [diff] [blame] | 147 | |
| 148 | /* datapage offsets for use by vdso */ |
| 149 | DEFINE(CFG_TB_ORIG_STAMP, offsetof(struct vdso_data, tb_orig_stamp)); |
| 150 | DEFINE(CFG_TB_TICKS_PER_SEC, offsetof(struct vdso_data, tb_ticks_per_sec)); |
| 151 | DEFINE(CFG_TB_TO_XS, offsetof(struct vdso_data, tb_to_xs)); |
| 152 | DEFINE(CFG_STAMP_XSEC, offsetof(struct vdso_data, stamp_xsec)); |
| 153 | DEFINE(CFG_TB_UPDATE_COUNT, offsetof(struct vdso_data, tb_update_count)); |
| 154 | DEFINE(CFG_TZ_MINUTEWEST, offsetof(struct vdso_data, tz_minuteswest)); |
| 155 | DEFINE(CFG_TZ_DSTTIME, offsetof(struct vdso_data, tz_dsttime)); |
| 156 | DEFINE(CFG_SYSCALL_MAP32, offsetof(struct vdso_data, syscall_map_32)); |
| 157 | DEFINE(WTOM_CLOCK_SEC, offsetof(struct vdso_data, wtom_clock_sec)); |
| 158 | DEFINE(WTOM_CLOCK_NSEC, offsetof(struct vdso_data, wtom_clock_nsec)); |
| 159 | DEFINE(TVAL32_TV_SEC, offsetof(struct timeval, tv_sec)); |
| 160 | DEFINE(TVAL32_TV_USEC, offsetof(struct timeval, tv_usec)); |
| 161 | DEFINE(TSPEC32_TV_SEC, offsetof(struct timespec, tv_sec)); |
| 162 | DEFINE(TSPEC32_TV_NSEC, offsetof(struct timespec, tv_nsec)); |
| 163 | |
| 164 | /* timeval/timezone offsets for use by vdso */ |
| 165 | DEFINE(TZONE_TZ_MINWEST, offsetof(struct timezone, tz_minuteswest)); |
| 166 | DEFINE(TZONE_TZ_DSTTIME, offsetof(struct timezone, tz_dsttime)); |
| 167 | |
| 168 | /* Other bits used by the vdso */ |
| 169 | DEFINE(CLOCK_REALTIME, CLOCK_REALTIME); |
| 170 | DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); |
| 171 | DEFINE(NSEC_PER_SEC, NSEC_PER_SEC); |
| 172 | DEFINE(CLOCK_REALTIME_RES, TICK_NSEC); |
| 173 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | return 0; |
| 175 | } |