18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This header file contains assembly-language definitions (assembly
38c2ecf20Sopenharmony_ci * macros, etc.) for this specific Xtensa processor's TIE extensions
48c2ecf20Sopenharmony_ci * and options.  It is customized to this Xtensa processor configuration.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
78c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
88c2ecf20Sopenharmony_ci * for more details.
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * Copyright (C) 1999-2007 Tensilica Inc.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifndef _XTENSA_CORE_TIE_ASM_H
148c2ecf20Sopenharmony_ci#define _XTENSA_CORE_TIE_ASM_H
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/*  Selection parameter values for save-area save/restore macros:  */
178c2ecf20Sopenharmony_ci/*  Option vs. TIE:  */
188c2ecf20Sopenharmony_ci#define XTHAL_SAS_TIE	0x0001	/* custom extension or coprocessor */
198c2ecf20Sopenharmony_ci#define XTHAL_SAS_OPT	0x0002	/* optional (and not a coprocessor) */
208c2ecf20Sopenharmony_ci/*  Whether used automatically by compiler:  */
218c2ecf20Sopenharmony_ci#define XTHAL_SAS_NOCC	0x0004	/* not used by compiler w/o special opts/code */
228c2ecf20Sopenharmony_ci#define XTHAL_SAS_CC	0x0008	/* used by compiler without special opts/code */
238c2ecf20Sopenharmony_ci/*  ABI handling across function calls:  */
248c2ecf20Sopenharmony_ci#define XTHAL_SAS_CALR	0x0010	/* caller-saved */
258c2ecf20Sopenharmony_ci#define XTHAL_SAS_CALE	0x0020	/* callee-saved */
268c2ecf20Sopenharmony_ci#define XTHAL_SAS_GLOB	0x0040	/* global across function calls (in thread) */
278c2ecf20Sopenharmony_ci/*  Misc  */
288c2ecf20Sopenharmony_ci#define XTHAL_SAS_ALL	0xFFFF	/* include all default NCP contents */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* Macro to save all non-coprocessor (extra) custom TIE and optional state
338c2ecf20Sopenharmony_ci * (not including zero-overhead loop registers).
348c2ecf20Sopenharmony_ci * Save area ptr (clobbered):  ptr  (1 byte aligned)
358c2ecf20Sopenharmony_ci * Scratch regs  (clobbered):  at1..at4  (only first XCHAL_NCP_NUM_ATMPS needed)
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_ci	.macro xchal_ncp_store  ptr at1 at2 at3 at4  continue=0 ofs=-1 select=XTHAL_SAS_ALL
388c2ecf20Sopenharmony_ci	xchal_sa_start	\continue, \ofs
398c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~\select
408c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1024-8, 4, 4
418c2ecf20Sopenharmony_ci	rsr	\at1, ACCLO		// MAC16 accumulator
428c2ecf20Sopenharmony_ci	rsr	\at2, ACCHI
438c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_ + 0
448c2ecf20Sopenharmony_ci	s32i	\at2, \ptr, .Lxchal_ofs_ + 4
458c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 8
468c2ecf20Sopenharmony_ci	.endif
478c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~\select
488c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1024-16, 4, 4
498c2ecf20Sopenharmony_ci	rsr	\at1, M0		// MAC16 registers
508c2ecf20Sopenharmony_ci	rsr	\at2, M1
518c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_ + 0
528c2ecf20Sopenharmony_ci	s32i	\at2, \ptr, .Lxchal_ofs_ + 4
538c2ecf20Sopenharmony_ci	rsr	\at1, M2
548c2ecf20Sopenharmony_ci	rsr	\at2, M3
558c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_ + 8
568c2ecf20Sopenharmony_ci	s32i	\at2, \ptr, .Lxchal_ofs_ + 12
578c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 16
588c2ecf20Sopenharmony_ci	.endif
598c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~\select
608c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1024-4, 4, 4
618c2ecf20Sopenharmony_ci	rsr	\at1, SCOMPARE1		// conditional store option
628c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_ + 0
638c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 4
648c2ecf20Sopenharmony_ci	.endif
658c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~\select
668c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1024-4, 4, 4
678c2ecf20Sopenharmony_ci	rur	\at1, THREADPTR		// threadptr option
688c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_ + 0
698c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 4
708c2ecf20Sopenharmony_ci	.endif
718c2ecf20Sopenharmony_ci	.endm	// xchal_ncp_store
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/* Macro to save all non-coprocessor (extra) custom TIE and optional state
748c2ecf20Sopenharmony_ci * (not including zero-overhead loop registers).
758c2ecf20Sopenharmony_ci * Save area ptr (clobbered):  ptr  (1 byte aligned)
768c2ecf20Sopenharmony_ci * Scratch regs  (clobbered):  at1..at4  (only first XCHAL_NCP_NUM_ATMPS needed)
778c2ecf20Sopenharmony_ci */
788c2ecf20Sopenharmony_ci	.macro xchal_ncp_load  ptr at1 at2 at3 at4  continue=0 ofs=-1 select=XTHAL_SAS_ALL
798c2ecf20Sopenharmony_ci	xchal_sa_start	\continue, \ofs
808c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~\select
818c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1024-8, 4, 4
828c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_ + 0
838c2ecf20Sopenharmony_ci	l32i	\at2, \ptr, .Lxchal_ofs_ + 4
848c2ecf20Sopenharmony_ci	wsr	\at1, ACCLO		// MAC16 accumulator
858c2ecf20Sopenharmony_ci	wsr	\at2, ACCHI
868c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 8
878c2ecf20Sopenharmony_ci	.endif
888c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~\select
898c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1024-16, 4, 4
908c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_ + 0
918c2ecf20Sopenharmony_ci	l32i	\at2, \ptr, .Lxchal_ofs_ + 4
928c2ecf20Sopenharmony_ci	wsr	\at1, M0		// MAC16 registers
938c2ecf20Sopenharmony_ci	wsr	\at2, M1
948c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_ + 8
958c2ecf20Sopenharmony_ci	l32i	\at2, \ptr, .Lxchal_ofs_ + 12
968c2ecf20Sopenharmony_ci	wsr	\at1, M2
978c2ecf20Sopenharmony_ci	wsr	\at2, M3
988c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 16
998c2ecf20Sopenharmony_ci	.endif
1008c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~\select
1018c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1024-4, 4, 4
1028c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_ + 0
1038c2ecf20Sopenharmony_ci	wsr	\at1, SCOMPARE1		// conditional store option
1048c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 4
1058c2ecf20Sopenharmony_ci	.endif
1068c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~\select
1078c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1024-4, 4, 4
1088c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_ + 0
1098c2ecf20Sopenharmony_ci	wur	\at1, THREADPTR		// threadptr option
1108c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 4
1118c2ecf20Sopenharmony_ci	.endif
1128c2ecf20Sopenharmony_ci	.endm	// xchal_ncp_load
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define XCHAL_NCP_NUM_ATMPS	2
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define XCHAL_SA_NUM_ATMPS	2
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#endif /*_XTENSA_CORE_TIE_ASM_H*/
1228c2ecf20Sopenharmony_ci
123