Import 2.1.34
[davej-history.git] / include / asm-sparc64 / processor.h
blob28deedf31ba265abe076815ed9d1acb244c65696
1 /* $Id: processor.h,v 1.20 1997/04/11 22:34:54 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
10 #include <asm/a.out.h>
11 #include <asm/pstate.h>
12 #include <asm/ptrace.h>
13 #include <asm/signal.h>
14 #include <asm/segment.h>
16 /* Bus types */
17 #define EISA_bus 0
18 #define EISA_bus__is_a_macro/* for versions in ksyms.c */
19 #define MCA_bus 0
20 #define MCA_bus__is_a_macro/* for versions in ksyms.c */
22 /* The sparc has no problems with write protection */
23 #define wp_works_ok 1
24 #define wp_works_ok__is_a_macro/* for versions in ksyms.c */
26 /* User lives in his very own context, and cannot reference us. */
27 #define TASK_SIZE ((1UL << (PAGE_SHIFT - 3)) * PGDIR_SIZE)
29 #ifndef __ASSEMBLY__
31 #define NSWINS 8
33 /* The Sparc processor specific thread struct. */
34 struct thread_struct {
35 /* Floating point regs */
36 /* Please check asm_offsets, so that not to much precious space
37 is wasted by this alignment and move the float_regs wherever
38 is better in this structure. Remember every byte of alignment
39 is multiplied by 512 to get the amount of wasted kernel memory. */
40 unsigned int float_regs[64]__attribute__((aligned(64)));
41 unsigned long fsr;
43 /* Context switch saved kernel state. */
44 unsigned long ksp, kpc, wstate, cwp;
46 /* Storage for windows when user stack is bogus. */
47 struct reg_window reg_window[NSWINS]__attribute__((aligned(16)));
48 unsigned long rwbuf_stkptrs[NSWINS]__attribute__((aligned(8)));
49 unsigned long w_saved;
51 /* Arch-specific task state flags, see below. */
52 unsigned long flags;
54 /* For signal handling */
55 unsigned long sig_address __attribute__((aligned(8)));
56 unsigned long sig_desc;
58 struct sigstack sstk_info;
59 int current_ds, new_signal;
61 struct pt_regs *kregs;
63 struct exec core_exec;/* just what it says. */
66 #endif/* !(__ASSEMBLY__) */
68 #define SPARC_FLAG_KTHREAD 0x1/* task is a kernel thread */
69 #define SPARC_FLAG_UNALIGNED 0x2/* is allowed to do unaligned accesses */
70 #define SPARC_FLAG_NEWSIGNALS 0x4/* task wants new-style signals */
71 #define SPARC_FLAG_32BIT 0x8/* task is older 32-bit binary */
73 #define INIT_MMAP { &init_mm, 0xfffff80000000000, 0xfffff80001000000, \
74 PAGE_SHARED , VM_READ | VM_WRITE | VM_EXEC }
76 #define INIT_TSS { \
77 /* FPU regs */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
78 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
79 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
80 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, \
81 /* FPU status */ \
82 0, \
83 /* ksp, kpc, wstate, cwp */ \
84 0, 0, 0, 0, \
85 /* reg_window */ \
86 { { { 0, }, { 0, } }, }, \
87 /* rwbuf_stkptrs */ \
88 { 0, 0, 0, 0, 0, 0, 0, 0, }, \
89 /* w_saved */ \
90 0, \
91 /* flags */ \
92 SPARC_FLAG_KTHREAD, \
93 /* sig_address, sig_desc */ \
94 0, 0, \
95 /* ex, sstk_info, current_ds, */ \
96 { 0, 0, }, USER_DS, \
97 /* new_signal, kregs */ \
98 0, 0, \
99 /* core_exec */ \
100 { 0, }, \
103 #ifndef __ASSEMBLY__
105 /* Return saved PC of a blocked thread. */
106 extern __inline__ unsigned longthread_saved_pc(struct thread_struct *t)
108 return t->kpc;
111 /* Do necessary setup to start up a newly executed thread. */
112 #define start_thread(regs, pc, sp) \
113 do { \
114 regs->tstate = (regs->tstate & (TSTATE_CWP)) | TSTATE_IE; \
115 regs->tpc = ((pc & (~3)) - 4); \
116 regs->tnpc = regs->tpc + 4; \
117 regs->y = 0; \
118 __asm__ __volatile__( \
119 "stx %%g0, [%0 + %2 + 0x00]\n\t" \
120 "stx %%g0, [%0 + %2 + 0x08]\n\t" \
121 "stx %%g0, [%0 + %2 + 0x10]\n\t" \
122 "stx %%g0, [%0 + %2 + 0x18]\n\t" \
123 "stx %%g0, [%0 + %2 + 0x20]\n\t" \
124 "stx %%g0, [%0 + %2 + 0x28]\n\t" \
125 "stx %%g0, [%0 + %2 + 0x30]\n\t" \
126 "stx %%g0, [%0 + %2 + 0x38]\n\t" \
127 "stx %%g0, [%0 + %2 + 0x40]\n\t" \
128 "stx %%g0, [%0 + %2 + 0x48]\n\t" \
129 "stx %%g0, [%0 + %2 + 0x50]\n\t" \
130 "stx %%g0, [%0 + %2 + 0x58]\n\t" \
131 "stx %%g0, [%0 + %2 + 0x60]\n\t" \
132 "stx %%g0, [%0 + %2 + 0x68]\n\t" \
133 "stx %1, [%0 + %2 + 0x70]\n\t" \
134 "stx %%g0, [%0 + %2 + 0x78]\n\t" \
136 :"r" (regs),"r" (sp - REGWIN_SZ), \
137 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
138 } while(0)
140 #define start_thread32(regs, pc, sp) \
141 do { \
142 register unsigned int zero asm("g1"); \
144 pc &= 0x00000000ffffffffUL; \
145 sp &= 0x00000000ffffffffUL; \
147 regs->tstate = (regs->tstate & (TSTATE_CWP)) | (TSTATE_IE | TSTATE_AM); \
148 regs->tpc = ((pc & (~3)) - 4); \
149 regs->tnpc = regs->tpc + 4; \
150 regs->y = 0; \
151 current->tss.flags |= SPARC_FLAG_32BIT; \
152 zero = 0; \
153 __asm__ __volatile__( \
154 "stx %%g0, [%0 + %2 + 0x00]\n\t" \
155 "stx %%g0, [%0 + %2 + 0x08]\n\t" \
156 "stx %%g0, [%0 + %2 + 0x10]\n\t" \
157 "stx %%g0, [%0 + %2 + 0x18]\n\t" \
158 "stx %%g0, [%0 + %2 + 0x20]\n\t" \
159 "stx %%g0, [%0 + %2 + 0x28]\n\t" \
160 "stx %%g0, [%0 + %2 + 0x30]\n\t" \
161 "stx %%g0, [%0 + %2 + 0x38]\n\t" \
162 "stx %%g0, [%0 + %2 + 0x40]\n\t" \
163 "stx %%g0, [%0 + %2 + 0x48]\n\t" \
164 "stx %%g0, [%0 + %2 + 0x50]\n\t" \
165 "stx %%g0, [%0 + %2 + 0x58]\n\t" \
166 "stx %%g0, [%0 + %2 + 0x60]\n\t" \
167 "stx %%g0, [%0 + %2 + 0x68]\n\t" \
168 "stx %1, [%0 + %2 + 0x70]\n\t" \
169 "stx %%g0, [%0 + %2 + 0x78]\n\t" \
171 :"r" (regs),"r" (sp - REGWIN32_SZ), \
172 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0])), \
173 "r" (zero)); \
174 } while(0)
176 /* Free all resources held by a thread. */
177 #define release_thread(tsk) do { } while(0)
179 #ifdef __KERNEL__
180 /* Allocation and freeing of basic task resources. */
182 /* XXX FIXME For task_struct must use SLAB or something other than
183 * XXX kmalloc() as FPU registers in TSS require that entire structure
184 * XXX be 64-byte aligned as well.
186 #define alloc_kernel_stack(tsk) __get_free_page(GFP_KERNEL)
187 #define free_kernel_stack(stack) free_page(stack)
188 #define alloc_task_struct() kmalloc(sizeof(struct task_struct), GFP_KERNEL)
189 #define free_task_struct(tsk) kfree(tsk)
190 #endif/* __KERNEL__ */
192 #endif/* !(__ASSEMBLY__) */
194 #endif/* !(__ASM_SPARC64_PROCESSOR_H) */
close