MN10300: Make the FPU operate in non-lazy mode under SMP
[pandora-kernel.git] / arch / mn10300 / include / asm / processor.h
1 /* MN10300 Processor specifics
2  *
3  * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd.
4  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5  * Written by David Howells (dhowells@redhat.com)
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public Licence
9  * as published by the Free Software Foundation; either version
10  * 2 of the Licence, or (at your option) any later version.
11  */
12
13 #ifndef _ASM_PROCESSOR_H
14 #define _ASM_PROCESSOR_H
15
16 #include <asm/page.h>
17 #include <asm/ptrace.h>
18 #include <asm/cpu-regs.h>
19 #include <linux/threads.h>
20
21 /* Forward declaration, a strange C thing */
22 struct task_struct;
23 struct mm_struct;
24
25 /*
26  * Default implementation of macro that returns current
27  * instruction pointer ("program counter").
28  */
29 #define current_text_addr()                     \
30 ({                                              \
31         void *__pc;                             \
32         asm("mov pc,%0" : "=a"(__pc));          \
33         __pc;                                   \
34 })
35
36 extern void show_registers(struct pt_regs *regs);
37
38 /*
39  *  CPU type and hardware bug flags. Kept separately for each CPU.
40  *  Members of this structure are referenced in head.S, so think twice
41  *  before touching them. [mj]
42  */
43
44 struct mn10300_cpuinfo {
45         int             type;
46         unsigned long   loops_per_sec;
47         char            hard_math;
48         unsigned long   *pgd_quick;
49         unsigned long   *pte_quick;
50         unsigned long   pgtable_cache_sz;
51 };
52
53 extern struct mn10300_cpuinfo boot_cpu_data;
54
55 #define cpu_data &boot_cpu_data
56 #define current_cpu_data boot_cpu_data
57
58 extern void identify_cpu(struct mn10300_cpuinfo *);
59 extern void print_cpu_info(struct mn10300_cpuinfo *);
60 extern void dodgy_tsc(void);
61 #define cpu_relax() barrier()
62
63 /*
64  * User space process size: 1.75GB (default).
65  */
66 #define TASK_SIZE               0x70000000
67
68 /*
69  * Where to put the userspace stack by default
70  */
71 #define STACK_TOP               0x70000000
72 #define STACK_TOP_MAX           STACK_TOP
73
74 /* This decides where the kernel will search for a free chunk of vm
75  * space during mmap's.
76  */
77 #define TASK_UNMAPPED_BASE      0x30000000
78
79 typedef struct {
80         unsigned long   seg;
81 } mm_segment_t;
82
83 struct fpu_state_struct {
84         unsigned long   fs[32];         /* fpu registers */
85         unsigned long   fpcr;           /* fpu control register */
86 };
87
88 struct thread_struct {
89         struct pt_regs          *uregs;         /* userspace register frame */
90         unsigned long           pc;             /* kernel PC */
91         unsigned long           sp;             /* kernel SP */
92         unsigned long           a3;             /* kernel FP */
93         unsigned long           wchan;
94         unsigned long           usp;
95         struct pt_regs          *__frame;
96         unsigned long           fpu_flags;
97 #define THREAD_USING_FPU        0x00000001      /* T if this task is using the FPU */
98 #define THREAD_HAS_FPU          0x00000002      /* T if this task owns the FPU right now */
99         struct fpu_state_struct fpu_state;
100 };
101
102 #define INIT_THREAD                             \
103 {                                               \
104         .uregs          = init_uregs,           \
105         .pc             = 0,                    \
106         .sp             = 0,                    \
107         .a3             = 0,                    \
108         .wchan          = 0,                    \
109         .__frame        = NULL,                 \
110 }
111
112 #define INIT_MMAP \
113 { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, \
114   NULL, NULL }
115
116 /*
117  * do necessary setup to start up a newly executed thread
118  * - need to discard the frame stacked by the kernel thread invoking the execve
119  *   syscall (see RESTORE_ALL macro)
120  */
121 #define start_thread(regs, new_pc, new_sp) do {         \
122         set_fs(USER_DS);                                \
123         __frame = current->thread.uregs;                \
124         __frame->epsw = EPSW_nSL | EPSW_IE | EPSW_IM;   \
125         __frame->pc = new_pc;                           \
126         __frame->sp = new_sp;                           \
127 } while (0)
128
129 /* Free all resources held by a thread. */
130 extern void release_thread(struct task_struct *);
131
132 /* Prepare to copy thread state - unlazy all lazy status */
133 extern void prepare_to_copy(struct task_struct *tsk);
134
135 /*
136  * create a kernel thread without removing it from tasklists
137  */
138 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
139
140 /*
141  * Return saved PC of a blocked thread.
142  */
143 extern unsigned long thread_saved_pc(struct task_struct *tsk);
144
145 unsigned long get_wchan(struct task_struct *p);
146
147 #define task_pt_regs(task) ((task)->thread.uregs)
148 #define KSTK_EIP(task) (task_pt_regs(task)->pc)
149 #define KSTK_ESP(task) (task_pt_regs(task)->sp)
150
151 #define KSTK_TOP(info)                          \
152 ({                                              \
153         (unsigned long)(info) + THREAD_SIZE;    \
154 })
155
156 #define ARCH_HAS_PREFETCH
157 #define ARCH_HAS_PREFETCHW
158
159 static inline void prefetch(const void *x)
160 {
161 #ifdef CONFIG_MN10300_CACHE_ENABLED
162 #ifdef CONFIG_MN10300_PROC_MN103E010
163         asm volatile ("nop; nop; dcpf (%0)" : : "r"(x));
164 #else
165         asm volatile ("dcpf (%0)" : : "r"(x));
166 #endif
167 #endif
168 }
169
170 static inline void prefetchw(const void *x)
171 {
172 #ifdef CONFIG_MN10300_CACHE_ENABLED
173 #ifdef CONFIG_MN10300_PROC_MN103E010
174         asm volatile ("nop; nop; dcpf (%0)" : : "r"(x));
175 #else
176         asm volatile ("dcpf (%0)" : : "r"(x));
177 #endif
178 #endif
179 }
180
181 #endif /* _ASM_PROCESSOR_H */