1 /* 2 * FreeRTOS+TCP <DEVELOPMENT BRANCH> 3 * Copyright (C) 2022 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 * http://aws.amazon.com/freertos 25 * http://www.FreeRTOS.org 26 */ 27 28 #ifndef PORTMACRO_H 29 #define PORTMACRO_H 30 31 #include <limits.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 /* Type definitions. */ 48 #define portCHAR char 49 #define portFLOAT float 50 #define portDOUBLE double 51 #define portLONG long 52 #define portSHORT short 53 #define portSTACK_TYPE unsigned long 54 #define portBASE_TYPE long 55 #define portPOINTER_SIZE_TYPE intptr_t 56 57 typedef portSTACK_TYPE StackType_t; 58 typedef long BaseType_t; 59 typedef unsigned long UBaseType_t; 60 61 typedef unsigned long TickType_t; 62 #define portMAX_DELAY ( TickType_t ) ULONG_MAX 63 64 #define portTICK_TYPE_IS_ATOMIC 1 65 66 /*-----------------------------------------------------------*/ 67 68 /* Architecture specifics. */ 69 #define portSTACK_GROWTH ( -1 ) 70 #define portHAS_STACK_OVERFLOW_CHECKING ( 1 ) 71 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) 72 #define portTICK_RATE_MICROSECONDS ( ( portTickType ) 1000000 / configTICK_RATE_HZ ) 73 #define portBYTE_ALIGNMENT 8 74 /*-----------------------------------------------------------*/ 75 76 /* Scheduler utilities. */ 77 extern void vPortYield( void ); 78 79 #define portYIELD() vPortYield() 80 81 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield( ) 82 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) 83 /*-----------------------------------------------------------*/ 84 85 /* Critical section management. */ 86 extern void vPortDisableInterrupts( void ); 87 extern void vPortEnableInterrupts( void ); 88 #define portSET_INTERRUPT_MASK() ( vPortDisableInterrupts() ) 89 #define portCLEAR_INTERRUPT_MASK() ( vPortEnableInterrupts() ) 90 91 extern portBASE_TYPE xPortSetInterruptMask( void ); 92 extern void vPortClearInterruptMask( portBASE_TYPE xMask ); 93 94 extern void vPortEnterCritical( void ); 95 extern void vPortExitCritical( void ); 96 #define portSET_INTERRUPT_MASK_FROM_ISR() xPortSetInterruptMask() 97 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( x ) vPortClearInterruptMask( x ) 98 #define portDISABLE_INTERRUPTS() portSET_INTERRUPT_MASK() 99 #define portENABLE_INTERRUPTS() portCLEAR_INTERRUPT_MASK() 100 #define portENTER_CRITICAL() vPortEnterCritical() 101 #define portEXIT_CRITICAL() vPortExitCritical() 102 103 /*-----------------------------------------------------------*/ 104 105 extern void vPortThreadDying( void * pxTaskToDelete, 106 volatile BaseType_t * pxPendYield ); 107 extern void vPortCancelThread( void * pxTaskToDelete ); 108 #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) ) 109 #define portCLEAN_UP_TCB( pxTCB ) vPortCancelThread( pxTCB ) 110 /*-----------------------------------------------------------*/ 111 112 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) 113 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) 114 /*-----------------------------------------------------------*/ 115 116 /* 117 * Tasks run in their own pthreads and context switches between them 118 * are always a full memory barrier. ISRs are emulated as signals 119 * which also imply a full memory barrier. 120 * 121 * Thus, only a compiler barrier is needed to prevent the compiler 122 * reordering. 123 */ 124 #define portMEMORY_BARRIER() __asm volatile ( "" ::: "memory" ) 125 126 extern unsigned long ulPortGetRunTime( void ); 127 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */ 128 #define portGET_RUN_TIME_COUNTER_VALUE() ulPortGetRunTime() 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif /* PORTMACRO_H */ 135