|
| 1 | +/* |
| 2 | + * FreeRTOS Kernel V10.4.1 |
| 3 | + * Copyright (C) 2020 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. |
| 14 | + * |
| 15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 17 | + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 18 | + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 19 | + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 20 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 | + * |
| 22 | + * https://www.FreeRTOS.org |
| 23 | + * https://github.com/FreeRTOS |
| 24 | + * |
| 25 | + */ |
| 26 | + |
| 27 | +#ifndef PORTMACRO_H |
| 28 | +#define PORTMACRO_H |
| 29 | + |
| 30 | +/* *INDENT-OFF* */ |
| 31 | +#ifdef __cplusplus |
| 32 | + extern "C" { |
| 33 | +#endif |
| 34 | +/* *INDENT-ON* */ |
| 35 | + |
| 36 | +/*----------------------------------------------------------- |
| 37 | + * Port specific definitions. |
| 38 | + * |
| 39 | + * The settings in this file configure FreeRTOS correctly for the |
| 40 | + * given hardware and compiler. |
| 41 | + * |
| 42 | + * These settings should not be altered. |
| 43 | + *----------------------------------------------------------- |
| 44 | + */ |
| 45 | + |
| 46 | +/* If configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H is set to 0 then iodefine.h |
| 47 | + * is included and used in FreeRTOS Kernel's Renesas RX port. If the macro is set |
| 48 | + * to 1 then platform.h is included and used in the port. If the macro is set to 2 |
| 49 | + * then neither iodefine.h nor platform.h are included. If the macro is undefined, |
| 50 | + * it is set to 0 (CC-RX/GNURX) or 2 (ICCRX) internally for backward compatibility. |
| 51 | + * When the FIT configurator or the Smart Configurator is used, platform.h has to be |
| 52 | + * used. */ |
| 53 | +#ifndef configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H |
| 54 | + #define configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H 0 |
| 55 | +#endif |
| 56 | + |
| 57 | +/* If configUSE_TASK_DPFPU_SUPPORT is set to 1 (or undefined) then each task will |
| 58 | + * be created without a DPFPU context, and a task must call vTaskUsesDPFPU() before |
| 59 | + * making use of any DPFPU registers. If configUSE_TASK_DPFPU_SUPPORT is set to 2 then |
| 60 | + * tasks are created with a DPFPU context by default, and calling vTaskUsesDPFPU() has |
| 61 | + * no effect. If configUSE_TASK_DPFPU_SUPPORT is set to 0 then tasks never take care |
| 62 | + * of any DPFPU context (even if DPFPU registers are used). */ |
| 63 | +#ifdef __RX_DFPU_INSNS__ |
| 64 | + /* The compiler may use DPFPU registers. */ |
| 65 | + #ifndef configUSE_TASK_DPFPU_SUPPORT |
| 66 | + #define configUSE_TASK_DPFPU_SUPPORT 1 |
| 67 | + #endif |
| 68 | +#else |
| 69 | + /* The compiler does not use DPFPU registers. */ |
| 70 | + #ifdef configUSE_TASK_DPFPU_SUPPORT |
| 71 | + #undef configUSE_TASK_DPFPU_SUPPORT |
| 72 | + #endif |
| 73 | + #define configUSE_TASK_DPFPU_SUPPORT 0 |
| 74 | +#endif |
| 75 | +#define portUSE_TASK_DPFPU_SUPPORT configUSE_TASK_DPFPU_SUPPORT |
| 76 | + |
| 77 | +#ifdef __RX_FPU_INSNS__ |
| 78 | + /* The compiler may use FPSW register. */ |
| 79 | + #define portUSE_TASK_FPU_SUPPORT 1 |
| 80 | +#else |
| 81 | + /* The compiler does not use FPSW register. */ |
| 82 | + #define portUSE_TASK_FPU_SUPPORT 0 |
| 83 | +#endif |
| 84 | + |
| 85 | +#ifdef __RXv1__ |
| 86 | + /* The CPU has only one accumulator. */ |
| 87 | + #define portUSE_TASK_ACC_SUPPORT 1 |
| 88 | +#elif !defined( __RXv2__ ) && !defined( __RXv3__ ) && ( __GNUC__ < 8 ) |
| 89 | + /* The CPU is RXv1 and has only one accumulator. */ |
| 90 | + #define portUSE_TASK_ACC_SUPPORT 1 |
| 91 | +#else |
| 92 | + /* The CPU has two accumulators. */ |
| 93 | + #define portUSE_TASK_ACC_SUPPORT 2 |
| 94 | +#endif |
| 95 | + |
| 96 | +/*-----------------------------------------------------------*/ |
| 97 | + |
| 98 | +/* Type definitions - these are a bit legacy and not really used now, other than |
| 99 | + * portSTACK_TYPE and portBASE_TYPE. */ |
| 100 | +#define portCHAR char |
| 101 | +#define portFLOAT float |
| 102 | +#define portDOUBLE double |
| 103 | +#define portLONG long |
| 104 | +#define portSHORT short |
| 105 | +#define portSTACK_TYPE uint32_t |
| 106 | +#define portBASE_TYPE long |
| 107 | + |
| 108 | +typedef portSTACK_TYPE StackType_t; |
| 109 | +typedef long BaseType_t; |
| 110 | +typedef unsigned long UBaseType_t; |
| 111 | + |
| 112 | +#if ( configUSE_16_BIT_TICKS == 1 ) |
| 113 | + typedef uint16_t TickType_t; |
| 114 | + #define portMAX_DELAY ( TickType_t ) 0xffff |
| 115 | +#else |
| 116 | + typedef uint32_t TickType_t; |
| 117 | + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL |
| 118 | + |
| 119 | + /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do |
| 120 | + * not need to be guarded with a critical section. */ |
| 121 | + #define portTICK_TYPE_IS_ATOMIC 1 |
| 122 | +#endif |
| 123 | + |
| 124 | +/*-----------------------------------------------------------*/ |
| 125 | + |
| 126 | +/* Inline assembler specifics. */ |
| 127 | +#if ( defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L ) ) |
| 128 | + /* *INDENT-OFF* */ |
| 129 | + #define _portASM( ... ) __asm volatile ( #__VA_ARGS__ "\n" ); |
| 130 | + #define portASM( ... ) _portASM( __VA_ARGS__ ) |
| 131 | + #define portASM_LAB_NEXT( name ) ?+ |
| 132 | + #define portASM_LAB_PREV( name ) ?- |
| 133 | + #define portASM_LAB( name_colon ) _portASM( ?: ) |
| 134 | + #define portASM_BEGIN |
| 135 | + #define portASM_END |
| 136 | + /* *INDENT-ON* */ |
| 137 | +#endif /* if ( defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L ) ) */ |
| 138 | + |
| 139 | +/* Workaround to reduce errors/warnings caused by e2 studio CDT's INDEXER and CODAN. */ |
| 140 | +#ifdef __CDT_PARSER__ |
| 141 | + #ifndef __asm |
| 142 | + #define __asm asm |
| 143 | + #endif |
| 144 | + #ifndef __attribute__ |
| 145 | + #define __attribute__( ... ) |
| 146 | + #endif |
| 147 | +#endif |
| 148 | + |
| 149 | +/*-----------------------------------------------------------*/ |
| 150 | + |
| 151 | +/* Hardware specifics. */ |
| 152 | +#define portBYTE_ALIGNMENT 8 /* Could make four, according to manual. */ |
| 153 | +#define portSTACK_GROWTH -1 |
| 154 | +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) |
| 155 | +#define portNOP() __asm volatile ( "NOP" ) |
| 156 | + |
| 157 | +/* Yield equivalent to "*portITU_SWINTR = 0x01; ( void ) ( *portITU_SWINTR == XXX );" |
| 158 | + * where portITU_SWINTR is the location of the software interrupt register |
| 159 | + * (0x000872E0) and XXX is an arbitrary number. Don't rely on the assembler to |
| 160 | + * select a register, so instead save and restore clobbered registers manually. */ |
| 161 | +/* *INDENT-OFF* */ |
| 162 | +#define portYIELD() \ |
| 163 | +__asm volatile \ |
| 164 | +( \ |
| 165 | + "PUSH.L R10 \n"\ |
| 166 | + "MOV.L #0x872E0, R10 \n"\ |
| 167 | + "MOV.B #0x1, [ R10 ] \n"\ |
| 168 | + "CMP [ R10 ].UB, R10 \n"\ |
| 169 | + "POP R10 "\ |
| 170 | + :::"cc" \ |
| 171 | +) |
| 172 | +/* *INDENT-ON* */ |
| 173 | + |
| 174 | +#define portYIELD_FROM_ISR( x ) if( ( x ) != pdFALSE ) portYIELD() |
| 175 | + |
| 176 | +/* These macros should not be called directly, but through the |
| 177 | + * taskENTER_CRITICAL() and taskEXIT_CRITICAL() macros. An extra check is |
| 178 | + * performed if configASSERT() is defined to ensure an assertion handler does not |
| 179 | + * inadvertently attempt to lower the IPL when the call to assert was triggered |
| 180 | + * because the IPL value was found to be above configMAX_SYSCALL_INTERRUPT_PRIORITY |
| 181 | + * when an ISR safe FreeRTOS API function was executed. ISR safe FreeRTOS API |
| 182 | + * functions are those that end in FromISR. FreeRTOS maintains a separate |
| 183 | + * interrupt API to ensure API function and interrupt entry is as fast and as |
| 184 | + * simple as possible. */ |
| 185 | +#define portENABLE_INTERRUPTS() __asm volatile ( "MVTIPL #0" ) |
| 186 | +#ifdef configASSERT |
| 187 | + #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( ( ulPortGetIPL() <= configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) |
| 188 | + #define portDISABLE_INTERRUPTS() if( ulPortGetIPL() < configMAX_SYSCALL_INTERRUPT_PRIORITY ) __asm volatile ( "MVTIPL %0" ::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) |
| 189 | +#else |
| 190 | + #define portDISABLE_INTERRUPTS() __asm volatile ( "MVTIPL %0" ::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) ) |
| 191 | +#endif |
| 192 | + |
| 193 | +/* Critical nesting counts are stored in the TCB. */ |
| 194 | +#define portCRITICAL_NESTING_IN_TCB ( 1 ) |
| 195 | + |
| 196 | +/* The critical nesting functions defined within tasks.c. */ |
| 197 | +extern void vTaskEnterCritical( void ); |
| 198 | +extern void vTaskExitCritical( void ); |
| 199 | +#define portENTER_CRITICAL() vTaskEnterCritical() |
| 200 | +#define portEXIT_CRITICAL() vTaskExitCritical() |
| 201 | + |
| 202 | +/* As this port allows interrupt nesting... */ |
| 203 | +uint32_t ulPortGetIPL( void ) __attribute__( ( naked ) ); |
| 204 | +void vPortSetIPL( uint32_t ulNewIPL ) __attribute__( ( naked ) ); |
| 205 | +#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortGetIPL(); portDISABLE_INTERRUPTS() |
| 206 | +#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ) vPortSetIPL( uxSavedInterruptStatus ) |
| 207 | + |
| 208 | +/*-----------------------------------------------------------*/ |
| 209 | + |
| 210 | +/* Task function macros as described on the FreeRTOS.org WEB site. */ |
| 211 | +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) |
| 212 | +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) |
| 213 | + |
| 214 | +/*-----------------------------------------------------------*/ |
| 215 | + |
| 216 | +/* If portUSE_TASK_DPFPU_SUPPORT is set to 1 (or left undefined) then tasks are |
| 217 | + * created without a DPFPU context and must call vPortTaskUsesDPFPU() to give |
| 218 | + * themselves a DPFPU context before using any DPFPU instructions. If |
| 219 | + * portUSE_TASK_DPFPU_SUPPORT is set to 2 then all tasks will have a DPFPU context |
| 220 | + * by default. */ |
| 221 | +#if ( portUSE_TASK_DPFPU_SUPPORT == 1 ) |
| 222 | + void vPortTaskUsesDPFPU( void ); |
| 223 | +#else |
| 224 | + |
| 225 | + /* Each task has a DPFPU context already, so define this function away to |
| 226 | + * nothing to prevent it being called accidentally. */ |
| 227 | + #define vPortTaskUsesDPFPU() |
| 228 | +#endif |
| 229 | +#define portTASK_USES_DPFPU() vPortTaskUsesDPFPU() |
| 230 | + |
| 231 | +/* Definition to allow compatibility with existing FreeRTOS Demo using flop.c. */ |
| 232 | +#define portTASK_USES_FLOATING_POINT() vPortTaskUsesDPFPU() |
| 233 | + |
| 234 | +/* *INDENT-OFF* */ |
| 235 | +#ifdef __cplusplus |
| 236 | + } |
| 237 | +#endif |
| 238 | +/* *INDENT-ON* */ |
| 239 | + |
| 240 | +#endif /* PORTMACRO_H */ |
0 commit comments