]> Pileus Git - ~andy/linux/blob - include/asm-parisc/processor.h
Merge master.kernel.org:/home/rmk/linux-2.6-mmc
[~andy/linux] / include / asm-parisc / processor.h
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/config.h>
13 #include <linux/threads.h>
14 #include <linux/spinlock_types.h>
15
16 #include <asm/hardware.h>
17 #include <asm/page.h>
18 #include <asm/pdc.h>
19 #include <asm/ptrace.h>
20 #include <asm/types.h>
21 #include <asm/system.h>
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
31 /* We cannot use MFIA as it was added for PA2.0 - prumpf
32
33    At one point there were no "0f/0b" type local symbols in gas for
34    PA-RISC.  This is no longer true, but this still seems like the
35    nicest way to implement this. */
36
37 #define current_text_addr() ({ void *pc; __asm__("\n\tblr 0,%0\n\tnop":"=r" (pc)); pc; })
38
39 #define TASK_SIZE               (current->thread.task_size)
40 #define TASK_UNMAPPED_BASE      (current->thread.map_base)
41
42 #define DEFAULT_TASK_SIZE32     (0xFFF00000UL)
43 #define DEFAULT_MAP_BASE32      (0x40000000UL)
44
45 #ifdef __LP64__
46 #define DEFAULT_TASK_SIZE       (MAX_ADDRESS-0xf000000)
47 #define DEFAULT_MAP_BASE        (0x200000000UL)
48 #else
49 #define DEFAULT_TASK_SIZE       DEFAULT_TASK_SIZE32
50 #define DEFAULT_MAP_BASE        DEFAULT_MAP_BASE32
51 #endif
52
53 #ifndef __ASSEMBLY__
54
55 /*
56  * Data detected about CPUs at boot time which is the same for all CPU's.
57  * HP boxes are SMP - ie identical processors.
58  *
59  * FIXME: some CPU rev info may be processor specific...
60  */
61 struct system_cpuinfo_parisc {
62         unsigned int    cpu_count;
63         unsigned int    cpu_hz;
64         unsigned int    hversion;
65         unsigned int    sversion;
66         enum cpu_type   cpu_type;
67
68         struct {
69                 struct pdc_model model;
70                 unsigned long versions;
71                 unsigned long cpuid;
72                 unsigned long capabilities;
73                 char   sys_model_name[81]; /* PDC-ROM returnes this model name */
74         } pdc;
75
76         char            *cpu_name;      /* e.g. "PA7300LC (PCX-L2)" */
77         char            *family_name;   /* e.g. "1.1e" */
78 };
79
80
81 /* Per CPU data structure - ie varies per CPU.  */
82 struct cpuinfo_parisc {
83         unsigned long it_value;     /* Interval Timer at last timer Intr */
84         unsigned long it_delta;     /* Interval delta (tic_10ms / HZ * 100) */
85         unsigned long irq_count;    /* number of IRQ's since boot */
86         unsigned long irq_max_cr16; /* longest time to handle a single IRQ */
87         unsigned long cpuid;        /* aka slot_number or set to NO_PROC_ID */
88         unsigned long hpa;          /* Host Physical address */
89         unsigned long txn_addr;     /* MMIO addr of EIR or id_eid */
90 #ifdef CONFIG_SMP
91         spinlock_t lock;            /* synchronization for ipi's */
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
105 extern struct system_cpuinfo_parisc boot_cpu_data;
106 extern struct cpuinfo_parisc cpu_data[NR_CPUS];
107 #define current_cpu_data cpu_data[smp_processor_id()]
108
109 #define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
110
111 typedef struct {
112         int seg;  
113 } mm_segment_t;
114
115 #define ARCH_MIN_TASKALIGN      8
116
117 struct thread_struct {
118         struct pt_regs regs;
119         unsigned long  task_size;
120         unsigned long  map_base;
121         unsigned long  flags;
122 }; 
123
124 /* Thread struct flags. */
125 #define PARISC_KERNEL_DEATH     (1UL << 31)     /* see die_if_kernel()... */
126
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 \
138         }
139
140 /*
141  * Return saved PC of a blocked thread.  This is used by ps mostly.
142  */
143
144 unsigned long thread_saved_pc(struct task_struct *t);
145 void show_trace(struct task_struct *task, unsigned long *stack);
146
147 /*
148  * Start user thread in another space.
149  *
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.
155  *
156  * For ELF we clear r23, because the dynamic linker uses it to pass
157  * the address of the finalizer function.
158  *
159  * We also initialize sr3 to an illegal value (illegal for our
160  * implementation, not for the architecture).
161  */
162 typedef unsigned int elf_caddr_t;
163
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;                                        \
170                                                         \
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;                              \
185                                                         \
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)
191
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.
195  *
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.
199  *
200  * Duplicated from dl-machine.h for the benefit of readers:
201  *
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:
205
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.
236
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
248
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.
253  *
254  * Note that the S/390 people took the easy way out and hacked their
255  * GCC to make the stack grow downwards.
256  *
257  * Final Note: For entry from syscall, the W (wide) bit of the PSW
258  * is stuffed into the lowest bit of the user sp (%r30), so we fill
259  * it in here from the current->personality
260  */
261
262 #ifdef __LP64__
263 #define USER_WIDE_MODE  (personality(current->personality) == PER_LINUX)
264 #else
265 #define USER_WIDE_MODE  0
266 #endif
267
268 #define start_thread(regs, new_pc, new_sp) do {         \
269         elf_addr_t *sp = (elf_addr_t *)new_sp;          \
270         __u32 spaceid = (__u32)current->mm->context;    \
271         elf_addr_t pc = (elf_addr_t)new_pc | 3;         \
272         elf_caddr_t *argv = (elf_caddr_t *)bprm->exec + 1;      \
273                                                         \
274         set_fs(USER_DS);                                \
275         regs->iasq[0] = spaceid;                        \
276         regs->iasq[1] = spaceid;                        \
277         regs->iaoq[0] = pc;                             \
278         regs->iaoq[1] = pc + 4;                         \
279         regs->sr[2] = LINUX_GATEWAY_SPACE;              \
280         regs->sr[3] = 0xffff;                           \
281         regs->sr[4] = spaceid;                          \
282         regs->sr[5] = spaceid;                          \
283         regs->sr[6] = spaceid;                          \
284         regs->sr[7] = spaceid;                          \
285         regs->gr[ 0] = USER_PSW | (USER_WIDE_MODE ? PSW_W : 0); \
286         regs->fr[ 0] = 0LL;                             \
287         regs->fr[ 1] = 0LL;                             \
288         regs->fr[ 2] = 0LL;                             \
289         regs->fr[ 3] = 0LL;                             \
290         regs->gr[30] = (((unsigned long)sp + 63) &~ 63) | (USER_WIDE_MODE ? 1 : 0); \
291         regs->gr[31] = pc;                              \
292                                                         \
293         get_user(regs->gr[25], (argv - 1));             \
294         regs->gr[24] = (long) argv;                     \
295         regs->gr[23] = 0;                               \
296 } while(0)
297
298 struct task_struct;
299 struct mm_struct;
300
301 /* Free all resources held by a thread. */
302 extern void release_thread(struct task_struct *);
303 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
304
305 /* Prepare to copy thread state - unlazy all lazy status */
306 #define prepare_to_copy(tsk)    do { } while (0)
307
308 extern void map_hpux_gateway_page(struct task_struct *tsk, struct mm_struct *mm);
309
310 extern unsigned long get_wchan(struct task_struct *p);
311
312 #define KSTK_EIP(tsk)   ((tsk)->thread.regs.iaoq[0])
313 #define KSTK_ESP(tsk)   ((tsk)->thread.regs.gr[30])
314
315
316 /*
317  * PA 2.0 defines data prefetch instructions on page 6-11 of the Kane book.
318  * In addition, many implementations do hardware prefetching of both
319  * instructions and data.
320  *
321  * PA7300LC (page 14-4 of the ERS) also implements prefetching by a load
322  * to gr0 but not in a way that Linux can use.  If the load would cause an
323  * interruption (eg due to prefetching 0), it is suppressed on PA2.0
324  * processors, but not on 7300LC.
325  */
326 #ifdef  CONFIG_PREFETCH
327 #define ARCH_HAS_PREFETCH
328 #define ARCH_HAS_PREFETCHW
329
330 extern inline void prefetch(const void *addr)
331 {
332         __asm__("ldw 0(%0), %%r0" : : "r" (addr));
333 }
334
335 extern inline void prefetchw(const void *addr)
336 {
337         __asm__("ldd 0(%0), %%r0" : : "r" (addr));
338 }
339 #endif
340
341 #define cpu_relax()     barrier()
342
343 #endif /* __ASSEMBLY__ */
344
345 #endif /* __ASM_PARISC_PROCESSOR_H */