portable.h
Go to the documentation of this file.
/*
* FreeRTOS Kernel V10.0.0
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software. If you wish to use our Amazon
* FreeRTOS name, please do so in a fair use way that does not cause confusion.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/
/*-----------------------------------------------------------
* Portable layer API. Each function must be defined for each port.
*----------------------------------------------------------*/
#ifndef PORTABLE_H
#define PORTABLE_H
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a
pre-processor definition was used to ensure the pre-processor found the correct
portmacro.h file for the port being used. That scheme was deprecated in favour
of setting the compiler's include path such that it found the correct
portmacro.h file - removing the need for the constant and allowing the
portmacro.h file to be located anywhere in relation to the port being used.
Purely for reasons of backward compatibility the old method is still valid, but
to make it clear that new projects should not use it, support for the port
specific constants has been moved into the deprecated_definitions.h header
file. */
#include "deprecated_definitions.h"
/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
did not result in a portmacro.h header file being included - and it should be
included here. In this case the path to the correct portmacro.h header file
must be set in the compiler's include path. */
#ifndef portENTER_CRITICAL
#include "portmacro.h"
#endif
#if portBYTE_ALIGNMENT == 32
#define portBYTE_ALIGNMENT_MASK ( 0x001f )
#endif
#if portBYTE_ALIGNMENT == 16
#define portBYTE_ALIGNMENT_MASK ( 0x000f )
#endif
#if portBYTE_ALIGNMENT == 8
#define portBYTE_ALIGNMENT_MASK ( 0x0007 )
#endif
#if portBYTE_ALIGNMENT == 4
#define portBYTE_ALIGNMENT_MASK ( 0x0003 )
#endif
#if portBYTE_ALIGNMENT == 2
#define portBYTE_ALIGNMENT_MASK ( 0x0001 )
#endif
#if portBYTE_ALIGNMENT == 1
#define portBYTE_ALIGNMENT_MASK ( 0x0000 )
#endif
#ifndef portBYTE_ALIGNMENT_MASK
#error "Invalid portBYTE_ALIGNMENT definition"
#endif
#ifndef portNUM_CONFIGURABLE_REGIONS
#define portNUM_CONFIGURABLE_REGIONS 1
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include "mpu_wrappers.h"
/*
* Setup the stack of a new task so it is ready to be placed under the
* scheduler control. The registers have to be placed on the stack in
* the order that the port expects to find them.
*
*/
#if( portUSING_MPU_WRAPPERS == 1 )
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
#else
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION;
#endif
/* Used by heap_5.c. */
typedef struct HeapRegion
{
uint8_t *pucStartAddress;
size_t xSizeInBytes;
} HeapRegion_t;
/*
* Used to define multiple heap regions for use by heap_5.c. This function
* must be called before any calls to pvPortMalloc() - not creating a task,
* queue, semaphore, mutex, software timer, event group, etc. will result in
* pvPortMalloc being called.
*
* pxHeapRegions passes in an array of HeapRegion_t structures - each of which
* defines a region of memory that can be used as the heap. The array is
* terminated by a HeapRegions_t structure that has a size of 0. The region
* with the lowest start address must appear first in the array.
*/
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
/*
* Map to the memory management routines required for the port.
*/
void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
void vPortFree( void *pv ) PRIVILEGED_FUNCTION;
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
/*
* Setup the hardware ready for the scheduler to take control. This generally
* sets up a tick interrupt and sets timers for the correct tick frequency.
*/
BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
/*
* Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
* the hardware is left in its original condition after the scheduler stops
* executing.
*/
void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
/*
* The structures and methods of manipulating the MPU are contained within the
* port layer.
*
* Fills the xMPUSettings structure with the memory region information
* contained in xRegions.
*/
#if( portUSING_MPU_WRAPPERS == 1 )
struct xMEMORY_REGION;
void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) PRIVILEGED_FUNCTION;
#endif
#ifdef __cplusplus
}
#endif
#endif /* PORTABLE_H */
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