ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-sparc / processor.h
1 /* $Id: processor.h,v 1.83 2001/10/08 09:32:13 davem Exp $
2  * include/asm-sparc/processor.h
3  *
4  * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
5  */
6
7 #ifndef __ASM_SPARC_PROCESSOR_H
8 #define __ASM_SPARC_PROCESSOR_H
9
10 /*
11  * Sparc32 implementation of macro that returns current
12  * instruction pointer ("program counter").
13  */
14 #define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; })
15
16 #include <linux/a.out.h>
17
18 #include <asm/psr.h>
19 #include <asm/ptrace.h>
20 #include <asm/head.h>
21 #include <asm/signal.h>
22 #include <asm/segment.h>
23 #include <asm/btfixup.h>
24 #include <asm/page.h>
25
26 /*
27  * Bus types
28  */
29 #define MCA_bus 0
30 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
31
32 /*
33  * The sparc has no problems with write protection
34  */
35 #define wp_works_ok 1
36 #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
37
38 /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too... 
39  * That one page is used to protect kernel from intruders, so that
40  * we can make our access_ok test faster
41  */
42 #define TASK_SIZE       PAGE_OFFSET
43
44 struct task_struct;
45
46 struct fpq {
47         unsigned long *insn_addr;
48         unsigned long insn;
49 };
50
51 typedef struct {
52         int seg;
53 } mm_segment_t;
54
55 /* The Sparc processor specific thread struct. */
56 struct thread_struct {
57         struct pt_regs *kregs;
58         unsigned int _pad1;
59
60         /* Special child fork kpsr/kwim values. */
61         unsigned long fork_kpsr __attribute__ ((aligned (8)));
62         unsigned long fork_kwim;
63
64         /* Floating point regs */
65         unsigned long   float_regs[32] __attribute__ ((aligned (8)));
66         unsigned long   fsr;
67         unsigned long   fpqdepth;
68         struct fpq      fpqueue[16];
69         unsigned long flags;
70         mm_segment_t current_ds;
71         struct exec core_exec;     /* just what it says. */
72         int new_signal;
73 };
74
75 #define SPARC_FLAG_KTHREAD      0x1    /* task is a kernel thread */
76 #define SPARC_FLAG_UNALIGNED    0x2    /* is allowed to do unaligned accesses */
77
78 #define INIT_THREAD  { \
79 /* kregs, _pad1, */ \
80    0, 0,  \
81 /* fork_kpsr, fork_kwim */ \
82    0,         0, \
83 /* FPU regs */   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
84                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, \
85 /* FPU status, FPU qdepth, FPU queue */ \
86    0,          0,  { { 0, 0, }, }, \
87 /* flags,              current_ds, */ \
88    SPARC_FLAG_KTHREAD, KERNEL_DS, \
89 /* core_exec */ \
90 { 0, }, \
91 /* new_signal */ \
92   0, \
93 }
94
95 /* Return saved PC of a blocked thread. */
96 extern unsigned long thread_saved_pc(struct task_struct *t);
97
98 /* Do necessary setup to start up a newly executed thread. */
99 extern __inline__ void start_thread(struct pt_regs * regs, unsigned long pc,
100                                     unsigned long sp)
101 {
102         register unsigned long zero asm("g1");
103
104         regs->psr = (regs->psr & (PSR_CWP)) | PSR_S;
105         regs->pc = ((pc & (~3)) - 4);
106         regs->npc = regs->pc + 4;
107         regs->y = 0;
108         zero = 0;
109         __asm__ __volatile__("std\t%%g0, [%0 + %3 + 0x00]\n\t"
110                              "std\t%%g0, [%0 + %3 + 0x08]\n\t"
111                              "std\t%%g0, [%0 + %3 + 0x10]\n\t"
112                              "std\t%%g0, [%0 + %3 + 0x18]\n\t"
113                              "std\t%%g0, [%0 + %3 + 0x20]\n\t"
114                              "std\t%%g0, [%0 + %3 + 0x28]\n\t"
115                              "std\t%%g0, [%0 + %3 + 0x30]\n\t"
116                              "st\t%1, [%0 + %3 + 0x38]\n\t"
117                              "st\t%%g0, [%0 + %3 + 0x3c]"
118                              : /* no outputs */
119                              : "r" (regs),
120                                "r" (sp - sizeof(struct reg_window)),
121                                "r" (zero),
122                                "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))
123                              : "memory");
124 }
125
126 /* Free all resources held by a thread. */
127 #define release_thread(tsk)             do { } while(0)
128 extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
129
130 /* Prepare to copy thread state - unlazy all lazy status */
131 #define prepare_to_copy(tsk)    do { } while (0)
132
133 extern unsigned long get_wchan(struct task_struct *);
134
135 #define KSTK_EIP(tsk)  ((tsk)->thread.kregs->pc)
136 #define KSTK_ESP(tsk)  ((tsk)->thread.kregs->u_regs[UREG_FP])
137
138 #ifdef __KERNEL__
139
140 extern struct task_struct *last_task_used_math;
141
142 #define cpu_relax()     barrier()
143
144 #endif
145
146 #endif /* __ASM_SPARC_PROCESSOR_H */