]> begriffs open source - freertos/blob - portable/GCC/RX700v3_DPFPU/portmacro.h
[AUTO][RELEASE]: Bump file header version to "10.5.0"
[freertos] / portable / GCC / RX700v3_DPFPU / portmacro.h
1 /*
2  * FreeRTOS Kernel V10.5.0
3  * Copyright (C) 2021 Amazon.com, 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
30 #ifndef PORTMACRO_H
31     #define PORTMACRO_H
32
33     #ifdef __cplusplus
34         extern "C" {
35     #endif
36
37 /*-----------------------------------------------------------
38  * Port specific definitions.
39  *
40  * The settings in this file configure FreeRTOS correctly for the
41  * given hardware and compiler.
42  *
43  * These settings should not be altered.
44  *-----------------------------------------------------------
45  */
46
47 /* When the FIT configurator or the Smart Configurator is used, platform.h has to be 
48  * used. */
49     #ifndef configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H
50         #define configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H 0
51     #endif
52
53 /* If configUSE_TASK_DPFPU_SUPPORT is set to 1 (or undefined) then each task will
54  * be created without a DPFPU context, and a task must call vTaskUsesDPFPU() before
55  * making use of any DPFPU registers.  If configUSE_TASK_DPFPU_SUPPORT is set to 2 then
56  * tasks are created with a DPFPU context by default, and calling vTaskUsesDPFPU() has
57  * no effect.  If configUSE_TASK_DPFPU_SUPPORT is set to 0 then tasks never take care
58  * of any DPFPU context (even if DPFPU registers are used). */
59     #ifndef configUSE_TASK_DPFPU_SUPPORT
60         #define configUSE_TASK_DPFPU_SUPPORT 1
61     #endif
62
63 /*-----------------------------------------------------------*/
64
65 /* Type definitions - these are a bit legacy and not really used now, other than
66  * portSTACK_TYPE and portBASE_TYPE. */
67     #define portCHAR          char
68     #define portFLOAT         float
69     #define portDOUBLE        double
70     #define portLONG          long
71     #define portSHORT         short
72     #define portSTACK_TYPE    uint32_t
73     #define portBASE_TYPE     long
74
75     typedef portSTACK_TYPE   StackType_t;
76     typedef long             BaseType_t;
77     typedef unsigned long    UBaseType_t;
78
79     #if ( configUSE_16_BIT_TICKS == 1 )
80         typedef uint16_t     TickType_t;
81         #define portMAX_DELAY              ( TickType_t ) 0xffff
82     #else
83         typedef uint32_t     TickType_t;
84         #define portMAX_DELAY              ( TickType_t ) 0xffffffffUL
85
86 /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
87  * not need to be guarded with a critical section. */
88         #define portTICK_TYPE_IS_ATOMIC    1
89     #endif
90
91 /*-----------------------------------------------------------*/
92
93 /* Hardware specifics. */
94     #define portBYTE_ALIGNMENT    8     /* Could make four, according to manual. */
95     #define portSTACK_GROWTH      -1
96     #define portTICK_PERIOD_MS    ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
97     #define portNOP()    __asm volatile ( "NOP" )
98
99 /* Yield equivalent to "*portITU_SWINTR = 0x01; ( void ) *portITU_SWINTR;"
100  * where portITU_SWINTR is the location of the software interrupt register
101  * (0x000872E0).  Don't rely on the assembler to select a register, so instead
102  * save and restore clobbered registers manually. */
103     #define portYIELD()           \
104     __asm volatile                \
105     (                             \
106         "PUSH.L R10                                     \n"\
107         "MOV.L  #0x872E0, R10           \n"\
108         "MOV.B  #0x1, [R10]                     \n"\
109         "CMP    [R10].UB, R10           \n"\
110         "POP    R10                                     \n"\
111         :::"cc"                                         \
112     )
113
114     #define portYIELD_FROM_ISR( x )                           do { if( ( x ) != pdFALSE ) portYIELD(); } while( 0 )
115
116 /* Workaround to reduce errors/warnings caused by e2 studio CDT's INDEXER and CODAN. */
117     #ifdef __CDT_PARSER__
118     #ifndef __asm
119     #define __asm asm
120     #endif
121     #ifndef __attribute__
122     #define __attribute__( ... )
123     #endif
124     #endif
125
126 /* These macros should not be called directly, but through the
127  * taskENTER_CRITICAL() and taskEXIT_CRITICAL() macros.  An extra check is
128  * performed if configASSERT() is defined to ensure an assertion handler does not
129  * inadvertently attempt to lower the IPL when the call to assert was triggered
130  * because the IPL value was found to be above  configMAX_SYSCALL_INTERRUPT_PRIORITY
131  * when an ISR safe FreeRTOS API function was executed.  ISR safe FreeRTOS API
132  * functions are those that end in FromISR.  FreeRTOS maintains a separate
133  * interrupt API to ensure API function and interrupt entry is as fast and as
134  * simple as possible. */
135     #define portENABLE_INTERRUPTS()                           __asm volatile ( "MVTIPL  #0")
136     #ifdef configASSERT
137         #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID()    configASSERT( ( ulPortGetIPL() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) )
138         #define portDISABLE_INTERRUPTS()                      if( ulPortGetIPL() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __asm volatile ( "MVTIPL      %0"::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) )
139     #else
140         #define portDISABLE_INTERRUPTS()                      __asm volatile ( "MVTIPL  %0"::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) )
141     #endif
142
143 /* Critical nesting counts are stored in the TCB. */
144     #define portCRITICAL_NESTING_IN_TCB    ( 1 )
145
146 /* The critical nesting functions defined within tasks.c. */
147     extern void vTaskEnterCritical( void );
148     extern void vTaskExitCritical( void );
149     #define portENTER_CRITICAL()    vTaskEnterCritical()
150     #define portEXIT_CRITICAL()     vTaskExitCritical()
151
152 /* As this port allows interrupt nesting... */
153     uint32_t ulPortGetIPL( void ) __attribute__( ( naked ) );
154     void vPortSetIPL( uint32_t ulNewIPL ) __attribute__( ( naked ) );
155     #define portSET_INTERRUPT_MASK_FROM_ISR()                              ulPortGetIPL(); portDISABLE_INTERRUPTS()
156     #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus )    vPortSetIPL( uxSavedInterruptStatus )
157
158 /*-----------------------------------------------------------*/
159
160 /* Task function macros as described on the FreeRTOS.org WEB site. */
161     #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )    void vFunction( void * pvParameters )
162     #define portTASK_FUNCTION( vFunction, pvParameters )          void vFunction( void * pvParameters )
163
164 /*-----------------------------------------------------------*/
165
166 /* If configUSE_TASK_DPFPU_SUPPORT is set to 1 (or left undefined) then tasks are
167  * created without a DPFPU context and must call vPortTaskUsesDPFPU() to give
168  * themselves a DPFPU context before using any DPFPU instructions.  If
169  * configUSE_TASK_DPFPU_SUPPORT is set to 2 then all tasks will have a DPFPU context
170  * by default. */
171     #if( configUSE_TASK_DPFPU_SUPPORT == 1 )
172         void vPortTaskUsesDPFPU( void );
173     #else
174 /* Each task has a DPFPU context already, so define this function away to
175  * nothing to prevent it being called accidentally. */
176         #define vPortTaskUsesDPFPU()
177     #endif
178     #define portTASK_USES_DPFPU() vPortTaskUsesDPFPU()
179
180 /* Definition to allow compatibility with existing FreeRTOS Demo using flop.c. */
181     #define portTASK_USES_FLOATING_POINT() vPortTaskUsesDPFPU()
182
183     #ifdef __cplusplus
184         }
185     #endif
186
187 #endif /* PORTMACRO_H */