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-2010 Tensilica 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 /* 588c2ecf20Sopenharmony_ci * Macro to save all non-coprocessor (extra) custom TIE and optional state 598c2ecf20Sopenharmony_ci * (not including zero-overhead loop registers). 608c2ecf20Sopenharmony_ci * Required parameters: 618c2ecf20Sopenharmony_ci * ptr Save area pointer address register (clobbered) 628c2ecf20Sopenharmony_ci * (register must contain a 4 byte aligned address). 638c2ecf20Sopenharmony_ci * at1..at4 Four temporary address registers (first XCHAL_NCP_NUM_ATMPS 648c2ecf20Sopenharmony_ci * registers are clobbered, the remaining are unused). 658c2ecf20Sopenharmony_ci * Optional parameters: 668c2ecf20Sopenharmony_ci * continue If macro invoked as part of a larger store sequence, set to 1 678c2ecf20Sopenharmony_ci * if this is not the first in the sequence. Defaults to 0. 688c2ecf20Sopenharmony_ci * ofs Offset from start of larger sequence (from value of first ptr 698c2ecf20Sopenharmony_ci * in sequence) at which to store. Defaults to next available space 708c2ecf20Sopenharmony_ci * (or 0 if <continue> is 0). 718c2ecf20Sopenharmony_ci * select Select what category(ies) of registers to store, as a bitmask 728c2ecf20Sopenharmony_ci * (see XTHAL_SAS_xxx constants). Defaults to all registers. 738c2ecf20Sopenharmony_ci * alloc Select what category(ies) of registers to allocate; if any 748c2ecf20Sopenharmony_ci * category is selected here that is not in <select>, space for 758c2ecf20Sopenharmony_ci * the corresponding registers is skipped without doing any store. 768c2ecf20Sopenharmony_ci */ 778c2ecf20Sopenharmony_ci .macro xchal_ncp_store ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=0 788c2ecf20Sopenharmony_ci xchal_sa_start \continue, \ofs 798c2ecf20Sopenharmony_ci // Optional global register used by default by the compiler: 808c2ecf20Sopenharmony_ci .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\select) 818c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1020, 4, 4 828c2ecf20Sopenharmony_ci rur.THREADPTR \at1 // threadptr option 838c2ecf20Sopenharmony_ci s32i \at1, \ptr, .Lxchal_ofs_+0 848c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 4 858c2ecf20Sopenharmony_ci .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\alloc)) == 0 868c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1020, 4, 4 878c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 4 888c2ecf20Sopenharmony_ci .endif 898c2ecf20Sopenharmony_ci // Optional caller-saved registers used by default by the compiler: 908c2ecf20Sopenharmony_ci .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select) 918c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1016, 4, 4 928c2ecf20Sopenharmony_ci rsr \at1, ACCLO // MAC16 option 938c2ecf20Sopenharmony_ci s32i \at1, \ptr, .Lxchal_ofs_+0 948c2ecf20Sopenharmony_ci rsr \at1, ACCHI // MAC16 option 958c2ecf20Sopenharmony_ci s32i \at1, \ptr, .Lxchal_ofs_+4 968c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 8 978c2ecf20Sopenharmony_ci .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0 988c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1016, 4, 4 998c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 8 1008c2ecf20Sopenharmony_ci .endif 1018c2ecf20Sopenharmony_ci // Optional caller-saved registers not used by default by the compiler: 1028c2ecf20Sopenharmony_ci .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select) 1038c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1004, 4, 4 1048c2ecf20Sopenharmony_ci rsr \at1, M0 // MAC16 option 1058c2ecf20Sopenharmony_ci s32i \at1, \ptr, .Lxchal_ofs_+0 1068c2ecf20Sopenharmony_ci rsr \at1, M1 // MAC16 option 1078c2ecf20Sopenharmony_ci s32i \at1, \ptr, .Lxchal_ofs_+4 1088c2ecf20Sopenharmony_ci rsr \at1, M2 // MAC16 option 1098c2ecf20Sopenharmony_ci s32i \at1, \ptr, .Lxchal_ofs_+8 1108c2ecf20Sopenharmony_ci rsr \at1, M3 // MAC16 option 1118c2ecf20Sopenharmony_ci s32i \at1, \ptr, .Lxchal_ofs_+12 1128c2ecf20Sopenharmony_ci rsr \at1, SCOMPARE1 // conditional store option 1138c2ecf20Sopenharmony_ci s32i \at1, \ptr, .Lxchal_ofs_+16 1148c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 20 1158c2ecf20Sopenharmony_ci .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0 1168c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1004, 4, 4 1178c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 20 1188c2ecf20Sopenharmony_ci .endif 1198c2ecf20Sopenharmony_ci .endm // xchal_ncp_store 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci /* 1228c2ecf20Sopenharmony_ci * Macro to restore all non-coprocessor (extra) custom TIE and optional state 1238c2ecf20Sopenharmony_ci * (not including zero-overhead loop registers). 1248c2ecf20Sopenharmony_ci * Required parameters: 1258c2ecf20Sopenharmony_ci * ptr Save area pointer address register (clobbered) 1268c2ecf20Sopenharmony_ci * (register must contain a 4 byte aligned address). 1278c2ecf20Sopenharmony_ci * at1..at4 Four temporary address registers (first XCHAL_NCP_NUM_ATMPS 1288c2ecf20Sopenharmony_ci * registers are clobbered, the remaining are unused). 1298c2ecf20Sopenharmony_ci * Optional parameters: 1308c2ecf20Sopenharmony_ci * continue If macro invoked as part of a larger load sequence, set to 1 1318c2ecf20Sopenharmony_ci * if this is not the first in the sequence. Defaults to 0. 1328c2ecf20Sopenharmony_ci * ofs Offset from start of larger sequence (from value of first ptr 1338c2ecf20Sopenharmony_ci * in sequence) at which to load. Defaults to next available space 1348c2ecf20Sopenharmony_ci * (or 0 if <continue> is 0). 1358c2ecf20Sopenharmony_ci * select Select what category(ies) of registers to load, as a bitmask 1368c2ecf20Sopenharmony_ci * (see XTHAL_SAS_xxx constants). Defaults to all registers. 1378c2ecf20Sopenharmony_ci * alloc Select what category(ies) of registers to allocate; if any 1388c2ecf20Sopenharmony_ci * category is selected here that is not in <select>, space for 1398c2ecf20Sopenharmony_ci * the corresponding registers is skipped without doing any load. 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ci .macro xchal_ncp_load ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=0 1428c2ecf20Sopenharmony_ci xchal_sa_start \continue, \ofs 1438c2ecf20Sopenharmony_ci // Optional global register used by default by the compiler: 1448c2ecf20Sopenharmony_ci .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\select) 1458c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1020, 4, 4 1468c2ecf20Sopenharmony_ci l32i \at1, \ptr, .Lxchal_ofs_+0 1478c2ecf20Sopenharmony_ci wur.THREADPTR \at1 // threadptr option 1488c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 4 1498c2ecf20Sopenharmony_ci .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\alloc)) == 0 1508c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1020, 4, 4 1518c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 4 1528c2ecf20Sopenharmony_ci .endif 1538c2ecf20Sopenharmony_ci // Optional caller-saved registers used by default by the compiler: 1548c2ecf20Sopenharmony_ci .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select) 1558c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1016, 4, 4 1568c2ecf20Sopenharmony_ci l32i \at1, \ptr, .Lxchal_ofs_+0 1578c2ecf20Sopenharmony_ci wsr \at1, ACCLO // MAC16 option 1588c2ecf20Sopenharmony_ci l32i \at1, \ptr, .Lxchal_ofs_+4 1598c2ecf20Sopenharmony_ci wsr \at1, ACCHI // MAC16 option 1608c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 8 1618c2ecf20Sopenharmony_ci .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0 1628c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1016, 4, 4 1638c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 8 1648c2ecf20Sopenharmony_ci .endif 1658c2ecf20Sopenharmony_ci // Optional caller-saved registers not used by default by the compiler: 1668c2ecf20Sopenharmony_ci .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select) 1678c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1004, 4, 4 1688c2ecf20Sopenharmony_ci l32i \at1, \ptr, .Lxchal_ofs_+0 1698c2ecf20Sopenharmony_ci wsr \at1, M0 // MAC16 option 1708c2ecf20Sopenharmony_ci l32i \at1, \ptr, .Lxchal_ofs_+4 1718c2ecf20Sopenharmony_ci wsr \at1, M1 // MAC16 option 1728c2ecf20Sopenharmony_ci l32i \at1, \ptr, .Lxchal_ofs_+8 1738c2ecf20Sopenharmony_ci wsr \at1, M2 // MAC16 option 1748c2ecf20Sopenharmony_ci l32i \at1, \ptr, .Lxchal_ofs_+12 1758c2ecf20Sopenharmony_ci wsr \at1, M3 // MAC16 option 1768c2ecf20Sopenharmony_ci l32i \at1, \ptr, .Lxchal_ofs_+16 1778c2ecf20Sopenharmony_ci wsr \at1, SCOMPARE1 // conditional store option 1788c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 20 1798c2ecf20Sopenharmony_ci .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0 1808c2ecf20Sopenharmony_ci xchal_sa_align \ptr, 0, 1004, 4, 4 1818c2ecf20Sopenharmony_ci .set .Lxchal_ofs_, .Lxchal_ofs_ + 20 1828c2ecf20Sopenharmony_ci .endif 1838c2ecf20Sopenharmony_ci .endm // xchal_ncp_load 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci#define XCHAL_NCP_NUM_ATMPS 1 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci#define XCHAL_SA_NUM_ATMPS 1 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci#endif /*_XTENSA_CORE_TIE_ASM_H*/ 1938c2ecf20Sopenharmony_ci 194