18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 1994 Waldorf GMBH 78c2ecf20Sopenharmony_ci * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle 88c2ecf20Sopenharmony_ci * Copyright (C) 1996 Paul M. Antoine 98c2ecf20Sopenharmony_ci * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci#ifndef _ASM_PROCESSOR_H 128c2ecf20Sopenharmony_ci#define _ASM_PROCESSOR_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/atomic.h> 158c2ecf20Sopenharmony_ci#include <linux/cpumask.h> 168c2ecf20Sopenharmony_ci#include <linux/sizes.h> 178c2ecf20Sopenharmony_ci#include <linux/threads.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include <asm/cachectl.h> 208c2ecf20Sopenharmony_ci#include <asm/cpu.h> 218c2ecf20Sopenharmony_ci#include <asm/cpu-info.h> 228c2ecf20Sopenharmony_ci#include <asm/dsemul.h> 238c2ecf20Sopenharmony_ci#include <asm/mipsregs.h> 248c2ecf20Sopenharmony_ci#include <asm/prefetch.h> 258c2ecf20Sopenharmony_ci#include <asm/vdso/processor.h> 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* 288c2ecf20Sopenharmony_ci * System setup and hardware flags.. 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ciextern unsigned int vced_count, vcei_count; 328c2ecf20Sopenharmony_ciextern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#ifdef CONFIG_32BIT 358c2ecf20Sopenharmony_ci#ifdef CONFIG_KVM_GUEST 368c2ecf20Sopenharmony_ci/* User space process size is limited to 1GB in KVM Guest Mode */ 378c2ecf20Sopenharmony_ci#define TASK_SIZE 0x3fff8000UL 388c2ecf20Sopenharmony_ci#else 398c2ecf20Sopenharmony_ci/* 408c2ecf20Sopenharmony_ci * User space process size: 2GB. This is hardcoded into a few places, 418c2ecf20Sopenharmony_ci * so don't change it unless you know what you are doing. 428c2ecf20Sopenharmony_ci */ 438c2ecf20Sopenharmony_ci#define TASK_SIZE 0x80000000UL 448c2ecf20Sopenharmony_ci#endif 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define STACK_TOP_MAX TASK_SIZE 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define TASK_IS_32BIT_ADDR 1 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#endif 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT 538c2ecf20Sopenharmony_ci/* 548c2ecf20Sopenharmony_ci * User space process size: 1TB. This is hardcoded into a few places, 558c2ecf20Sopenharmony_ci * so don't change it unless you know what you are doing. TASK_SIZE 568c2ecf20Sopenharmony_ci * is limited to 1TB by the R4000 architecture; R10000 and better can 578c2ecf20Sopenharmony_ci * support 16TB; the architectural reserve for future expansion is 588c2ecf20Sopenharmony_ci * 8192EB ... 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_ci#define TASK_SIZE32 0x7fff8000UL 618c2ecf20Sopenharmony_ci#ifdef CONFIG_MIPS_VA_BITS_48 628c2ecf20Sopenharmony_ci#define TASK_SIZE64 (0x1UL << ((cpu_data[0].vmbits>48)?48:cpu_data[0].vmbits)) 638c2ecf20Sopenharmony_ci#else 648c2ecf20Sopenharmony_ci#define TASK_SIZE64 0x10000000000UL 658c2ecf20Sopenharmony_ci#endif 668c2ecf20Sopenharmony_ci#define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64) 678c2ecf20Sopenharmony_ci#define STACK_TOP_MAX TASK_SIZE64 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define TASK_SIZE_OF(tsk) \ 708c2ecf20Sopenharmony_ci (test_tsk_thread_flag(tsk, TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64) 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define TASK_IS_32BIT_ADDR test_thread_flag(TIF_32BIT_ADDR) 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#endif 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#define VDSO_RANDOMIZE_SIZE (TASK_IS_32BIT_ADDR ? SZ_1M : SZ_64M) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciextern unsigned long mips_stack_top(void); 798c2ecf20Sopenharmony_ci#define STACK_TOP mips_stack_top() 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* 828c2ecf20Sopenharmony_ci * This decides where the kernel will search for a free chunk of vm 838c2ecf20Sopenharmony_ci * space during mmap's. 848c2ecf20Sopenharmony_ci */ 858c2ecf20Sopenharmony_ci#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define NUM_FPU_REGS 32 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_HAS_MSA 918c2ecf20Sopenharmony_ci# define FPU_REG_WIDTH 128 928c2ecf20Sopenharmony_ci#else 938c2ecf20Sopenharmony_ci# define FPU_REG_WIDTH 64 948c2ecf20Sopenharmony_ci#endif 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciunion fpureg { 978c2ecf20Sopenharmony_ci __u32 val32[FPU_REG_WIDTH / 32]; 988c2ecf20Sopenharmony_ci __u64 val64[FPU_REG_WIDTH / 64]; 998c2ecf20Sopenharmony_ci}; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_LITTLE_ENDIAN 1028c2ecf20Sopenharmony_ci# define FPR_IDX(width, idx) (idx) 1038c2ecf20Sopenharmony_ci#else 1048c2ecf20Sopenharmony_ci# define FPR_IDX(width, idx) ((idx) ^ ((64 / (width)) - 1)) 1058c2ecf20Sopenharmony_ci#endif 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define BUILD_FPR_ACCESS(width) \ 1088c2ecf20Sopenharmony_cistatic inline u##width get_fpr##width(union fpureg *fpr, unsigned idx) \ 1098c2ecf20Sopenharmony_ci{ \ 1108c2ecf20Sopenharmony_ci return fpr->val##width[FPR_IDX(width, idx)]; \ 1118c2ecf20Sopenharmony_ci} \ 1128c2ecf20Sopenharmony_ci \ 1138c2ecf20Sopenharmony_cistatic inline void set_fpr##width(union fpureg *fpr, unsigned idx, \ 1148c2ecf20Sopenharmony_ci u##width val) \ 1158c2ecf20Sopenharmony_ci{ \ 1168c2ecf20Sopenharmony_ci fpr->val##width[FPR_IDX(width, idx)] = val; \ 1178c2ecf20Sopenharmony_ci} 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ciBUILD_FPR_ACCESS(32) 1208c2ecf20Sopenharmony_ciBUILD_FPR_ACCESS(64) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* 1238c2ecf20Sopenharmony_ci * It would be nice to add some more fields for emulator statistics, 1248c2ecf20Sopenharmony_ci * the additional information is private to the FPU emulator for now. 1258c2ecf20Sopenharmony_ci * See arch/mips/include/asm/fpu_emulator.h. 1268c2ecf20Sopenharmony_ci */ 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cistruct mips_fpu_struct { 1298c2ecf20Sopenharmony_ci union fpureg fpr[NUM_FPU_REGS]; 1308c2ecf20Sopenharmony_ci unsigned int fcr31; 1318c2ecf20Sopenharmony_ci unsigned int msacsr; 1328c2ecf20Sopenharmony_ci}; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define NUM_DSP_REGS 6 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_citypedef unsigned long dspreg_t; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_cistruct mips_dsp_state { 1398c2ecf20Sopenharmony_ci dspreg_t dspr[NUM_DSP_REGS]; 1408c2ecf20Sopenharmony_ci unsigned int dspcontrol; 1418c2ecf20Sopenharmony_ci}; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define INIT_CPUMASK { \ 1448c2ecf20Sopenharmony_ci {0,} \ 1458c2ecf20Sopenharmony_ci} 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistruct mips3264_watch_reg_state { 1488c2ecf20Sopenharmony_ci /* The width of watchlo is 32 in a 32 bit kernel and 64 in a 1498c2ecf20Sopenharmony_ci 64 bit kernel. We use unsigned long as it has the same 1508c2ecf20Sopenharmony_ci property. */ 1518c2ecf20Sopenharmony_ci unsigned long watchlo[NUM_WATCH_REGS]; 1528c2ecf20Sopenharmony_ci /* Only the mask and IRW bits from watchhi. */ 1538c2ecf20Sopenharmony_ci u16 watchhi[NUM_WATCH_REGS]; 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ciunion mips_watch_reg_state { 1578c2ecf20Sopenharmony_ci struct mips3264_watch_reg_state mips3264; 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_CAVIUM_OCTEON) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_cistruct octeon_cop2_state { 1638c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0201 */ 1648c2ecf20Sopenharmony_ci unsigned long cop2_crc_iv; 1658c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0202 (Set with DMTC2 rt, 0x1202) */ 1668c2ecf20Sopenharmony_ci unsigned long cop2_crc_length; 1678c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0200 (set with DMTC2 rt, 0x4200) */ 1688c2ecf20Sopenharmony_ci unsigned long cop2_crc_poly; 1698c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0402; DMFC2 rt, 0x040A */ 1708c2ecf20Sopenharmony_ci unsigned long cop2_llm_dat[2]; 1718c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0084 */ 1728c2ecf20Sopenharmony_ci unsigned long cop2_3des_iv; 1738c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0080; DMFC2 rt, 0x0081; DMFC2 rt, 0x0082 */ 1748c2ecf20Sopenharmony_ci unsigned long cop2_3des_key[3]; 1758c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0088 (Set with DMTC2 rt, 0x0098) */ 1768c2ecf20Sopenharmony_ci unsigned long cop2_3des_result; 1778c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0111 (FIXME: Read Pass1 Errata) */ 1788c2ecf20Sopenharmony_ci unsigned long cop2_aes_inp0; 1798c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0102; DMFC2 rt, 0x0103 */ 1808c2ecf20Sopenharmony_ci unsigned long cop2_aes_iv[2]; 1818c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0104; DMFC2 rt, 0x0105; DMFC2 rt, 0x0106; DMFC2 1828c2ecf20Sopenharmony_ci * rt, 0x0107 */ 1838c2ecf20Sopenharmony_ci unsigned long cop2_aes_key[4]; 1848c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0110 */ 1858c2ecf20Sopenharmony_ci unsigned long cop2_aes_keylen; 1868c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0100; DMFC2 rt, 0x0101 */ 1878c2ecf20Sopenharmony_ci unsigned long cop2_aes_result[2]; 1888c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0240; DMFC2 rt, 0x0241; DMFC2 rt, 0x0242; DMFC2 1898c2ecf20Sopenharmony_ci * rt, 0x0243; DMFC2 rt, 0x0244; DMFC2 rt, 0x0245; DMFC2 rt, 1908c2ecf20Sopenharmony_ci * 0x0246; DMFC2 rt, 0x0247; DMFC2 rt, 0x0248; DMFC2 rt, 1918c2ecf20Sopenharmony_ci * 0x0249; DMFC2 rt, 0x024A; DMFC2 rt, 0x024B; DMFC2 rt, 1928c2ecf20Sopenharmony_ci * 0x024C; DMFC2 rt, 0x024D; DMFC2 rt, 0x024E - Pass2 */ 1938c2ecf20Sopenharmony_ci unsigned long cop2_hsh_datw[15]; 1948c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0250; DMFC2 rt, 0x0251; DMFC2 rt, 0x0252; DMFC2 1958c2ecf20Sopenharmony_ci * rt, 0x0253; DMFC2 rt, 0x0254; DMFC2 rt, 0x0255; DMFC2 rt, 1968c2ecf20Sopenharmony_ci * 0x0256; DMFC2 rt, 0x0257 - Pass2 */ 1978c2ecf20Sopenharmony_ci unsigned long cop2_hsh_ivw[8]; 1988c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x0258; DMFC2 rt, 0x0259 - Pass2 */ 1998c2ecf20Sopenharmony_ci unsigned long cop2_gfm_mult[2]; 2008c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x025E - Pass2 */ 2018c2ecf20Sopenharmony_ci unsigned long cop2_gfm_poly; 2028c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x025A; DMFC2 rt, 0x025B - Pass2 */ 2038c2ecf20Sopenharmony_ci unsigned long cop2_gfm_result[2]; 2048c2ecf20Sopenharmony_ci /* DMFC2 rt, 0x24F, DMFC2 rt, 0x50, OCTEON III */ 2058c2ecf20Sopenharmony_ci unsigned long cop2_sha3[2]; 2068c2ecf20Sopenharmony_ci}; 2078c2ecf20Sopenharmony_ci#define COP2_INIT \ 2088c2ecf20Sopenharmony_ci .cp2 = {0,}, 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_cistruct octeon_cvmseg_state { 2118c2ecf20Sopenharmony_ci unsigned long cvmseg[CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE] 2128c2ecf20Sopenharmony_ci [cpu_dcache_line_size() / sizeof(unsigned long)]; 2138c2ecf20Sopenharmony_ci}; 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci#elif defined(CONFIG_CPU_XLP) 2168c2ecf20Sopenharmony_cistruct nlm_cop2_state { 2178c2ecf20Sopenharmony_ci u64 rx[4]; 2188c2ecf20Sopenharmony_ci u64 tx[4]; 2198c2ecf20Sopenharmony_ci u32 tx_msg_status; 2208c2ecf20Sopenharmony_ci u32 rx_msg_status; 2218c2ecf20Sopenharmony_ci}; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci#define COP2_INIT \ 2248c2ecf20Sopenharmony_ci .cp2 = {{0}, {0}, 0, 0}, 2258c2ecf20Sopenharmony_ci#else 2268c2ecf20Sopenharmony_ci#define COP2_INIT 2278c2ecf20Sopenharmony_ci#endif 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_citypedef struct { 2308c2ecf20Sopenharmony_ci unsigned long seg; 2318c2ecf20Sopenharmony_ci} mm_segment_t; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_HAS_MSA 2348c2ecf20Sopenharmony_ci# define ARCH_MIN_TASKALIGN 16 2358c2ecf20Sopenharmony_ci# define FPU_ALIGN __aligned(16) 2368c2ecf20Sopenharmony_ci#else 2378c2ecf20Sopenharmony_ci# define ARCH_MIN_TASKALIGN 8 2388c2ecf20Sopenharmony_ci# define FPU_ALIGN 2398c2ecf20Sopenharmony_ci#endif 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_cistruct mips_abi; 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/* 2448c2ecf20Sopenharmony_ci * If you change thread_struct remember to change the #defines below too! 2458c2ecf20Sopenharmony_ci */ 2468c2ecf20Sopenharmony_cistruct thread_struct { 2478c2ecf20Sopenharmony_ci /* Saved main processor registers. */ 2488c2ecf20Sopenharmony_ci unsigned long reg16; 2498c2ecf20Sopenharmony_ci unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23; 2508c2ecf20Sopenharmony_ci unsigned long reg29, reg30, reg31; 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci /* Saved cp0 stuff. */ 2538c2ecf20Sopenharmony_ci unsigned long cp0_status; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci#ifdef CONFIG_MIPS_FP_SUPPORT 2568c2ecf20Sopenharmony_ci /* Saved fpu/fpu emulator stuff. */ 2578c2ecf20Sopenharmony_ci struct mips_fpu_struct fpu FPU_ALIGN; 2588c2ecf20Sopenharmony_ci /* Assigned branch delay slot 'emulation' frame */ 2598c2ecf20Sopenharmony_ci atomic_t bd_emu_frame; 2608c2ecf20Sopenharmony_ci /* PC of the branch from a branch delay slot 'emulation' */ 2618c2ecf20Sopenharmony_ci unsigned long bd_emu_branch_pc; 2628c2ecf20Sopenharmony_ci /* PC to continue from following a branch delay slot 'emulation' */ 2638c2ecf20Sopenharmony_ci unsigned long bd_emu_cont_pc; 2648c2ecf20Sopenharmony_ci#endif 2658c2ecf20Sopenharmony_ci#ifdef CONFIG_MIPS_MT_FPAFF 2668c2ecf20Sopenharmony_ci /* Emulated instruction count */ 2678c2ecf20Sopenharmony_ci unsigned long emulated_fp; 2688c2ecf20Sopenharmony_ci /* Saved per-thread scheduler affinity mask */ 2698c2ecf20Sopenharmony_ci cpumask_t user_cpus_allowed; 2708c2ecf20Sopenharmony_ci#endif /* CONFIG_MIPS_MT_FPAFF */ 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci /* Saved state of the DSP ASE, if available. */ 2738c2ecf20Sopenharmony_ci struct mips_dsp_state dsp; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci /* Saved watch register state, if available. */ 2768c2ecf20Sopenharmony_ci union mips_watch_reg_state watch; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci /* Other stuff associated with the thread. */ 2798c2ecf20Sopenharmony_ci unsigned long cp0_badvaddr; /* Last user fault */ 2808c2ecf20Sopenharmony_ci unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */ 2818c2ecf20Sopenharmony_ci unsigned long error_code; 2828c2ecf20Sopenharmony_ci unsigned long trap_nr; 2838c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_CAVIUM_OCTEON 2848c2ecf20Sopenharmony_ci struct octeon_cop2_state cp2 __attribute__ ((__aligned__(128))); 2858c2ecf20Sopenharmony_ci struct octeon_cvmseg_state cvmseg __attribute__ ((__aligned__(128))); 2868c2ecf20Sopenharmony_ci#endif 2878c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_XLP 2888c2ecf20Sopenharmony_ci struct nlm_cop2_state cp2; 2898c2ecf20Sopenharmony_ci#endif 2908c2ecf20Sopenharmony_ci struct mips_abi *abi; 2918c2ecf20Sopenharmony_ci}; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci#ifdef CONFIG_MIPS_MT_FPAFF 2948c2ecf20Sopenharmony_ci#define FPAFF_INIT \ 2958c2ecf20Sopenharmony_ci .emulated_fp = 0, \ 2968c2ecf20Sopenharmony_ci .user_cpus_allowed = INIT_CPUMASK, 2978c2ecf20Sopenharmony_ci#else 2988c2ecf20Sopenharmony_ci#define FPAFF_INIT 2998c2ecf20Sopenharmony_ci#endif /* CONFIG_MIPS_MT_FPAFF */ 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci#ifdef CONFIG_MIPS_FP_SUPPORT 3028c2ecf20Sopenharmony_ci# define FPU_INIT \ 3038c2ecf20Sopenharmony_ci .fpu = { \ 3048c2ecf20Sopenharmony_ci .fpr = {{{0,},},}, \ 3058c2ecf20Sopenharmony_ci .fcr31 = 0, \ 3068c2ecf20Sopenharmony_ci .msacsr = 0, \ 3078c2ecf20Sopenharmony_ci }, \ 3088c2ecf20Sopenharmony_ci /* Delay slot emulation */ \ 3098c2ecf20Sopenharmony_ci .bd_emu_frame = ATOMIC_INIT(BD_EMUFRAME_NONE), \ 3108c2ecf20Sopenharmony_ci .bd_emu_branch_pc = 0, \ 3118c2ecf20Sopenharmony_ci .bd_emu_cont_pc = 0, 3128c2ecf20Sopenharmony_ci#else 3138c2ecf20Sopenharmony_ci# define FPU_INIT 3148c2ecf20Sopenharmony_ci#endif 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci#define INIT_THREAD { \ 3178c2ecf20Sopenharmony_ci /* \ 3188c2ecf20Sopenharmony_ci * Saved main processor registers \ 3198c2ecf20Sopenharmony_ci */ \ 3208c2ecf20Sopenharmony_ci .reg16 = 0, \ 3218c2ecf20Sopenharmony_ci .reg17 = 0, \ 3228c2ecf20Sopenharmony_ci .reg18 = 0, \ 3238c2ecf20Sopenharmony_ci .reg19 = 0, \ 3248c2ecf20Sopenharmony_ci .reg20 = 0, \ 3258c2ecf20Sopenharmony_ci .reg21 = 0, \ 3268c2ecf20Sopenharmony_ci .reg22 = 0, \ 3278c2ecf20Sopenharmony_ci .reg23 = 0, \ 3288c2ecf20Sopenharmony_ci .reg29 = 0, \ 3298c2ecf20Sopenharmony_ci .reg30 = 0, \ 3308c2ecf20Sopenharmony_ci .reg31 = 0, \ 3318c2ecf20Sopenharmony_ci /* \ 3328c2ecf20Sopenharmony_ci * Saved cp0 stuff \ 3338c2ecf20Sopenharmony_ci */ \ 3348c2ecf20Sopenharmony_ci .cp0_status = 0, \ 3358c2ecf20Sopenharmony_ci /* \ 3368c2ecf20Sopenharmony_ci * Saved FPU/FPU emulator stuff \ 3378c2ecf20Sopenharmony_ci */ \ 3388c2ecf20Sopenharmony_ci FPU_INIT \ 3398c2ecf20Sopenharmony_ci /* \ 3408c2ecf20Sopenharmony_ci * FPU affinity state (null if not FPAFF) \ 3418c2ecf20Sopenharmony_ci */ \ 3428c2ecf20Sopenharmony_ci FPAFF_INIT \ 3438c2ecf20Sopenharmony_ci /* \ 3448c2ecf20Sopenharmony_ci * Saved DSP stuff \ 3458c2ecf20Sopenharmony_ci */ \ 3468c2ecf20Sopenharmony_ci .dsp = { \ 3478c2ecf20Sopenharmony_ci .dspr = {0, }, \ 3488c2ecf20Sopenharmony_ci .dspcontrol = 0, \ 3498c2ecf20Sopenharmony_ci }, \ 3508c2ecf20Sopenharmony_ci /* \ 3518c2ecf20Sopenharmony_ci * saved watch register stuff \ 3528c2ecf20Sopenharmony_ci */ \ 3538c2ecf20Sopenharmony_ci .watch = {{{0,},},}, \ 3548c2ecf20Sopenharmony_ci /* \ 3558c2ecf20Sopenharmony_ci * Other stuff associated with the process \ 3568c2ecf20Sopenharmony_ci */ \ 3578c2ecf20Sopenharmony_ci .cp0_badvaddr = 0, \ 3588c2ecf20Sopenharmony_ci .cp0_baduaddr = 0, \ 3598c2ecf20Sopenharmony_ci .error_code = 0, \ 3608c2ecf20Sopenharmony_ci .trap_nr = 0, \ 3618c2ecf20Sopenharmony_ci /* \ 3628c2ecf20Sopenharmony_ci * Platform specific cop2 registers(null if no COP2) \ 3638c2ecf20Sopenharmony_ci */ \ 3648c2ecf20Sopenharmony_ci COP2_INIT \ 3658c2ecf20Sopenharmony_ci} 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_cistruct task_struct; 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci/* Free all resources held by a thread. */ 3708c2ecf20Sopenharmony_ci#define release_thread(thread) do { } while(0) 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci/* 3738c2ecf20Sopenharmony_ci * Do necessary setup to start up a newly executed thread. 3748c2ecf20Sopenharmony_ci */ 3758c2ecf20Sopenharmony_ciextern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp); 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_cistatic inline void flush_thread(void) 3788c2ecf20Sopenharmony_ci{ 3798c2ecf20Sopenharmony_ci} 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ciunsigned long get_wchan(struct task_struct *p); 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci#define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + \ 3848c2ecf20Sopenharmony_ci THREAD_SIZE - 32 - sizeof(struct pt_regs)) 3858c2ecf20Sopenharmony_ci#define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk)) 3868c2ecf20Sopenharmony_ci#define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc) 3878c2ecf20Sopenharmony_ci#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29]) 3888c2ecf20Sopenharmony_ci#define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status) 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_ci/* 3918c2ecf20Sopenharmony_ci * Return_address is a replacement for __builtin_return_address(count) 3928c2ecf20Sopenharmony_ci * which on certain architectures cannot reasonably be implemented in GCC 3938c2ecf20Sopenharmony_ci * (MIPS, Alpha) or is unusable with -fomit-frame-pointer (i386). 3948c2ecf20Sopenharmony_ci * Note that __builtin_return_address(x>=1) is forbidden because GCC 3958c2ecf20Sopenharmony_ci * aborts compilation on some CPUs. It's simply not possible to unwind 3968c2ecf20Sopenharmony_ci * some CPU's stackframes. 3978c2ecf20Sopenharmony_ci * 3988c2ecf20Sopenharmony_ci * __builtin_return_address works only for non-leaf functions. We avoid the 3998c2ecf20Sopenharmony_ci * overhead of a function call by forcing the compiler to save the return 4008c2ecf20Sopenharmony_ci * address register on the stack. 4018c2ecf20Sopenharmony_ci */ 4028c2ecf20Sopenharmony_ci#define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);}) 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_HAS_PREFETCH 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci#define ARCH_HAS_PREFETCH 4078c2ecf20Sopenharmony_ci#define prefetch(x) __builtin_prefetch((x), 0, 1) 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci#define ARCH_HAS_PREFETCHW 4108c2ecf20Sopenharmony_ci#define prefetchw(x) __builtin_prefetch((x), 1, 1) 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci#endif 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci/* 4158c2ecf20Sopenharmony_ci * Functions & macros implementing the PR_GET_FP_MODE & PR_SET_FP_MODE options 4168c2ecf20Sopenharmony_ci * to the prctl syscall. 4178c2ecf20Sopenharmony_ci */ 4188c2ecf20Sopenharmony_ciextern int mips_get_process_fp_mode(struct task_struct *task); 4198c2ecf20Sopenharmony_ciextern int mips_set_process_fp_mode(struct task_struct *task, 4208c2ecf20Sopenharmony_ci unsigned int value); 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci#define GET_FP_MODE(task) mips_get_process_fp_mode(task) 4238c2ecf20Sopenharmony_ci#define SET_FP_MODE(task,value) mips_set_process_fp_mode(task, value) 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci#endif /* _ASM_PROCESSOR_H */ 426