Vekatech / VK_RZ_A1H_LCD_demo
Committer:
tvendov
Date:
Thu Feb 16 10:23:48 2017 +0000
Revision:
0:6435b67ad23c
Initial lcd support (VKLCD50RTA & VKLCD70RT companion boards)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tvendov 0:6435b67ad23c 1 /*******************************************************************************
tvendov 0:6435b67ad23c 2 * DISCLAIMER
tvendov 0:6435b67ad23c 3 * This software is supplied by Renesas Electronics Corporation and is only
tvendov 0:6435b67ad23c 4 * intended for use with Renesas products. No other uses are authorized. This
tvendov 0:6435b67ad23c 5 * software is owned by Renesas Electronics Corporation and is protected under
tvendov 0:6435b67ad23c 6 * all applicable laws, including copyright laws.
tvendov 0:6435b67ad23c 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
tvendov 0:6435b67ad23c 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
tvendov 0:6435b67ad23c 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
tvendov 0:6435b67ad23c 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
tvendov 0:6435b67ad23c 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
tvendov 0:6435b67ad23c 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
tvendov 0:6435b67ad23c 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
tvendov 0:6435b67ad23c 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
tvendov 0:6435b67ad23c 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
tvendov 0:6435b67ad23c 16 * Renesas reserves the right, without notice, to make changes to this software
tvendov 0:6435b67ad23c 17 * and to discontinue the availability of this software. By using this software,
tvendov 0:6435b67ad23c 18 * you agree to the additional terms and conditions found by accessing the
tvendov 0:6435b67ad23c 19 * following link:
tvendov 0:6435b67ad23c 20 * http://www.renesas.com/disclaimer
tvendov 0:6435b67ad23c 21 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
tvendov 0:6435b67ad23c 22 *******************************************************************************/
tvendov 0:6435b67ad23c 23 /**
tvendov 0:6435b67ad23c 24 * @file r_ospl_RTX.c
tvendov 0:6435b67ad23c 25 * @brief OS Porting Layer API for RTX
tvendov 0:6435b67ad23c 26 *
tvendov 0:6435b67ad23c 27 * $Module: OSPL $ $PublicVersion: 0.90 $ (=R_OSPL_VERSION)
tvendov 0:6435b67ad23c 28 * $Rev: 35 $
tvendov 0:6435b67ad23c 29 * $Date:: 2014-04-15 21:38:18 +0900#$
tvendov 0:6435b67ad23c 30 */
tvendov 0:6435b67ad23c 31
tvendov 0:6435b67ad23c 32
tvendov 0:6435b67ad23c 33 /******************************************************************************
tvendov 0:6435b67ad23c 34 Includes <System Includes> , "Project Includes"
tvendov 0:6435b67ad23c 35 ******************************************************************************/
tvendov 0:6435b67ad23c 36 #include "r_ospl.h"
tvendov 0:6435b67ad23c 37 #include "r_ospl_os_less_private.h"
tvendov 0:6435b67ad23c 38 #include "r_ospl_private.h"
tvendov 0:6435b67ad23c 39 #include "pl310.h" /* 2nd cache */
tvendov 0:6435b67ad23c 40 #if R_OSPL_IS_PREEMPTION
tvendov 0:6435b67ad23c 41 #include "cmsis_os.h"
tvendov 0:6435b67ad23c 42 #include "gic.h"
tvendov 0:6435b67ad23c 43 #include "r_ospl_RTX_private.h"
tvendov 0:6435b67ad23c 44 #endif
tvendov 0:6435b67ad23c 45
tvendov 0:6435b67ad23c 46
tvendov 0:6435b67ad23c 47 /******************************************************************************
tvendov 0:6435b67ad23c 48 Typedef definitions
tvendov 0:6435b67ad23c 49 ******************************************************************************/
tvendov 0:6435b67ad23c 50
tvendov 0:6435b67ad23c 51 /******************************************************************************
tvendov 0:6435b67ad23c 52 Macro definitions
tvendov 0:6435b67ad23c 53 ******************************************************************************/
tvendov 0:6435b67ad23c 54
tvendov 0:6435b67ad23c 55 /**
tvendov 0:6435b67ad23c 56 * @def OS_ERROR_SIGNAL
tvendov 0:6435b67ad23c 57 * @brief CMSIS-RTOS defined immediate value
tvendov 0:6435b67ad23c 58 * @par Parameters
tvendov 0:6435b67ad23c 59 * None
tvendov 0:6435b67ad23c 60 * @return None.
tvendov 0:6435b67ad23c 61 */
tvendov 0:6435b67ad23c 62 #define OS_ERROR_SIGNAL 0x80000000
tvendov 0:6435b67ad23c 63
tvendov 0:6435b67ad23c 64
tvendov 0:6435b67ad23c 65 /**
tvendov 0:6435b67ad23c 66 * @def R_OSPL_EVENT_WATCH
tvendov 0:6435b67ad23c 67 * @brief Debug tool
tvendov 0:6435b67ad23c 68 * @par Parameters
tvendov 0:6435b67ad23c 69 * None
tvendov 0:6435b67ad23c 70 * @return None.
tvendov 0:6435b67ad23c 71 */
tvendov 0:6435b67ad23c 72 #define R_OSPL_EVENT_WATCH 0 /* [R_OSPL_EVENT_WATCH] 0 or 1 */
tvendov 0:6435b67ad23c 73
tvendov 0:6435b67ad23c 74
tvendov 0:6435b67ad23c 75 /******************************************************************************
tvendov 0:6435b67ad23c 76 Imported global variables and functions (from other files)
tvendov 0:6435b67ad23c 77 ******************************************************************************/
tvendov 0:6435b67ad23c 78
tvendov 0:6435b67ad23c 79 /******************************************************************************
tvendov 0:6435b67ad23c 80 Exported global variables and functions (to be accessed by other files)
tvendov 0:6435b67ad23c 81 ******************************************************************************/
tvendov 0:6435b67ad23c 82
tvendov 0:6435b67ad23c 83 /******************************************************************************
tvendov 0:6435b67ad23c 84 Private global variables and functions
tvendov 0:6435b67ad23c 85 ******************************************************************************/
tvendov 0:6435b67ad23c 86
tvendov 0:6435b67ad23c 87
tvendov 0:6435b67ad23c 88 /***********************************************************************
tvendov 0:6435b67ad23c 89 * Implement: R_OSPL_Initialize
tvendov 0:6435b67ad23c 90 ************************************************************************/
tvendov 0:6435b67ad23c 91 errnum_t R_OSPL_Initialize( const void *const in_NullConfig )
tvendov 0:6435b67ad23c 92 {
tvendov 0:6435b67ad23c 93 R_UNREFERENCED_VARIABLE( in_NullConfig );
tvendov 0:6435b67ad23c 94 return 0;
tvendov 0:6435b67ad23c 95 }
tvendov 0:6435b67ad23c 96
tvendov 0:6435b67ad23c 97
tvendov 0:6435b67ad23c 98 /***********************************************************************
tvendov 0:6435b67ad23c 99 * Implement: R_OSPL_THREAD_GetCurrentId
tvendov 0:6435b67ad23c 100 ************************************************************************/
tvendov 0:6435b67ad23c 101 r_ospl_thread_id_t R_OSPL_THREAD_GetCurrentId(void)
tvendov 0:6435b67ad23c 102 {
tvendov 0:6435b67ad23c 103 return osThreadGetId();
tvendov 0:6435b67ad23c 104 }
tvendov 0:6435b67ad23c 105
tvendov 0:6435b67ad23c 106
tvendov 0:6435b67ad23c 107 /***********************************************************************
tvendov 0:6435b67ad23c 108 * Implement: R_OSPL_EVENT_Set
tvendov 0:6435b67ad23c 109 ************************************************************************/
tvendov 0:6435b67ad23c 110 void R_OSPL_EVENT_Set( r_ospl_thread_id_t const ThreadId, bit_flags32_t const SetFlags )
tvendov 0:6435b67ad23c 111 {
tvendov 0:6435b67ad23c 112 int32_t ret;
tvendov 0:6435b67ad23c 113
tvendov 0:6435b67ad23c 114 if ( ThreadId != NULL ) {
tvendov 0:6435b67ad23c 115 #if R_OSPL_EVENT_WATCH
tvendov 0:6435b67ad23c 116 R_D_AddToIntLog( 0x70100000 + SetFlags );
tvendov 0:6435b67ad23c 117 R_D_AddToIntLog( (uintptr_t) R_OSPL_THREAD_GetCurrentId() );
tvendov 0:6435b67ad23c 118 R_D_AddToIntLog( (uintptr_t) ThreadId );
tvendov 0:6435b67ad23c 119 #endif
tvendov 0:6435b67ad23c 120
tvendov 0:6435b67ad23c 121 ret = osSignalSet( (osThreadId) ThreadId, (int32_t) SetFlags );
tvendov 0:6435b67ad23c 122 ASSERT_D( (ret & OS_ERROR_SIGNAL) == 0, R_NOOP() );
tvendov 0:6435b67ad23c 123 R_UNREFERENCED_VARIABLE( ret ); /* for Release configuration */
tvendov 0:6435b67ad23c 124 }
tvendov 0:6435b67ad23c 125 }
tvendov 0:6435b67ad23c 126
tvendov 0:6435b67ad23c 127
tvendov 0:6435b67ad23c 128 /***********************************************************************
tvendov 0:6435b67ad23c 129 * Implement: R_OSPL_EVENT_Clear
tvendov 0:6435b67ad23c 130 ************************************************************************/
tvendov 0:6435b67ad23c 131 void R_OSPL_EVENT_Clear( r_ospl_thread_id_t const ThreadId, bit_flags32_t const ClearFlags1 )
tvendov 0:6435b67ad23c 132 {
tvendov 0:6435b67ad23c 133 int32_t ret;
tvendov 0:6435b67ad23c 134
tvendov 0:6435b67ad23c 135 if ( ThreadId != NULL ) {
tvendov 0:6435b67ad23c 136 IF_D( ( ClearFlags1 & ~0xFFFF ) != 0 ) {
tvendov 0:6435b67ad23c 137 R_NOOP();
tvendov 0:6435b67ad23c 138 }
tvendov 0:6435b67ad23c 139
tvendov 0:6435b67ad23c 140 #if R_OSPL_EVENT_WATCH
tvendov 0:6435b67ad23c 141 R_D_AddToIntLog( 0x70C00000 + ClearFlags1 );
tvendov 0:6435b67ad23c 142 R_D_AddToIntLog( (uintptr_t) R_OSPL_THREAD_GetCurrentId() );
tvendov 0:6435b67ad23c 143 R_D_AddToIntLog( (uintptr_t) ThreadId );
tvendov 0:6435b67ad23c 144 #endif
tvendov 0:6435b67ad23c 145
tvendov 0:6435b67ad23c 146 ret = osSignalClear( (osThreadId) ThreadId, (int32_t) ClearFlags1 );
tvendov 0:6435b67ad23c 147 /* "& 0xFFFF" is for avoiding error in osSignalClear */
tvendov 0:6435b67ad23c 148 ASSERT_D( (ret & OS_ERROR_SIGNAL) == 0, R_NOOP() );
tvendov 0:6435b67ad23c 149 R_UNREFERENCED_VARIABLE( ret ); /* for Release configuration */
tvendov 0:6435b67ad23c 150 }
tvendov 0:6435b67ad23c 151 }
tvendov 0:6435b67ad23c 152
tvendov 0:6435b67ad23c 153
tvendov 0:6435b67ad23c 154 /***********************************************************************
tvendov 0:6435b67ad23c 155 * Implement: R_OSPL_EVENT_Get
tvendov 0:6435b67ad23c 156 ************************************************************************/
tvendov 0:6435b67ad23c 157 #if ( ! defined( osCMSIS ) || osCMSIS <= 0x10001 ) && R_OSPL_VERSION < 85
tvendov 0:6435b67ad23c 158 bit_flags32_t R_OSPL_EVENT_Get( r_ospl_thread_id_t const ThreadId )
tvendov 0:6435b67ad23c 159 {
tvendov 0:6435b67ad23c 160 int32_t ret;
tvendov 0:6435b67ad23c 161
tvendov 0:6435b67ad23c 162 if ( ThreadId == NULL ) {
tvendov 0:6435b67ad23c 163 ret = 0;
tvendov 0:6435b67ad23c 164 } else {
tvendov 0:6435b67ad23c 165 ret = osSignalGet( (osThreadId) ThreadId );
tvendov 0:6435b67ad23c 166 ASSERT_D( (ret & OS_ERROR_SIGNAL) == 0, R_NOOP() );
tvendov 0:6435b67ad23c 167 }
tvendov 0:6435b67ad23c 168
tvendov 0:6435b67ad23c 169 return (bit_flags32_t) ret;
tvendov 0:6435b67ad23c 170 }
tvendov 0:6435b67ad23c 171 #endif
tvendov 0:6435b67ad23c 172
tvendov 0:6435b67ad23c 173
tvendov 0:6435b67ad23c 174 /***********************************************************************
tvendov 0:6435b67ad23c 175 * Implement: R_OSPL_EVENT_Wait
tvendov 0:6435b67ad23c 176 ************************************************************************/
tvendov 0:6435b67ad23c 177 errnum_t R_OSPL_EVENT_Wait( bit_flags32_t const WaigingFlags, bit_flags32_t *const out_GotFlags,
tvendov 0:6435b67ad23c 178 uint32_t const Timeout_msec )
tvendov 0:6435b67ad23c 179 {
tvendov 0:6435b67ad23c 180 errnum_t e;
tvendov 0:6435b67ad23c 181 osEvent event;
tvendov 0:6435b67ad23c 182
tvendov 0:6435b67ad23c 183 R_STATIC_ASSERT( R_OSPL_INFINITE == TO_UNSIGNED( osWaitForever ), "" );
tvendov 0:6435b67ad23c 184
tvendov 0:6435b67ad23c 185 #if R_OSPL_EVENT_WATCH
tvendov 0:6435b67ad23c 186 R_D_AddToIntLog( 0x70BE0000 + WaigingFlags );
tvendov 0:6435b67ad23c 187 R_D_AddToIntLog( (uintptr_t) R_OSPL_THREAD_GetCurrentId() );
tvendov 0:6435b67ad23c 188
tvendov 0:6435b67ad23c 189 {
tvendov 0:6435b67ad23c 190 static int tc;
tvendov 0:6435b67ad23c 191 if ( R_D_Counter( &tc, 0, NULL ) ) {
tvendov 0:6435b67ad23c 192 R_DEBUG_BREAK();
tvendov 0:6435b67ad23c 193 }
tvendov 0:6435b67ad23c 194 }
tvendov 0:6435b67ad23c 195 #endif
tvendov 0:6435b67ad23c 196
tvendov 0:6435b67ad23c 197
tvendov 0:6435b67ad23c 198 event = osSignalWait( (int32_t) WaigingFlags, Timeout_msec );
tvendov 0:6435b67ad23c 199
tvendov 0:6435b67ad23c 200
tvendov 0:6435b67ad23c 201 #if R_OSPL_EVENT_WATCH
tvendov 0:6435b67ad23c 202 R_D_AddToIntLog( 0x70AF0000 );
tvendov 0:6435b67ad23c 203 R_D_AddToIntLog( (uintptr_t) R_OSPL_THREAD_GetCurrentId() );
tvendov 0:6435b67ad23c 204 #endif
tvendov 0:6435b67ad23c 205
tvendov 0:6435b67ad23c 206 if ( (event.status == osOK) || (event.status == osEventTimeout) ) {
tvendov 0:6435b67ad23c 207 if ( out_GotFlags != NULL ) {
tvendov 0:6435b67ad23c 208 *out_GotFlags = R_OSPL_TIMEOUT;
tvendov 0:6435b67ad23c 209 }
tvendov 0:6435b67ad23c 210 IF ( event.status == osEventTimeout ) {
tvendov 0:6435b67ad23c 211 e=E_TIME_OUT;
tvendov 0:6435b67ad23c 212 goto fin;
tvendov 0:6435b67ad23c 213 }
tvendov 0:6435b67ad23c 214 } else {
tvendov 0:6435b67ad23c 215 ASSERT_R( event.status == osEventSignal, e=E_OTHERS; goto fin );
tvendov 0:6435b67ad23c 216
tvendov 0:6435b67ad23c 217 if ( out_GotFlags != NULL ) {
tvendov 0:6435b67ad23c 218 *out_GotFlags = (bit_flags32_t) event.value.signals;
tvendov 0:6435b67ad23c 219 }
tvendov 0:6435b67ad23c 220 }
tvendov 0:6435b67ad23c 221
tvendov 0:6435b67ad23c 222 e=0;
tvendov 0:6435b67ad23c 223 fin:
tvendov 0:6435b67ad23c 224 return e;
tvendov 0:6435b67ad23c 225 }
tvendov 0:6435b67ad23c 226
tvendov 0:6435b67ad23c 227
tvendov 0:6435b67ad23c 228 /***********************************************************************
tvendov 0:6435b67ad23c 229 * Implement: R_OSPL_SetInterruptPriority
tvendov 0:6435b67ad23c 230 ************************************************************************/
tvendov 0:6435b67ad23c 231 errnum_t R_OSPL_SetInterruptPriority( bsp_int_src_t const IRQ_Num, int_fast32_t const Priority )
tvendov 0:6435b67ad23c 232 {
tvendov 0:6435b67ad23c 233 GIC_SetPriority( IRQ_Num, (uint32_t) Priority );
tvendov 0:6435b67ad23c 234 return 0;
tvendov 0:6435b67ad23c 235 }
tvendov 0:6435b67ad23c 236
tvendov 0:6435b67ad23c 237
tvendov 0:6435b67ad23c 238 /***********************************************************************
tvendov 0:6435b67ad23c 239 * Implement: R_OSPL_MEMORY_Flush
tvendov 0:6435b67ad23c 240 ************************************************************************/
tvendov 0:6435b67ad23c 241 void R_OSPL_MEMORY_Flush( r_ospl_flush_t const FlushType )
tvendov 0:6435b67ad23c 242 {
tvendov 0:6435b67ad23c 243 if ( FlushType == R_OSPL_FLUSH_WRITEBACK_INVALIDATE ) {
tvendov 0:6435b67ad23c 244 #if 0
tvendov 0:6435b67ad23c 245 printf( "L1Flush\n" );
tvendov 0:6435b67ad23c 246 #endif
tvendov 0:6435b67ad23c 247
tvendov 0:6435b67ad23c 248 #if IS_RTX_USED
tvendov 0:6435b67ad23c 249 __v7_clean_inv_dcache_all();
tvendov 0:6435b67ad23c 250 #else
tvendov 0:6435b67ad23c 251 #error
tvendov 0:6435b67ad23c 252 #endif
tvendov 0:6435b67ad23c 253 } else if ( FlushType == R_OSPL_FLUSH_WRITEBACK_INVALIDATE_2ND ) {
tvendov 0:6435b67ad23c 254 #if 0
tvendov 0:6435b67ad23c 255 printf( "PL310Flush\n" );
tvendov 0:6435b67ad23c 256 #endif
tvendov 0:6435b67ad23c 257
tvendov 0:6435b67ad23c 258 PL310_CleanInvAllByWay();
tvendov 0:6435b67ad23c 259 } else {
tvendov 0:6435b67ad23c 260 ASSERT_D( false, R_NOOP() );
tvendov 0:6435b67ad23c 261 }
tvendov 0:6435b67ad23c 262 }
tvendov 0:6435b67ad23c 263
tvendov 0:6435b67ad23c 264
tvendov 0:6435b67ad23c 265 /**
tvendov 0:6435b67ad23c 266 * @brief R_OSPL_Is1bitOnly_Fast32_Sub
tvendov 0:6435b67ad23c 267 *
tvendov 0:6435b67ad23c 268 * @par Parameters
tvendov 0:6435b67ad23c 269 * None
tvendov 0:6435b67ad23c 270 * @return None.
tvendov 0:6435b67ad23c 271 */
tvendov 0:6435b67ad23c 272 #ifndef R_OSPL_NDEBUG
tvendov 0:6435b67ad23c 273 static bool_t R_OSPL_Is1bitOnly_Fast32_Sub( uint_fast32_t Value )
tvendov 0:6435b67ad23c 274 {
tvendov 0:6435b67ad23c 275 if ( (Value & 0x0000FFFFu) == 0 ) {
tvendov 0:6435b67ad23c 276 Value >>= 16;
tvendov 0:6435b67ad23c 277 }
tvendov 0:6435b67ad23c 278 if ( (Value & 0x000000FFu) == 0 ) {
tvendov 0:6435b67ad23c 279 Value >>= 8;
tvendov 0:6435b67ad23c 280 }
tvendov 0:6435b67ad23c 281 if ( (Value & 0x0000000Fu) == 0 ) {
tvendov 0:6435b67ad23c 282 Value >>= 4;
tvendov 0:6435b67ad23c 283 }
tvendov 0:6435b67ad23c 284 if ( (Value & 0x00000003u) == 0 ) {
tvendov 0:6435b67ad23c 285 Value >>= 2;
tvendov 0:6435b67ad23c 286 }
tvendov 0:6435b67ad23c 287 if ( (Value & 0x00000001u) == 0 ) {
tvendov 0:6435b67ad23c 288 Value >>= 1;
tvendov 0:6435b67ad23c 289 }
tvendov 0:6435b67ad23c 290 return ( Value == 1 );
tvendov 0:6435b67ad23c 291 }
tvendov 0:6435b67ad23c 292 #endif
tvendov 0:6435b67ad23c 293
tvendov 0:6435b67ad23c 294
tvendov 0:6435b67ad23c 295 /***********************************************************************
tvendov 0:6435b67ad23c 296 * Implement: R_OSPL_MEMORY_RangeFlush
tvendov 0:6435b67ad23c 297 ************************************************************************/
tvendov 0:6435b67ad23c 298 errnum_t R_OSPL_MEMORY_RangeFlush( r_ospl_flush_t const FlushType,
tvendov 0:6435b67ad23c 299 const void *const StartAddress, size_t const Length )
tvendov 0:6435b67ad23c 300 {
tvendov 0:6435b67ad23c 301 errnum_t e;
tvendov 0:6435b67ad23c 302 size_t cache_line_size;
tvendov 0:6435b67ad23c 303 size_t cache_line_mask;
tvendov 0:6435b67ad23c 304 uintptr_t start;
tvendov 0:6435b67ad23c 305 uintptr_t over;
tvendov 0:6435b67ad23c 306
tvendov 0:6435b67ad23c 307 ASSERT_R( FlushType == R_OSPL_FLUSH_INVALIDATE, e=E_BAD_COMMAND_ID; goto fin );
tvendov 0:6435b67ad23c 308
tvendov 0:6435b67ad23c 309 cache_line_size = R_OSPL_MEMORY_GetCacheLineSize();
tvendov 0:6435b67ad23c 310 cache_line_mask = cache_line_size - 1u;
tvendov 0:6435b67ad23c 311 ASSERT_D( R_OSPL_Is1bitOnly_Fast32_Sub( cache_line_size ), e=E_OTHERS; goto fin );
tvendov 0:6435b67ad23c 312
tvendov 0:6435b67ad23c 313 /* ->MISRA 11.3 */ /* ->SEC R2.7.1 */
tvendov 0:6435b67ad23c 314 ASSERT_R( ( (uintptr_t) StartAddress & cache_line_mask ) == 0u, e=E_OTHERS; goto fin );
tvendov 0:6435b67ad23c 315 ASSERT_R( ( Length & cache_line_mask ) == 0u, e=E_OTHERS; goto fin );
tvendov 0:6435b67ad23c 316
tvendov 0:6435b67ad23c 317 start = (uintptr_t) StartAddress;
tvendov 0:6435b67ad23c 318 over = ((uintptr_t) StartAddress + Length) - 1u;
tvendov 0:6435b67ad23c 319 /* <-MISRA 11.3 */ /* <-SEC R2.7.1 */
tvendov 0:6435b67ad23c 320
tvendov 0:6435b67ad23c 321 R_OSPL_MEMORY_RangeFlush_Sub( start, over, cache_line_size );
tvendov 0:6435b67ad23c 322
tvendov 0:6435b67ad23c 323 e=0;
tvendov 0:6435b67ad23c 324 fin:
tvendov 0:6435b67ad23c 325 return e;
tvendov 0:6435b67ad23c 326 }
tvendov 0:6435b67ad23c 327
tvendov 0:6435b67ad23c 328
tvendov 0:6435b67ad23c 329 /***********************************************************************
tvendov 0:6435b67ad23c 330 * Implement: R_OSPL_MEMORY_GetSpecification
tvendov 0:6435b67ad23c 331 ************************************************************************/
tvendov 0:6435b67ad23c 332 void R_OSPL_MEMORY_GetSpecification( r_ospl_memory_spec_t *const out_MemorySpec )
tvendov 0:6435b67ad23c 333 {
tvendov 0:6435b67ad23c 334 IF_DQ( out_MemorySpec == NULL ) {
tvendov 0:6435b67ad23c 335 goto fin;
tvendov 0:6435b67ad23c 336 }
tvendov 0:6435b67ad23c 337
tvendov 0:6435b67ad23c 338 out_MemorySpec->CacheLineSize = R_OSPL_MEMORY_GetCacheLineSize();
tvendov 0:6435b67ad23c 339
tvendov 0:6435b67ad23c 340 fin:
tvendov 0:6435b67ad23c 341 return;
tvendov 0:6435b67ad23c 342 }
tvendov 0:6435b67ad23c 343
tvendov 0:6435b67ad23c 344
tvendov 0:6435b67ad23c 345 /***********************************************************************
tvendov 0:6435b67ad23c 346 * Implement: R_OSPL_Delay
tvendov 0:6435b67ad23c 347 ************************************************************************/
tvendov 0:6435b67ad23c 348 errnum_t R_OSPL_Delay( uint32_t const DelayTime_msec )
tvendov 0:6435b67ad23c 349 {
tvendov 0:6435b67ad23c 350 errnum_t e;
tvendov 0:6435b67ad23c 351 osStatus rs;
tvendov 0:6435b67ad23c 352 bool_t const is_overflow = ( DelayTime_msec > R_OSPL_MAX_TIME_OUT );
tvendov 0:6435b67ad23c 353 uint32_t const delay_parameter = DelayTime_msec + 1u;
tvendov 0:6435b67ad23c 354
tvendov 0:6435b67ad23c 355 ASSERT_D( ! is_overflow, R_NOOP() );
tvendov 0:6435b67ad23c 356 /* RTX 5.16: If delay_parameter = 100000, "osDelay" waits 65534 */
tvendov 0:6435b67ad23c 357
tvendov 0:6435b67ad23c 358 rs= osDelay( delay_parameter );
tvendov 0:6435b67ad23c 359 IF ( rs == osErrorISR ) {
tvendov 0:6435b67ad23c 360 e=E_NOT_THREAD;
tvendov 0:6435b67ad23c 361 R_OSPL_RaiseUnrecoverable( e );
tvendov 0:6435b67ad23c 362 goto fin;
tvendov 0:6435b67ad23c 363 }
tvendov 0:6435b67ad23c 364 IF ( IS( is_overflow ) ) {
tvendov 0:6435b67ad23c 365 e=E_TIME_OUT;
tvendov 0:6435b67ad23c 366 goto fin;
tvendov 0:6435b67ad23c 367 }
tvendov 0:6435b67ad23c 368
tvendov 0:6435b67ad23c 369 IF (
tvendov 0:6435b67ad23c 370 (rs != osOK) && /* for delay_parameter == 0 */
tvendov 0:6435b67ad23c 371 (rs != osEventTimeout) ) { /* for delay_parameter != 0 */
tvendov 0:6435b67ad23c 372 e=E_OTHERS;
tvendov 0:6435b67ad23c 373 goto fin;
tvendov 0:6435b67ad23c 374 }
tvendov 0:6435b67ad23c 375
tvendov 0:6435b67ad23c 376 e=0;
tvendov 0:6435b67ad23c 377 fin:
tvendov 0:6435b67ad23c 378 return e;
tvendov 0:6435b67ad23c 379 }
tvendov 0:6435b67ad23c 380
tvendov 0:6435b67ad23c 381
tvendov 0:6435b67ad23c 382 /***********************************************************************
tvendov 0:6435b67ad23c 383 * Implement: R_OSPL_QUEUE_Create
tvendov 0:6435b67ad23c 384 ************************************************************************/
tvendov 0:6435b67ad23c 385 errnum_t R_OSPL_QUEUE_Create( r_ospl_queue_t **out_self, r_ospl_queue_def_t *QueueDefine )
tvendov 0:6435b67ad23c 386 {
tvendov 0:6435b67ad23c 387 errnum_t e;
tvendov 0:6435b67ad23c 388 r_ospl_queue_t *self = QueueDefine;
tvendov 0:6435b67ad23c 389
tvendov 0:6435b67ad23c 390 self->MailQId = osMailCreate( (osMailQDef_t *) QueueDefine->MailQDef, NULL );
tvendov 0:6435b67ad23c 391 IF ( self->MailQId == NULL ) {
tvendov 0:6435b67ad23c 392 e=E_OTHERS;
tvendov 0:6435b67ad23c 393 goto fin;
tvendov 0:6435b67ad23c 394 }
tvendov 0:6435b67ad23c 395 self->PublicStatus.UsedCount = 0;
tvendov 0:6435b67ad23c 396
tvendov 0:6435b67ad23c 397 *out_self = self;
tvendov 0:6435b67ad23c 398
tvendov 0:6435b67ad23c 399 e=0;
tvendov 0:6435b67ad23c 400 fin:
tvendov 0:6435b67ad23c 401 return e;
tvendov 0:6435b67ad23c 402 }
tvendov 0:6435b67ad23c 403
tvendov 0:6435b67ad23c 404
tvendov 0:6435b67ad23c 405 /***********************************************************************
tvendov 0:6435b67ad23c 406 * Implement: R_OSPL_QUEUE_GetStatus
tvendov 0:6435b67ad23c 407 ************************************************************************/
tvendov 0:6435b67ad23c 408 errnum_t R_OSPL_QUEUE_GetStatus( r_ospl_queue_t *self, const r_ospl_queue_status_t **out_Status )
tvendov 0:6435b67ad23c 409 {
tvendov 0:6435b67ad23c 410 *out_Status = &self->PublicStatus;
tvendov 0:6435b67ad23c 411 return 0;
tvendov 0:6435b67ad23c 412 }
tvendov 0:6435b67ad23c 413
tvendov 0:6435b67ad23c 414
tvendov 0:6435b67ad23c 415 /***********************************************************************
tvendov 0:6435b67ad23c 416 * Implement: R_OSPL_QUEUE_Allocate
tvendov 0:6435b67ad23c 417 ************************************************************************/
tvendov 0:6435b67ad23c 418 errnum_t R_OSPL_QUEUE_Allocate( r_ospl_queue_t *self, void *out_Address, uint32_t Timeout_msec )
tvendov 0:6435b67ad23c 419 {
tvendov 0:6435b67ad23c 420 errnum_t e;
tvendov 0:6435b67ad23c 421 void *address;
tvendov 0:6435b67ad23c 422 bool_t was_all_enabled = false;
tvendov 0:6435b67ad23c 423
tvendov 0:6435b67ad23c 424 address = osMailAlloc( self->MailQId, Timeout_msec );
tvendov 0:6435b67ad23c 425 *(void **) out_Address = address;
tvendov 0:6435b67ad23c 426 IF ( address == NULL && Timeout_msec > 0 ) {
tvendov 0:6435b67ad23c 427 if ( R_OSPL_THREAD_GetCurrentId() == NULL ) {
tvendov 0:6435b67ad23c 428 e=E_NOT_THREAD;
tvendov 0:6435b67ad23c 429 } else {
tvendov 0:6435b67ad23c 430 e=E_TIME_OUT;
tvendov 0:6435b67ad23c 431 }
tvendov 0:6435b67ad23c 432 goto fin;
tvendov 0:6435b67ad23c 433 }
tvendov 0:6435b67ad23c 434
tvendov 0:6435b67ad23c 435 was_all_enabled = R_OSPL_DisableAllInterrupt();
tvendov 0:6435b67ad23c 436 self->PublicStatus.UsedCount += 1;
tvendov 0:6435b67ad23c 437
tvendov 0:6435b67ad23c 438 e=0;
tvendov 0:6435b67ad23c 439 fin:
tvendov 0:6435b67ad23c 440 if ( was_all_enabled ) {
tvendov 0:6435b67ad23c 441 R_OSPL_EnableAllInterrupt();
tvendov 0:6435b67ad23c 442 }
tvendov 0:6435b67ad23c 443 return e;
tvendov 0:6435b67ad23c 444 }
tvendov 0:6435b67ad23c 445
tvendov 0:6435b67ad23c 446
tvendov 0:6435b67ad23c 447 /***********************************************************************
tvendov 0:6435b67ad23c 448 * Implement: R_OSPL_QUEUE_Put
tvendov 0:6435b67ad23c 449 ************************************************************************/
tvendov 0:6435b67ad23c 450 errnum_t R_OSPL_QUEUE_Put( r_ospl_queue_t *self, void *Address )
tvendov 0:6435b67ad23c 451 {
tvendov 0:6435b67ad23c 452 errnum_t e;
tvendov 0:6435b67ad23c 453 osStatus status;
tvendov 0:6435b67ad23c 454
tvendov 0:6435b67ad23c 455 status = osMailPut( self->MailQId, Address );
tvendov 0:6435b67ad23c 456 IF ( status != osOK ) {
tvendov 0:6435b67ad23c 457 e=E_OTHERS;
tvendov 0:6435b67ad23c 458 goto fin;
tvendov 0:6435b67ad23c 459 }
tvendov 0:6435b67ad23c 460
tvendov 0:6435b67ad23c 461 e=0;
tvendov 0:6435b67ad23c 462 fin:
tvendov 0:6435b67ad23c 463 return e;
tvendov 0:6435b67ad23c 464 }
tvendov 0:6435b67ad23c 465
tvendov 0:6435b67ad23c 466
tvendov 0:6435b67ad23c 467 /***********************************************************************
tvendov 0:6435b67ad23c 468 * Implement: R_OSPL_QUEUE_Get
tvendov 0:6435b67ad23c 469 ************************************************************************/
tvendov 0:6435b67ad23c 470 errnum_t R_OSPL_QUEUE_Get( r_ospl_queue_t *self, void *out_Address, uint32_t Timeout_msec )
tvendov 0:6435b67ad23c 471 {
tvendov 0:6435b67ad23c 472 errnum_t e;
tvendov 0:6435b67ad23c 473 osEvent event;
tvendov 0:6435b67ad23c 474
tvendov 0:6435b67ad23c 475 event = osMailGet( self->MailQId, Timeout_msec );
tvendov 0:6435b67ad23c 476
tvendov 0:6435b67ad23c 477 if ( event.status != osOK ) {
tvendov 0:6435b67ad23c 478 IF ( event.status != osEventMail ) {
tvendov 0:6435b67ad23c 479 if ( event.status == osEventTimeout ) {
tvendov 0:6435b67ad23c 480 e = E_TIME_OUT;
tvendov 0:6435b67ad23c 481 } else if ( event.status == osErrorParameter ) {
tvendov 0:6435b67ad23c 482 if ( R_OSPL_THREAD_GetCurrentId() == NULL ) {
tvendov 0:6435b67ad23c 483 e = E_NOT_THREAD;
tvendov 0:6435b67ad23c 484 } else {
tvendov 0:6435b67ad23c 485 e = E_OTHERS;
tvendov 0:6435b67ad23c 486 }
tvendov 0:6435b67ad23c 487 } else {
tvendov 0:6435b67ad23c 488 e = E_OTHERS;
tvendov 0:6435b67ad23c 489 }
tvendov 0:6435b67ad23c 490 goto fin;
tvendov 0:6435b67ad23c 491 }
tvendov 0:6435b67ad23c 492 }
tvendov 0:6435b67ad23c 493
tvendov 0:6435b67ad23c 494 *(void **) out_Address = event.value.p;
tvendov 0:6435b67ad23c 495
tvendov 0:6435b67ad23c 496 e=0;
tvendov 0:6435b67ad23c 497 fin:
tvendov 0:6435b67ad23c 498 return e;
tvendov 0:6435b67ad23c 499 }
tvendov 0:6435b67ad23c 500
tvendov 0:6435b67ad23c 501
tvendov 0:6435b67ad23c 502 /***********************************************************************
tvendov 0:6435b67ad23c 503 * Implement: R_OSPL_QUEUE_Free
tvendov 0:6435b67ad23c 504 ************************************************************************/
tvendov 0:6435b67ad23c 505 errnum_t R_OSPL_QUEUE_Free( r_ospl_queue_t *self, void *Address )
tvendov 0:6435b67ad23c 506 {
tvendov 0:6435b67ad23c 507 errnum_t e;
tvendov 0:6435b67ad23c 508 osStatus status;
tvendov 0:6435b67ad23c 509 bool_t was_all_enabled = false;
tvendov 0:6435b67ad23c 510
tvendov 0:6435b67ad23c 511 status = osMailFree( self->MailQId, Address );
tvendov 0:6435b67ad23c 512 IF ( status != osOK ) {
tvendov 0:6435b67ad23c 513 e=E_OTHERS;
tvendov 0:6435b67ad23c 514 goto fin;
tvendov 0:6435b67ad23c 515 }
tvendov 0:6435b67ad23c 516
tvendov 0:6435b67ad23c 517 was_all_enabled = R_OSPL_DisableAllInterrupt();
tvendov 0:6435b67ad23c 518 self->PublicStatus.UsedCount -= 1;
tvendov 0:6435b67ad23c 519
tvendov 0:6435b67ad23c 520 e=0;
tvendov 0:6435b67ad23c 521 fin:
tvendov 0:6435b67ad23c 522 if ( was_all_enabled ) {
tvendov 0:6435b67ad23c 523 R_OSPL_EnableAllInterrupt();
tvendov 0:6435b67ad23c 524 }
tvendov 0:6435b67ad23c 525 return e;
tvendov 0:6435b67ad23c 526 }
tvendov 0:6435b67ad23c 527
tvendov 0:6435b67ad23c 528
tvendov 0:6435b67ad23c 529