1 #ifndef __ASM_SH64_PROCESSOR_H
2 #define __ASM_SH64_PROCESSOR_H
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
9 * include/asm-sh64/processor.h
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
20 #include <asm/types.h>
21 #include <asm/cache.h>
23 #include <asm/registers.h>
24 #include <linux/threads.h>
27 * Default implementation of macro that returns current
28 * instruction pointer ("program counter").
30 #define current_text_addr() ({ \
32 unsigned long long __dummy; \
33 __asm__("gettr " __t0 ", %1\n\t" \
34 "pta 4, " __t0 "\n\t" \
35 "gettr " __t0 ", %0\n\t" \
36 "ptabs %1, " __t0 "\n\t" \
37 :"=r" (pc), "=r" (__dummy) \
42 * CPU type and hardware bug flags. Kept separately for each CPU.
52 unsigned long loops_per_jiffy;
56 unsigned long *pgd_quick;
57 unsigned long *pmd_quick;
58 unsigned long *pte_quick;
59 unsigned long pgtable_cache_sz;
60 unsigned int cpu_clock, master_clock, bus_clock, module_clock;
63 struct cache_info icache;
64 struct cache_info dcache;
71 extern struct sh_cpuinfo boot_cpu_data;
73 #define cpu_data (&boot_cpu_data)
74 #define current_cpu_data boot_cpu_data
79 * User space process size: 2GB - 4k.
81 #define TASK_SIZE 0x7ffff000UL
83 /* This decides where the kernel will search for a free chunk of vm
84 * space during mmap's.
86 #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
92 * When it's set, it means the processor doesn't have right to use FPU,
93 * and it results exception when the floating operation is executed.
96 * Interrupt level mask
102 #define SR_FD 0x00008000
104 #if defined(CONFIG_SH64_SR_WATCH)
105 #define SR_MMU 0x84000000
107 #define SR_MMU 0x80000000
110 #define SR_IMASK 0x000000f0
111 #define SR_SSTEP 0x08000000
116 * FPU structure and data : require 8-byte alignment as we need to access it
120 struct sh_fpu_hard_struct {
121 unsigned long fp_regs[64];
123 /* long status; * software status information */
127 /* Dummy fpu emulator */
128 struct sh_fpu_soft_struct {
129 unsigned long long fp_regs[32];
131 unsigned char lookahead;
132 unsigned long entry_pc;
137 struct sh_fpu_hard_struct hard;
138 // struct sh_fpu_soft_struct soft;
139 /* 'hard' itself only produces 32 bit alignment, yet we need
140 to access it using 64 bit load/store as well. */
141 unsigned long long alignment_dummy;
144 struct thread_struct {
148 unsigned long trap_no, error_code;
149 unsigned long address;
150 /* Hardware debugging registers may come here */
152 struct pt_regs *kregs;
153 /* floating point info */
154 union sh_fpu_union fpu;
158 { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
160 extern struct pt_regs fake_swapper_regs;
162 #define INIT_THREAD { \
163 sizeof(init_stack) + (long) &init_stack, /* sp */ \
167 &fake_swapper_regs, /*kregs*/ \
168 {{{0,}},} /* fpu state */ \
172 * Do necessary setup to start up a newly executed thread.
174 #define SR_USER (SR_MMU | SR_FD)
176 #define start_thread(regs, new_pc, new_sp) \
178 regs->sr = SR_USER; /* User mode. */ \
179 regs->pc = new_pc - 4; /* Compensate syscall exit */ \
180 regs->pc |= 1; /* Set SHmedia ! */ \
181 regs->regs[18] = 0; \
182 regs->regs[15] = new_sp
184 /* Forward declaration, a strange C thing */
188 /* Free all resources held by a thread. */
189 extern void release_thread(struct task_struct *);
191 * create a kernel thread without removing it from tasklists
193 extern int arch_kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
199 #define EISA_bus__is_a_macro /* for versions in ksyms.c */
201 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
204 /* Copy and release all segment info associated with a VM */
205 #define copy_segments(p, mm) do { } while(0)
206 #define release_segments(mm) do { } while(0)
207 #define forget_segments() do { } while (0)
210 * FPU lazy state save handling.
213 extern __inline__ void release_fpu(void)
215 unsigned long long __dummy;
217 /* Set FD flag in SR */
218 __asm__ __volatile__("getcon " __c0 ", %0\n\t"
220 "putcon %0, " __c0 "\n\t"
225 extern __inline__ void grab_fpu(void)
227 unsigned long long __dummy;
229 /* Clear out FD flag in SR */
230 __asm__ __volatile__("getcon " __c0 ", %0\n\t"
232 "putcon %0, " __c0 "\n\t"
237 /* Round to nearest, no exceptions on inexact, overflow, underflow,
238 zero-divide, invalid. Configure option for whether to flush denorms to
239 zero, or except if a denorm is encountered. */
240 #if defined(CONFIG_SH64_FPU_DENORM_FLUSH)
241 #define FPSCR_INIT 0x00040000
243 #define FPSCR_INIT 0x00000000
246 /* Save the current FP regs */
247 void fpsave(struct sh_fpu_hard_struct *fpregs);
249 /* Initialise the FP state of a task */
250 void fpinit(struct sh_fpu_hard_struct *fpregs);
253 * Return saved PC of a blocked thread.
255 extern __inline__ unsigned long thread_saved_pc(struct thread_struct *t)
260 extern unsigned long get_wchan(struct task_struct *p);
262 #define KSTK_EIP(tsk) ((tsk)->thread.pc)
263 #define KSTK_ESP(tsk) ((tsk)->thread.sp)
265 #endif /* __ASSEMBLY__ */
267 #define TASK_STKPAGES 2 /* Must be power of 2. 2 minimum */
268 #define THREAD_SIZE (TASK_STKPAGES * PAGE_SIZE)
269 #define INIT_TASK_SIZE THREAD_SIZE
273 extern struct task_struct *last_task_used_math;
275 extern struct task_struct * alloc_task_struct(void);
276 extern void free_task_struct(struct task_struct *);
277 #define get_task_struct(tsk) atomic_inc(&mem_map[MAP_NR(tsk)].count)
279 #define init_task (init_task_union.task)
280 #define init_stack (init_task_union.stack)
282 #endif /* __ASSEMBLY__ */
283 #endif /* __ASM_SH64_PROCESSOR_H */