MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-sparc64 / processor.h
blob416fad2ef1b1a9494926089848f759f86d30878f
1 /* $Id: processor.h,v 1.83 2002/02/10 06:04:33 davem Exp $
2 * include/asm-sparc64/processor.h
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
7 #ifndef __ASM_SPARC64_PROCESSOR_H
8 #define __ASM_SPARC64_PROCESSOR_H
11 * Sparc64 implementation of macro that returns current
12 * instruction pointer ("program counter").
14 #define current_text_addr() ({ void *pc; __asm__("rd %%pc, %0" : "=r" (pc)); pc; })
16 #include <linux/config.h>
17 #include <asm/asi.h>
18 #include <asm/a.out.h>
19 #include <asm/pstate.h>
20 #include <asm/ptrace.h>
21 #include <asm/segment.h>
22 #include <asm/page.h>
24 /* Bus types */
25 #define MCA_bus 0
26 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
28 /* The sparc has no problems with write protection */
29 #define wp_works_ok 1
30 #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
33 * User lives in his very own context, and cannot reference us. Note
34 * that TASK_SIZE is a misnomer, it really gives maximum user virtual
35 * address that the kernel will allocate out.
37 #define VA_BITS 44
38 #ifndef __ASSEMBLY__
39 #define VPTE_SIZE (1UL << (VA_BITS - PAGE_SHIFT + 3))
40 #else
41 #define VPTE_SIZE (1 << (VA_BITS - PAGE_SHIFT + 3))
42 #endif
43 #define TASK_SIZE ((unsigned long)-VPTE_SIZE)
46 * The vpte base must be able to hold the entire vpte, half
47 * of which lives above, and half below, the base. And it
48 * is placed as close to the highest address range as possible.
50 #define VPTE_BASE_SPITFIRE (-(VPTE_SIZE/2))
51 #if 1
52 #define VPTE_BASE_CHEETAH VPTE_BASE_SPITFIRE
53 #else
54 #define VPTE_BASE_CHEETAH 0xffe0000000000000
55 #endif
57 #ifndef __ASSEMBLY__
59 typedef struct {
60 unsigned char seg;
61 } mm_segment_t;
63 /* The Sparc processor specific thread struct. */
64 /* XXX This should die, everything can go into thread_info now. */
65 struct thread_struct {
66 #ifdef CONFIG_DEBUG_SPINLOCK
67 /* How many spinlocks held by this thread.
68 * Used with spin lock debugging to catch tasks
69 * sleeping illegally with locks held.
71 int smp_lock_count;
72 unsigned int smp_lock_pc;
73 #else
74 int dummy; /* f'in gcc bug... */
75 #endif
78 #endif /* !(__ASSEMBLY__) */
80 #ifndef CONFIG_DEBUG_SPINLOCK
81 #define INIT_THREAD { \
82 0, \
84 #else /* CONFIG_DEBUG_SPINLOCK */
85 #define INIT_THREAD { \
86 /* smp_lock_count, smp_lock_pc, */ \
87 0, 0, \
89 #endif /* !(CONFIG_DEBUG_SPINLOCK) */
91 #ifndef __ASSEMBLY__
93 #include <linux/types.h>
95 /* Return saved PC of a blocked thread. */
96 struct task_struct;
97 extern unsigned long thread_saved_pc(struct task_struct *);
99 /* On Uniprocessor, even in RMO processes see TSO semantics */
100 #ifdef CONFIG_SMP
101 #define TSTATE_INITIAL_MM TSTATE_TSO
102 #else
103 #define TSTATE_INITIAL_MM TSTATE_RMO
104 #endif
106 /* Do necessary setup to start up a newly executed thread. */
107 #define start_thread(regs, pc, sp) \
108 do { \
109 regs->tstate = (regs->tstate & (TSTATE_CWP)) | (TSTATE_INITIAL_MM|TSTATE_IE) | (ASI_PNF << 24); \
110 regs->tpc = ((pc & (~3)) - 4); \
111 regs->tnpc = regs->tpc + 4; \
112 regs->y = 0; \
113 set_thread_wstate(1 << 3); \
114 if (current_thread_info()->utraps) { \
115 if (*(current_thread_info()->utraps) < 2) \
116 kfree(current_thread_info()->utraps); \
117 else \
118 (*(current_thread_info()->utraps))--; \
119 current_thread_info()->utraps = NULL; \
121 __asm__ __volatile__( \
122 "stx %%g0, [%0 + %2 + 0x00]\n\t" \
123 "stx %%g0, [%0 + %2 + 0x08]\n\t" \
124 "stx %%g0, [%0 + %2 + 0x10]\n\t" \
125 "stx %%g0, [%0 + %2 + 0x18]\n\t" \
126 "stx %%g0, [%0 + %2 + 0x20]\n\t" \
127 "stx %%g0, [%0 + %2 + 0x28]\n\t" \
128 "stx %%g0, [%0 + %2 + 0x30]\n\t" \
129 "stx %%g0, [%0 + %2 + 0x38]\n\t" \
130 "stx %%g0, [%0 + %2 + 0x40]\n\t" \
131 "stx %%g0, [%0 + %2 + 0x48]\n\t" \
132 "stx %%g0, [%0 + %2 + 0x50]\n\t" \
133 "stx %%g0, [%0 + %2 + 0x58]\n\t" \
134 "stx %%g0, [%0 + %2 + 0x60]\n\t" \
135 "stx %%g0, [%0 + %2 + 0x68]\n\t" \
136 "stx %1, [%0 + %2 + 0x70]\n\t" \
137 "stx %%g0, [%0 + %2 + 0x78]\n\t" \
138 "wrpr %%g0, (1 << 3), %%wstate\n\t" \
140 : "r" (regs), "r" (sp - sizeof(struct reg_window) - STACK_BIAS), \
141 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
142 } while (0)
144 #define start_thread32(regs, pc, sp) \
145 do { \
146 pc &= 0x00000000ffffffffUL; \
147 sp &= 0x00000000ffffffffUL; \
149 regs->tstate = (regs->tstate & (TSTATE_CWP))|(TSTATE_INITIAL_MM|TSTATE_IE|TSTATE_AM); \
150 regs->tpc = ((pc & (~3)) - 4); \
151 regs->tnpc = regs->tpc + 4; \
152 regs->y = 0; \
153 set_thread_wstate(2 << 3); \
154 if (current_thread_info()->utraps) { \
155 if (*(current_thread_info()->utraps) < 2) \
156 kfree(current_thread_info()->utraps); \
157 else \
158 (*(current_thread_info()->utraps))--; \
159 current_thread_info()->utraps = NULL; \
161 __asm__ __volatile__( \
162 "stx %%g0, [%0 + %2 + 0x00]\n\t" \
163 "stx %%g0, [%0 + %2 + 0x08]\n\t" \
164 "stx %%g0, [%0 + %2 + 0x10]\n\t" \
165 "stx %%g0, [%0 + %2 + 0x18]\n\t" \
166 "stx %%g0, [%0 + %2 + 0x20]\n\t" \
167 "stx %%g0, [%0 + %2 + 0x28]\n\t" \
168 "stx %%g0, [%0 + %2 + 0x30]\n\t" \
169 "stx %%g0, [%0 + %2 + 0x38]\n\t" \
170 "stx %%g0, [%0 + %2 + 0x40]\n\t" \
171 "stx %%g0, [%0 + %2 + 0x48]\n\t" \
172 "stx %%g0, [%0 + %2 + 0x50]\n\t" \
173 "stx %%g0, [%0 + %2 + 0x58]\n\t" \
174 "stx %%g0, [%0 + %2 + 0x60]\n\t" \
175 "stx %%g0, [%0 + %2 + 0x68]\n\t" \
176 "stx %1, [%0 + %2 + 0x70]\n\t" \
177 "stx %%g0, [%0 + %2 + 0x78]\n\t" \
178 "wrpr %%g0, (2 << 3), %%wstate\n\t" \
180 : "r" (regs), "r" (sp - sizeof(struct reg_window32)), \
181 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
182 } while (0)
184 /* Free all resources held by a thread. */
185 #define release_thread(tsk) do { } while (0)
187 /* Prepare to copy thread state - unlazy all lazy status */
188 #define prepare_to_copy(tsk) do { } while (0)
190 extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
192 extern unsigned long get_wchan(struct task_struct *task);
194 #define KSTK_EIP(tsk) ((tsk)->thread_info->kregs->tpc)
195 #define KSTK_ESP(tsk) ((tsk)->thread_info->kregs->u_regs[UREG_FP])
197 #define cpu_relax() barrier()
199 #endif /* !(__ASSEMBLY__) */
201 #endif /* !(__ASM_SPARC64_PROCESSOR_H) */