18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * tie-asm.h -- compile-time HAL assembler definitions dependent on CORE & TIE
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci *  NOTE:  This header file is not meant to be included directly.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci/* This header file contains assembly-language definitions (assembly
88c2ecf20Sopenharmony_ci   macros, etc.) for this specific Xtensa processor's TIE extensions
98c2ecf20Sopenharmony_ci   and options.  It is customized to this Xtensa processor configuration.
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci   Copyright (c) 1999-2015 Cadence Design Systems Inc.
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci   Permission is hereby granted, free of charge, to any person obtaining
148c2ecf20Sopenharmony_ci   a copy of this software and associated documentation files (the
158c2ecf20Sopenharmony_ci   "Software"), to deal in the Software without restriction, including
168c2ecf20Sopenharmony_ci   without limitation the rights to use, copy, modify, merge, publish,
178c2ecf20Sopenharmony_ci   distribute, sublicense, and/or sell copies of the Software, and to
188c2ecf20Sopenharmony_ci   permit persons to whom the Software is furnished to do so, subject to
198c2ecf20Sopenharmony_ci   the following conditions:
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci   The above copyright notice and this permission notice shall be included
228c2ecf20Sopenharmony_ci   in all copies or substantial portions of the Software.
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
258c2ecf20Sopenharmony_ci   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
268c2ecf20Sopenharmony_ci   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
278c2ecf20Sopenharmony_ci   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
288c2ecf20Sopenharmony_ci   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
298c2ecf20Sopenharmony_ci   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
308c2ecf20Sopenharmony_ci   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#ifndef _XTENSA_CORE_TIE_ASM_H
338c2ecf20Sopenharmony_ci#define _XTENSA_CORE_TIE_ASM_H
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/*  Selection parameter values for save-area save/restore macros:  */
368c2ecf20Sopenharmony_ci/*  Option vs. TIE:  */
378c2ecf20Sopenharmony_ci#define XTHAL_SAS_TIE	0x0001	/* custom extension or coprocessor */
388c2ecf20Sopenharmony_ci#define XTHAL_SAS_OPT	0x0002	/* optional (and not a coprocessor) */
398c2ecf20Sopenharmony_ci#define XTHAL_SAS_ANYOT	0x0003	/* both of the above */
408c2ecf20Sopenharmony_ci/*  Whether used automatically by compiler:  */
418c2ecf20Sopenharmony_ci#define XTHAL_SAS_NOCC	0x0004	/* not used by compiler w/o special opts/code */
428c2ecf20Sopenharmony_ci#define XTHAL_SAS_CC	0x0008	/* used by compiler without special opts/code */
438c2ecf20Sopenharmony_ci#define XTHAL_SAS_ANYCC	0x000C	/* both of the above */
448c2ecf20Sopenharmony_ci/*  ABI handling across function calls:  */
458c2ecf20Sopenharmony_ci#define XTHAL_SAS_CALR	0x0010	/* caller-saved */
468c2ecf20Sopenharmony_ci#define XTHAL_SAS_CALE	0x0020	/* callee-saved */
478c2ecf20Sopenharmony_ci#define XTHAL_SAS_GLOB	0x0040	/* global across function calls (in thread) */
488c2ecf20Sopenharmony_ci#define XTHAL_SAS_ANYABI	0x0070	/* all of the above three */
498c2ecf20Sopenharmony_ci/*  Misc  */
508c2ecf20Sopenharmony_ci#define XTHAL_SAS_ALL	0xFFFF	/* include all default NCP contents */
518c2ecf20Sopenharmony_ci#define XTHAL_SAS3(optie,ccuse,abi)	( ((optie) & XTHAL_SAS_ANYOT)  \
528c2ecf20Sopenharmony_ci					| ((ccuse) & XTHAL_SAS_ANYCC)  \
538c2ecf20Sopenharmony_ci					| ((abi)   & XTHAL_SAS_ANYABI) )
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci    /*
578c2ecf20Sopenharmony_ci      *  Macro to store all non-coprocessor (extra) custom TIE and optional state
588c2ecf20Sopenharmony_ci      *  (not including zero-overhead loop registers).
598c2ecf20Sopenharmony_ci      *  Required parameters:
608c2ecf20Sopenharmony_ci      *      ptr         Save area pointer address register (clobbered)
618c2ecf20Sopenharmony_ci      *                  (register must contain a 4 byte aligned address).
628c2ecf20Sopenharmony_ci      *      at1..at4    Four temporary address registers (first XCHAL_NCP_NUM_ATMPS
638c2ecf20Sopenharmony_ci      *                  registers are clobbered, the remaining are unused).
648c2ecf20Sopenharmony_ci      *  Optional parameters:
658c2ecf20Sopenharmony_ci      *      continue    If macro invoked as part of a larger store sequence, set to 1
668c2ecf20Sopenharmony_ci      *                  if this is not the first in the sequence.  Defaults to 0.
678c2ecf20Sopenharmony_ci      *      ofs         Offset from start of larger sequence (from value of first ptr
688c2ecf20Sopenharmony_ci      *                  in sequence) at which to store.  Defaults to next available space
698c2ecf20Sopenharmony_ci      *                  (or 0 if <continue> is 0).
708c2ecf20Sopenharmony_ci      *      select      Select what category(ies) of registers to store, as a bitmask
718c2ecf20Sopenharmony_ci      *                  (see XTHAL_SAS_xxx constants).  Defaults to all registers.
728c2ecf20Sopenharmony_ci      *      alloc       Select what category(ies) of registers to allocate; if any
738c2ecf20Sopenharmony_ci      *                  category is selected here that is not in <select>, space for
748c2ecf20Sopenharmony_ci      *                  the corresponding registers is skipped without doing any store.
758c2ecf20Sopenharmony_ci      */
768c2ecf20Sopenharmony_ci    .macro xchal_ncp_store  ptr at1 at2 at3 at4  continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=0
778c2ecf20Sopenharmony_ci	xchal_sa_start	\continue, \ofs
788c2ecf20Sopenharmony_ci	// Optional caller-saved registers used by default by the compiler:
798c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select)
808c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1016, 4, 4
818c2ecf20Sopenharmony_ci	rsr.ACCLO	\at1		// MAC16 option
828c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_+0
838c2ecf20Sopenharmony_ci	rsr.ACCHI	\at1		// MAC16 option
848c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_+4
858c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 8
868c2ecf20Sopenharmony_ci	.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
878c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1016, 4, 4
888c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 8
898c2ecf20Sopenharmony_ci	.endif
908c2ecf20Sopenharmony_ci	// Optional caller-saved registers not used by default by the compiler:
918c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select)
928c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1004, 4, 4
938c2ecf20Sopenharmony_ci	rsr.SCOMPARE1	\at1		// conditional store option
948c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_+0
958c2ecf20Sopenharmony_ci	rsr.M0	\at1		// MAC16 option
968c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_+4
978c2ecf20Sopenharmony_ci	rsr.M1	\at1		// MAC16 option
988c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_+8
998c2ecf20Sopenharmony_ci	rsr.M2	\at1		// MAC16 option
1008c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_+12
1018c2ecf20Sopenharmony_ci	rsr.M3	\at1		// MAC16 option
1028c2ecf20Sopenharmony_ci	s32i	\at1, \ptr, .Lxchal_ofs_+16
1038c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 20
1048c2ecf20Sopenharmony_ci	.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
1058c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1004, 4, 4
1068c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 20
1078c2ecf20Sopenharmony_ci	.endif
1088c2ecf20Sopenharmony_ci    .endm	// xchal_ncp_store
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci    /*
1118c2ecf20Sopenharmony_ci      *  Macro to load all non-coprocessor (extra) custom TIE and optional state
1128c2ecf20Sopenharmony_ci      *  (not including zero-overhead loop registers).
1138c2ecf20Sopenharmony_ci      *  Required parameters:
1148c2ecf20Sopenharmony_ci      *      ptr         Save area pointer address register (clobbered)
1158c2ecf20Sopenharmony_ci      *                  (register must contain a 4 byte aligned address).
1168c2ecf20Sopenharmony_ci      *      at1..at4    Four temporary address registers (first XCHAL_NCP_NUM_ATMPS
1178c2ecf20Sopenharmony_ci      *                  registers are clobbered, the remaining are unused).
1188c2ecf20Sopenharmony_ci      *  Optional parameters:
1198c2ecf20Sopenharmony_ci      *      continue    If macro invoked as part of a larger load sequence, set to 1
1208c2ecf20Sopenharmony_ci      *                  if this is not the first in the sequence.  Defaults to 0.
1218c2ecf20Sopenharmony_ci      *      ofs         Offset from start of larger sequence (from value of first ptr
1228c2ecf20Sopenharmony_ci      *                  in sequence) at which to load.  Defaults to next available space
1238c2ecf20Sopenharmony_ci      *                  (or 0 if <continue> is 0).
1248c2ecf20Sopenharmony_ci      *      select      Select what category(ies) of registers to load, as a bitmask
1258c2ecf20Sopenharmony_ci      *                  (see XTHAL_SAS_xxx constants).  Defaults to all registers.
1268c2ecf20Sopenharmony_ci      *      alloc       Select what category(ies) of registers to allocate; if any
1278c2ecf20Sopenharmony_ci      *                  category is selected here that is not in <select>, space for
1288c2ecf20Sopenharmony_ci      *                  the corresponding registers is skipped without doing any load.
1298c2ecf20Sopenharmony_ci      */
1308c2ecf20Sopenharmony_ci    .macro xchal_ncp_load  ptr at1 at2 at3 at4  continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=0
1318c2ecf20Sopenharmony_ci	xchal_sa_start	\continue, \ofs
1328c2ecf20Sopenharmony_ci	// Optional caller-saved registers used by default by the compiler:
1338c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select)
1348c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1016, 4, 4
1358c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_+0
1368c2ecf20Sopenharmony_ci	wsr.ACCLO	\at1		// MAC16 option
1378c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_+4
1388c2ecf20Sopenharmony_ci	wsr.ACCHI	\at1		// MAC16 option
1398c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 8
1408c2ecf20Sopenharmony_ci	.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
1418c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1016, 4, 4
1428c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 8
1438c2ecf20Sopenharmony_ci	.endif
1448c2ecf20Sopenharmony_ci	// Optional caller-saved registers not used by default by the compiler:
1458c2ecf20Sopenharmony_ci	.ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select)
1468c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1004, 4, 4
1478c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_+0
1488c2ecf20Sopenharmony_ci	wsr.SCOMPARE1	\at1		// conditional store option
1498c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_+4
1508c2ecf20Sopenharmony_ci	wsr.M0	\at1		// MAC16 option
1518c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_+8
1528c2ecf20Sopenharmony_ci	wsr.M1	\at1		// MAC16 option
1538c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_+12
1548c2ecf20Sopenharmony_ci	wsr.M2	\at1		// MAC16 option
1558c2ecf20Sopenharmony_ci	l32i	\at1, \ptr, .Lxchal_ofs_+16
1568c2ecf20Sopenharmony_ci	wsr.M3	\at1		// MAC16 option
1578c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 20
1588c2ecf20Sopenharmony_ci	.elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
1598c2ecf20Sopenharmony_ci	xchal_sa_align	\ptr, 0, 1004, 4, 4
1608c2ecf20Sopenharmony_ci	.set	.Lxchal_ofs_, .Lxchal_ofs_ + 20
1618c2ecf20Sopenharmony_ci	.endif
1628c2ecf20Sopenharmony_ci    .endm	// xchal_ncp_load
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci#define XCHAL_NCP_NUM_ATMPS	1
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci#define XCHAL_SA_NUM_ATMPS	1
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci#endif /*_XTENSA_CORE_TIE_ASM_H*/
1708c2ecf20Sopenharmony_ci
171