18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_PROCESSOR_H 38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_PROCESSOR_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Copyright (C) 2001 PPC 64 Team, IBM Corp 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <asm/reg.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifdef CONFIG_VSX 128c2ecf20Sopenharmony_ci#define TS_FPRWIDTH 2 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN__ 158c2ecf20Sopenharmony_ci#define TS_FPROFFSET 0 168c2ecf20Sopenharmony_ci#define TS_VSRLOWOFFSET 1 178c2ecf20Sopenharmony_ci#else 188c2ecf20Sopenharmony_ci#define TS_FPROFFSET 1 198c2ecf20Sopenharmony_ci#define TS_VSRLOWOFFSET 0 208c2ecf20Sopenharmony_ci#endif 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#else 238c2ecf20Sopenharmony_ci#define TS_FPRWIDTH 1 248c2ecf20Sopenharmony_ci#define TS_FPROFFSET 0 258c2ecf20Sopenharmony_ci#endif 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64 288c2ecf20Sopenharmony_ci/* Default SMT priority is set to 3. Use 11- 13bits to save priority. */ 298c2ecf20Sopenharmony_ci#define PPR_PRIORITY 3 308c2ecf20Sopenharmony_ci#ifdef __ASSEMBLY__ 318c2ecf20Sopenharmony_ci#define DEFAULT_PPR (PPR_PRIORITY << 50) 328c2ecf20Sopenharmony_ci#else 338c2ecf20Sopenharmony_ci#define DEFAULT_PPR ((u64)PPR_PRIORITY << 50) 348c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 358c2ecf20Sopenharmony_ci#endif /* CONFIG_PPC64 */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 388c2ecf20Sopenharmony_ci#include <linux/types.h> 398c2ecf20Sopenharmony_ci#include <linux/thread_info.h> 408c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 418c2ecf20Sopenharmony_ci#include <asm/hw_breakpoint.h> 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* We do _not_ want to define new machine types at all, those must die 448c2ecf20Sopenharmony_ci * in favor of using the device-tree 458c2ecf20Sopenharmony_ci * -- BenH. 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* PREP sub-platform types. Unused */ 498c2ecf20Sopenharmony_ci#define _PREP_Motorola 0x01 /* motorola prep */ 508c2ecf20Sopenharmony_ci#define _PREP_Firm 0x02 /* firmworks prep */ 518c2ecf20Sopenharmony_ci#define _PREP_IBM 0x00 /* ibm prep */ 528c2ecf20Sopenharmony_ci#define _PREP_Bull 0x03 /* bull prep */ 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* CHRP sub-platform types. These are arbitrary */ 558c2ecf20Sopenharmony_ci#define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */ 568c2ecf20Sopenharmony_ci#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */ 578c2ecf20Sopenharmony_ci#define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */ 588c2ecf20Sopenharmony_ci#define _CHRP_briq 0x07 /* TotalImpact's briQ */ 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#if defined(__KERNEL__) && defined(CONFIG_PPC32) 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciextern int _chrp_type; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* Macros for adjusting thread priority (hardware multi-threading) */ 678c2ecf20Sopenharmony_ci#define HMT_very_low() asm volatile("or 31,31,31 # very low priority") 688c2ecf20Sopenharmony_ci#define HMT_low() asm volatile("or 1,1,1 # low priority") 698c2ecf20Sopenharmony_ci#define HMT_medium_low() asm volatile("or 6,6,6 # medium low priority") 708c2ecf20Sopenharmony_ci#define HMT_medium() asm volatile("or 2,2,2 # medium priority") 718c2ecf20Sopenharmony_ci#define HMT_medium_high() asm volatile("or 5,5,5 # medium high priority") 728c2ecf20Sopenharmony_ci#define HMT_high() asm volatile("or 3,3,3 # high priority") 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64 778c2ecf20Sopenharmony_ci#include <asm/task_size_64.h> 788c2ecf20Sopenharmony_ci#else 798c2ecf20Sopenharmony_ci#include <asm/task_size_32.h> 808c2ecf20Sopenharmony_ci#endif 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistruct task_struct; 838c2ecf20Sopenharmony_civoid start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp); 848c2ecf20Sopenharmony_civoid release_thread(struct task_struct *); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET] 878c2ecf20Sopenharmony_ci#define TS_CKFPR(i) ckfp_state.fpr[i][TS_FPROFFSET] 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* FP and VSX 0-31 register set */ 908c2ecf20Sopenharmony_cistruct thread_fp_state { 918c2ecf20Sopenharmony_ci u64 fpr[32][TS_FPRWIDTH] __attribute__((aligned(16))); 928c2ecf20Sopenharmony_ci u64 fpscr; /* Floating point status */ 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci/* Complete AltiVec register set including VSCR */ 968c2ecf20Sopenharmony_cistruct thread_vr_state { 978c2ecf20Sopenharmony_ci vector128 vr[32] __attribute__((aligned(16))); 988c2ecf20Sopenharmony_ci vector128 vscr __attribute__((aligned(16))); 998c2ecf20Sopenharmony_ci}; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cistruct debug_reg { 1028c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_ADV_DEBUG_REGS 1038c2ecf20Sopenharmony_ci /* 1048c2ecf20Sopenharmony_ci * The following help to manage the use of Debug Control Registers 1058c2ecf20Sopenharmony_ci * om the BookE platforms. 1068c2ecf20Sopenharmony_ci */ 1078c2ecf20Sopenharmony_ci uint32_t dbcr0; 1088c2ecf20Sopenharmony_ci uint32_t dbcr1; 1098c2ecf20Sopenharmony_ci#ifdef CONFIG_BOOKE 1108c2ecf20Sopenharmony_ci uint32_t dbcr2; 1118c2ecf20Sopenharmony_ci#endif 1128c2ecf20Sopenharmony_ci /* 1138c2ecf20Sopenharmony_ci * The stored value of the DBSR register will be the value at the 1148c2ecf20Sopenharmony_ci * last debug interrupt. This register can only be read from the 1158c2ecf20Sopenharmony_ci * user (will never be written to) and has value while helping to 1168c2ecf20Sopenharmony_ci * describe the reason for the last debug trap. Torez 1178c2ecf20Sopenharmony_ci */ 1188c2ecf20Sopenharmony_ci uint32_t dbsr; 1198c2ecf20Sopenharmony_ci /* 1208c2ecf20Sopenharmony_ci * The following will contain addresses used by debug applications 1218c2ecf20Sopenharmony_ci * to help trace and trap on particular address locations. 1228c2ecf20Sopenharmony_ci * The bits in the Debug Control Registers above help define which 1238c2ecf20Sopenharmony_ci * of the following registers will contain valid data and/or addresses. 1248c2ecf20Sopenharmony_ci */ 1258c2ecf20Sopenharmony_ci unsigned long iac1; 1268c2ecf20Sopenharmony_ci unsigned long iac2; 1278c2ecf20Sopenharmony_ci#if CONFIG_PPC_ADV_DEBUG_IACS > 2 1288c2ecf20Sopenharmony_ci unsigned long iac3; 1298c2ecf20Sopenharmony_ci unsigned long iac4; 1308c2ecf20Sopenharmony_ci#endif 1318c2ecf20Sopenharmony_ci unsigned long dac1; 1328c2ecf20Sopenharmony_ci unsigned long dac2; 1338c2ecf20Sopenharmony_ci#if CONFIG_PPC_ADV_DEBUG_DVCS > 0 1348c2ecf20Sopenharmony_ci unsigned long dvc1; 1358c2ecf20Sopenharmony_ci unsigned long dvc2; 1368c2ecf20Sopenharmony_ci#endif 1378c2ecf20Sopenharmony_ci#endif 1388c2ecf20Sopenharmony_ci}; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_cistruct thread_struct { 1418c2ecf20Sopenharmony_ci unsigned long ksp; /* Kernel stack pointer */ 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64 1448c2ecf20Sopenharmony_ci unsigned long ksp_vsid; 1458c2ecf20Sopenharmony_ci#endif 1468c2ecf20Sopenharmony_ci struct pt_regs *regs; /* Pointer to saved register state */ 1478c2ecf20Sopenharmony_ci#ifdef CONFIG_BOOKE 1488c2ecf20Sopenharmony_ci /* BookE base exception scratch space; align on cacheline */ 1498c2ecf20Sopenharmony_ci unsigned long normsave[8] ____cacheline_aligned; 1508c2ecf20Sopenharmony_ci#endif 1518c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC32 1528c2ecf20Sopenharmony_ci void *pgdir; /* root of page-table tree */ 1538c2ecf20Sopenharmony_ci unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */ 1548c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_RTAS 1558c2ecf20Sopenharmony_ci unsigned long rtas_sp; /* stack pointer for when in RTAS */ 1568c2ecf20Sopenharmony_ci#endif 1578c2ecf20Sopenharmony_ci#endif 1588c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC_BOOK3S_32) && defined(CONFIG_PPC_KUAP) 1598c2ecf20Sopenharmony_ci unsigned long kuap; /* opened segments for user access */ 1608c2ecf20Sopenharmony_ci#endif 1618c2ecf20Sopenharmony_ci#ifdef CONFIG_VMAP_STACK 1628c2ecf20Sopenharmony_ci unsigned long srr0; 1638c2ecf20Sopenharmony_ci unsigned long srr1; 1648c2ecf20Sopenharmony_ci unsigned long dar; 1658c2ecf20Sopenharmony_ci unsigned long dsisr; 1668c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S_32 1678c2ecf20Sopenharmony_ci unsigned long r0, r3, r4, r5, r6, r8, r9, r11; 1688c2ecf20Sopenharmony_ci unsigned long lr, ctr; 1698c2ecf20Sopenharmony_ci#endif 1708c2ecf20Sopenharmony_ci#endif 1718c2ecf20Sopenharmony_ci /* Debug Registers */ 1728c2ecf20Sopenharmony_ci struct debug_reg debug; 1738c2ecf20Sopenharmony_ci struct thread_fp_state fp_state; 1748c2ecf20Sopenharmony_ci struct thread_fp_state *fp_save_area; 1758c2ecf20Sopenharmony_ci int fpexc_mode; /* floating-point exception mode */ 1768c2ecf20Sopenharmony_ci unsigned int align_ctl; /* alignment handling control */ 1778c2ecf20Sopenharmony_ci#ifdef CONFIG_HAVE_HW_BREAKPOINT 1788c2ecf20Sopenharmony_ci struct perf_event *ptrace_bps[HBP_NUM_MAX]; 1798c2ecf20Sopenharmony_ci /* 1808c2ecf20Sopenharmony_ci * Helps identify source of single-step exception and subsequent 1818c2ecf20Sopenharmony_ci * hw-breakpoint enablement 1828c2ecf20Sopenharmony_ci */ 1838c2ecf20Sopenharmony_ci struct perf_event *last_hit_ubp[HBP_NUM_MAX]; 1848c2ecf20Sopenharmony_ci#endif /* CONFIG_HAVE_HW_BREAKPOINT */ 1858c2ecf20Sopenharmony_ci struct arch_hw_breakpoint hw_brk[HBP_NUM_MAX]; /* hardware breakpoint info */ 1868c2ecf20Sopenharmony_ci unsigned long trap_nr; /* last trap # on this thread */ 1878c2ecf20Sopenharmony_ci u8 load_slb; /* Ages out SLB preload cache entries */ 1888c2ecf20Sopenharmony_ci u8 load_fp; 1898c2ecf20Sopenharmony_ci#ifdef CONFIG_ALTIVEC 1908c2ecf20Sopenharmony_ci u8 load_vec; 1918c2ecf20Sopenharmony_ci struct thread_vr_state vr_state; 1928c2ecf20Sopenharmony_ci struct thread_vr_state *vr_save_area; 1938c2ecf20Sopenharmony_ci unsigned long vrsave; 1948c2ecf20Sopenharmony_ci int used_vr; /* set if process has used altivec */ 1958c2ecf20Sopenharmony_ci#endif /* CONFIG_ALTIVEC */ 1968c2ecf20Sopenharmony_ci#ifdef CONFIG_VSX 1978c2ecf20Sopenharmony_ci /* VSR status */ 1988c2ecf20Sopenharmony_ci int used_vsr; /* set if process has used VSX */ 1998c2ecf20Sopenharmony_ci#endif /* CONFIG_VSX */ 2008c2ecf20Sopenharmony_ci#ifdef CONFIG_SPE 2018c2ecf20Sopenharmony_ci unsigned long evr[32]; /* upper 32-bits of SPE regs */ 2028c2ecf20Sopenharmony_ci u64 acc; /* Accumulator */ 2038c2ecf20Sopenharmony_ci unsigned long spefscr; /* SPE & eFP status */ 2048c2ecf20Sopenharmony_ci unsigned long spefscr_last; /* SPEFSCR value on last prctl 2058c2ecf20Sopenharmony_ci call or trap return */ 2068c2ecf20Sopenharmony_ci int used_spe; /* set if process has used spe */ 2078c2ecf20Sopenharmony_ci#endif /* CONFIG_SPE */ 2088c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 2098c2ecf20Sopenharmony_ci u8 load_tm; 2108c2ecf20Sopenharmony_ci u64 tm_tfhar; /* Transaction fail handler addr */ 2118c2ecf20Sopenharmony_ci u64 tm_texasr; /* Transaction exception & summary */ 2128c2ecf20Sopenharmony_ci u64 tm_tfiar; /* Transaction fail instr address reg */ 2138c2ecf20Sopenharmony_ci struct pt_regs ckpt_regs; /* Checkpointed registers */ 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci unsigned long tm_tar; 2168c2ecf20Sopenharmony_ci unsigned long tm_ppr; 2178c2ecf20Sopenharmony_ci unsigned long tm_dscr; 2188c2ecf20Sopenharmony_ci unsigned long tm_amr; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci /* 2218c2ecf20Sopenharmony_ci * Checkpointed FP and VSX 0-31 register set. 2228c2ecf20Sopenharmony_ci * 2238c2ecf20Sopenharmony_ci * When a transaction is active/signalled/scheduled etc., *regs is the 2248c2ecf20Sopenharmony_ci * most recent set of/speculated GPRs with ckpt_regs being the older 2258c2ecf20Sopenharmony_ci * checkpointed regs to which we roll back if transaction aborts. 2268c2ecf20Sopenharmony_ci * 2278c2ecf20Sopenharmony_ci * These are analogous to how ckpt_regs and pt_regs work 2288c2ecf20Sopenharmony_ci */ 2298c2ecf20Sopenharmony_ci struct thread_fp_state ckfp_state; /* Checkpointed FP state */ 2308c2ecf20Sopenharmony_ci struct thread_vr_state ckvr_state; /* Checkpointed VR state */ 2318c2ecf20Sopenharmony_ci unsigned long ckvrsave; /* Checkpointed VRSAVE */ 2328c2ecf20Sopenharmony_ci#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ 2338c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_MEM_KEYS 2348c2ecf20Sopenharmony_ci unsigned long amr; 2358c2ecf20Sopenharmony_ci unsigned long iamr; 2368c2ecf20Sopenharmony_ci#endif 2378c2ecf20Sopenharmony_ci#ifdef CONFIG_KVM_BOOK3S_32_HANDLER 2388c2ecf20Sopenharmony_ci void* kvm_shadow_vcpu; /* KVM internal data */ 2398c2ecf20Sopenharmony_ci#endif /* CONFIG_KVM_BOOK3S_32_HANDLER */ 2408c2ecf20Sopenharmony_ci#if defined(CONFIG_KVM) && defined(CONFIG_BOOKE) 2418c2ecf20Sopenharmony_ci struct kvm_vcpu *kvm_vcpu; 2428c2ecf20Sopenharmony_ci#endif 2438c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64 2448c2ecf20Sopenharmony_ci unsigned long dscr; 2458c2ecf20Sopenharmony_ci unsigned long fscr; 2468c2ecf20Sopenharmony_ci /* 2478c2ecf20Sopenharmony_ci * This member element dscr_inherit indicates that the process 2488c2ecf20Sopenharmony_ci * has explicitly attempted and changed the DSCR register value 2498c2ecf20Sopenharmony_ci * for itself. Hence kernel wont use the default CPU DSCR value 2508c2ecf20Sopenharmony_ci * contained in the PACA structure anymore during process context 2518c2ecf20Sopenharmony_ci * switch. Once this variable is set, this behaviour will also be 2528c2ecf20Sopenharmony_ci * inherited to all the children of this process from that point 2538c2ecf20Sopenharmony_ci * onwards. 2548c2ecf20Sopenharmony_ci */ 2558c2ecf20Sopenharmony_ci int dscr_inherit; 2568c2ecf20Sopenharmony_ci unsigned long tidr; 2578c2ecf20Sopenharmony_ci#endif 2588c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S_64 2598c2ecf20Sopenharmony_ci unsigned long tar; 2608c2ecf20Sopenharmony_ci unsigned long ebbrr; 2618c2ecf20Sopenharmony_ci unsigned long ebbhr; 2628c2ecf20Sopenharmony_ci unsigned long bescr; 2638c2ecf20Sopenharmony_ci unsigned long siar; 2648c2ecf20Sopenharmony_ci unsigned long sdar; 2658c2ecf20Sopenharmony_ci unsigned long sier; 2668c2ecf20Sopenharmony_ci unsigned long mmcr2; 2678c2ecf20Sopenharmony_ci unsigned mmcr0; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci unsigned used_ebb; 2708c2ecf20Sopenharmony_ci unsigned long mmcr3; 2718c2ecf20Sopenharmony_ci unsigned long sier2; 2728c2ecf20Sopenharmony_ci unsigned long sier3; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci#endif 2758c2ecf20Sopenharmony_ci}; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci#define ARCH_MIN_TASKALIGN 16 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) 2808c2ecf20Sopenharmony_ci#define INIT_SP_LIMIT ((unsigned long)&init_stack) 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci#ifdef CONFIG_SPE 2838c2ecf20Sopenharmony_ci#define SPEFSCR_INIT \ 2848c2ecf20Sopenharmony_ci .spefscr = SPEFSCR_FINVE | SPEFSCR_FDBZE | SPEFSCR_FUNFE | SPEFSCR_FOVFE, \ 2858c2ecf20Sopenharmony_ci .spefscr_last = SPEFSCR_FINVE | SPEFSCR_FDBZE | SPEFSCR_FUNFE | SPEFSCR_FOVFE, 2868c2ecf20Sopenharmony_ci#else 2878c2ecf20Sopenharmony_ci#define SPEFSCR_INIT 2888c2ecf20Sopenharmony_ci#endif 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC32 2918c2ecf20Sopenharmony_ci#define INIT_THREAD { \ 2928c2ecf20Sopenharmony_ci .ksp = INIT_SP, \ 2938c2ecf20Sopenharmony_ci .ksp_limit = INIT_SP_LIMIT, \ 2948c2ecf20Sopenharmony_ci .pgdir = swapper_pg_dir, \ 2958c2ecf20Sopenharmony_ci .fpexc_mode = MSR_FE0 | MSR_FE1, \ 2968c2ecf20Sopenharmony_ci SPEFSCR_INIT \ 2978c2ecf20Sopenharmony_ci} 2988c2ecf20Sopenharmony_ci#else 2998c2ecf20Sopenharmony_ci#define INIT_THREAD { \ 3008c2ecf20Sopenharmony_ci .ksp = INIT_SP, \ 3018c2ecf20Sopenharmony_ci .fpexc_mode = 0, \ 3028c2ecf20Sopenharmony_ci} 3038c2ecf20Sopenharmony_ci#endif 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci#define task_pt_regs(tsk) ((tsk)->thread.regs) 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ciunsigned long get_wchan(struct task_struct *p); 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci#define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0) 3108c2ecf20Sopenharmony_ci#define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0) 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci/* Get/set floating-point exception mode */ 3138c2ecf20Sopenharmony_ci#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr)) 3148c2ecf20Sopenharmony_ci#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val)) 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ciextern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr); 3178c2ecf20Sopenharmony_ciextern int set_fpexc_mode(struct task_struct *tsk, unsigned int val); 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci#define GET_ENDIAN(tsk, adr) get_endian((tsk), (adr)) 3208c2ecf20Sopenharmony_ci#define SET_ENDIAN(tsk, val) set_endian((tsk), (val)) 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ciextern int get_endian(struct task_struct *tsk, unsigned long adr); 3238c2ecf20Sopenharmony_ciextern int set_endian(struct task_struct *tsk, unsigned int val); 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci#define GET_UNALIGN_CTL(tsk, adr) get_unalign_ctl((tsk), (adr)) 3268c2ecf20Sopenharmony_ci#define SET_UNALIGN_CTL(tsk, val) set_unalign_ctl((tsk), (val)) 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ciextern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr); 3298c2ecf20Sopenharmony_ciextern int set_unalign_ctl(struct task_struct *tsk, unsigned int val); 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ciextern void load_fp_state(struct thread_fp_state *fp); 3328c2ecf20Sopenharmony_ciextern void store_fp_state(struct thread_fp_state *fp); 3338c2ecf20Sopenharmony_ciextern void load_vr_state(struct thread_vr_state *vr); 3348c2ecf20Sopenharmony_ciextern void store_vr_state(struct thread_vr_state *vr); 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_cistatic inline unsigned int __unpack_fe01(unsigned long msr_bits) 3378c2ecf20Sopenharmony_ci{ 3388c2ecf20Sopenharmony_ci return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8); 3398c2ecf20Sopenharmony_ci} 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_cistatic inline unsigned long __pack_fe01(unsigned int fpmode) 3428c2ecf20Sopenharmony_ci{ 3438c2ecf20Sopenharmony_ci return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1); 3448c2ecf20Sopenharmony_ci} 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64 3478c2ecf20Sopenharmony_ci#define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0) 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci#define spin_begin() HMT_low() 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci#define spin_cpu_relax() barrier() 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci#define spin_end() HMT_medium() 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci#define spin_until_cond(cond) \ 3568c2ecf20Sopenharmony_cido { \ 3578c2ecf20Sopenharmony_ci if (unlikely(!(cond))) { \ 3588c2ecf20Sopenharmony_ci spin_begin(); \ 3598c2ecf20Sopenharmony_ci do { \ 3608c2ecf20Sopenharmony_ci spin_cpu_relax(); \ 3618c2ecf20Sopenharmony_ci } while (!(cond)); \ 3628c2ecf20Sopenharmony_ci spin_end(); \ 3638c2ecf20Sopenharmony_ci } \ 3648c2ecf20Sopenharmony_ci} while (0) 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci#else 3678c2ecf20Sopenharmony_ci#define cpu_relax() barrier() 3688c2ecf20Sopenharmony_ci#endif 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci/* Check that a certain kernel stack pointer is valid in task_struct p */ 3718c2ecf20Sopenharmony_ciint validate_sp(unsigned long sp, struct task_struct *p, 3728c2ecf20Sopenharmony_ci unsigned long nbytes); 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci/* 3758c2ecf20Sopenharmony_ci * Prefetch macros. 3768c2ecf20Sopenharmony_ci */ 3778c2ecf20Sopenharmony_ci#define ARCH_HAS_PREFETCH 3788c2ecf20Sopenharmony_ci#define ARCH_HAS_PREFETCHW 3798c2ecf20Sopenharmony_ci#define ARCH_HAS_SPINLOCK_PREFETCH 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_cistatic inline void prefetch(const void *x) 3828c2ecf20Sopenharmony_ci{ 3838c2ecf20Sopenharmony_ci if (unlikely(!x)) 3848c2ecf20Sopenharmony_ci return; 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ci __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x)); 3878c2ecf20Sopenharmony_ci} 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_cistatic inline void prefetchw(const void *x) 3908c2ecf20Sopenharmony_ci{ 3918c2ecf20Sopenharmony_ci if (unlikely(!x)) 3928c2ecf20Sopenharmony_ci return; 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x)); 3958c2ecf20Sopenharmony_ci} 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci#define spin_lock_prefetch(x) prefetchw(x) 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci#define HAVE_ARCH_PICK_MMAP_LAYOUT 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64 4028c2ecf20Sopenharmony_cistatic inline unsigned long get_clean_sp(unsigned long sp, int is_32) 4038c2ecf20Sopenharmony_ci{ 4048c2ecf20Sopenharmony_ci if (is_32) 4058c2ecf20Sopenharmony_ci return sp & 0x0ffffffffUL; 4068c2ecf20Sopenharmony_ci return sp; 4078c2ecf20Sopenharmony_ci} 4088c2ecf20Sopenharmony_ci#else 4098c2ecf20Sopenharmony_cistatic inline unsigned long get_clean_sp(unsigned long sp, int is_32) 4108c2ecf20Sopenharmony_ci{ 4118c2ecf20Sopenharmony_ci return sp; 4128c2ecf20Sopenharmony_ci} 4138c2ecf20Sopenharmony_ci#endif 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_ci/* asm stubs */ 4168c2ecf20Sopenharmony_ciextern unsigned long isa300_idle_stop_noloss(unsigned long psscr_val); 4178c2ecf20Sopenharmony_ciextern unsigned long isa300_idle_stop_mayloss(unsigned long psscr_val); 4188c2ecf20Sopenharmony_ciextern unsigned long isa206_idle_insn_mayloss(unsigned long type); 4198c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_970_NAP 4208c2ecf20Sopenharmony_ciextern void power4_idle_nap(void); 4218c2ecf20Sopenharmony_ci#endif 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ciextern unsigned long cpuidle_disable; 4248c2ecf20Sopenharmony_cienum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF}; 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ciextern int powersave_nap; /* set if nap mode can be used in idle loop */ 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ciextern void power7_idle_type(unsigned long type); 4298c2ecf20Sopenharmony_ciextern void arch300_idle_type(unsigned long stop_psscr_val, 4308c2ecf20Sopenharmony_ci unsigned long stop_psscr_mask); 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ciextern int fix_alignment(struct pt_regs *); 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64 4358c2ecf20Sopenharmony_ci/* 4368c2ecf20Sopenharmony_ci * We handle most unaligned accesses in hardware. On the other hand 4378c2ecf20Sopenharmony_ci * unaligned DMA can be very expensive on some ppc64 IO chips (it does 4388c2ecf20Sopenharmony_ci * powers of 2 writes until it reaches sufficient alignment). 4398c2ecf20Sopenharmony_ci * 4408c2ecf20Sopenharmony_ci * Based on this we disable the IP header alignment in network drivers. 4418c2ecf20Sopenharmony_ci */ 4428c2ecf20Sopenharmony_ci#define NET_IP_ALIGN 0 4438c2ecf20Sopenharmony_ci#endif 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 4468c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 4478c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_PROCESSOR_H */ 448