]> begriffs open source - freertos/blob - portable/template/portmacro.h
Make taskYIELD available to unprivileged tasks (#817)
[freertos] / portable / template / portmacro.h
1 /*
2  * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3  * license and copyright intentionally withheld to promote copying into user code.
4  */
5
6 #ifndef PORTMACRO_H
7 #define PORTMACRO_H
8
9 /*-----------------------------------------------------------
10  * Port specific definitions.
11  *
12  * The settings in this file configure FreeRTOS correctly for the
13  * given hardware and compiler.
14  *
15  * These settings should not be altered.
16  *-----------------------------------------------------------
17  */
18
19 /* Type definitions. */
20 #define portCHAR                 char
21 #define portFLOAT                float
22 #define portDOUBLE               double
23 #define portLONG                 long
24 #define portSHORT                int
25 #define portSTACK_TYPE           uint8_t
26 #define portBASE_TYPE            char
27
28 #define portSTACK_GROWTH         ( -1 )
29 #define portBYTE_ALIGNMENT       4
30 #define portPOINTER_SIZE_TYPE    size_t
31 typedef portSTACK_TYPE   StackType_t;
32 typedef signed char      BaseType_t;
33 typedef unsigned char    UBaseType_t;
34
35 #if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
36     typedef uint16_t     TickType_t;
37     #define portMAX_DELAY    ( TickType_t ) 0xffff
38 #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
39     typedef uint32_t     TickType_t;
40     #define portMAX_DELAY    ( TickType_t ) 0xffffffffUL
41 #else
42     #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width.
43 #endif
44
45 /* Architecture specific optimisations. */
46 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
47     #define configUSE_PORT_OPTIMISED_TASK_SELECTION    1
48 #endif
49
50 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
51
52 /* Check the configuration. */
53     #if ( configMAX_PRIORITIES > 32 )
54         #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.
55     #endif
56
57 /* Store/clear the ready priorities in a bit map. */
58     #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities )    ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
59     #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities )     ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
60
61 /*-----------------------------------------------------------*/
62
63     #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
64     {                                                                    \
65         uxTopPriority = 0;                                               \
66     }                                                                    \
67     while( 0 )
68
69 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
70
71 #define portDISABLE_INTERRUPTS()   \
72     { /* Disable the interrupts */ \
73     }
74 #define portENABLE_INTERRUPTS()   \
75     { /* Enable the interrupts */ \
76     }
77
78 #define portENTER_CRITICAL()                                             \
79     { /* preserve current interrupt state and then disable interrupts */ \
80     }
81 #define portEXIT_CRITICAL()                              \
82     { /* restore previously preserved interrupt state */ \
83     }
84
85 extern void vPortYield( void );
86 #define portYIELD()                                           vPortYield()
87
88 /* Task function macros as described on the FreeRTOS.org WEB site. */
89 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters )    void vFunction( void * pvParameters )
90 #define portTASK_FUNCTION( vFunction, pvParameters )          void vFunction( void * pvParameters )
91
92 #endif /* PORTMACRO_H */