1 /* $Id: processor.h,v 1.57 1999/08/04 03:20:05 davem Exp $
2 * include/asm-sparc64/processor.h
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
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; })
17 #include <asm/a.out.h>
18 #include <asm/pstate.h>
19 #include <asm/ptrace.h>
20 #include <asm/signal.h>
21 #include <asm/segment.h>
25 #define EISA_bus__is_a_macro /* for versions in ksyms.c */
27 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
29 /* The sparc has no problems with write protection */
31 #define wp_works_ok__is_a_macro /* for versions in ksyms.c */
33 /* User lives in his very own context, and cannot reference us. */
35 #define TASK_SIZE ((unsigned long)-PGDIR_SIZE)
37 #define TASK_SIZE 0xfffffffc00000000
48 /* The Sparc processor specific thread struct. */
49 struct thread_struct
{
51 unsigned long ksp
__attribute__ ((aligned(16)));
52 unsigned char wstate
, cwp
, flags
;
53 mm_segment_t current_ds
;
54 unsigned char w_saved
, fpdepth
;
55 unsigned char fpsaved
[7];
56 unsigned char __pad1
[3];
57 struct pt_regs
*kregs
;
60 unsigned long *utraps
;
63 unsigned long sig_address
;
64 unsigned long sig_desc
;
66 /* D$ lines 3 and 4 */
67 unsigned long xfsr
[7];
70 struct reg_window reg_window
[NSWINS
];
71 unsigned long rwbuf_stkptrs
[NSWINS
];
73 /* Performance counter state */
74 u64
*user_cntd0
, *user_cntd1
;
75 u64 kernel_cntd0
, kernel_cntd1
;
79 #endif /* !(__ASSEMBLY__) */
81 #define SPARC_FLAG_UNALIGNED 0x01 /* is allowed to do unaligned accesses */
82 #define SPARC_FLAG_NEWSIGNALS 0x02 /* task wants new-style signals */
83 #define SPARC_FLAG_32BIT 0x04 /* task is older 32-bit binary */
84 #define SPARC_FLAG_NEWCHILD 0x08 /* task is just-spawned child process */
85 #define SPARC_FLAG_PERFCTR 0x10 /* task has performance counters active */
87 #define INIT_MMAP { &init_mm, 0xfffff80000000000, 0xfffff80001000000, \
88 NULL, PAGE_SHARED , VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
90 #define INIT_THREAD { \
91 /* ksp, wstate, cwp, flags, current_ds, */ \
92 0, 0, 0, 0, KERNEL_DS, \
93 /* w_saved, fpdepth, fpsaved, pad1, kregs, */ \
94 0, 0, { 0 }, { 0 }, 0, \
95 /* utraps, gsr, pad2, sig_address, sig_desc, */ \
100 { { { 0, }, { 0, } }, }, \
101 /* rwbuf_stkptrs */ \
102 { 0, 0, 0, 0, 0, 0, 0, }, \
103 /* user_cntd0, user_cndd1, kernel_cntd0, kernel_cntd0, pcr_reg */ \
109 /* Return saved PC of a blocked thread. */
110 extern __inline__
unsigned long thread_saved_pc(struct thread_struct
*t
)
112 unsigned long *sp
= (unsigned long *)(t
->ksp
+ STACK_BIAS
);
113 unsigned long *fp
= (unsigned long *)(sp
[14] + STACK_BIAS
);
118 /* On Uniprocessor, even in RMO processes see TSO semantics */
120 #define TSTATE_INITIAL_MM TSTATE_TSO
122 #define TSTATE_INITIAL_MM TSTATE_RMO
125 /* Do necessary setup to start up a newly executed thread. */
126 #define start_thread(regs, pc, sp) \
128 regs->tstate = (regs->tstate & (TSTATE_CWP)) | (TSTATE_INITIAL_MM|TSTATE_IE) | (ASI_PNF << 24); \
129 regs->tpc = ((pc & (~3)) - 4); \
130 regs->tnpc = regs->tpc + 4; \
132 current->thread.wstate = (1 << 3); \
133 if (current->thread.utraps) { \
134 if (*(current->thread.utraps) < 2) \
135 kfree (current->thread.utraps); \
137 (*(current->thread.utraps))--; \
138 current->thread.utraps = NULL; \
140 __asm__ __volatile__( \
141 "stx %%g0, [%0 + %2 + 0x00]\n\t" \
142 "stx %%g0, [%0 + %2 + 0x08]\n\t" \
143 "stx %%g0, [%0 + %2 + 0x10]\n\t" \
144 "stx %%g0, [%0 + %2 + 0x18]\n\t" \
145 "stx %%g0, [%0 + %2 + 0x20]\n\t" \
146 "stx %%g0, [%0 + %2 + 0x28]\n\t" \
147 "stx %%g0, [%0 + %2 + 0x30]\n\t" \
148 "stx %%g0, [%0 + %2 + 0x38]\n\t" \
149 "stx %%g0, [%0 + %2 + 0x40]\n\t" \
150 "stx %%g0, [%0 + %2 + 0x48]\n\t" \
151 "stx %%g0, [%0 + %2 + 0x50]\n\t" \
152 "stx %%g0, [%0 + %2 + 0x58]\n\t" \
153 "stx %%g0, [%0 + %2 + 0x60]\n\t" \
154 "stx %%g0, [%0 + %2 + 0x68]\n\t" \
155 "stx %1, [%0 + %2 + 0x70]\n\t" \
156 "stx %%g0, [%0 + %2 + 0x78]\n\t" \
157 "wrpr %%g0, (1 << 3), %%wstate\n\t" \
159 : "r" (regs), "r" (sp - REGWIN_SZ - STACK_BIAS), \
160 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
163 #define start_thread32(regs, pc, sp) \
165 pc &= 0x00000000ffffffffUL; \
166 sp &= 0x00000000ffffffffUL; \
168 regs->tstate = (regs->tstate & (TSTATE_CWP))|(TSTATE_INITIAL_MM|TSTATE_IE|TSTATE_AM); \
169 regs->tpc = ((pc & (~3)) - 4); \
170 regs->tnpc = regs->tpc + 4; \
172 current->thread.wstate = (2 << 3); \
173 if (current->thread.utraps) { \
174 if (*(current->thread.utraps) < 2) \
175 kfree (current->thread.utraps); \
177 (*(current->thread.utraps))--; \
178 current->thread.utraps = NULL; \
180 __asm__ __volatile__( \
181 "stx %%g0, [%0 + %2 + 0x00]\n\t" \
182 "stx %%g0, [%0 + %2 + 0x08]\n\t" \
183 "stx %%g0, [%0 + %2 + 0x10]\n\t" \
184 "stx %%g0, [%0 + %2 + 0x18]\n\t" \
185 "stx %%g0, [%0 + %2 + 0x20]\n\t" \
186 "stx %%g0, [%0 + %2 + 0x28]\n\t" \
187 "stx %%g0, [%0 + %2 + 0x30]\n\t" \
188 "stx %%g0, [%0 + %2 + 0x38]\n\t" \
189 "stx %%g0, [%0 + %2 + 0x40]\n\t" \
190 "stx %%g0, [%0 + %2 + 0x48]\n\t" \
191 "stx %%g0, [%0 + %2 + 0x50]\n\t" \
192 "stx %%g0, [%0 + %2 + 0x58]\n\t" \
193 "stx %%g0, [%0 + %2 + 0x60]\n\t" \
194 "stx %%g0, [%0 + %2 + 0x68]\n\t" \
195 "stx %1, [%0 + %2 + 0x70]\n\t" \
196 "stx %%g0, [%0 + %2 + 0x78]\n\t" \
197 "wrpr %%g0, (2 << 3), %%wstate\n\t" \
199 : "r" (regs), "r" (sp - REGWIN32_SZ), \
200 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
203 /* Free all resources held by a thread. */
204 #define release_thread(tsk) do { } while(0)
206 extern pid_t
kernel_thread(int (*fn
)(void *), void * arg
, unsigned long flags
);
208 #define copy_segments(tsk, mm) do { } while (0)
209 #define release_segments(mm) do { } while (0)
210 #define forget_segments() do { } while (0)
213 #define THREAD_SIZE (2*PAGE_SIZE)
214 /* Allocation and freeing of task_struct and kernel stack. */
215 #define alloc_task_struct() ((struct task_struct *)__get_free_pages(GFP_KERNEL, 1))
216 #define free_task_struct(tsk) free_pages((unsigned long)(tsk),1)
218 #define init_task (init_task_union.task)
219 #define init_stack (init_task_union.stack)
221 #endif /* __KERNEL__ */
223 #endif /* !(__ASSEMBLY__) */
225 #endif /* !(__ASM_SPARC64_PROCESSOR_H) */