Labor04
portable.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Kernel V10.0.0
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software. If you wish to use our Amazon
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * http://www.FreeRTOS.org
24  * http://aws.amazon.com/freertos
25  *
26  * 1 tab == 4 spaces!
27  */
28 
29 /*-----------------------------------------------------------
30  * Portable layer API. Each function must be defined for each port.
31  *----------------------------------------------------------*/
32 
33 #ifndef PORTABLE_H
34 #define PORTABLE_H
35 
36 /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
37 pre-processor definition was used to ensure the pre-processor found the correct
38 portmacro.h file for the port being used. That scheme was deprecated in favour
39 of setting the compiler's include path such that it found the correct
40 portmacro.h file - removing the need for the constant and allowing the
41 portmacro.h file to be located anywhere in relation to the port being used.
42 Purely for reasons of backward compatibility the old method is still valid, but
43 to make it clear that new projects should not use it, support for the port
44 specific constants has been moved into the deprecated_definitions.h header
45 file. */
46 #include "deprecated_definitions.h"
47 
48 /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
49 did not result in a portmacro.h header file being included - and it should be
50 included here. In this case the path to the correct portmacro.h header file
51 must be set in the compiler's include path. */
52 #ifndef portENTER_CRITICAL
53 #include "portmacro.h"
54 #endif
55 
56 #if portBYTE_ALIGNMENT == 32
57 #define portBYTE_ALIGNMENT_MASK ( 0x001f )
58 #endif
59 
60 #if portBYTE_ALIGNMENT == 16
61 #define portBYTE_ALIGNMENT_MASK ( 0x000f )
62 #endif
63 
64 #if portBYTE_ALIGNMENT == 8
65 #define portBYTE_ALIGNMENT_MASK ( 0x0007 )
66 #endif
67 
68 #if portBYTE_ALIGNMENT == 4
69 #define portBYTE_ALIGNMENT_MASK ( 0x0003 )
70 #endif
71 
72 #if portBYTE_ALIGNMENT == 2
73 #define portBYTE_ALIGNMENT_MASK ( 0x0001 )
74 #endif
75 
76 #if portBYTE_ALIGNMENT == 1
77 #define portBYTE_ALIGNMENT_MASK ( 0x0000 )
78 #endif
79 
80 #ifndef portBYTE_ALIGNMENT_MASK
81 #error "Invalid portBYTE_ALIGNMENT definition"
82 #endif
83 
84 #ifndef portNUM_CONFIGURABLE_REGIONS
85 #define portNUM_CONFIGURABLE_REGIONS 1
86 #endif
87 
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
91 
92 #include "mpu_wrappers.h"
93 
94 /*
95  * Setup the stack of a new task so it is ready to be placed under the
96  * scheduler control. The registers have to be placed on the stack in
97  * the order that the port expects to find them.
98  *
99  */
100 #if( portUSING_MPU_WRAPPERS == 1 )
101 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
102 #else
103 StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION;
104 #endif
105 
106 /* Used by heap_5.c. */
107 typedef struct HeapRegion
108 {
109  uint8_t *pucStartAddress;
110  size_t xSizeInBytes;
112 
113 /*
114  * Used to define multiple heap regions for use by heap_5.c. This function
115  * must be called before any calls to pvPortMalloc() - not creating a task,
116  * queue, semaphore, mutex, software timer, event group, etc. will result in
117  * pvPortMalloc being called.
118  *
119  * pxHeapRegions passes in an array of HeapRegion_t structures - each of which
120  * defines a region of memory that can be used as the heap. The array is
121  * terminated by a HeapRegions_t structure that has a size of 0. The region
122  * with the lowest start address must appear first in the array.
123  */
124 void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
125 
126 
127 /*
128  * Map to the memory management routines required for the port.
129  */
130 void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
131 void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
135 
136 /*
137  * Setup the hardware ready for the scheduler to take control. This generally
138  * sets up a tick interrupt and sets timers for the correct tick frequency.
139  */
141 
142 /*
143  * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
144  * the hardware is left in its original condition after the scheduler stops
145  * executing.
146  */
148 
149 /*
150  * The structures and methods of manipulating the MPU are contained within the
151  * port layer.
152  *
153  * Fills the xMPUSettings structure with the memory region information
154  * contained in xRegions.
155  */
156 #if( portUSING_MPU_WRAPPERS == 1 )
157 struct xMEMORY_REGION;
158 void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION;
159 #endif
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 #endif /* PORTABLE_H */
166 
xPortStartScheduler
BaseType_t xPortStartScheduler(void)
Definition: port.c:252
main
int main(void)
app entry point
Definition: Main.c:26
task.h
configTICK_RATE_HZ
#define configTICK_RATE_HZ
Definition: FreeRTOSConfig.h:29
xPortPendSVHandler
void xPortPendSVHandler(void)
Definition: port.c:375
vTaskStepTick
void vTaskStepTick(const TickType_t xTicksToJump) PRIVILEGED_FUNCTION
HeapRegion::pucStartAddress
uint8_t * pucStartAddress
Definition: portable.h:109
portNVIC_SYSTICK_INT_BIT
#define portNVIC_SYSTICK_INT_BIT
Definition: port.c:70
xPortGetMinimumEverFreeHeapSize
size_t xPortGetMinimumEverFreeHeapSize(void) PRIVILEGED_FUNCTION
vPortRaiseBASEPRI
static portFORCE_INLINE void vPortRaiseBASEPRI(void)
Definition: portmacro.h:178
vPortClearBASEPRIFromISR
static portFORCE_INLINE void vPortClearBASEPRIFromISR(void)
Definition: portmacro.h:193
prvStartFirstTask
static void prvStartFirstTask(void)
Definition: port.c:226
portPRIGROUP_SHIFT
#define portPRIGROUP_SHIFT
Definition: port.c:87
mpu_wrappers.h
HeapRegion::xSizeInBytes
size_t xSizeInBytes
Definition: portable.h:110
portNVIC_PENDSV_PRI
#define portNVIC_PENDSV_PRI
Definition: port.c:76
xMEMORY_REGION
Definition: task.h:104
prvTaskExitError
static void prvTaskExitError(void)
Definition: port.c:195
portSY_FULL_READ_WRITE
#define portSY_FULL_READ_WRITE
Definition: portmacro.h:79
configKERNEL_INTERRUPT_PRIORITY
#define configKERNEL_INTERRUPT_PRIORITY
Definition: FreeRTOSConfig.h:20
vPortEnterCritical
void vPortEnterCritical(void)
Definition: port.c:347
portNVIC_SYSTICK_PRI
#define portNVIC_SYSTICK_PRI
Definition: port.c:77
PRIVILEGED_FUNCTION
#define PRIVILEGED_FUNCTION
Definition: mpu_wrappers.h:174
portNVIC_SYSTICK_LOAD_REG
#define portNVIC_SYSTICK_LOAD_REG
Definition: port.c:66
vPortSuppressTicksAndSleep
void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
TickType_t
uint32_t TickType_t
Definition: portmacro.h:64
portNVIC_SYSTICK_ENABLE_BIT
#define portNVIC_SYSTICK_ENABLE_BIT
Definition: port.c:71
pdFALSE
#define pdFALSE
Definition: projdefs.h:45
vPortGetIPSR
__asm uint32_t vPortGetIPSR(void)
Definition: port.c:630
vPortFree
void vPortFree(void *pv) PRIVILEGED_FUNCTION
Definition: heap_1.c:123
UBaseType_t
unsigned long UBaseType_t
Definition: portmacro.h:58
configCPU_CLOCK_HZ
#define configCPU_CLOCK_HZ
Definition: FreeRTOSConfig.h:15
eAbortSleep
@ eAbortSleep
Definition: task.h:145
configMAX_SYSCALL_INTERRUPT_PRIORITY
#define configMAX_SYSCALL_INTERRUPT_PRIORITY
Definition: FreeRTOSConfig.h:24
portDISABLE_INTERRUPTS
#define portDISABLE_INTERRUPTS()
Definition: portmacro.h:105
vPortEndScheduler
void vPortEndScheduler(void)
Definition: port.c:339
xPortGetFreeHeapSize
size_t xPortGetFreeHeapSize(void) PRIVILEGED_FUNCTION
Definition: heap_1.c:142
portNVIC_PENDSVSET_BIT
#define portNVIC_PENDSVSET_BIT
Definition: portmacro.h:96
portMAX_8_BIT_VALUE
#define portMAX_8_BIT_VALUE
Definition: port.c:83
pxPortInitialiseStack
StackType_t * pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters)
Definition: port.c:176
vPortDefineHeapRegions
void vPortDefineHeapRegions(const HeapRegion_t *const pxHeapRegions) PRIVILEGED_FUNCTION
StackType_t
portSTACK_TYPE StackType_t
Definition: portmacro.h:56
vPortSVCHandler
void vPortSVCHandler(void)
Definition: port.c:209
eTaskConfirmSleepModeStatus
eSleepModeStatus eTaskConfirmSleepModeStatus(void) PRIVILEGED_FUNCTION
configSYSTICK_CLOCK_HZ
#define configSYSTICK_CLOCK_HZ
Definition: port.c:46
uxCriticalNesting
static UBaseType_t uxCriticalNesting
Definition: port.c:135
xPortSysTickHandler
void xPortSysTickHandler(void)
Definition: port.c:412
TaskFunction_t
void(* TaskFunction_t)(void *)
Definition: projdefs.h:36
FreeRTOS.h
portNVIC_SYSTICK_CURRENT_VALUE_REG
#define portNVIC_SYSTICK_CURRENT_VALUE_REG
Definition: port.c:67
portMISSED_COUNTS_FACTOR
#define portMISSED_COUNTS_FACTOR
Definition: port.c:101
portVECTACTIVE_MASK
#define portVECTACTIVE_MASK
Definition: port.c:90
portNVIC_SYSPRI2_REG
#define portNVIC_SYSPRI2_REG
Definition: port.c:68
portNVIC_SYSTICK_CLK_BIT
#define portNVIC_SYSTICK_CLK_BIT
Definition: port.c:48
HeapRegion_t
struct HeapRegion HeapRegion_t
portENABLE_INTERRUPTS
#define portENABLE_INTERRUPTS()
Definition: portmacro.h:106
portINITIAL_XPSR
#define portINITIAL_XPSR
Definition: port.c:93
configPOST_SLEEP_PROCESSING
#define configPOST_SLEEP_PROCESSING(x)
Definition: FreeRTOS.h:751
portTOP_BIT_OF_BYTE
#define portTOP_BIT_OF_BYTE
Definition: port.c:84
deprecated_definitions.h
pvPortMalloc
void * pvPortMalloc(size_t xSize) PRIVILEGED_FUNCTION
Definition: heap_1.c:71
xPortStartScheduler
BaseType_t xPortStartScheduler(void) PRIVILEGED_FUNCTION
Definition: port.c:252
vPortSetupTimerInterrupt
void vPortSetupTimerInterrupt(void)
Definition: port.c:607
pxPortInitialiseStack
StackType_t * pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters) PRIVILEGED_FUNCTION
Definition: port.c:176
BaseType_t
long BaseType_t
Definition: portmacro.h:57
configPRE_SLEEP_PROCESSING
#define configPRE_SLEEP_PROCESSING(x)
Definition: FreeRTOS.h:747
portFIRST_USER_INTERRUPT_NUMBER
#define portFIRST_USER_INTERRUPT_NUMBER
Definition: port.c:80
vPortEndScheduler
void vPortEndScheduler(void) PRIVILEGED_FUNCTION
Definition: port.c:339
portMAX_24_BIT_NUMBER
#define portMAX_24_BIT_NUMBER
Definition: port.c:96
pxCurrentTCB
PRIVILEGED_DATA TCB_t *volatile pxCurrentTCB
Definition: tasks.c:347
portMAX_PRIGROUP_BITS
#define portMAX_PRIGROUP_BITS
Definition: port.c:85
xTaskIncrementTick
BaseType_t xTaskIncrementTick(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2588
vTaskSwitchContext
void vTaskSwitchContext(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2850
configASSERT
#define configASSERT(x)
Definition: FreeRTOS.h:235
vPortExitCritical
void vPortExitCritical(void)
Definition: port.c:364
portNVIC_IP_REGISTERS_OFFSET_16
#define portNVIC_IP_REGISTERS_OFFSET_16
Definition: port.c:81
portAIRCR_REG
#define portAIRCR_REG
Definition: port.c:82
portNVIC_INT_CTRL_REG
#define portNVIC_INT_CTRL_REG
Definition: portmacro.h:95
portmacro.h
portNVIC_SYSTICK_CTRL_REG
#define portNVIC_SYSTICK_CTRL_REG
Definition: port.c:65
HeapRegion
Definition: portable.h:108
portPRIORITY_GROUP_MASK
#define portPRIORITY_GROUP_MASK
Definition: port.c:86
vPortInitialiseBlocks
void vPortInitialiseBlocks(void) PRIVILEGED_FUNCTION
Definition: heap_1.c:135
portSTART_ADDRESS_MASK
#define portSTART_ADDRESS_MASK
Definition: port.c:105
portNVIC_SYSTICK_COUNT_FLAG_BIT
#define portNVIC_SYSTICK_COUNT_FLAG_BIT
Definition: port.c:72