More cleaning ...
[linux-2.6/linux-mips.git] / include / asm-parisc / processor.h
blobded1c49045104656bd64c2465caf4deb3c8980cb
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/config.h>
13 #include <linux/threads.h>
15 #include <asm/hardware.h>
16 #include <asm/page.h>
17 #include <asm/pdc.h>
18 #include <asm/ptrace.h>
19 #include <asm/types.h>
20 #include <asm/system.h>
21 #endif /* __ASSEMBLY__ */
23 #define KERNEL_STACK_SIZE (4*PAGE_SIZE)
26 * Default implementation of macro that returns current
27 * instruction pointer ("program counter").
30 /* We cannot use MFIA as it was added for PA2.0 - prumpf
32 At one point there were no "0f/0b" type local symbols in gas for
33 PA-RISC. This is no longer true, but this still seems like the
34 nicest way to implement this. */
36 #define current_text_addr() ({ void *pc; __asm__("\n\tblr 0,%0\n\tnop":"=r" (pc)); pc; })
38 #define TASK_SIZE (current->thread.task_size)
39 #define DEFAULT_TASK_SIZE (0xFFF00000UL)
41 #define TASK_UNMAPPED_BASE (current->thread.map_base)
42 #define DEFAULT_MAP_BASE (0x40000000UL)
44 #ifndef __ASSEMBLY__
47 ** Data detected about CPUs at boot time which is the same for all CPU's.
48 ** HP boxes are SMP - ie identical processors.
50 ** FIXME: some CPU rev info may be processor specific...
52 struct system_cpuinfo_parisc {
53 unsigned int cpu_count;
54 unsigned int cpu_hz;
55 unsigned int hversion;
56 unsigned int sversion;
57 enum cpu_type cpu_type;
59 struct {
60 struct pdc_model model;
61 unsigned long versions;
62 unsigned long cpuid;
63 unsigned long capabilities;
64 char sys_model_name[81]; /* PDC-ROM returnes this model name */
65 } pdc;
67 char *cpu_name; /* e.g. "PA7300LC (PCX-L2)" */
68 char *family_name; /* e.g. "1.1e" */
73 ** Per CPU data structure - ie varies per CPU.
75 struct cpuinfo_parisc {
76 unsigned long it_value; /* Interval Timer at last timer Intr */
77 unsigned long it_delta; /* Interval delta (tic_10ms / HZ * 100) */
78 unsigned long irq_count; /* number of IRQ's since boot */
79 unsigned long irq_max_cr16; /* longest time to handle a single IRQ */
80 unsigned long cpuid; /* aka slot_number or set to NO_PROC_ID */
81 unsigned long hpa; /* Host Physical address */
82 unsigned long txn_addr; /* MMIO addr of EIR or id_eid */
83 #ifdef CONFIG_SMP
84 spinlock_t lock; /* synchronization for ipi's */
85 unsigned long pending_ipi; /* bitmap of type ipi_message_type */
86 unsigned long ipi_count; /* number ipi Interrupts */
87 #endif
88 unsigned long bh_count; /* number of times bh was invoked */
89 unsigned long prof_counter; /* per CPU profiling support */
90 unsigned long prof_multiplier; /* per CPU profiling support */
91 unsigned long fp_rev;
92 unsigned long fp_model;
93 unsigned int state;
94 struct parisc_device *dev;
95 unsigned long loops_per_jiffy;
98 extern struct system_cpuinfo_parisc boot_cpu_data;
99 extern struct cpuinfo_parisc cpu_data[NR_CPUS];
100 #define current_cpu_data cpu_data[smp_processor_id()]
102 #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
104 #ifdef CONFIG_EISA
105 extern int EISA_bus;
106 #else
107 #define EISA_bus 0
108 #endif
110 #define MCA_bus 0
111 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
113 typedef struct {
114 int seg;
115 } mm_segment_t;
117 struct thread_struct {
118 struct pt_regs regs;
119 unsigned long task_size;
120 unsigned long map_base;
121 unsigned long flags;
124 /* Thread struct flags. */
125 #define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
127 #define INIT_THREAD { \
128 regs: { gr: { 0, }, \
129 fr: { 0, }, \
130 sr: { 0, }, \
131 iasq: { 0, }, \
132 iaoq: { 0, }, \
133 cr27: 0, \
134 }, \
135 task_size: DEFAULT_TASK_SIZE, \
136 map_base: DEFAULT_MAP_BASE, \
137 flags: 0 \
141 * Return saved PC of a blocked thread. This is used by ps mostly.
144 unsigned long thread_saved_pc(struct task_struct *t);
145 void show_trace(struct task_struct *task, unsigned long *stack);
148 * Start user thread in another space.
150 * Note that we set both the iaoq and r31 to the new pc. When
151 * the kernel initially calls execve it will return through an
152 * rfi path that will use the values in the iaoq. The execve
153 * syscall path will return through the gateway page, and
154 * that uses r31 to branch to.
156 * For ELF we clear r23, because the dynamic linker uses it to pass
157 * the address of the finalizer function.
159 * We also initialize sr3 to an illegal value (illegal for our
160 * implementation, not for the architecture).
162 typedef unsigned int elf_caddr_t;
164 #define start_thread_som(regs, new_pc, new_sp) do { \
165 unsigned long *sp = (unsigned long *)new_sp; \
166 __u32 spaceid = (__u32)current->mm->context; \
167 unsigned long pc = (unsigned long)new_pc; \
168 /* offset pc for priv. level */ \
169 pc |= 3; \
171 set_fs(USER_DS); \
172 regs->iasq[0] = spaceid; \
173 regs->iasq[1] = spaceid; \
174 regs->iaoq[0] = pc; \
175 regs->iaoq[1] = pc + 4; \
176 regs->sr[2] = LINUX_GATEWAY_SPACE; \
177 regs->sr[3] = 0xffff; \
178 regs->sr[4] = spaceid; \
179 regs->sr[5] = spaceid; \
180 regs->sr[6] = spaceid; \
181 regs->sr[7] = spaceid; \
182 regs->gr[ 0] = USER_PSW; \
183 regs->gr[30] = ((new_sp)+63)&~63; \
184 regs->gr[31] = pc; \
186 get_user(regs->gr[26],&sp[0]); \
187 get_user(regs->gr[25],&sp[-1]); \
188 get_user(regs->gr[24],&sp[-2]); \
189 get_user(regs->gr[23],&sp[-3]); \
190 } while(0)
192 /* The ELF abi wants things done a "wee bit" differently than
193 * som does. Supporting this behavior here avoids
194 * having our own version of create_elf_tables.
196 * Oh, and yes, that is not a typo, we are really passing argc in r25
197 * and argv in r24 (rather than r26 and r25). This is because that's
198 * where __libc_start_main wants them.
200 * Duplicated from dl-machine.h for the benefit of readers:
202 * Our initial stack layout is rather different from everyone else's
203 * due to the unique PA-RISC ABI. As far as I know it looks like
204 * this:
206 ----------------------------------- (user startup code creates this frame)
207 | 32 bytes of magic |
208 |---------------------------------|
209 | 32 bytes argument/sp save area |
210 |---------------------------------| (bprm->p)
211 | ELF auxiliary info |
212 | (up to 28 words) |
213 |---------------------------------|
214 | NULL |
215 |---------------------------------|
216 | Environment pointers |
217 |---------------------------------|
218 | NULL |
219 |---------------------------------|
220 | Argument pointers |
221 |---------------------------------| <- argv
222 | argc (1 word) |
223 |---------------------------------| <- bprm->exec (HACK!)
224 | N bytes of slack |
225 |---------------------------------|
226 | filename passed to execve |
227 |---------------------------------| (mm->env_end)
228 | env strings |
229 |---------------------------------| (mm->env_start, mm->arg_end)
230 | arg strings |
231 |---------------------------------|
232 | additional faked arg strings if |
233 | we're invoked via binfmt_script |
234 |---------------------------------| (mm->arg_start)
235 stack base is at TASK_SIZE - rlim_max.
237 on downward growing arches, it looks like this:
238 stack base at TASK_SIZE
239 | filename passed to execve
240 | env strings
241 | arg strings
242 | faked arg strings
243 | slack
244 | ELF
245 | envps
246 | argvs
247 | argc
249 * The pleasant part of this is that if we need to skip arguments we
250 * can just decrement argc and move argv, because the stack pointer
251 * is utterly unrelated to the location of the environment and
252 * argument vectors.
254 * Note that the S/390 people took the easy way out and hacked their
255 * GCC to make the stack grow downwards.
258 #define start_thread(regs, new_pc, new_sp) do { \
259 elf_addr_t *sp = (elf_addr_t *)new_sp; \
260 __u32 spaceid = (__u32)current->mm->context; \
261 elf_addr_t pc = (elf_addr_t)new_pc | 3; \
262 elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1; \
264 set_fs(USER_DS); \
265 regs->iasq[0] = spaceid; \
266 regs->iasq[1] = spaceid; \
267 regs->iaoq[0] = pc; \
268 regs->iaoq[1] = pc + 4; \
269 regs->sr[2] = LINUX_GATEWAY_SPACE; \
270 regs->sr[3] = 0xffff; \
271 regs->sr[4] = spaceid; \
272 regs->sr[5] = spaceid; \
273 regs->sr[6] = spaceid; \
274 regs->sr[7] = spaceid; \
275 regs->gr[ 0] = USER_PSW; \
276 regs->fr[ 0] = 0LL; \
277 regs->fr[ 1] = 0LL; \
278 regs->fr[ 2] = 0LL; \
279 regs->fr[ 3] = 0LL; \
280 regs->gr[30] = ((unsigned long)sp + 63) &~ 63; \
281 regs->gr[31] = pc; \
283 get_user(regs->gr[25], (argv - 1)); \
284 regs->gr[24] = (long) argv; \
285 regs->gr[23] = 0; \
286 } while(0)
288 struct task_struct;
289 struct mm_struct;
291 /* Free all resources held by a thread. */
292 extern void release_thread(struct task_struct *);
293 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
295 /* Prepare to copy thread state - unlazy all lazy status */
296 #define prepare_to_copy(tsk) do { } while (0)
298 extern void map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm);
300 static inline unsigned long get_wchan(struct task_struct *p)
302 return 0xdeadbeef; /* XXX */
305 #define KSTK_EIP(tsk) ((tsk)->thread.regs.iaoq[0])
306 #define KSTK_ESP(tsk) ((tsk)->thread.regs.gr[30])
308 #endif /* __ASSEMBLY__ */
310 #ifdef CONFIG_PA20
311 #define ARCH_HAS_PREFETCH
312 extern inline void prefetch(const void *addr)
314 __asm__("ldw 0(%0), %%r0" : : "r" (addr));
317 #define ARCH_HAS_PREFETCHW
318 extern inline void prefetchw(const void *addr)
320 __asm__("ldd 0(%0), %%r0" : : "r" (addr));
322 #endif
324 #define cpu_relax() barrier()
326 #endif /* __ASM_PARISC_PROCESSOR_H */