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