13d8536b4Sopenharmony_ci/*
23d8536b4Sopenharmony_ci * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
33d8536b4Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
43d8536b4Sopenharmony_ci *
53d8536b4Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification,
63d8536b4Sopenharmony_ci * are permitted provided that the following conditions are met:
73d8536b4Sopenharmony_ci *
83d8536b4Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of
93d8536b4Sopenharmony_ci *    conditions and the following disclaimer.
103d8536b4Sopenharmony_ci *
113d8536b4Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list
123d8536b4Sopenharmony_ci *    of conditions and the following disclaimer in the documentation and/or other materials
133d8536b4Sopenharmony_ci *    provided with the distribution.
143d8536b4Sopenharmony_ci *
153d8536b4Sopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used
163d8536b4Sopenharmony_ci *    to endorse or promote products derived from this software without specific prior written
173d8536b4Sopenharmony_ci *    permission.
183d8536b4Sopenharmony_ci *
193d8536b4Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
203d8536b4Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
213d8536b4Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
223d8536b4Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
233d8536b4Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
243d8536b4Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
253d8536b4Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
263d8536b4Sopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
273d8536b4Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
283d8536b4Sopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
293d8536b4Sopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
303d8536b4Sopenharmony_ci */
313d8536b4Sopenharmony_ci
323d8536b4Sopenharmony_ci/**
333d8536b4Sopenharmony_ci * @defgroup Special Register Fields and Values
343d8536b4Sopenharmony_ci * @ingroup kernel
353d8536b4Sopenharmony_ci */
363d8536b4Sopenharmony_ci
373d8536b4Sopenharmony_ci#ifndef _ARCH_REGS_H
383d8536b4Sopenharmony_ci#define _ARCH_REGS_H
393d8536b4Sopenharmony_ci
403d8536b4Sopenharmony_ci#ifdef __cplusplus
413d8536b4Sopenharmony_ci#if __cplusplus
423d8536b4Sopenharmony_ciextern "C" {
433d8536b4Sopenharmony_ci#endif /* __cplusplus */
443d8536b4Sopenharmony_ci#endif /* __cplusplus */
453d8536b4Sopenharmony_ci
463d8536b4Sopenharmony_ci/* PS register -- imprecise exception */
473d8536b4Sopenharmony_ci#define SPREG_PS_DEPC_SHIFT                                  4
483d8536b4Sopenharmony_ci#define SPREG_PS_DEPC_MASK                                   0x00000004
493d8536b4Sopenharmony_ci#define SPREG_PS_DEPC                                        SPREG_PS_DEPC_MASK
503d8536b4Sopenharmony_ci/* PS register -- interrupt part */
513d8536b4Sopenharmony_ci#define SPREG_PS_DI_SHIFT                                    3
523d8536b4Sopenharmony_ci#define SPREG_PS_DI_MASK                                     0x0000000F
533d8536b4Sopenharmony_ci#define SPREG_PS_DI                                          SPREG_PS_DI_MASK
543d8536b4Sopenharmony_ci#define SPREG_PS_DI_DEPC                                     0x0000000C
553d8536b4Sopenharmony_ci/* PS register -- stack part */
563d8536b4Sopenharmony_ci#define SPREG_PS_STACK_SHIFT                                 5
573d8536b4Sopenharmony_ci#define SPREG_PS_STACK_MASK                                  0x000000E0
583d8536b4Sopenharmony_ci#define SPREG_PS_STACK_INTERRUPT                             0x00000000
593d8536b4Sopenharmony_ci#define SPREG_PS_STACK_CROSS                                 0x00000020
603d8536b4Sopenharmony_ci#define SPREG_PS_STACK_IDLE                                  0x00000040
613d8536b4Sopenharmony_ci#define SPREG_PS_STACK_KERNEL                                0x00000060
623d8536b4Sopenharmony_ci#define SPREG_PS_STACK_PAGE                                  0x000000E0
633d8536b4Sopenharmony_ci#define SPREG_PS_STACK_FIRSTINT                              0x00000080
643d8536b4Sopenharmony_ci#define SPREG_PS_STACK_FIRSTKER                              0x000000A0
653d8536b4Sopenharmony_ci/* PS register -- entry no rotate */
663d8536b4Sopenharmony_ci#define SPREG_PS_ENTRYNR_SHIFT                               22
673d8536b4Sopenharmony_ci#define SPREG_PS_ENTRYNR_MASK                                0x00400000
683d8536b4Sopenharmony_ci#define SPREG_PS_ENTRYNR                                     SPREG_PS_ENTRYNR_MASK
693d8536b4Sopenharmony_ci
703d8536b4Sopenharmony_ci/* Exccause Register  -- cause */
713d8536b4Sopenharmony_ci#define SPREG_EXCCAUSE_CAUSE_SHIFT                           0
723d8536b4Sopenharmony_ci#define SPREG_EXCCAUSE_CAUSE_BITS                            4
733d8536b4Sopenharmony_ci#define SPREG_EXCCAUSE_CAUSE_MASK                            0x0000000F
743d8536b4Sopenharmony_ci
753d8536b4Sopenharmony_ci/**
763d8536b4Sopenharmony_ci * @ingroup Execute level of core
773d8536b4Sopenharmony_ci */
783d8536b4Sopenharmony_ci#define EXEC_LEVEL_APPLICATION_CODE                          2
793d8536b4Sopenharmony_ci#define EXEC_LEVEL_EXCEPTION_HANDLER                         3
803d8536b4Sopenharmony_ci#define EXEC_LEVEL_INTERRUPT_HANDLER                         4
813d8536b4Sopenharmony_ci#define EXEC_LEVEL_NON_INTERRUPTIBLE                         5
823d8536b4Sopenharmony_ci
833d8536b4Sopenharmony_ci/**
843d8536b4Sopenharmony_ci * @ingroup Schedule Flag stored on Task Context
853d8536b4Sopenharmony_ci */
863d8536b4Sopenharmony_ci#define OS_SCHED_FLAG_TASKPREEMT                             4 /* Task Preemted through LOS_Schedule */
873d8536b4Sopenharmony_ci
883d8536b4Sopenharmony_ci/**
893d8536b4Sopenharmony_ci * @ingroup Context Fields Define
903d8536b4Sopenharmony_ci */
913d8536b4Sopenharmony_ci#define CONTEXT_OFF_EPC                                      0
923d8536b4Sopenharmony_ci#define CONTEXT_OFF_PC                                       0 /* reuse with EPC */
933d8536b4Sopenharmony_ci#define CONTEXT_OFF_PS                                       4
943d8536b4Sopenharmony_ci#define CONTEXT_OFF_A0                                       8
953d8536b4Sopenharmony_ci#define CONTEXT_OFF_A1                                       12
963d8536b4Sopenharmony_ci#define CONTEXT_OFF_A2                                       16
973d8536b4Sopenharmony_ci#define CONTEXT_OFF_A3                                       20
983d8536b4Sopenharmony_ci#define CONTEXT_OFF_A4                                       24
993d8536b4Sopenharmony_ci#define CONTEXT_OFF_A5                                       28
1003d8536b4Sopenharmony_ci#define CONTEXT_OFF_A6                                       32
1013d8536b4Sopenharmony_ci#define CONTEXT_OFF_A7                                       36
1023d8536b4Sopenharmony_ci#define CONTEXT_OFF_A8                                       40
1033d8536b4Sopenharmony_ci#define CONTEXT_OFF_A9                                       44
1043d8536b4Sopenharmony_ci#define CONTEXT_OFF_A10                                      48
1053d8536b4Sopenharmony_ci#define CONTEXT_OFF_A11                                      52
1063d8536b4Sopenharmony_ci#define CONTEXT_OFF_A12                                      56
1073d8536b4Sopenharmony_ci#define CONTEXT_OFF_A13                                      60
1083d8536b4Sopenharmony_ci#define CONTEXT_OFF_A14                                      64
1093d8536b4Sopenharmony_ci#define CONTEXT_OFF_A15                                      68
1103d8536b4Sopenharmony_ci#define CONTEXT_OFF_RESERVED                                 72
1113d8536b4Sopenharmony_ci#define CONTEXT_OFF_SAR                                      72
1123d8536b4Sopenharmony_ci#define CONTEXT_OFF_SCHED_FLAG                               76 /* reuse with exccause */
1133d8536b4Sopenharmony_ci#define CONTEXT_OFF_EXCCAUSE                                 76
1143d8536b4Sopenharmony_ci#define CONTEXT_OFF_EXCVADDR                                 80
1153d8536b4Sopenharmony_ci#define CONTEXT_OFF_LBEG                                     84
1163d8536b4Sopenharmony_ci#define CONTEXT_OFF_LEND                                     88
1173d8536b4Sopenharmony_ci#define CONTEXT_OFF_LCOUNT                                   92
1183d8536b4Sopenharmony_ci
1193d8536b4Sopenharmony_ci#if (defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U))
1203d8536b4Sopenharmony_ci#define CONTEXT_OFF_TMP0                                     96
1213d8536b4Sopenharmony_ci#define CONTEXT_OFF_CPENABLE                                 100
1223d8536b4Sopenharmony_ci#define CONTEXT_OFF_CPSTORED                                 102
1233d8536b4Sopenharmony_ci#define CONTEXT_OFF_FCR                                      104
1243d8536b4Sopenharmony_ci#define CONTEXT_OFF_FSR                                      108
1253d8536b4Sopenharmony_ci#define CONTEXT_OFF_F0                                       112
1263d8536b4Sopenharmony_ci#define CONTEXT_OFF_F1                                       116
1273d8536b4Sopenharmony_ci#define CONTEXT_OFF_F2                                       120
1283d8536b4Sopenharmony_ci#define CONTEXT_OFF_F3                                       124
1293d8536b4Sopenharmony_ci#define CONTEXT_OFF_F4                                       128
1303d8536b4Sopenharmony_ci#define CONTEXT_OFF_F5                                       132
1313d8536b4Sopenharmony_ci#define CONTEXT_OFF_F6                                       136
1323d8536b4Sopenharmony_ci#define CONTEXT_OFF_F7                                       140
1333d8536b4Sopenharmony_ci#define CONTEXT_OFF_F8                                       144
1343d8536b4Sopenharmony_ci#define CONTEXT_OFF_F9                                       148
1353d8536b4Sopenharmony_ci#define CONTEXT_OFF_F10                                      152
1363d8536b4Sopenharmony_ci#define CONTEXT_OFF_F11                                      156
1373d8536b4Sopenharmony_ci#define CONTEXT_OFF_F12                                      160
1383d8536b4Sopenharmony_ci#define CONTEXT_OFF_F13                                      164
1393d8536b4Sopenharmony_ci#define CONTEXT_OFF_F14                                      168
1403d8536b4Sopenharmony_ci#define CONTEXT_OFF_F15                                      172
1413d8536b4Sopenharmony_ci#define CONTEXT_SIZE                                         192
1423d8536b4Sopenharmony_ci#else
1433d8536b4Sopenharmony_ci#define CONTEXT_SIZE                                         112
1443d8536b4Sopenharmony_ci#endif
1453d8536b4Sopenharmony_ci#define LEVEL1_TINRERRUPT_CAUSE                              4
1463d8536b4Sopenharmony_ci#define ALLOC_CAUSE                                          5
1473d8536b4Sopenharmony_ci#define LOWBIT_CALLNMODE                                     30
1483d8536b4Sopenharmony_ci#define HIGHBIT_CALLNMODE                                    31
1493d8536b4Sopenharmony_ci#define PS_OWB_SHIFT                                         8
1503d8536b4Sopenharmony_ci#define EXCCAUSE_LEVEL1INTERRUPT                             4
1513d8536b4Sopenharmony_ci#define XTENSA_LOGREG_NUM                                    16
1523d8536b4Sopenharmony_ci#define INDEX_OF_SP                                          1
1533d8536b4Sopenharmony_ci#define INDEX_OF_ARGS0                                       6
1543d8536b4Sopenharmony_ci
1553d8536b4Sopenharmony_ci#define WINDOWSTARTBITS                                      16
1563d8536b4Sopenharmony_ci#define WINDOWBASEBITS                                       4
1573d8536b4Sopenharmony_ci#define WINDOWSTARTMASK                                      ((1 << WINDOWSTARTBITS) - 1)
1583d8536b4Sopenharmony_ci
1593d8536b4Sopenharmony_ci#define WOE_ENABLE                                           0x40000
1603d8536b4Sopenharmony_ci#define BIT_CALLINC                                          16
1613d8536b4Sopenharmony_ci#define LEVEL_MASK                                           0xf
1623d8536b4Sopenharmony_ci#define INT_MASK                                             5
1633d8536b4Sopenharmony_ci#define LEVEL1_INT_MASK                                      1
1643d8536b4Sopenharmony_ci#define USER_VECTOR_MODE                                     0x20
1653d8536b4Sopenharmony_ci#define LEVEL1                                               1
1663d8536b4Sopenharmony_ci#define LEVEL2                                               2
1673d8536b4Sopenharmony_ci#define LEVEL3                                               3
1683d8536b4Sopenharmony_ci#define LEVEL4                                               4
1693d8536b4Sopenharmony_ci#define LEVEL5                                               5
1703d8536b4Sopenharmony_ci
1713d8536b4Sopenharmony_ci#ifdef __cplusplus
1723d8536b4Sopenharmony_ci#if __cplusplus
1733d8536b4Sopenharmony_ci}
1743d8536b4Sopenharmony_ci#endif /* __cplusplus */
1753d8536b4Sopenharmony_ci#endif /* __cplusplus */
1763d8536b4Sopenharmony_ci
1773d8536b4Sopenharmony_ci#endif /* _ARCH_REGS_H */
178