2 * include/asm-xtensa/coprocessor.h
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * Copyright (C) 2003 - 2007 Tensilica Inc.
12 #ifndef _XTENSA_COPROCESSOR_H
13 #define _XTENSA_COPROCESSOR_H
15 #include <variant/tie.h>
17 #include <asm/types.h>
20 # include <variant/tie-asm.h>
22 .macro xchal_sa_start a b
27 .macro xchal_sa_align ptr minofs maxofs ofsalign totalign
28 .set
.Lxchal_ofs_
, .Lxchal_ofs_
+ .Lxchal_pofs_
+ \totalign
- 1
29 .set
.Lxchal_ofs_
, (.Lxchal_ofs_
& -\totalign
) - .Lxchal_pofs_
32 #define _SELECT ( XTHAL_SAS_TIE | XTHAL_SAS_OPT \
34 | XTHAL_SAS_CALR | XTHAL_SAS_CALE )
36 .macro save_xtregs_opt ptr clb at1 at2 at3 at4 offset
37 .if XTREGS_OPT_SIZE
> 0
38 addi \clb
, \ptr
, \offset
39 xchal_ncp_store \clb
\at
1 \at
2 \at
3 \at
4 select
=_SELECT
43 .macro load_xtregs_opt ptr clb at1 at2 at3 at4 offset
44 .if XTREGS_OPT_SIZE
> 0
45 addi \clb
, \ptr
, \offset
46 xchal_ncp_load \clb
\at
1 \at
2 \at
3 \at
4 select
=_SELECT
51 #define _SELECT ( XTHAL_SAS_TIE | XTHAL_SAS_OPT \
53 | XTHAL_SAS_CALR | XTHAL_SAS_CALE | XTHAL_SAS_GLOB )
55 .macro save_xtregs_user ptr clb at1 at2 at3 at4 offset
56 .if XTREGS_USER_SIZE
> 0
57 addi \clb
, \ptr
, \offset
58 xchal_ncp_store \clb
\at
1 \at
2 \at
3 \at
4 select
=_SELECT
62 .macro load_xtregs_user ptr clb at1 at2 at3 at4 offset
63 .if XTREGS_USER_SIZE
> 0
64 addi \clb
, \ptr
, \offset
65 xchal_ncp_load \clb
\at
1 \at
2 \at
3 \at
4 select
=_SELECT
72 #endif /* __ASSEMBLY__ */
75 * XTENSA_HAVE_COPROCESSOR(x) returns 1 if coprocessor x is configured.
77 * XTENSA_HAVE_IO_PORT(x) returns 1 if io-port x is configured.
81 #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 \
93 * Additional registers.
94 * We define three types of additional registers:
95 * ext: extra registers that are used by the compiler
96 * cpn: optional registers that can be used by a user application
97 * cpX: coprocessor registers that can only be used if the corresponding
98 * CPENABLE bit is set.
101 #define XCHAL_SA_REG(list,cc,abi,type,y,name,z,align,size,...) \
102 __REG ## list (cc, abi, type, name, size, align)
104 #define __REG0(cc,abi,t,name,s,a) __REG0_ ## cc (abi,name)
105 #define __REG1(cc,abi,t,name,s,a) __REG1_ ## cc (name)
106 #define __REG2(cc,abi,type,...) __REG2_ ## type (__VA_ARGS__)
108 #define __REG0_0(abi,name)
109 #define __REG0_1(abi,name) __REG0_1 ## abi (name)
110 #define __REG0_10(name) __u32 name;
111 #define __REG0_11(name) __u32 name;
112 #define __REG0_12(name)
114 #define __REG1_0(name) __u32 name;
115 #define __REG1_1(name)
117 #define __REG2_0(n,s,a) __u32 name;
118 #define __REG2_1(n,s,a) unsigned char n[s] __attribute__ ((aligned(a)));
119 #define __REG2_2(n,s,a) unsigned char n[s] __attribute__ ((aligned(a)));
121 typedef struct { XCHAL_NCP_SA_LIST(0) } xtregs_opt_t
122 __attribute__ ((aligned (XCHAL_NCP_SA_ALIGN
)));
123 typedef struct { XCHAL_NCP_SA_LIST(1) } xtregs_user_t
124 __attribute__ ((aligned (XCHAL_NCP_SA_ALIGN
)));
126 #if XTENSA_HAVE_COPROCESSORS
128 typedef struct { XCHAL_CP0_SA_LIST(2) } xtregs_cp0_t
129 __attribute__ ((aligned (XCHAL_CP0_SA_ALIGN
)));
130 typedef struct { XCHAL_CP1_SA_LIST(2) } xtregs_cp1_t
131 __attribute__ ((aligned (XCHAL_CP1_SA_ALIGN
)));
132 typedef struct { XCHAL_CP2_SA_LIST(2) } xtregs_cp2_t
133 __attribute__ ((aligned (XCHAL_CP2_SA_ALIGN
)));
134 typedef struct { XCHAL_CP3_SA_LIST(2) } xtregs_cp3_t
135 __attribute__ ((aligned (XCHAL_CP3_SA_ALIGN
)));
136 typedef struct { XCHAL_CP4_SA_LIST(2) } xtregs_cp4_t
137 __attribute__ ((aligned (XCHAL_CP4_SA_ALIGN
)));
138 typedef struct { XCHAL_CP5_SA_LIST(2) } xtregs_cp5_t
139 __attribute__ ((aligned (XCHAL_CP5_SA_ALIGN
)));
140 typedef struct { XCHAL_CP6_SA_LIST(2) } xtregs_cp6_t
141 __attribute__ ((aligned (XCHAL_CP6_SA_ALIGN
)));
142 typedef struct { XCHAL_CP7_SA_LIST(2) } xtregs_cp7_t
143 __attribute__ ((aligned (XCHAL_CP7_SA_ALIGN
)));
145 extern struct thread_info
* coprocessor_owner
[XCHAL_CP_MAX
];
146 extern void coprocessor_flush(struct thread_info
*, int);
148 extern void coprocessor_release_all(struct thread_info
*);
149 extern void coprocessor_flush_all(struct thread_info
*);
151 #endif /* XTENSA_HAVE_COPROCESSORS */
153 #endif /* !__ASSEMBLY__ */
154 #endif /* _XTENSA_COPROCESSOR_H */