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) 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> 18 #define EISA_bus__is_a_macro/* for versions in ksyms.c */ 20 #define MCA_bus__is_a_macro/* for versions in ksyms.c */ 22 /* The sparc has no problems with write protection */ 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) 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))); 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. */ 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 } 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, }, \ 83 /* ksp, kpc, wstate, cwp */ \ 86 { { { 0, }, { 0, } }, }, \ 88 { 0, 0, 0, 0, 0, 0, 0, 0, }, \ 93 /* sig_address, sig_desc */ \ 95 /* ex, sstk_info, current_ds, */ \ 97 /* new_signal, kregs */ \ 105 /* Return saved PC of a blocked thread. */ 106 extern __inline__
unsigned longthread_saved_pc(struct thread_struct
*t
) 111 /* Do necessary setup to start up a newly executed thread. */ 112 #define start_thread(regs, pc, sp) \ 114 regs->tstate = (regs->tstate & (TSTATE_CWP)) | TSTATE_IE; \ 115 regs->tpc = ((pc & (~3)) - 4); \ 116 regs->tnpc = regs->tpc + 4; \ 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]))); \ 140 #define start_thread32(regs, pc, sp) \ 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; \ 151 current->tss.flags |= SPARC_FLAG_32BIT; \ 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])), \ 176 /* Free all resources held by a thread. */ 177 #define release_thread(tsk) do { } while(0) 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) */