Path: blob/master/arch/xtensa/include/asm/coprocessor.h
15126 views
/*1* include/asm-xtensa/coprocessor.h2*3* This file is subject to the terms and conditions of the GNU General Public4* License. See the file "COPYING" in the main directory of this archive5* for more details.6*7* Copyright (C) 2003 - 2007 Tensilica Inc.8*/91011#ifndef _XTENSA_COPROCESSOR_H12#define _XTENSA_COPROCESSOR_H1314#include <linux/stringify.h>15#include <variant/core.h>16#include <variant/tie.h>17#include <asm/types.h>1819#ifdef __ASSEMBLY__20# include <variant/tie-asm.h>2122.macro xchal_sa_start a b23.set .Lxchal_pofs_, 024.set .Lxchal_ofs_, 025.endm2627.macro xchal_sa_align ptr minofs maxofs ofsalign totalign28.set .Lxchal_ofs_, .Lxchal_ofs_ + .Lxchal_pofs_ + \totalign - 129.set .Lxchal_ofs_, (.Lxchal_ofs_ & -\totalign) - .Lxchal_pofs_30.endm3132#define _SELECT ( XTHAL_SAS_TIE | XTHAL_SAS_OPT \33| XTHAL_SAS_CC \34| XTHAL_SAS_CALR | XTHAL_SAS_CALE )3536.macro save_xtregs_opt ptr clb at1 at2 at3 at4 offset37.if XTREGS_OPT_SIZE > 038addi \clb, \ptr, \offset39xchal_ncp_store \clb \at1 \at2 \at3 \at4 select=_SELECT40.endif41.endm4243.macro load_xtregs_opt ptr clb at1 at2 at3 at4 offset44.if XTREGS_OPT_SIZE > 045addi \clb, \ptr, \offset46xchal_ncp_load \clb \at1 \at2 \at3 \at4 select=_SELECT47.endif48.endm49#undef _SELECT5051#define _SELECT ( XTHAL_SAS_TIE | XTHAL_SAS_OPT \52| XTHAL_SAS_NOCC \53| XTHAL_SAS_CALR | XTHAL_SAS_CALE | XTHAL_SAS_GLOB )5455.macro save_xtregs_user ptr clb at1 at2 at3 at4 offset56.if XTREGS_USER_SIZE > 057addi \clb, \ptr, \offset58xchal_ncp_store \clb \at1 \at2 \at3 \at4 select=_SELECT59.endif60.endm6162.macro load_xtregs_user ptr clb at1 at2 at3 at4 offset63.if XTREGS_USER_SIZE > 064addi \clb, \ptr, \offset65xchal_ncp_load \clb \at1 \at2 \at3 \at4 select=_SELECT66.endif67.endm68#undef _SELECT69707172#endif /* __ASSEMBLY__ */7374/*75* XTENSA_HAVE_COPROCESSOR(x) returns 1 if coprocessor x is configured.76*77* XTENSA_HAVE_IO_PORT(x) returns 1 if io-port x is configured.78*79*/8081#define XTENSA_HAVE_COPROCESSOR(x) \82((XCHAL_CP_MASK ^ XCHAL_CP_PORT_MASK) & (1 << (x)))83#define XTENSA_HAVE_COPROCESSORS \84(XCHAL_CP_MASK ^ XCHAL_CP_PORT_MASK)85#define XTENSA_HAVE_IO_PORT(x) \86(XCHAL_CP_PORT_MASK & (1 << (x)))87#define XTENSA_HAVE_IO_PORTS \88XCHAL_CP_PORT_MASK8990#ifndef __ASSEMBLY__919293#if XCHAL_HAVE_CP9495#define RSR_CPENABLE(x) do { \96__asm__ __volatile__("rsr %0," __stringify(CPENABLE) : "=a" (x)); \97} while(0);98#define WSR_CPENABLE(x) do { \99__asm__ __volatile__("wsr %0," __stringify(CPENABLE) "; rsync" \100:: "a" (x)); \101} while(0);102103#endif /* XCHAL_HAVE_CP */104105106/*107* Additional registers.108* We define three types of additional registers:109* ext: extra registers that are used by the compiler110* cpn: optional registers that can be used by a user application111* cpX: coprocessor registers that can only be used if the corresponding112* CPENABLE bit is set.113*/114115#define XCHAL_SA_REG(list,cc,abi,type,y,name,z,align,size,...) \116__REG ## list (cc, abi, type, name, size, align)117118#define __REG0(cc,abi,t,name,s,a) __REG0_ ## cc (abi,name)119#define __REG1(cc,abi,t,name,s,a) __REG1_ ## cc (name)120#define __REG2(cc,abi,type,...) __REG2_ ## type (__VA_ARGS__)121122#define __REG0_0(abi,name)123#define __REG0_1(abi,name) __REG0_1 ## abi (name)124#define __REG0_10(name) __u32 name;125#define __REG0_11(name) __u32 name;126#define __REG0_12(name)127128#define __REG1_0(name) __u32 name;129#define __REG1_1(name)130131#define __REG2_0(n,s,a) __u32 name;132#define __REG2_1(n,s,a) unsigned char n[s] __attribute__ ((aligned(a)));133#define __REG2_2(n,s,a) unsigned char n[s] __attribute__ ((aligned(a)));134135typedef struct { XCHAL_NCP_SA_LIST(0) } xtregs_opt_t136__attribute__ ((aligned (XCHAL_NCP_SA_ALIGN)));137typedef struct { XCHAL_NCP_SA_LIST(1) } xtregs_user_t138__attribute__ ((aligned (XCHAL_NCP_SA_ALIGN)));139140#if XTENSA_HAVE_COPROCESSORS141142typedef struct { XCHAL_CP0_SA_LIST(2) } xtregs_cp0_t143__attribute__ ((aligned (XCHAL_CP0_SA_ALIGN)));144typedef struct { XCHAL_CP1_SA_LIST(2) } xtregs_cp1_t145__attribute__ ((aligned (XCHAL_CP1_SA_ALIGN)));146typedef struct { XCHAL_CP2_SA_LIST(2) } xtregs_cp2_t147__attribute__ ((aligned (XCHAL_CP2_SA_ALIGN)));148typedef struct { XCHAL_CP3_SA_LIST(2) } xtregs_cp3_t149__attribute__ ((aligned (XCHAL_CP3_SA_ALIGN)));150typedef struct { XCHAL_CP4_SA_LIST(2) } xtregs_cp4_t151__attribute__ ((aligned (XCHAL_CP4_SA_ALIGN)));152typedef struct { XCHAL_CP5_SA_LIST(2) } xtregs_cp5_t153__attribute__ ((aligned (XCHAL_CP5_SA_ALIGN)));154typedef struct { XCHAL_CP6_SA_LIST(2) } xtregs_cp6_t155__attribute__ ((aligned (XCHAL_CP6_SA_ALIGN)));156typedef struct { XCHAL_CP7_SA_LIST(2) } xtregs_cp7_t157__attribute__ ((aligned (XCHAL_CP7_SA_ALIGN)));158159extern struct thread_info* coprocessor_owner[XCHAL_CP_MAX];160extern void coprocessor_save(void*, int);161extern void coprocessor_load(void*, int);162extern void coprocessor_flush(struct thread_info*, int);163extern void coprocessor_restore(struct thread_info*, int);164165extern void coprocessor_release_all(struct thread_info*);166extern void coprocessor_flush_all(struct thread_info*);167168static inline void coprocessor_clear_cpenable(void)169{170unsigned long i = 0;171WSR_CPENABLE(i);172}173174#endif /* XTENSA_HAVE_COPROCESSORS */175176#endif /* !__ASSEMBLY__ */177#endif /* _XTENSA_COPROCESSOR_H */178179180