2 * include/asm-sh/processor.h
4 * Copyright (C) 1999, 2000 Niibe Yutaka
7 #ifndef __ASM_SH_PROCESSOR_H
8 #define __ASM_SH_PROCESSOR_H
11 #include <asm/types.h>
12 #include <linux/threads.h>
15 * Default implementation of macro that returns current
16 * instruction pointer ("program counter").
18 #define current_text_addr() ({ void *pc; __asm__("mova 1f, %0\n1:":"=z" (pc)); pc; })
21 * CPU type and hardware bug flags. Kept separately for each CPU.
24 CPU_SH7708, /* Represents 7707, 7708, 7708S, 7708R, 7709 */
25 CPU_SH7729, /* Represents 7709A, 7729 */
26 CPU_SH7750, /* Represents 7750, 7751 */
34 unsigned long loops_per_jiffy;
36 unsigned int cpu_clock, master_clock, bus_clock, module_clock;
37 #ifdef CONFIG_CPU_SUBTYPE_ST40STB1
38 unsigned int memory_clock;
42 extern struct sh_cpuinfo boot_cpu_data;
44 #define cpu_data (&boot_cpu_data)
45 #define current_cpu_data boot_cpu_data
48 * User space process size: 2GB.
50 * Since SH7709 and SH7750 have "area 7", we can't use 0x7c000000--0x7fffffff
52 #define TASK_SIZE 0x7c000000UL
54 /* This decides where the kernel will search for a free chunk of vm
55 * space during mmap's.
57 #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
63 * When it's set, it means the processor doesn't have right to use FPU,
64 * and it results exception when the floating operation is executed.
67 * Interrupt level mask
69 #define SR_FD 0x00008000
70 #define SR_IMASK 0x000000f0
73 * FPU structure and data
76 struct sh_fpu_hard_struct {
77 unsigned long fp_regs[16];
78 unsigned long xfp_regs[16];
82 long status; /* software status information */
85 /* Dummy fpu emulator */
86 struct sh_fpu_soft_struct {
87 unsigned long fp_regs[16];
88 unsigned long xfp_regs[16];
92 unsigned char lookahead;
93 unsigned long entry_pc;
97 struct sh_fpu_hard_struct hard;
98 struct sh_fpu_soft_struct soft;
101 struct thread_struct {
105 unsigned long trap_no, error_code;
106 unsigned long address;
107 /* Hardware debugging registers may come here */
109 /* floating point info */
110 union sh_fpu_union fpu;
113 #define INIT_THREAD { \
114 sizeof(init_stack) + (long) &init_stack, /* sp */ \
118 {{{0,}},} /* fpu state */ \
122 * Do necessary setup to start up a newly executed thread.
124 #define start_thread(regs, new_pc, new_sp) \
127 regs->sr = 0; /* User mode. */ \
129 regs->regs[15] = new_sp
131 /* Forward declaration, a strange C thing */
135 /* Free all resources held by a thread. */
136 extern void release_thread(struct task_struct *);
138 * create a kernel thread without removing it from tasklists
140 extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
146 #define EISA_bus__is_a_macro /* for versions in ksyms.c */
148 #define MCA_bus__is_a_macro /* for versions in ksyms.c */
151 /* Copy and release all segment info associated with a VM */
152 #define copy_segments(p, mm) do { } while(0)
153 #define release_segments(mm) do { } while(0)
156 * FPU lazy state save handling.
159 static __inline__ void release_fpu(void)
161 unsigned long __dummy;
163 /* Set FD flag in SR */
164 __asm__ __volatile__("stc sr, %0\n\t"
171 static __inline__ void grab_fpu(void)
173 unsigned long __dummy;
175 /* Clear out FD flag in SR */
176 __asm__ __volatile__("stc sr, %0\n\t"
183 extern void save_fpu(struct task_struct *__tsk);
185 #define unlazy_fpu(tsk) do { \
186 if ((tsk)->flags & PF_USEDFPU) { \
192 #define clear_fpu(tsk) do { \
193 if ((tsk)->flags & PF_USEDFPU) \
194 (tsk)->flags &= ~PF_USEDFPU; \
197 /* Double presision, NANS as NANS, rounding to nearest, no exceptions */
198 #define FPSCR_INIT 0x00080000
201 * Return saved PC of a blocked thread.
203 static __inline__ unsigned long thread_saved_pc(struct thread_struct *t)
208 extern unsigned long get_wchan(struct task_struct *p);
210 #define KSTK_EIP(tsk) ((tsk)->thread.pc)
211 #define KSTK_ESP(tsk) ((tsk)->thread.sp)
213 #define THREAD_SIZE (2*PAGE_SIZE)
214 extern struct task_struct * alloc_task_struct(void);
215 extern void free_task_struct(struct task_struct *);
216 #define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)
218 #define init_task (init_task_union.task)
219 #define init_stack (init_task_union.stack)
221 #define cpu_relax() do { } while (0)
223 #endif /* __ASM_SH_PROCESSOR_H */