Blame view

include/asm-powerpc/processor.h 7.78 KB
9f04b9e32   Paul Mackerras   powerpc: Merged p...
1
2
  #ifndef _ASM_POWERPC_PROCESSOR_H
  #define _ASM_POWERPC_PROCESSOR_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
4
  
  /*
9f04b9e32   Paul Mackerras   powerpc: Merged p...
5
6
7
8
9
10
   * Copyright (C) 2001 PPC 64 Team, IBM Corp
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version
   * 2 of the License, or (at your option) any later version.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
12

9f04b9e32   Paul Mackerras   powerpc: Merged p...
13
  #include <asm/reg.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14

9f04b9e32   Paul Mackerras   powerpc: Merged p...
15
16
  #ifndef __ASSEMBLY__
  #include <linux/compiler.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
  #include <asm/ptrace.h>
  #include <asm/types.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19

799d6046d   Paul Mackerras   [PATCH] powerpc: ...
20
21
22
  /* We do _not_ want to define new machine types at all, those must die
   * in favor of using the device-tree
   * -- BenH.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24

799d6046d   Paul Mackerras   [PATCH] powerpc: ...
25
  /* PREP sub-platform types see residual.h for these */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
29
  #define _PREP_Motorola	0x01	/* motorola prep */
  #define _PREP_Firm	0x02	/* firmworks prep */
  #define _PREP_IBM	0x00	/* ibm prep */
  #define _PREP_Bull	0x03	/* bull prep */
799d6046d   Paul Mackerras   [PATCH] powerpc: ...
30
  /* CHRP sub-platform types. These are arbitrary */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
  #define _CHRP_Motorola	0x04	/* motorola chrp, the cobra */
  #define _CHRP_IBM	0x05	/* IBM chrp, the longtrail and longtrail 2 */
  #define _CHRP_Pegasos	0x06	/* Genesi/bplan's Pegasos and Pegasos2 */
26c5032ea   Benjamin Herrenschmidt   [POWERPC] Add bri...
34
  #define _CHRP_briq	0x07	/* TotalImpact's briQ */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35

e8222502e   Benjamin Herrenschmidt   [PATCH] powerpc: ...
36
37
38
  #if defined(__KERNEL__) && defined(CONFIG_PPC32)
  
  extern int _chrp_type;
799d6046d   Paul Mackerras   [PATCH] powerpc: ...
39

0a26b1364   Paul Mackerras   ppc: Remove CHRP,...
40
  #ifdef CONFIG_PPC_PREP
799d6046d   Paul Mackerras   [PATCH] powerpc: ...
41

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42
43
  /* what kind of prep workstation we are */
  extern int _prep_type;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44

0a26b1364   Paul Mackerras   ppc: Remove CHRP,...
45
  #endif /* CONFIG_PPC_PREP */
e8222502e   Benjamin Herrenschmidt   [PATCH] powerpc: ...
46
  #endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  /*
   * Default implementation of macro that returns current
   * instruction pointer ("program counter").
   */
  #define current_text_addr() ({ __label__ _l; _l: &&_l;})
  
  /* Macros for adjusting thread priority (hardware multi-threading) */
  #define HMT_very_low()   asm volatile("or 31,31,31   # very low priority")
  #define HMT_low()	 asm volatile("or 1,1,1	     # low priority")
  #define HMT_medium_low() asm volatile("or 6,6,6      # medium low priority")
  #define HMT_medium()	 asm volatile("or 2,2,2	     # medium priority")
  #define HMT_medium_high() asm volatile("or 5,5,5      # medium high priority")
  #define HMT_high()	 asm volatile("or 3,3,3	     # high priority")
  
  #ifdef __KERNEL__
  
  extern int have_of;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
65
  
  struct task_struct;
9f04b9e32   Paul Mackerras   powerpc: Merged p...
66
  void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
68
69
70
  void release_thread(struct task_struct *);
  
  /* Prepare to copy thread state - unlazy all lazy status */
  extern void prepare_to_copy(struct task_struct *tsk);
9f04b9e32   Paul Mackerras   powerpc: Merged p...
71
  /* Create a new kernel thread. */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
74
75
76
77
  extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
  
  /* Lazy FPU handling on uni-processor */
  extern struct task_struct *last_task_used_math;
  extern struct task_struct *last_task_used_altivec;
  extern struct task_struct *last_task_used_spe;
9f04b9e32   Paul Mackerras   powerpc: Merged p...
78
79
  #ifdef CONFIG_PPC32
  #define TASK_SIZE	(CONFIG_TASK_SIZE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
80
81
82
83
  /* This decides where the kernel will search for a free chunk of vm
   * space during mmap's.
   */
  #define TASK_UNMAPPED_BASE	(TASK_SIZE / 8 * 3)
9f04b9e32   Paul Mackerras   powerpc: Merged p...
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  #endif
  
  #ifdef CONFIG_PPC64
  /* 64-bit user address space is 44-bits (16TB user VM) */
  #define TASK_SIZE_USER64 (0x0000100000000000UL)
  
  /* 
   * 32-bit user address space is 4GB - 1 page 
   * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT
   */
  #define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE))
  
  #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
  		TASK_SIZE_USER32 : TASK_SIZE_USER64)
  
  /* This decides where the kernel will search for a free chunk of vm
   * space during mmap's.
   */
  #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
  #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
  
  #define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \
  		TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
108
109
110
111
112
113
114
  
  typedef struct {
  	unsigned long seg;
  } mm_segment_t;
  
  struct thread_struct {
  	unsigned long	ksp;		/* Kernel stack pointer */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
115
116
117
  #ifdef CONFIG_PPC64
  	unsigned long	ksp_vsid;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
119
  	struct pt_regs	*regs;		/* Pointer to saved register state */
  	mm_segment_t	fs;		/* for get_fs() validation */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
120
  #ifdef CONFIG_PPC32
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
121
  	void		*pgdir;		/* root of page-table tree */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
122
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
123
124
125
126
127
  #if defined(CONFIG_4xx) || defined (CONFIG_BOOKE)
  	unsigned long	dbcr0;		/* debug control register values */
  	unsigned long	dbcr1;
  #endif
  	double		fpr[32];	/* Complete floating point set */
25c8a78b1   David Gibson   [PATCH] powerpc: ...
128
129
130
131
132
  	struct {			/* fpr ... fpscr must be contiguous */
  
  		unsigned int pad;
  		unsigned int val;	/* Floating point status */
  	} fpscr;
9f04b9e32   Paul Mackerras   powerpc: Merged p...
133
  	int		fpexc_mode;	/* floating-point exception mode */
e9370ae15   Paul Mackerras   [PATCH] powerpc: ...
134
  	unsigned int	align_ctl;	/* alignment handling control */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
135
136
137
  #ifdef CONFIG_PPC64
  	unsigned long	start_tb;	/* Start purr when proc switched in */
  	unsigned long	accum_tb;	/* Total accumilated purr for process */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
138
139
  #endif
  	unsigned long	dabr;		/* Data address breakpoint register */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
  #ifdef CONFIG_ALTIVEC
  	/* Complete AltiVec register set */
  	vector128	vr[32] __attribute((aligned(16)));
  	/* AltiVec status */
  	vector128	vscr __attribute((aligned(16)));
  	unsigned long	vrsave;
  	int		used_vr;	/* set if process has used altivec */
  #endif /* CONFIG_ALTIVEC */
  #ifdef CONFIG_SPE
  	unsigned long	evr[32];	/* upper 32-bits of SPE regs */
  	u64		acc;		/* Accumulator */
  	unsigned long	spefscr;	/* SPE & eFP status */
  	int		used_spe;	/* set if process has used spe */
  #endif /* CONFIG_SPE */
  };
  
  #define ARCH_MIN_TASKALIGN 16
  
  #define INIT_SP		(sizeof(init_stack) + (unsigned long) &init_stack)
9f04b9e32   Paul Mackerras   powerpc: Merged p...
159
160
  
  #ifdef CONFIG_PPC32
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
161
162
163
164
165
166
  #define INIT_THREAD { \
  	.ksp = INIT_SP, \
  	.fs = KERNEL_DS, \
  	.pgdir = swapper_pg_dir, \
  	.fpexc_mode = MSR_FE0 | MSR_FE1, \
  }
9f04b9e32   Paul Mackerras   powerpc: Merged p...
167
168
169
170
171
172
  #else
  #define INIT_THREAD  { \
  	.ksp = INIT_SP, \
  	.regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
  	.fs = KERNEL_DS, \
  	.fpr = {0}, \
25c8a78b1   David Gibson   [PATCH] powerpc: ...
173
  	.fpscr = { .val = 0, }, \
ddf5f75a1   Arnd Bergmann   [POWERPC] disable...
174
  	.fpexc_mode = 0, \
9f04b9e32   Paul Mackerras   powerpc: Merged p...
175
176
  }
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
177
178
179
180
  
  /*
   * Return saved PC of a blocked thread. For now, this is the "user" PC
   */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
181
182
  #define thread_saved_pc(tsk)    \
          ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
183
184
  
  unsigned long get_wchan(struct task_struct *p);
9f04b9e32   Paul Mackerras   powerpc: Merged p...
185
186
  #define KSTK_EIP(tsk)  ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
  #define KSTK_ESP(tsk)  ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
187
188
  
  /* Get/set floating-point exception mode */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
189
190
  #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
  #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
191
192
193
  
  extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
  extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
fab5db97e   Paul Mackerras   [PATCH] powerpc: ...
194
195
196
197
198
  #define GET_ENDIAN(tsk, adr) get_endian((tsk), (adr))
  #define SET_ENDIAN(tsk, val) set_endian((tsk), (val))
  
  extern int get_endian(struct task_struct *tsk, unsigned long adr);
  extern int set_endian(struct task_struct *tsk, unsigned int val);
e9370ae15   Paul Mackerras   [PATCH] powerpc: ...
199
200
201
202
203
  #define GET_UNALIGN_CTL(tsk, adr)	get_unalign_ctl((tsk), (adr))
  #define SET_UNALIGN_CTL(tsk, val)	set_unalign_ctl((tsk), (val))
  
  extern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr);
  extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val);
9f04b9e32   Paul Mackerras   powerpc: Merged p...
204
  static inline unsigned int __unpack_fe01(unsigned long msr_bits)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
205
206
207
  {
  	return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
  }
9f04b9e32   Paul Mackerras   powerpc: Merged p...
208
  static inline unsigned long __pack_fe01(unsigned int fpmode)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
209
210
211
  {
  	return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
  }
9f04b9e32   Paul Mackerras   powerpc: Merged p...
212
213
214
  #ifdef CONFIG_PPC64
  #define cpu_relax()	do { HMT_low(); HMT_medium(); barrier(); } while (0)
  #else
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
215
  #define cpu_relax()	barrier()
9f04b9e32   Paul Mackerras   powerpc: Merged p...
216
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
217

2f25194db   Anton Blanchard   [PATCH] powerpc: ...
218
219
220
  /* Check that a certain kernel stack pointer is valid in task_struct p */
  int validate_sp(unsigned long sp, struct task_struct *p,
                         unsigned long nbytes);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
221
222
223
224
225
226
  /*
   * Prefetch macros.
   */
  #define ARCH_HAS_PREFETCH
  #define ARCH_HAS_PREFETCHW
  #define ARCH_HAS_SPINLOCK_PREFETCH
9f04b9e32   Paul Mackerras   powerpc: Merged p...
227
  static inline void prefetch(const void *x)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
228
  {
9f04b9e32   Paul Mackerras   powerpc: Merged p...
229
230
231
232
  	if (unlikely(!x))
  		return;
  
  	__asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
233
  }
9f04b9e32   Paul Mackerras   powerpc: Merged p...
234
  static inline void prefetchw(const void *x)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
235
  {
9f04b9e32   Paul Mackerras   powerpc: Merged p...
236
237
238
239
  	if (unlikely(!x))
  		return;
  
  	__asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
240
241
242
  }
  
  #define spin_lock_prefetch(x)	prefetchw(x)
9f04b9e32   Paul Mackerras   powerpc: Merged p...
243
244
245
  #ifdef CONFIG_PPC64
  #define HAVE_ARCH_PICK_MMAP_LAYOUT
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
246

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
247
  #endif /* __KERNEL__ */
9f04b9e32   Paul Mackerras   powerpc: Merged p...
248
249
  #endif /* __ASSEMBLY__ */
  #endif /* _ASM_POWERPC_PROCESSOR_H */