xref: /Kernel-v10.6.2/portable/ThirdParty/GCC/ARC_EM_HS/portmacro.h (revision ef7b253b56c9788077f5ecd6c9deb4021923d646)
1 /*
2  * FreeRTOS Kernel V10.6.2
3  * Copyright (C) 2020 Synopsys, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * https://www.FreeRTOS.org
25  * https://github.com/FreeRTOS
26  *
27  */
28 
29 #ifndef PORTMACRO_H
30 #define PORTMACRO_H
31 
32 /* *INDENT-OFF* */
33 #ifdef __cplusplus
34     extern "C" {
35 #endif
36 /* *INDENT-ON* */
37 
38 /* record stack high address for stack check */
39 #ifndef configRECORD_STACK_HIGH_ADDRESS
40     #define configRECORD_STACK_HIGH_ADDRESS    1
41 #endif
42 
43 /*-----------------------------------------------------------
44  * Port specific definitions.
45  *
46  * The settings in this file configure FreeRTOS correctly for the
47  * given hardware and compiler.
48  *
49  * These settings should not be altered.
50  *-----------------------------------------------------------
51  */
52 
53 /* Type definitions. */
54 #define portCHAR          char
55 #define portFLOAT         float
56 #define portDOUBLE        double
57 #define portLONG          long
58 #define portSHORT         short
59 #define portSTACK_TYPE    unsigned int
60 #define portBASE_TYPE     portLONG
61 
62 #ifndef Asm
63     #define Asm           __asm__ volatile
64 #endif
65 
66 /*
67  *  normal constants
68  */
69 #ifndef NULL
70     #define NULL    0           /* invalid pointer */
71 #endif /* NULL */
72 
73 #ifndef true
74     #define true    1           /* true */
75 #endif /* true */
76 
77 #ifndef false
78     #define false    0          /* false */
79 #endif /* false */
80 
81 typedef portSTACK_TYPE     StackType_t;
82 typedef long               BaseType_t;
83 typedef unsigned long      UBaseType_t;
84 
85 #if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
86     typedef uint16_t       TickType_t;
87     #define portMAX_DELAY          ( TickType_t ) 0xffff
88 #elif ( configTICK_TYPE_WIDTH_IN_BITS  == TICK_TYPE_WIDTH_32_BITS )
89     typedef uint32_t             TickType_t;
90     #define portMAX_DELAY    ( TickType_t ) 0xffffffffUL
91 #else
92     #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
93 #endif
94 
95 #define portNO_CRITICAL_NESTING    ( ( uint32_t ) 0 )
96 #define portSTACK_GROWTH           ( -1 )
97 #define portTICK_PERIOD_MS         ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
98 #define portBYTE_ALIGNMENT         8
99 #define portNOP()               Asm( "nop_s" );
100 #define IPM_ENABLE_ALL             1
101 
102 #define portYIELD_FROM_ISR()    vPortYieldFromIsr()
103 #define portYIELD()             vPortYield()
104 
105 /* Critical section management. */
106 #define portDISABLE_INTERRUPTS() \
107     {                            \
108         Asm( "clri" );           \
109         Asm( "" ::: "memory" );  \
110     }                            \
111 
112 #define portENABLE_INTERRUPTS() \
113     {                           \
114         Asm( "" ::: "memory" ); \
115         Asm( "seti" );          \
116     }                           \
117 
118 extern volatile unsigned int ulCriticalNesting;
119 
120 #define portENTER_CRITICAL()     \
121     {                            \
122         portDISABLE_INTERRUPTS() \
123         ulCriticalNesting++;     \
124     }
125 
126 
127 #define portEXIT_CRITICAL()                                    \
128     {                                                          \
129         if( ulCriticalNesting > portNO_CRITICAL_NESTING )      \
130         {                                                      \
131             ulCriticalNesting--;                               \
132             if( ulCriticalNesting == portNO_CRITICAL_NESTING ) \
133             {                                                  \
134                 portENABLE_INTERRUPTS()                        \
135             }                                                  \
136         }                                                      \
137     }
138 
139 
140 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )    void vFunction( void * pvParameters )
141 #define portTASK_FUNCTION( vFunction, pvParameters )          void vFunction( void * pvParameters )
142 
143 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()              do {} while( 0 )     /* we use the timer */
144 #define portALT_GET_RUN_TIME_COUNTER_VALUE( dest )            ( dest = xTickCount )
145 
146 #if defined( __MW__ )
147     extern void task_end_hook( void * pxTCB );
148     #define portCLEAN_UP_TCB( pxTCB )    task_end_hook( ( void * ) pxTCB )
149 #endif
150 
151 void vPortYield( void );
152 void vPortYieldFromIsr( void );
153 
154 /* *INDENT-OFF* */
155 #ifdef __cplusplus
156     }
157 #endif
158 /* *INDENT-ON* */
159 
160 #endif /* PORTMACRO_H */
161