]> begriffs open source - freertos/blob - portable/CCS/ARM_Cortex-R4/portmacro.h
Add SPDX-License-Identifier: MIT to MIT licensed files.
[freertos] / portable / CCS / ARM_Cortex-R4 / portmacro.h
1 /*\r
2  * FreeRTOS Kernel <DEVELOPMENT BRANCH>\r
3  * Copyright (C) 2021 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * SPDX-License-Identifier: MIT
6  *
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
13  *\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
16  *\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
23  *\r
24  * https://www.FreeRTOS.org\r
25  * https://github.com/FreeRTOS\r
26  *\r
27  */\r
28 \r
29 #ifndef __PORTMACRO_H__\r
30 #define __PORTMACRO_H__\r
31 \r
32 /*-----------------------------------------------------------\r
33  * Port specific definitions.\r
34  *\r
35  * The settings in this file configure FreeRTOS correctly for the\r
36  * given hardware and compiler.\r
37  *\r
38  * These settings should not be altered.\r
39  *-----------------------------------------------------------\r
40  */\r
41 \r
42 /* Type definitions. */\r
43 #define portCHAR        char\r
44 #define portFLOAT       float\r
45 #define portDOUBLE      double\r
46 #define portLONG        long\r
47 #define portSHORT       short\r
48 #define portSTACK_TYPE  uint32_t\r
49 #define portBASE_TYPE   long\r
50 \r
51 typedef portSTACK_TYPE StackType_t;\r
52 typedef long BaseType_t;\r
53 typedef unsigned long UBaseType_t;\r
54 \r
55 #if (configUSE_16_BIT_TICKS == 1)\r
56     typedef uint16_t TickType_t;\r
57     #define portMAX_DELAY (TickType_t) 0xFFFF\r
58 #else\r
59     typedef uint32_t TickType_t;\r
60     #define portMAX_DELAY (TickType_t) 0xFFFFFFFFF\r
61 \r
62         /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do\r
63         not need to be guarded with a critical section. */\r
64         #define portTICK_TYPE_IS_ATOMIC 1\r
65 #endif\r
66 \r
67 \r
68 /* Architecture specifics. */\r
69 #define portSTACK_GROWTH    (-1)\r
70 #define portTICK_PERIOD_MS    ((TickType_t) 1000 / configTICK_RATE_HZ)\r
71 #define portBYTE_ALIGNMENT  8\r
72 \r
73 /* Critical section handling. */\r
74 extern void vPortEnterCritical(void);\r
75 extern void vPortExitCritical(void);\r
76 #define portENTER_CRITICAL()            vPortEnterCritical()\r
77 #define portEXIT_CRITICAL()                     vPortExitCritical()\r
78 #define portDISABLE_INTERRUPTS()        asm( " CPSID I" )\r
79 #define portENABLE_INTERRUPTS()         asm( " CPSIE I" )\r
80 \r
81 /* Scheduler utilities. */\r
82 #pragma SWI_ALIAS( vPortYield, 0 )\r
83 extern void vPortYield( void );\r
84 #define portYIELD()                     vPortYield()\r
85 #define portSYS_SSIR1_REG                       ( * ( ( volatile uint32_t * ) 0xFFFFFFB0 ) )\r
86 #define portSYS_SSIR1_SSKEY                     ( 0x7500UL )\r
87 #define portYIELD_WITHIN_API()          { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  asm( " DSB " ); asm( " ISB " ); }\r
88 #define portYIELD_FROM_ISR( x )         do { if( x != pdFALSE ) { portSYS_SSIR1_REG = portSYS_SSIR1_SSKEY;  ( void ) portSYS_SSIR1_REG; } } while( 0 )\r
89 \r
90 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION\r
91         #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1\r
92 #endif\r
93 \r
94 /* Architecture specific optimisations. */\r
95 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1\r
96 \r
97         /* Check the configuration. */\r
98         #if( configMAX_PRIORITIES > 32 )\r
99                 #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32.  It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.\r
100         #endif\r
101 \r
102         /* Store/clear the ready priorities in a bit map. */\r
103         #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )\r
104         #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )\r
105 \r
106         /*-----------------------------------------------------------*/\r
107 \r
108         #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __clz( ( uxReadyPriorities ) ) )\r
109 \r
110 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
111 \r
112 \r
113 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
114 #define portTASK_FUNCTION(vFunction, pvParameters)       void vFunction(void *pvParameters)\r
115 #define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters)\r
116 \r
117 #endif /* __PORTMACRO_H__ */\r
118 \r