2 * FreeRTOS Kernel V10.5.1
\r
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * SPDX-License-Identifier: MIT
\r
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
8 * this software and associated documentation files (the "Software"), to deal in
\r
9 * the Software without restriction, including without limitation the rights to
\r
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
11 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
12 * subject to the following conditions:
\r
14 * The above copyright notice and this permission notice shall be included in all
\r
15 * copies or substantial portions of the Software.
\r
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
24 * https://www.FreeRTOS.org
\r
25 * https://github.com/FreeRTOS
\r
33 #include "intrinsics.h"
\r
39 /*-----------------------------------------------------------
\r
40 * Port specific definitions.
\r
42 * The settings in this file configure FreeRTOS correctly for the
\r
43 * given hardware and compiler.
\r
45 * These settings should not be altered.
\r
46 *-----------------------------------------------------------
\r
49 /* Type definitions. */
\r
50 #if __riscv_xlen == 64
\r
51 #define portSTACK_TYPE uint64_t
\r
52 #define portBASE_TYPE int64_t
\r
53 #define portUBASE_TYPE uint64_t
\r
54 #define portMAX_DELAY ( TickType_t ) 0xffffffffffffffffUL
\r
55 #define portPOINTER_SIZE_TYPE uint64_t
\r
56 #elif __riscv_xlen == 32
\r
57 #define portSTACK_TYPE uint32_t
\r
58 #define portBASE_TYPE int32_t
\r
59 #define portUBASE_TYPE uint32_t
\r
60 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
\r
62 #error Assembler did not define __riscv_xlen
\r
65 typedef portSTACK_TYPE StackType_t;
\r
66 typedef portBASE_TYPE BaseType_t;
\r
67 typedef portUBASE_TYPE UBaseType_t;
\r
68 typedef portUBASE_TYPE TickType_t;
\r
70 /* Legacy type definitions. */
\r
71 #define portCHAR char
\r
72 #define portFLOAT float
\r
73 #define portDOUBLE double
\r
74 #define portLONG long
\r
75 #define portSHORT short
\r
77 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
\r
78 * not need to be guarded with a critical section. */
\r
79 #define portTICK_TYPE_IS_ATOMIC 1
\r
80 /*-----------------------------------------------------------*/
\r
82 /* Architecture specifics. */
\r
83 #define portSTACK_GROWTH ( -1 )
\r
84 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
\r
85 #define portBYTE_ALIGNMENT 16
\r
86 /*-----------------------------------------------------------*/
\r
88 /* Scheduler utilities. */
\r
89 extern void vTaskSwitchContext( void );
\r
90 #define portYIELD() __asm volatile( "ecall" );
\r
91 #define portEND_SWITCHING_ISR( xSwitchRequired ) do { if( xSwitchRequired ) vTaskSwitchContext(); } while( 0 )
\r
92 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
\r
93 /*-----------------------------------------------------------*/
\r
95 /* Critical section management. */
\r
96 #define portCRITICAL_NESTING_IN_TCB 0
\r
98 #define portSET_INTERRUPT_MASK_FROM_ISR() 0
\r
99 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue
\r
101 #define portDISABLE_INTERRUPTS() __disable_interrupt()
\r
102 #define portENABLE_INTERRUPTS() __enable_interrupt()
\r
104 extern size_t xCriticalNesting;
\r
105 #define portENTER_CRITICAL() \
\r
107 portDISABLE_INTERRUPTS(); \
\r
108 xCriticalNesting++; \
\r
111 #define portEXIT_CRITICAL() \
\r
113 xCriticalNesting--; \
\r
114 if( xCriticalNesting == 0 ) \
\r
116 portENABLE_INTERRUPTS(); \
\r
120 /*-----------------------------------------------------------*/
\r
122 /* Architecture specific optimisations. */
\r
123 #if( configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 )
\r
125 #error configUSE_PORT_OPTIMISED_TASK_SELECTION cannot yet be used in the IAR RISC-V port, the CLZ instruction needs to be emulated.
\r
127 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
\r
130 /*-----------------------------------------------------------*/
\r
132 /* Task function macros as described on the FreeRTOS.org WEB site. These are
\r
133 * not necessary for to use this port. They are defined so the common demo
\r
134 * files (which build with all the ports) will build. */
\r
135 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
136 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
138 /*-----------------------------------------------------------*/
\r
140 #define portNOP() __asm volatile( " nop " )
\r
141 #define portINLINE __inline
\r
143 #ifndef portFORCE_INLINE
\r
144 #define portFORCE_INLINE inline __attribute__(( always_inline))
\r
147 #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
\r
148 /*-----------------------------------------------------------*/
\r
150 /* Suppress warnings that are generated by the IAR tools, but cannot be fixed in
\r
151 * the source code because to do so would cause other compilers to generate
\r
153 #pragma diag_suppress=Pa082
\r
155 /* configCLINT_BASE_ADDRESS is a legacy definition that was replaced by the
\r
156 * configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS definitions. For
\r
157 * backward compatibility derive the newer definitions from the old if the old
\r
158 * definition is found. */
\r
159 #if defined( configCLINT_BASE_ADDRESS ) && !defined( configMTIME_BASE_ADDRESS ) && ( configCLINT_BASE_ADDRESS == 0 )
\r
160 /* Legacy case where configCLINT_BASE_ADDRESS was defined as 0 to indicate
\r
161 * there was no CLINT. Equivalent now is to set the MTIME and MTIMECMP
\r
162 * addresses to 0. */
\r
163 #define configMTIME_BASE_ADDRESS ( 0 )
\r
164 #define configMTIMECMP_BASE_ADDRESS ( 0 )
\r
165 #elif defined( configCLINT_BASE_ADDRESS ) && !defined( configMTIME_BASE_ADDRESS )
\r
166 /* Legacy case where configCLINT_BASE_ADDRESS was set to the base address of
\r
167 * the CLINT. Equivalent now is to derive the MTIME and MTIMECMP addresses
\r
168 * from the CLINT address. */
\r
169 #define configMTIME_BASE_ADDRESS ( ( configCLINT_BASE_ADDRESS ) + 0xBFF8UL )
\r
170 #define configMTIMECMP_BASE_ADDRESS ( ( configCLINT_BASE_ADDRESS ) + 0x4000UL )
\r
171 #elif !defined( configMTIME_BASE_ADDRESS ) || !defined( configMTIMECMP_BASE_ADDRESS )
\r
172 #error configMTIME_BASE_ADDRESS and configMTIMECMP_BASE_ADDRESS must be defined in FreeRTOSConfig.h. Set them to zero if there is no MTIME (machine time) clock. See https://www.FreeRTOS.org/Using-FreeRTOS-on-RISC-V.html
\r
179 #endif /* PORTMACRO_H */
\r