162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * include/asm-xtensa/coprocessor.h 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 562306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 662306a36Sopenharmony_ci * for more details. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Copyright (C) 2003 - 2007 Tensilica Inc. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#ifndef _XTENSA_COPROCESSOR_H 1362306a36Sopenharmony_ci#define _XTENSA_COPROCESSOR_H 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include <variant/tie.h> 1662306a36Sopenharmony_ci#include <asm/core.h> 1762306a36Sopenharmony_ci#include <asm/types.h> 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#ifdef __ASSEMBLY__ 2062306a36Sopenharmony_ci# include <variant/tie-asm.h> 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci.macro xchal_sa_start a b 2362306a36Sopenharmony_ci .set .Lxchal_pofs_, 0 2462306a36Sopenharmony_ci .set .Lxchal_ofs_, 0 2562306a36Sopenharmony_ci.endm 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci.macro xchal_sa_align ptr minofs maxofs ofsalign totalign 2862306a36Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + .Lxchal_pofs_ + \totalign - 1 2962306a36Sopenharmony_ci .set .Lxchal_ofs_, (.Lxchal_ofs_ & -\totalign) - .Lxchal_pofs_ 3062306a36Sopenharmony_ci.endm 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define _SELECT ( XTHAL_SAS_TIE | XTHAL_SAS_OPT \ 3362306a36Sopenharmony_ci | XTHAL_SAS_CC \ 3462306a36Sopenharmony_ci | XTHAL_SAS_CALR | XTHAL_SAS_CALE ) 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci.macro save_xtregs_opt ptr clb at1 at2 at3 at4 offset 3762306a36Sopenharmony_ci .if XTREGS_OPT_SIZE > 0 3862306a36Sopenharmony_ci addi \clb, \ptr, \offset 3962306a36Sopenharmony_ci xchal_ncp_store \clb \at1 \at2 \at3 \at4 select=_SELECT 4062306a36Sopenharmony_ci .endif 4162306a36Sopenharmony_ci.endm 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci.macro load_xtregs_opt ptr clb at1 at2 at3 at4 offset 4462306a36Sopenharmony_ci .if XTREGS_OPT_SIZE > 0 4562306a36Sopenharmony_ci addi \clb, \ptr, \offset 4662306a36Sopenharmony_ci xchal_ncp_load \clb \at1 \at2 \at3 \at4 select=_SELECT 4762306a36Sopenharmony_ci .endif 4862306a36Sopenharmony_ci.endm 4962306a36Sopenharmony_ci#undef _SELECT 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define _SELECT ( XTHAL_SAS_TIE | XTHAL_SAS_OPT \ 5262306a36Sopenharmony_ci | XTHAL_SAS_NOCC \ 5362306a36Sopenharmony_ci | XTHAL_SAS_CALR | XTHAL_SAS_CALE | XTHAL_SAS_GLOB ) 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci.macro save_xtregs_user ptr clb at1 at2 at3 at4 offset 5662306a36Sopenharmony_ci .if XTREGS_USER_SIZE > 0 5762306a36Sopenharmony_ci addi \clb, \ptr, \offset 5862306a36Sopenharmony_ci xchal_ncp_store \clb \at1 \at2 \at3 \at4 select=_SELECT 5962306a36Sopenharmony_ci .endif 6062306a36Sopenharmony_ci.endm 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci.macro load_xtregs_user ptr clb at1 at2 at3 at4 offset 6362306a36Sopenharmony_ci .if XTREGS_USER_SIZE > 0 6462306a36Sopenharmony_ci addi \clb, \ptr, \offset 6562306a36Sopenharmony_ci xchal_ncp_load \clb \at1 \at2 \at3 \at4 select=_SELECT 6662306a36Sopenharmony_ci .endif 6762306a36Sopenharmony_ci.endm 6862306a36Sopenharmony_ci#undef _SELECT 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */ 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* 7562306a36Sopenharmony_ci * XTENSA_HAVE_COPROCESSOR(x) returns 1 if coprocessor x is configured. 7662306a36Sopenharmony_ci * 7762306a36Sopenharmony_ci * XTENSA_HAVE_IO_PORT(x) returns 1 if io-port x is configured. 7862306a36Sopenharmony_ci * 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define XTENSA_HAVE_COPROCESSOR(x) \ 8262306a36Sopenharmony_ci ((XCHAL_CP_MASK ^ XCHAL_CP_PORT_MASK) & (1 << (x))) 8362306a36Sopenharmony_ci#define XTENSA_HAVE_COPROCESSORS \ 8462306a36Sopenharmony_ci (XCHAL_CP_MASK ^ XCHAL_CP_PORT_MASK) 8562306a36Sopenharmony_ci#define XTENSA_HAVE_IO_PORT(x) \ 8662306a36Sopenharmony_ci (XCHAL_CP_PORT_MASK & (1 << (x))) 8762306a36Sopenharmony_ci#define XTENSA_HAVE_IO_PORTS \ 8862306a36Sopenharmony_ci XCHAL_CP_PORT_MASK 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci/* 9362306a36Sopenharmony_ci * Additional registers. 9462306a36Sopenharmony_ci * We define three types of additional registers: 9562306a36Sopenharmony_ci * ext: extra registers that are used by the compiler 9662306a36Sopenharmony_ci * cpn: optional registers that can be used by a user application 9762306a36Sopenharmony_ci * cpX: coprocessor registers that can only be used if the corresponding 9862306a36Sopenharmony_ci * CPENABLE bit is set. 9962306a36Sopenharmony_ci */ 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci#define XCHAL_SA_REG(list,cc,abi,type,y,name,z,align,size,...) \ 10262306a36Sopenharmony_ci __REG ## list (cc, abi, type, name, size, align) 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci#define __REG0(cc,abi,t,name,s,a) __REG0_ ## cc (abi,name) 10562306a36Sopenharmony_ci#define __REG1(cc,abi,t,name,s,a) __REG1_ ## cc (name) 10662306a36Sopenharmony_ci#define __REG2(cc,abi,type,...) __REG2_ ## type (__VA_ARGS__) 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci#define __REG0_0(abi,name) 10962306a36Sopenharmony_ci#define __REG0_1(abi,name) __REG0_1 ## abi (name) 11062306a36Sopenharmony_ci#define __REG0_10(name) __u32 name; 11162306a36Sopenharmony_ci#define __REG0_11(name) __u32 name; 11262306a36Sopenharmony_ci#define __REG0_12(name) 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#define __REG1_0(name) __u32 name; 11562306a36Sopenharmony_ci#define __REG1_1(name) 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#define __REG2_0(n,s,a) __u32 name; 11862306a36Sopenharmony_ci#define __REG2_1(n,s,a) unsigned char n[s] __attribute__ ((aligned(a))); 11962306a36Sopenharmony_ci#define __REG2_2(n,s,a) unsigned char n[s] __attribute__ ((aligned(a))); 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_citypedef struct { XCHAL_NCP_SA_LIST(0) } xtregs_opt_t 12262306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_NCP_SA_ALIGN))); 12362306a36Sopenharmony_citypedef struct { XCHAL_NCP_SA_LIST(1) } xtregs_user_t 12462306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_NCP_SA_ALIGN))); 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci#if XTENSA_HAVE_COPROCESSORS 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_citypedef struct { XCHAL_CP0_SA_LIST(2) } xtregs_cp0_t 12962306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_CP0_SA_ALIGN))); 13062306a36Sopenharmony_citypedef struct { XCHAL_CP1_SA_LIST(2) } xtregs_cp1_t 13162306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_CP1_SA_ALIGN))); 13262306a36Sopenharmony_citypedef struct { XCHAL_CP2_SA_LIST(2) } xtregs_cp2_t 13362306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_CP2_SA_ALIGN))); 13462306a36Sopenharmony_citypedef struct { XCHAL_CP3_SA_LIST(2) } xtregs_cp3_t 13562306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_CP3_SA_ALIGN))); 13662306a36Sopenharmony_citypedef struct { XCHAL_CP4_SA_LIST(2) } xtregs_cp4_t 13762306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_CP4_SA_ALIGN))); 13862306a36Sopenharmony_citypedef struct { XCHAL_CP5_SA_LIST(2) } xtregs_cp5_t 13962306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_CP5_SA_ALIGN))); 14062306a36Sopenharmony_citypedef struct { XCHAL_CP6_SA_LIST(2) } xtregs_cp6_t 14162306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_CP6_SA_ALIGN))); 14262306a36Sopenharmony_citypedef struct { XCHAL_CP7_SA_LIST(2) } xtregs_cp7_t 14362306a36Sopenharmony_ci __attribute__ ((aligned (XCHAL_CP7_SA_ALIGN))); 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_cistruct thread_info; 14662306a36Sopenharmony_civoid coprocessor_flush(struct thread_info *ti, int cp_index); 14762306a36Sopenharmony_civoid coprocessor_release_all(struct thread_info *ti); 14862306a36Sopenharmony_civoid coprocessor_flush_all(struct thread_info *ti); 14962306a36Sopenharmony_civoid coprocessor_flush_release_all(struct thread_info *ti); 15062306a36Sopenharmony_civoid local_coprocessors_flush_release_all(void); 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci#endif /* XTENSA_HAVE_COPROCESSORS */ 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 15562306a36Sopenharmony_ci#endif /* _XTENSA_COPROCESSOR_H */ 156