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