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  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version
13  * 2 of the License, or (at your option) any later version.
14  */
15 
16 #include <stddef.h>
17 #include <linux/config.h>
18 #include <linux/signal.h>
19 #include <linux/sched.h>
20 #include <linux/kernel.h>
21 #include <linux/errno.h>
22 #include <linux/string.h>
23 #include <linux/types.h>
24 #include <linux/ptrace.h>
25 #include <linux/mman.h>
26 #include <linux/mm.h>
27 #include <asm/io.h>
28 #include <asm/page.h>
29 #include <asm/pgtable.h>
30 #include <asm/processor.h>
31 #include <asm/hardirq.h>
32 
33 #include <asm/naca.h>
34 #include <asm/paca.h>
35 #include <asm/iSeries/ItLpPaca.h>
36 #include <asm/iSeries/ItLpQueue.h>
37 #include <asm/iSeries/HvLpEvent.h>
38 #include <asm/prom.h>
39 #include <asm/rtas.h>
40 #include <asm/cputable.h>
41 
42 #define DEFINE(sym, val) \
43 	asm volatile("\n#define\t" #sym "\t%0" : : "i" (val))
44 
45 int
main(void)46 main(void)
47 {
48 	DEFINE(SIGPENDING, offsetof(struct task_struct, sigpending));
49 	DEFINE(THREAD, offsetof(struct task_struct, thread));
50 	DEFINE(MM, offsetof(struct task_struct, mm));
51 	DEFINE(TASK_STRUCT_SIZE, sizeof(struct task_struct));
52 	DEFINE(KSP, offsetof(struct thread_struct, ksp));
53 
54 	DEFINE(PACA, offsetof(struct naca_struct, paca));
55 	DEFINE(SLBSIZE, offsetof(struct naca_struct, slb_size));
56 	DEFINE(DCACHEL1LOGLINESIZE, offsetof(struct naca_struct, dCacheL1LogLineSize));
57 	DEFINE(DCACHEL1LINESPERPAGE, offsetof(struct naca_struct, dCacheL1LinesPerPage));
58 	DEFINE(ICACHEL1LOGLINESIZE, offsetof(struct naca_struct, iCacheL1LogLineSize));
59 	DEFINE(ICACHEL1LINESPERPAGE, offsetof(struct naca_struct, iCacheL1LinesPerPage));
60 
61 	DEFINE(DCACHEL1LINESIZE, offsetof(struct systemcfg, dCacheL1LineSize));
62 	DEFINE(ICACHEL1LINESIZE, offsetof(struct systemcfg, iCacheL1LineSize));
63 	DEFINE(PLATFORM, offsetof(struct systemcfg, platform));
64 
65 	DEFINE(PACA_SIZE, sizeof(struct paca_struct));
66 	DEFINE(PACAPACAINDEX, offsetof(struct paca_struct, xPacaIndex));
67 	DEFINE(PACAPROCSTART, offsetof(struct paca_struct, xProcStart));
68 	DEFINE(PACAKSAVE, offsetof(struct paca_struct, xKsave));
69 	DEFINE(PACACURRENT, offsetof(struct paca_struct, xCurrent));
70 	DEFINE(PACASAVEDMSR, offsetof(struct paca_struct, xSavedMsr));
71 	DEFINE(PACASTABREAL, offsetof(struct paca_struct, xStab_data.real));
72 	DEFINE(PACASTABVIRT, offsetof(struct paca_struct, xStab_data.virt));
73 	DEFINE(PACASTABRR, offsetof(struct paca_struct, xStab_data.next_round_robin));
74 	DEFINE(PACAR1, offsetof(struct paca_struct, xR1));
75 	DEFINE(PACALPQUEUE, offsetof(struct paca_struct, lpQueuePtr));
76 	DEFINE(PACATOC, offsetof(struct paca_struct, xTOC));
77 	DEFINE(PACAEXCSP, offsetof(struct paca_struct, exception_sp));
78 	DEFINE(PACAHRDWINTSTACK, offsetof(struct paca_struct, xHrdIntStack));
79 	DEFINE(PACAPROCENABLED, offsetof(struct paca_struct, xProcEnabled));
80 	DEFINE(PACAHRDWINTCOUNT, offsetof(struct paca_struct, xHrdIntCount));
81 	DEFINE(PACADEFAULTDECR, offsetof(struct paca_struct, default_decr));
82 
83 	DEFINE(PACAPROFMODE, offsetof(struct paca_struct, prof_mode));
84 	DEFINE(PACAPROFLEN, offsetof(struct paca_struct, prof_len));
85 	DEFINE(PACAPROFSHIFT, offsetof(struct paca_struct, prof_shift));
86 	DEFINE(PACAPROFBUFFER, offsetof(struct paca_struct, prof_buffer));
87 	DEFINE(PACAPROFSTEXT, offsetof(struct paca_struct, prof_stext));
88 	DEFINE(PACAPROFETEXT, offsetof(struct paca_struct, prof_etext));
89 	DEFINE(PACAPMC1, offsetof(struct paca_struct, pmc[0]));
90 	DEFINE(PACAPMC2, offsetof(struct paca_struct, pmc[1]));
91 	DEFINE(PACAPMC3, offsetof(struct paca_struct, pmc[2]));
92 	DEFINE(PACAPMC4, offsetof(struct paca_struct, pmc[3]));
93 	DEFINE(PACAPMC5, offsetof(struct paca_struct, pmc[4]));
94 	DEFINE(PACAPMC6, offsetof(struct paca_struct, pmc[5]));
95 	DEFINE(PACAPMC7, offsetof(struct paca_struct, pmc[6]));
96 	DEFINE(PACAPMC8, offsetof(struct paca_struct, pmc[7]));
97 	DEFINE(PACAMMCR0, offsetof(struct paca_struct, pmc[8]));
98 	DEFINE(PACAMMCR1, offsetof(struct paca_struct, pmc[9]));
99 	DEFINE(PACAMMCRA, offsetof(struct paca_struct, pmc[10]));
100 	DEFINE(PACAPMCC1, offsetof(struct paca_struct, pmcc[0]));
101 	DEFINE(PACAPMCC2, offsetof(struct paca_struct, pmcc[1]));
102 	DEFINE(PACAPMCC3, offsetof(struct paca_struct, pmcc[2]));
103 	DEFINE(PACAPMCC4, offsetof(struct paca_struct, pmcc[3]));
104 	DEFINE(PACAPMCC5, offsetof(struct paca_struct, pmcc[4]));
105 	DEFINE(PACAPMCC6, offsetof(struct paca_struct, pmcc[5]));
106 	DEFINE(PACAPMCC7, offsetof(struct paca_struct, pmcc[6]));
107 	DEFINE(PACAPMCC8, offsetof(struct paca_struct, pmcc[7]));
108 
109 	DEFINE(PACALPPACA, offsetof(struct paca_struct, xLpPaca));
110 	DEFINE(LPPACA, offsetof(struct paca_struct, xLpPaca));
111 	DEFINE(PACAREGSAV, offsetof(struct paca_struct, xRegSav));
112 	DEFINE(PACAEXC, offsetof(struct paca_struct, exception_stack));
113 	DEFINE(PACAGUARD, offsetof(struct paca_struct, guard));
114 	DEFINE(LPPACASRR0, offsetof(struct ItLpPaca, xSavedSrr0));
115 	DEFINE(LPPACASRR1, offsetof(struct ItLpPaca, xSavedSrr1));
116 	DEFINE(LPPACAANYINT, offsetof(struct ItLpPaca, xIntDword.xAnyInt));
117 	DEFINE(LPPACADECRINT, offsetof(struct ItLpPaca, xIntDword.xFields.xDecrInt));
118 	DEFINE(LPPACAPDCINT, offsetof(struct ItLpPaca, xIntDword.xFields.xPdcInt));
119 	DEFINE(LPQCUREVENTPTR, offsetof(struct ItLpQueue, xSlicCurEventPtr));
120 	DEFINE(LPQOVERFLOW, offsetof(struct ItLpQueue, xPlicOverflowIntPending));
121 	DEFINE(LPEVENTFLAGS, offsetof(struct HvLpEvent, xFlags));
122 	DEFINE(PROMENTRY, offsetof(struct prom_t, entry));
123 
124 	DEFINE(RTASBASE, offsetof(struct rtas_t, base));
125 	DEFINE(RTASENTRY, offsetof(struct rtas_t, entry));
126 	DEFINE(RTASSIZE, offsetof(struct rtas_t, size));
127 
128 	DEFINE(LAST_SYSCALL, offsetof(struct thread_struct, last_syscall));
129 	DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
130 	DEFINE(PT_TRACESYS, PT_TRACESYS);
131 	DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
132 	DEFINE(NEED_RESCHED, offsetof(struct task_struct, need_resched));
133 	DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0]));
134 	DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode));
135 	DEFINE(THREAD_FPSCR, offsetof(struct thread_struct, fpscr));
136 #ifdef CONFIG_ALTIVEC
137 	DEFINE(THREAD_VR0, offsetof(struct thread_struct, vr[0]));
138 	DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave));
139 	DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr));
140 #endif /* CONFIG_ALTIVEC */
141 	DEFINE(THREAD_FLAGS, offsetof(struct thread_struct, flags));
142 	DEFINE(PPC_FLAG_32BIT, PPC_FLAG_32BIT);
143 	/*
144 	 * Interrupt register frame
145 	 */
146 	DEFINE(TASK_UNION_SIZE, sizeof(union task_union));
147 	DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD);
148 	/*
149 	 * 288 = # of volatile regs, int & fp, for leaf routines
150 	 * which do not stack a frame.  See the PPC64 ABI.
151 	 */
152 	DEFINE(INT_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 288);
153 	/*
154 	 * Create extra stack space for SRR0 and SRR1 when calling prom/rtas.
155 	 */
156 	DEFINE(PROM_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16 + 288);
157 	DEFINE(RTAS_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16 + 288);
158 	DEFINE(GPR0, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[0]));
159 	DEFINE(GPR1, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[1]));
160 	DEFINE(GPR2, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[2]));
161 	DEFINE(GPR3, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[3]));
162 	DEFINE(GPR4, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[4]));
163 	DEFINE(GPR5, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[5]));
164 	DEFINE(GPR6, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[6]));
165 	DEFINE(GPR7, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[7]));
166 	DEFINE(GPR8, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[8]));
167 	DEFINE(GPR9, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[9]));
168 	DEFINE(GPR20, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[20]));
169 	DEFINE(GPR21, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[21]));
170 	DEFINE(GPR22, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[22]));
171 	DEFINE(GPR23, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[23]));
172 	/*
173 	 * Note: these symbols include _ because they overlap with special
174 	 * register names
175 	 */
176 	DEFINE(_NIP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, nip));
177 	DEFINE(_MSR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, msr));
178 	DEFINE(_CTR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, ctr));
179 	DEFINE(_LINK, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, link));
180 	DEFINE(_CCR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, ccr));
181 	DEFINE(_XER, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, xer));
182 	DEFINE(_DAR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dar));
183 	DEFINE(_DSISR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dsisr));
184 	DEFINE(ORIG_GPR3, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, orig_gpr3));
185 	DEFINE(RESULT, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, result));
186 	DEFINE(TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap));
187 	DEFINE(SOFTE, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, softe));
188 
189 	/*
190 	 * These _only_ to be used with {PROM,RTAS}_FRAME_SIZE!!!
191 	 */
192 	DEFINE(_SRR0, STACK_FRAME_OVERHEAD+sizeof(struct pt_regs));
193 	DEFINE(_SRR1, STACK_FRAME_OVERHEAD+sizeof(struct pt_regs)+8);
194 
195 	DEFINE(CLONE_VM, CLONE_VM);
196 
197 	/* About the CPU features table */
198 	DEFINE(CPU_SPEC_ENTRY_SIZE, sizeof(struct cpu_spec));
199 	DEFINE(CPU_SPEC_PVR_MASK, offsetof(struct cpu_spec, pvr_mask));
200 	DEFINE(CPU_SPEC_PVR_VALUE, offsetof(struct cpu_spec, pvr_value));
201 	DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features));
202 	DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
203 
204 	/* About the CPU features table */
205 	DEFINE(CPU_SPEC_ENTRY_SIZE, sizeof(struct cpu_spec));
206 	DEFINE(CPU_SPEC_PVR_MASK, offsetof(struct cpu_spec, pvr_mask));
207 	DEFINE(CPU_SPEC_PVR_VALUE, offsetof(struct cpu_spec, pvr_value));
208 	DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features));
209 	DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
210 
211 	return 0;
212 }
213