2005-10-10 08:19:43 +04:00
|
|
|
#ifndef _ASM_POWERPC_PROCESSOR_H
|
|
|
|
#define _ASM_POWERPC_PROCESSOR_H
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
2005-10-10 08:19:43 +04:00
|
|
|
* 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.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
#include <asm/reg.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <linux/compiler.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/types.h>
|
|
|
|
|
2005-11-10 05:37:51 +03:00
|
|
|
/* We do _not_ want to define new machine types at all, those must die
|
|
|
|
* in favor of using the device-tree
|
|
|
|
* -- BenH.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
|
2005-11-10 05:37:51 +03:00
|
|
|
/* PREP sub-platform types see residual.h for these */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define _PREP_Motorola 0x01 /* motorola prep */
|
|
|
|
#define _PREP_Firm 0x02 /* firmworks prep */
|
|
|
|
#define _PREP_IBM 0x00 /* ibm prep */
|
|
|
|
#define _PREP_Bull 0x03 /* bull prep */
|
|
|
|
|
2005-11-10 05:37:51 +03:00
|
|
|
/* CHRP sub-platform types. These are arbitrary */
|
2005-04-17 02:20:36 +04:00
|
|
|
#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 */
|
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
#if defined(__KERNEL__) && defined(CONFIG_PPC32)
|
|
|
|
|
|
|
|
extern int _chrp_type;
|
2005-11-10 05:37:51 +03:00
|
|
|
|
2006-03-28 03:22:10 +04:00
|
|
|
#ifdef CONFIG_PPC_PREP
|
2005-11-10 05:37:51 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* what kind of prep workstation we are */
|
|
|
|
extern int _prep_type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is used to identify the board type from a given PReP board
|
2005-11-10 05:37:51 +03:00
|
|
|
* vendor. Board revision is also made available. This will be moved
|
|
|
|
* elsewhere soon
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
extern unsigned char ucBoardRev;
|
|
|
|
extern unsigned char ucBoardRevMaj, ucBoardRevMin;
|
2005-11-10 05:37:51 +03:00
|
|
|
|
2006-03-28 03:22:10 +04:00
|
|
|
#endif /* CONFIG_PPC_PREP */
|
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
#ifndef CONFIG_PPC_MULTIPLATFORM
|
2005-04-17 02:20:36 +04:00
|
|
|
#define _machine 0
|
|
|
|
#endif /* CONFIG_PPC_MULTIPLATFORM */
|
2006-03-28 16:15:54 +04:00
|
|
|
|
|
|
|
#endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
/*
|
|
|
|
* 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;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
struct task_struct;
|
2005-10-10 08:19:43 +04:00
|
|
|
void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
|
2005-04-17 02:20:36 +04:00
|
|
|
void release_thread(struct task_struct *);
|
|
|
|
|
|
|
|
/* Prepare to copy thread state - unlazy all lazy status */
|
|
|
|
extern void prepare_to_copy(struct task_struct *tsk);
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
/* Create a new kernel thread. */
|
2005-04-17 02:20:36 +04:00
|
|
|
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;
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
#define TASK_SIZE (CONFIG_TASK_SIZE)
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* 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)
|
2005-10-10 08:19:43 +04:00
|
|
|
#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
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long seg;
|
|
|
|
} mm_segment_t;
|
|
|
|
|
|
|
|
struct thread_struct {
|
|
|
|
unsigned long ksp; /* Kernel stack pointer */
|
2005-10-10 08:19:43 +04:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long ksp_vsid;
|
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
struct pt_regs *regs; /* Pointer to saved register state */
|
|
|
|
mm_segment_t fs; /* for get_fs() validation */
|
2005-10-10 08:19:43 +04:00
|
|
|
#ifdef CONFIG_PPC32
|
2005-04-17 02:20:36 +04:00
|
|
|
void *pgdir; /* root of page-table tree */
|
|
|
|
signed long last_syscall;
|
2005-10-10 08:19:43 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
#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 */
|
[PATCH] powerpc: Fix handling of fpscr on 64-bit
The recent merge of fpu.S broken the handling of fpscr for
ARCH=powerpc and CONFIG_PPC64=y. FP registers could be corrupted,
leading to strange random application crashes.
The confusion arises, because the thread_struct has (and requires) a
64-bit area to save the fpscr, because we use load/store double
instructions to get it in to/out of the FPU. However, only the low
32-bits are actually used, so we want to treat it as a 32-bit quantity
when manipulating its bits to avoid extra load/stores on 32-bit. This
patch replaces the current definition with a structure of two 32-bit
quantities (pad and val), to clarify things as much as is possible.
The 'val' field is used when manipulating bits, the structure itself
is used when obtaining the address for loading/unloading the value
from the FPU.
While we're at it, consolidate the 4 (!) almost identical versions of
cvt_fd() and cvt_df() (arch/ppc/kernel/misc.S,
arch/ppc64/kernel/misc.S, arch/powerpc/kernel/misc_32.S,
arch/powerpc/kernel/misc_64.S) into a single version in fpu.S. The
new version takes a pointer to thread_struct and applies the correct
offset itself, rather than a pointer to the fpscr field itself, again
to avoid confusion as to which is the correct field to use.
Finally, this patch makes ARCH=ppc64 also use the consolidated fpu.S
code, which it previously did not.
Built for G5 (ARCH=ppc64 and ARCH=powerpc), 32-bit powermac (ARCH=ppc
and ARCH=powerpc) and Walnut (ARCH=ppc, CONFIG_MATH_EMULATION=y).
Booted on G5 (ARCH=powerpc) and things which previously fell over no
longer do.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-10-27 10:27:25 +04:00
|
|
|
struct { /* fpr ... fpscr must be contiguous */
|
|
|
|
|
|
|
|
unsigned int pad;
|
|
|
|
unsigned int val; /* Floating point status */
|
|
|
|
} fpscr;
|
2005-10-10 08:19:43 +04:00
|
|
|
int fpexc_mode; /* floating-point exception mode */
|
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long start_tb; /* Start purr when proc switched in */
|
|
|
|
unsigned long accum_tb; /* Total accumilated purr for process */
|
|
|
|
#endif
|
|
|
|
unsigned long dabr; /* Data address breakpoint register */
|
2005-04-17 02:20:36 +04:00
|
|
|
#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)
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
|
|
|
|
#ifdef CONFIG_PPC32
|
2005-04-17 02:20:36 +04:00
|
|
|
#define INIT_THREAD { \
|
|
|
|
.ksp = INIT_SP, \
|
|
|
|
.fs = KERNEL_DS, \
|
|
|
|
.pgdir = swapper_pg_dir, \
|
|
|
|
.fpexc_mode = MSR_FE0 | MSR_FE1, \
|
|
|
|
}
|
2005-10-10 08:19:43 +04:00
|
|
|
#else
|
|
|
|
#define INIT_THREAD { \
|
|
|
|
.ksp = INIT_SP, \
|
|
|
|
.regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
|
|
|
|
.fs = KERNEL_DS, \
|
|
|
|
.fpr = {0}, \
|
[PATCH] powerpc: Fix handling of fpscr on 64-bit
The recent merge of fpu.S broken the handling of fpscr for
ARCH=powerpc and CONFIG_PPC64=y. FP registers could be corrupted,
leading to strange random application crashes.
The confusion arises, because the thread_struct has (and requires) a
64-bit area to save the fpscr, because we use load/store double
instructions to get it in to/out of the FPU. However, only the low
32-bits are actually used, so we want to treat it as a 32-bit quantity
when manipulating its bits to avoid extra load/stores on 32-bit. This
patch replaces the current definition with a structure of two 32-bit
quantities (pad and val), to clarify things as much as is possible.
The 'val' field is used when manipulating bits, the structure itself
is used when obtaining the address for loading/unloading the value
from the FPU.
While we're at it, consolidate the 4 (!) almost identical versions of
cvt_fd() and cvt_df() (arch/ppc/kernel/misc.S,
arch/ppc64/kernel/misc.S, arch/powerpc/kernel/misc_32.S,
arch/powerpc/kernel/misc_64.S) into a single version in fpu.S. The
new version takes a pointer to thread_struct and applies the correct
offset itself, rather than a pointer to the fpscr field itself, again
to avoid confusion as to which is the correct field to use.
Finally, this patch makes ARCH=ppc64 also use the consolidated fpu.S
code, which it previously did not.
Built for G5 (ARCH=ppc64 and ARCH=powerpc), 32-bit powermac (ARCH=ppc
and ARCH=powerpc) and Walnut (ARCH=ppc, CONFIG_MATH_EMULATION=y).
Booted on G5 (ARCH=powerpc) and things which previously fell over no
longer do.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-10-27 10:27:25 +04:00
|
|
|
.fpscr = { .val = 0, }, \
|
2005-10-10 08:19:43 +04:00
|
|
|
.fpexc_mode = MSR_FE0|MSR_FE1, \
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return saved PC of a blocked thread. For now, this is the "user" PC
|
|
|
|
*/
|
2005-10-10 08:19:43 +04:00
|
|
|
#define thread_saved_pc(tsk) \
|
|
|
|
((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
unsigned long get_wchan(struct task_struct *p);
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
#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)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* Get/set floating-point exception mode */
|
2005-10-10 08:19:43 +04:00
|
|
|
#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
|
|
|
|
#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
|
|
|
|
extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
static inline unsigned int __unpack_fe01(unsigned long msr_bits)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
|
|
|
|
}
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
static inline unsigned long __pack_fe01(unsigned int fpmode)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
|
|
|
|
}
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
#define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0)
|
|
|
|
#else
|
2005-04-17 02:20:36 +04:00
|
|
|
#define cpu_relax() barrier()
|
2005-10-10 08:19:43 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-03-27 04:46:18 +04:00
|
|
|
/* 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);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Prefetch macros.
|
|
|
|
*/
|
|
|
|
#define ARCH_HAS_PREFETCH
|
|
|
|
#define ARCH_HAS_PREFETCHW
|
|
|
|
#define ARCH_HAS_SPINLOCK_PREFETCH
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
static inline void prefetch(const void *x)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-10-10 08:19:43 +04:00
|
|
|
if (unlikely(!x))
|
|
|
|
return;
|
|
|
|
|
|
|
|
__asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
static inline void prefetchw(const void *x)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-10-10 08:19:43 +04:00
|
|
|
if (unlikely(!x))
|
|
|
|
return;
|
|
|
|
|
|
|
|
__asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define spin_lock_prefetch(x) prefetchw(x)
|
|
|
|
|
2005-10-10 08:19:43 +04:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
#define HAVE_ARCH_PICK_MMAP_LAYOUT
|
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
2005-10-10 08:19:43 +04:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_POWERPC_PROCESSOR_H */
|