Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * include/asm-parisc/processor.h | |
3 | * | |
4 | * Copyright (C) 1994 Linus Torvalds | |
5 | * Copyright (C) 2001 Grant Grundler | |
6 | */ | |
7 | ||
8 | #ifndef __ASM_PARISC_PROCESSOR_H | |
9 | #define __ASM_PARISC_PROCESSOR_H | |
10 | ||
11 | #ifndef __ASSEMBLY__ | |
1da177e4 LT |
12 | #include <linux/threads.h> |
13 | ||
959f4f13 | 14 | #include <asm/prefetch.h> |
1da177e4 | 15 | #include <asm/hardware.h> |
1da177e4 LT |
16 | #include <asm/pdc.h> |
17 | #include <asm/ptrace.h> | |
18 | #include <asm/types.h> | |
19 | #include <asm/system.h> | |
20 | #endif /* __ASSEMBLY__ */ | |
21 | ||
22 | #define KERNEL_STACK_SIZE (4*PAGE_SIZE) | |
23 | ||
24 | /* | |
25 | * Default implementation of macro that returns current | |
26 | * instruction pointer ("program counter"). | |
27 | */ | |
1b6d1b5e KM |
28 | #ifdef CONFIG_PA20 |
29 | #define current_ia(x) __asm__("mfia %0" : "=r"(x)) | |
30 | #else /* mfia added in pa2.0 */ | |
31 | #define current_ia(x) __asm__("blr 0,%0\n\tnop" : "=r"(x)) | |
32 | #endif | |
33 | #define current_text_addr() ({ void *pc; current_ia(pc); pc; }) | |
1da177e4 | 34 | |
82455257 DH |
35 | #define TASK_SIZE_OF(tsk) ((tsk)->thread.task_size) |
36 | #define TASK_SIZE TASK_SIZE_OF(current) | |
1da177e4 LT |
37 | #define TASK_UNMAPPED_BASE (current->thread.map_base) |
38 | ||
39 | #define DEFAULT_TASK_SIZE32 (0xFFF00000UL) | |
40 | #define DEFAULT_MAP_BASE32 (0x40000000UL) | |
41 | ||
513e7ecd | 42 | #ifdef CONFIG_64BIT |
1da177e4 LT |
43 | #define DEFAULT_TASK_SIZE (MAX_ADDRESS-0xf000000) |
44 | #define DEFAULT_MAP_BASE (0x200000000UL) | |
45 | #else | |
46 | #define DEFAULT_TASK_SIZE DEFAULT_TASK_SIZE32 | |
47 | #define DEFAULT_MAP_BASE DEFAULT_MAP_BASE32 | |
48 | #endif | |
49 | ||
922a70d3 DH |
50 | #ifdef __KERNEL__ |
51 | ||
52 | /* XXX: STACK_TOP actually should be STACK_BOTTOM for parisc. | |
53 | * prumpf */ | |
54 | ||
55 | #define STACK_TOP TASK_SIZE | |
56 | #define STACK_TOP_MAX DEFAULT_TASK_SIZE | |
57 | ||
58 | #endif | |
59 | ||
1da177e4 LT |
60 | #ifndef __ASSEMBLY__ |
61 | ||
62 | /* | |
63 | * Data detected about CPUs at boot time which is the same for all CPU's. | |
64 | * HP boxes are SMP - ie identical processors. | |
65 | * | |
66 | * FIXME: some CPU rev info may be processor specific... | |
67 | */ | |
68 | struct system_cpuinfo_parisc { | |
69 | unsigned int cpu_count; | |
70 | unsigned int cpu_hz; | |
71 | unsigned int hversion; | |
72 | unsigned int sversion; | |
73 | enum cpu_type cpu_type; | |
74 | ||
75 | struct { | |
76 | struct pdc_model model; | |
77 | unsigned long versions; | |
78 | unsigned long cpuid; | |
79 | unsigned long capabilities; | |
80 | char sys_model_name[81]; /* PDC-ROM returnes this model name */ | |
81 | } pdc; | |
82 | ||
e9541d0c HD |
83 | const char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */ |
84 | const char *family_name; /* e.g. "1.1e" */ | |
1da177e4 LT |
85 | }; |
86 | ||
87 | ||
88 | /* Per CPU data structure - ie varies per CPU. */ | |
89 | struct cpuinfo_parisc { | |
90 | unsigned long it_value; /* Interval Timer at last timer Intr */ | |
91 | unsigned long it_delta; /* Interval delta (tic_10ms / HZ * 100) */ | |
92 | unsigned long irq_count; /* number of IRQ's since boot */ | |
93 | unsigned long irq_max_cr16; /* longest time to handle a single IRQ */ | |
94 | unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */ | |
95 | unsigned long hpa; /* Host Physical address */ | |
96 | unsigned long txn_addr; /* MMIO addr of EIR or id_eid */ | |
97 | #ifdef CONFIG_SMP | |
1da177e4 LT |
98 | unsigned long pending_ipi; /* bitmap of type ipi_message_type */ |
99 | unsigned long ipi_count; /* number ipi Interrupts */ | |
100 | #endif | |
101 | unsigned long bh_count; /* number of times bh was invoked */ | |
102 | unsigned long prof_counter; /* per CPU profiling support */ | |
103 | unsigned long prof_multiplier; /* per CPU profiling support */ | |
104 | unsigned long fp_rev; | |
105 | unsigned long fp_model; | |
106 | unsigned int state; | |
107 | struct parisc_device *dev; | |
108 | unsigned long loops_per_jiffy; | |
109 | }; | |
110 | ||
111 | extern struct system_cpuinfo_parisc boot_cpu_data; | |
112 | extern struct cpuinfo_parisc cpu_data[NR_CPUS]; | |
113 | #define current_cpu_data cpu_data[smp_processor_id()] | |
114 | ||
115 | #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF) | |
116 | ||
117 | typedef struct { | |
118 | int seg; | |
119 | } mm_segment_t; | |
120 | ||
121 | #define ARCH_MIN_TASKALIGN 8 | |
122 | ||
123 | struct thread_struct { | |
124 | struct pt_regs regs; | |
125 | unsigned long task_size; | |
126 | unsigned long map_base; | |
127 | unsigned long flags; | |
128 | }; | |
129 | ||
130 | /* Thread struct flags. */ | |
f053725b KM |
131 | #define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */ |
132 | #define PARISC_UAC_SIGBUS (1UL << 1) | |
1da177e4 LT |
133 | #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */ |
134 | ||
f053725b KM |
135 | #define PARISC_UAC_SHIFT 0 |
136 | #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS) | |
137 | ||
138 | #define SET_UNALIGN_CTL(task,value) \ | |
139 | ({ \ | |
140 | (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \ | |
141 | | (((value) << PARISC_UAC_SHIFT) & \ | |
142 | PARISC_UAC_MASK)); \ | |
143 | 0; \ | |
144 | }) | |
145 | ||
146 | #define GET_UNALIGN_CTL(task,addr) \ | |
147 | ({ \ | |
148 | put_user(((task)->thread.flags & PARISC_UAC_MASK) \ | |
149 | >> PARISC_UAC_SHIFT, (int __user *) (addr)); \ | |
150 | }) | |
151 | ||
1da177e4 | 152 | #define INIT_THREAD { \ |
02d79800 AD |
153 | .regs = { .gr = { 0, }, \ |
154 | .fr = { 0, }, \ | |
155 | .sr = { 0, }, \ | |
156 | .iasq = { 0, }, \ | |
157 | .iaoq = { 0, }, \ | |
158 | .cr27 = 0, \ | |
1da177e4 | 159 | }, \ |
02d79800 AD |
160 | .task_size = DEFAULT_TASK_SIZE, \ |
161 | .map_base = DEFAULT_MAP_BASE, \ | |
162 | .flags = 0 \ | |
1da177e4 LT |
163 | } |
164 | ||
165 | /* | |
166 | * Return saved PC of a blocked thread. This is used by ps mostly. | |
167 | */ | |
168 | ||
169 | unsigned long thread_saved_pc(struct task_struct *t); | |
170 | void show_trace(struct task_struct *task, unsigned long *stack); | |
171 | ||
172 | /* | |
173 | * Start user thread in another space. | |
174 | * | |
175 | * Note that we set both the iaoq and r31 to the new pc. When | |
176 | * the kernel initially calls execve it will return through an | |
177 | * rfi path that will use the values in the iaoq. The execve | |
178 | * syscall path will return through the gateway page, and | |
179 | * that uses r31 to branch to. | |
180 | * | |
181 | * For ELF we clear r23, because the dynamic linker uses it to pass | |
182 | * the address of the finalizer function. | |
183 | * | |
184 | * We also initialize sr3 to an illegal value (illegal for our | |
185 | * implementation, not for the architecture). | |
186 | */ | |
187 | typedef unsigned int elf_caddr_t; | |
188 | ||
189 | #define start_thread_som(regs, new_pc, new_sp) do { \ | |
190 | unsigned long *sp = (unsigned long *)new_sp; \ | |
191 | __u32 spaceid = (__u32)current->mm->context; \ | |
192 | unsigned long pc = (unsigned long)new_pc; \ | |
193 | /* offset pc for priv. level */ \ | |
194 | pc |= 3; \ | |
195 | \ | |
196 | set_fs(USER_DS); \ | |
197 | regs->iasq[0] = spaceid; \ | |
198 | regs->iasq[1] = spaceid; \ | |
199 | regs->iaoq[0] = pc; \ | |
200 | regs->iaoq[1] = pc + 4; \ | |
201 | regs->sr[2] = LINUX_GATEWAY_SPACE; \ | |
202 | regs->sr[3] = 0xffff; \ | |
203 | regs->sr[4] = spaceid; \ | |
204 | regs->sr[5] = spaceid; \ | |
205 | regs->sr[6] = spaceid; \ | |
206 | regs->sr[7] = spaceid; \ | |
207 | regs->gr[ 0] = USER_PSW; \ | |
208 | regs->gr[30] = ((new_sp)+63)&~63; \ | |
209 | regs->gr[31] = pc; \ | |
210 | \ | |
211 | get_user(regs->gr[26],&sp[0]); \ | |
212 | get_user(regs->gr[25],&sp[-1]); \ | |
213 | get_user(regs->gr[24],&sp[-2]); \ | |
214 | get_user(regs->gr[23],&sp[-3]); \ | |
215 | } while(0) | |
216 | ||
217 | /* The ELF abi wants things done a "wee bit" differently than | |
218 | * som does. Supporting this behavior here avoids | |
219 | * having our own version of create_elf_tables. | |
220 | * | |
221 | * Oh, and yes, that is not a typo, we are really passing argc in r25 | |
222 | * and argv in r24 (rather than r26 and r25). This is because that's | |
223 | * where __libc_start_main wants them. | |
224 | * | |
225 | * Duplicated from dl-machine.h for the benefit of readers: | |
226 | * | |
227 | * Our initial stack layout is rather different from everyone else's | |
228 | * due to the unique PA-RISC ABI. As far as I know it looks like | |
229 | * this: | |
230 | ||
231 | ----------------------------------- (user startup code creates this frame) | |
232 | | 32 bytes of magic | | |
233 | |---------------------------------| | |
234 | | 32 bytes argument/sp save area | | |
235 | |---------------------------------| (bprm->p) | |
236 | | ELF auxiliary info | | |
237 | | (up to 28 words) | | |
238 | |---------------------------------| | |
239 | | NULL | | |
240 | |---------------------------------| | |
241 | | Environment pointers | | |
242 | |---------------------------------| | |
243 | | NULL | | |
244 | |---------------------------------| | |
245 | | Argument pointers | | |
246 | |---------------------------------| <- argv | |
247 | | argc (1 word) | | |
248 | |---------------------------------| <- bprm->exec (HACK!) | |
249 | | N bytes of slack | | |
250 | |---------------------------------| | |
251 | | filename passed to execve | | |
252 | |---------------------------------| (mm->env_end) | |
253 | | env strings | | |
254 | |---------------------------------| (mm->env_start, mm->arg_end) | |
255 | | arg strings | | |
256 | |---------------------------------| | |
257 | | additional faked arg strings if | | |
258 | | we're invoked via binfmt_script | | |
259 | |---------------------------------| (mm->arg_start) | |
260 | stack base is at TASK_SIZE - rlim_max. | |
261 | ||
262 | on downward growing arches, it looks like this: | |
263 | stack base at TASK_SIZE | |
264 | | filename passed to execve | |
265 | | env strings | |
266 | | arg strings | |
267 | | faked arg strings | |
268 | | slack | |
269 | | ELF | |
270 | | envps | |
271 | | argvs | |
272 | | argc | |
273 | ||
274 | * The pleasant part of this is that if we need to skip arguments we | |
275 | * can just decrement argc and move argv, because the stack pointer | |
276 | * is utterly unrelated to the location of the environment and | |
277 | * argument vectors. | |
278 | * | |
279 | * Note that the S/390 people took the easy way out and hacked their | |
280 | * GCC to make the stack grow downwards. | |
281 | * | |
282 | * Final Note: For entry from syscall, the W (wide) bit of the PSW | |
283 | * is stuffed into the lowest bit of the user sp (%r30), so we fill | |
284 | * it in here from the current->personality | |
285 | */ | |
286 | ||
513e7ecd | 287 | #ifdef CONFIG_64BIT |
df570b9c | 288 | #define USER_WIDE_MODE (!test_thread_flag(TIF_32BIT)) |
1da177e4 LT |
289 | #else |
290 | #define USER_WIDE_MODE 0 | |
291 | #endif | |
292 | ||
293 | #define start_thread(regs, new_pc, new_sp) do { \ | |
294 | elf_addr_t *sp = (elf_addr_t *)new_sp; \ | |
295 | __u32 spaceid = (__u32)current->mm->context; \ | |
296 | elf_addr_t pc = (elf_addr_t)new_pc | 3; \ | |
297 | elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \ | |
298 | \ | |
299 | set_fs(USER_DS); \ | |
300 | regs->iasq[0] = spaceid; \ | |
301 | regs->iasq[1] = spaceid; \ | |
302 | regs->iaoq[0] = pc; \ | |
303 | regs->iaoq[1] = pc + 4; \ | |
304 | regs->sr[2] = LINUX_GATEWAY_SPACE; \ | |
305 | regs->sr[3] = 0xffff; \ | |
306 | regs->sr[4] = spaceid; \ | |
307 | regs->sr[5] = spaceid; \ | |
308 | regs->sr[6] = spaceid; \ | |
309 | regs->sr[7] = spaceid; \ | |
310 | regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \ | |
311 | regs->fr[ 0] = 0LL; \ | |
312 | regs->fr[ 1] = 0LL; \ | |
313 | regs->fr[ 2] = 0LL; \ | |
314 | regs->fr[ 3] = 0LL; \ | |
315 | regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \ | |
316 | regs->gr[31] = pc; \ | |
317 | \ | |
318 | get_user(regs->gr[25], (argv - 1)); \ | |
319 | regs->gr[24] = (long) argv; \ | |
320 | regs->gr[23] = 0; \ | |
321 | } while(0) | |
322 | ||
323 | struct task_struct; | |
324 | struct mm_struct; | |
325 | ||
326 | /* Free all resources held by a thread. */ | |
327 | extern void release_thread(struct task_struct *); | |
328 | extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | |
329 | ||
330 | /* Prepare to copy thread state - unlazy all lazy status */ | |
331 | #define prepare_to_copy(tsk) do { } while (0) | |
332 | ||
333 | extern void map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm); | |
334 | ||
335 | extern unsigned long get_wchan(struct task_struct *p); | |
336 | ||
337 | #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0]) | |
338 | #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30]) | |
339 | ||
1da177e4 LT |
340 | #define cpu_relax() barrier() |
341 | ||
20f4d3cb JB |
342 | /* Used as a macro to identify the combined VIPT/PIPT cached |
343 | * CPUs which require a guarantee of coherency (no inequivalent | |
344 | * aliases with different data, whether clean or not) to operate */ | |
345 | static inline int parisc_requires_coherency(void) | |
346 | { | |
347 | #ifdef CONFIG_PA8X00 | |
2cbd42db KM |
348 | return (boot_cpu_data.cpu_type == mako) || |
349 | (boot_cpu_data.cpu_type == mako2); | |
20f4d3cb JB |
350 | #else |
351 | return 0; | |
352 | #endif | |
353 | } | |
354 | ||
1da177e4 LT |
355 | #endif /* __ASSEMBLY__ */ |
356 | ||
357 | #endif /* __ASM_PARISC_PROCESSOR_H */ |