]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/IAR/RISC-V/portmacro.h
Correct code comments that referred to taskYIELD_FROM_ISR to portYIELD_FROM_ISR.
[freertos] / FreeRTOS / Source / portable / IAR / RISC-V / portmacro.h
1 /*\r
2  * FreeRTOS Kernel V10.2.1\r
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 \r
29 #ifndef PORTMACRO_H\r
30 #define PORTMACRO_H\r
31 \r
32 #include "intrinsics.h"\r
33 \r
34 #ifdef __cplusplus\r
35 extern "C" {\r
36 #endif\r
37 \r
38 /*-----------------------------------------------------------\r
39  * Port specific definitions.\r
40  *\r
41  * The settings in this file configure FreeRTOS correctly for the\r
42  * given hardware and compiler.\r
43  *\r
44  * These settings should not be altered.\r
45  *-----------------------------------------------------------\r
46  */\r
47 \r
48 /* Type definitions. */\r
49 #if __riscv_xlen == 64\r
50         #define portSTACK_TYPE                  uint64_t\r
51         #define portBASE_TYPE                   int64_t\r
52         #define portUBASE_TYPE                  uint64_t\r
53         #define portMAX_DELAY                   ( TickType_t ) 0xffffffffffffffffUL\r
54         #define portPOINTER_SIZE_TYPE   uint64_t\r
55 #elif __riscv_xlen == 32\r
56         #define portSTACK_TYPE  uint32_t\r
57         #define portBASE_TYPE   int32_t\r
58         #define portUBASE_TYPE  uint32_t\r
59         #define portMAX_DELAY ( TickType_t ) 0xffffffffUL\r
60 #else\r
61         #error Assembler did not define __riscv_xlen\r
62 #endif\r
63 \r
64 \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
69 \r
70 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do\r
71 not need to be guarded with a critical section. */\r
72 #define portTICK_TYPE_IS_ATOMIC 1\r
73 /*-----------------------------------------------------------*/\r
74 \r
75 /* Architecture specifics. */\r
76 #define portSTACK_GROWTH                        ( -1 )\r
77 #define portTICK_PERIOD_MS                      ( ( TickType_t ) 1000 / configTICK_RATE_HZ )\r
78 #ifdef __riscv64\r
79         #error This is the RV32 port that has not yet been adapted for 64.\r
80         #define portBYTE_ALIGNMENT                      16\r
81 #else\r
82         #define portBYTE_ALIGNMENT                      16\r
83 #endif\r
84 /*-----------------------------------------------------------*/\r
85 \r
86 \r
87 /* Scheduler utilities. */\r
88 extern void vTaskSwitchContext( void );\r
89 #define portYIELD() __asm volatile( "ecall" );\r
90 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vTaskSwitchContext()\r
91 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )\r
92 /*-----------------------------------------------------------*/\r
93 \r
94 \r
95 /* Critical section management. */\r
96 #define portCRITICAL_NESTING_IN_TCB                                     1\r
97 extern void vTaskEnterCritical( void );\r
98 extern void vTaskExitCritical( void );\r
99 \r
100 #define portSET_INTERRUPT_MASK_FROM_ISR() 0\r
101 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) uxSavedStatusValue\r
102 #define portDISABLE_INTERRUPTS()        __disable_interrupt()\r
103 #define portENABLE_INTERRUPTS()         __enable_interrupt()\r
104 #define portENTER_CRITICAL()    vTaskEnterCritical()\r
105 #define portEXIT_CRITICAL()             vTaskExitCritical()\r
106 \r
107 /*-----------------------------------------------------------*/\r
108 \r
109 /* Architecture specific optimisations. */\r
110 #if( configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 )\r
111 \r
112         #error configUSE_PORT_OPTIMISED_TASK_SELECTION cannot yet be used in the IAR RISC-V port, the CLZ instruction needs to be emulated.\r
113 \r
114 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
115 \r
116 \r
117 /*-----------------------------------------------------------*/\r
118 \r
119 /* Task function macros as described on the FreeRTOS.org WEB site.  These are\r
120 not necessary for to use this port.  They are defined so the common demo files\r
121 (which build with all the ports) will build. */\r
122 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
123 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
124 \r
125 /*-----------------------------------------------------------*/\r
126 \r
127 #define portNOP() __asm volatile        ( " nop " )\r
128 \r
129 #define portINLINE      __inline\r
130 \r
131 #ifndef portFORCE_INLINE\r
132         #define portFORCE_INLINE inline __attribute__(( always_inline))\r
133 #endif\r
134 \r
135 #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )\r
136 \r
137 \r
138 /* Suppress warnings that are generated by the IAR tools, but cannot be fixed in\r
139 the source code because to do so would cause other compilers to generate\r
140 warnings. */\r
141 #pragma diag_suppress=Pa082\r
142 \r
143 \r
144 #ifdef __cplusplus\r
145 }\r
146 #endif\r
147 \r
148 #endif /* PORTMACRO_H */\r
149 \r