1 #ifndef _ASM_POWERPC_PROCESSOR_H
2 #define _ASM_POWERPC_PROCESSOR_H
5 * Copyright (C) 2001 PPC 64 Team, IBM Corp
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
13 #include <linux/config.h>
17 #include <linux/compiler.h>
18 #include <asm/ptrace.h>
19 #include <asm/types.h>
21 #include <asm/systemcfg.h>
25 /* 32-bit platform types */
26 /* We only need to define a new _MACH_xxx for machines which are part of
27 * a configuration which supports more than one type of different machine.
28 * This is currently limited to CONFIG_PPC_MULTIPLATFORM and CHRP/PReP/PMac.
31 #define _MACH_prep 0x00000001
32 #define _MACH_Pmac 0x00000002 /* pmac or pmac clone (non-chrp) */
33 #define _MACH_chrp 0x00000004 /* chrp machine */
35 /* see residual.h for these */
36 #define _PREP_Motorola 0x01 /* motorola prep */
37 #define _PREP_Firm 0x02 /* firmworks prep */
38 #define _PREP_IBM 0x00 /* ibm prep */
39 #define _PREP_Bull 0x03 /* bull prep */
41 /* these are arbitrary */
42 #define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */
43 #define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */
44 #define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */
46 #ifdef CONFIG_PPC_MULTIPLATFORM
49 /* what kind of prep workstation we are */
50 extern int _prep_type;
51 extern int _chrp_type;
54 * This is used to identify the board type from a given PReP board
55 * vendor. Board revision is also made available.
57 extern unsigned char ucSystemType;
58 extern unsigned char ucBoardRev;
59 extern unsigned char ucBoardRevMaj, ucBoardRevMin;
62 #endif /* CONFIG_PPC_MULTIPLATFORM */
63 #endif /* CONFIG_PPC32 */
66 /* Platforms supported by PPC64 */
67 #define PLATFORM_PSERIES 0x0100
68 #define PLATFORM_PSERIES_LPAR 0x0101
69 #define PLATFORM_ISERIES_LPAR 0x0201
70 #define PLATFORM_LPAR 0x0001
71 #define PLATFORM_POWERMAC 0x0400
72 #define PLATFORM_MAPLE 0x0500
73 #define PLATFORM_BPA 0x1000
75 /* Compatibility with drivers coming from PPC32 world */
76 #define _machine (systemcfg->platform)
77 #define _MACH_Pmac PLATFORM_POWERMAC
81 * Default implementation of macro that returns current
82 * instruction pointer ("program counter").
84 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
86 /* Macros for adjusting thread priority (hardware multi-threading) */
87 #define HMT_very_low() asm volatile("or 31,31,31 # very low priority")
88 #define HMT_low() asm volatile("or 1,1,1 # low priority")
89 #define HMT_medium_low() asm volatile("or 6,6,6 # medium low priority")
90 #define HMT_medium() asm volatile("or 2,2,2 # medium priority")
91 #define HMT_medium_high() asm volatile("or 5,5,5 # medium high priority")
92 #define HMT_high() asm volatile("or 3,3,3 # high priority")
99 void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
100 void release_thread(struct task_struct *);
102 /* Prepare to copy thread state - unlazy all lazy status */
103 extern void prepare_to_copy(struct task_struct *tsk);
105 /* Create a new kernel thread. */
106 extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
108 /* Lazy FPU handling on uni-processor */
109 extern struct task_struct *last_task_used_math;
110 extern struct task_struct *last_task_used_altivec;
111 extern struct task_struct *last_task_used_spe;
114 #define TASK_SIZE (CONFIG_TASK_SIZE)
116 /* This decides where the kernel will search for a free chunk of vm
117 * space during mmap's.
119 #define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
123 /* 64-bit user address space is 44-bits (16TB user VM) */
124 #define TASK_SIZE_USER64 (0x0000100000000000UL)
127 * 32-bit user address space is 4GB - 1 page
128 * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT
130 #define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE))
132 #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
133 TASK_SIZE_USER32 : TASK_SIZE_USER64)
135 /* This decides where the kernel will search for a free chunk of vm
136 * space during mmap's.
138 #define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
139 #define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
141 #define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \
142 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
149 struct thread_struct {
150 unsigned long ksp; /* Kernel stack pointer */
152 unsigned long ksp_vsid;
154 struct pt_regs *regs; /* Pointer to saved register state */
155 mm_segment_t fs; /* for get_fs() validation */
157 void *pgdir; /* root of page-table tree */
158 signed long last_syscall;
160 #if defined(CONFIG_4xx) || defined (CONFIG_BOOKE)
161 unsigned long dbcr0; /* debug control register values */
164 double fpr[32]; /* Complete floating point set */
165 struct { /* fpr ... fpscr must be contiguous */
168 unsigned int val; /* Floating point status */
170 int fpexc_mode; /* floating-point exception mode */
172 unsigned long start_tb; /* Start purr when proc switched in */
173 unsigned long accum_tb; /* Total accumilated purr for process */
174 unsigned long vdso_base; /* base of the vDSO library */
176 unsigned long dabr; /* Data address breakpoint register */
177 #ifdef CONFIG_ALTIVEC
178 /* Complete AltiVec register set */
179 vector128 vr[32] __attribute((aligned(16)));
181 vector128 vscr __attribute((aligned(16)));
182 unsigned long vrsave;
183 int used_vr; /* set if process has used altivec */
184 #endif /* CONFIG_ALTIVEC */
186 unsigned long evr[32]; /* upper 32-bits of SPE regs */
187 u64 acc; /* Accumulator */
188 unsigned long spefscr; /* SPE & eFP status */
189 int used_spe; /* set if process has used spe */
190 #endif /* CONFIG_SPE */
193 #define ARCH_MIN_TASKALIGN 16
195 #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
199 #define INIT_THREAD { \
202 .pgdir = swapper_pg_dir, \
203 .fpexc_mode = MSR_FE0 | MSR_FE1, \
206 #define INIT_THREAD { \
208 .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
211 .fpscr = { .val = 0, }, \
212 .fpexc_mode = MSR_FE0|MSR_FE1, \
217 * Return saved PC of a blocked thread. For now, this is the "user" PC
219 #define thread_saved_pc(tsk) \
220 ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
222 unsigned long get_wchan(struct task_struct *p);
224 #define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
225 #define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
227 /* Get/set floating-point exception mode */
228 #define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
229 #define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
231 extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
232 extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
234 static inline unsigned int __unpack_fe01(unsigned long msr_bits)
236 return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
239 static inline unsigned long __pack_fe01(unsigned int fpmode)
241 return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
245 #define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0)
247 #define cpu_relax() barrier()
253 #define ARCH_HAS_PREFETCH
254 #define ARCH_HAS_PREFETCHW
255 #define ARCH_HAS_SPINLOCK_PREFETCH
257 static inline void prefetch(const void *x)
262 __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
265 static inline void prefetchw(const void *x)
270 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
273 #define spin_lock_prefetch(x) prefetchw(x)
276 #define HAVE_ARCH_PICK_MMAP_LAYOUT
279 #endif /* __KERNEL__ */
280 #endif /* __ASSEMBLY__ */
281 #endif /* _ASM_POWERPC_PROCESSOR_H */