Graphics framework for GR-PEACH. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE
Dependents: ImageZoomInout_Sample ImageRotaion_Sample ImageScroll_Sample GR-PEACH_LCD_4_3inch_Save_to_USB ... more
r_ospl_memory.c
00001 /******************************************************************************* 00002 * DISCLAIMER 00003 * This software is supplied by Renesas Electronics Corporation and is only 00004 * intended for use with Renesas products. No other uses are authorized. This 00005 * software is owned by Renesas Electronics Corporation and is protected under 00006 * all applicable laws, including copyright laws. 00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING 00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT 00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. 00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR 00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE 00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00016 * Renesas reserves the right, without notice, to make changes to this software 00017 * and to discontinue the availability of this software. By using this software, 00018 * you agree to the additional terms and conditions found by accessing the 00019 * following link: 00020 * http://www.renesas.com/disclaimer 00021 * Copyright (C) 2012 - 2015 Renesas Electronics Corporation. All rights reserved. 00022 *******************************************************************************/ 00023 /** 00024 * @file r_ospl_memory.c 00025 * @brief Memory map 00026 * 00027 * $Module: OSPL $ $PublicVersion: 0.90 $ (=R_OSPL_VERSION) 00028 * $Rev: $ 00029 * $Date:: $ 00030 */ 00031 00032 00033 /****************************************************************************** 00034 Includes <System Includes> , "Project Includes" 00035 ******************************************************************************/ 00036 #include "r_ospl.h" 00037 #ifdef R_OSPL_TEST_CODE 00038 #include "r_ospl_test.h" 00039 #endif 00040 #include "r_ospl_private.h" 00041 00042 /****************************************************************************** 00043 Typedef definitions 00044 ******************************************************************************/ 00045 00046 /** 00047 * @struct gs_address_table_line_t 00048 * @brief gs_address_table_line_t 00049 */ 00050 typedef struct st_gs_address_table_line_t gs_address_table_line_t; 00051 struct st_gs_address_table_line_t { 00052 00053 /** Address */ 00054 uintptr_t Address; 00055 00056 /** Value */ 00057 int_fast32_t Value; 00058 }; 00059 00060 00061 /** 00062 * @struct gs_address_table_line_c_t 00063 * @brief gs_address_table_line_c_t 00064 */ 00065 typedef struct st_gs_address_table_line_c_t gs_address_table_line_c_t; 00066 struct st_gs_address_table_line_c_t { 00067 00068 /** Address */ 00069 uintptr_t Address; 00070 00071 /** Value */ 00072 r_ospl_axi_cache_attribute_t Value; 00073 }; 00074 00075 00076 /****************************************************************************** 00077 Macro definitions 00078 ******************************************************************************/ 00079 00080 /* ->MISRA 17.4 : These are addresses */ 00081 00082 #define GS_MIRROR_SIZE 0x40000000u 00083 #define GS_CACHED_START 0x00000000u 00084 #define GS_CACHED_END ( GS_CACHED_START + GS_MIRROR_SIZE ) 00085 #define GS_UNCACHED_START 0x40000000u 00086 #define GS_UNCACHED_END ( GS_UNCACHED_START + GS_MIRROR_SIZE ) 00087 00088 #define GS_IO_START 0x60A00000u 00089 00090 /* From "scatter.scat" file */ 00091 #if defined( RZ_A1L ) 00092 #define LRAM_SIZE 0x00300000u 00093 #else /* RZ/A1H */ 00094 #define LRAM_SIZE 0x00A00000u 00095 #endif 00096 #define LRAM_START 0x20000000u 00097 #define LRAM_END ( LRAM_START + LRAM_SIZE ) 00098 #define UNUSED_UNCACHED_LRAM_START 0x60000000u 00099 #define UNCACHED_LRAM_END ( UNUSED_UNCACHED_LRAM_START + LRAM_SIZE ) 00100 00101 /* <-MISRA 17.4 */ 00102 00103 #define GS_EXTERNAL_START_0x00000000 0x00000000u 00104 #define GS_EXTERNAL_SDRAM_START_0x08000000 0x08000000u 00105 #define GS_INTERNAL_RAM_START_0x20000000 0x20000000u 00106 #define GS_INTERNAL_REGISTERS_START_0x80000000 0x80000000u 00107 00108 #if defined( RZ_A1L_EV_BOARD ) 00109 #define GS_SDRAM_SIZE 0x04000000u 00110 #else 00111 #define GS_SDRAM_SIZE 0x08000000u 00112 #endif 00113 00114 00115 /****************************************************************************** 00116 Imported global variables and functions (from other files) 00117 ******************************************************************************/ 00118 00119 /****************************************************************************** 00120 Exported global variables and functions (to be accessed by other files) 00121 ******************************************************************************/ 00122 00123 /****************************************************************************** 00124 Private global variables and functions 00125 ******************************************************************************/ 00126 #ifdef R_OSPL_TEST_CODE 00127 static r_ospl_axi_envronment_t gs_Environment; 00128 #endif 00129 00130 00131 /****************************************************************************** 00132 * Implement: R_OSPL_ToPhysicalAddress 00133 ******************************************************************************/ 00134 errnum_t R_OSPL_ToPhysicalAddress( const volatile void *in_Address, uintptr_t *out_PhysicalAddress ) 00135 { 00136 errnum_t e; 00137 /* ->MISRA 11.3 */ /* ->SEC R2.7.1 */ 00138 uintptr_t const address = (uintptr_t) in_Address; 00139 /* <-MISRA 11.3 */ /* <-SEC R2.7.1 */ 00140 00141 IF_DQ( out_PhysicalAddress == NULL ) { 00142 e=E_OTHERS; 00143 goto fin; 00144 } 00145 00146 *out_PhysicalAddress = address; 00147 00148 e=0; 00149 fin: 00150 return e; 00151 } 00152 00153 00154 /****************************************************************************** 00155 * Implement: R_OSPL_ToCachedAddress 00156 ******************************************************************************/ 00157 errnum_t R_OSPL_ToCachedAddress( const volatile void *in_Address, void *out_CachedAddress ) 00158 { 00159 /* ->MISRA 11.3 */ /* ->SEC R2.7.1 */ 00160 /* ->QAC 0289 */ /* ->QAC 1002 : Image$$BEGIN_OF_NOCACHE_RAM_BARRIER$$Base */ 00161 errnum_t e; 00162 #if IS_MBED_USED 00163 uintptr_t address = (uintptr_t) in_Address; 00164 const uintptr_t uncached_from_cached = UNUSED_UNCACHED_LRAM_START - LRAM_START; 00165 #else 00166 uintptr_t const address = (uintptr_t) in_Address; 00167 #endif 00168 00169 IF_DQ( out_CachedAddress == NULL ) { 00170 e=E_OTHERS; 00171 goto fin; 00172 } 00173 00174 #if IS_MBED_USED 00175 IF ( address < LRAM_START ) { 00176 e = E_ACCESS_DENIED; 00177 } 00178 else if ( address < LRAM_END ) { 00179 e = 0; 00180 } else IF ( address < UNUSED_UNCACHED_LRAM_START ) { 00181 e = E_ACCESS_DENIED; 00182 } 00183 else if ( address < UNCACHED_LRAM_END ) { 00184 address -= uncached_from_cached; 00185 e = 0; 00186 } else { 00187 e = E_ACCESS_DENIED; 00188 } 00189 #else 00190 IF ( (address >= (uintptr_t)&Image$$BEGIN_OF_NOCACHE_RAM_BARRIER$$Base) && 00191 (address < (uintptr_t)&Image$$END_OF_INTERNAL_RAM_BARRIER$$ZI$$Limit) ) { 00192 /* "BEGIN_OF_NOCACHE_RAM_BARRIER" is defined in "scatter.sct" file. */ 00193 /* Image$$ execution region symbols */ 00194 /* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0377d/CHDFHJDJ.html */ 00195 00196 e = E_ACCESS_DENIED; 00197 } 00198 else IF ( address >= UNUSED_UNCACHED_LRAM_START ) { 00199 e = E_ACCESS_DENIED; 00200 } 00201 else { 00202 e = 0; 00203 } 00204 #endif 00205 00206 *(void **) out_CachedAddress = (void *) address; 00207 00208 fin: 00209 return e; 00210 /* <-QAC 0289 *//* <-QAC 1002 */ 00211 /* <-MISRA 11.3 */ /* <-SEC R2.7.1 */ 00212 } 00213 00214 00215 /****************************************************************************** 00216 * Implement: R_OSPL_ToUncachedAddress 00217 ******************************************************************************/ 00218 errnum_t R_OSPL_ToUncachedAddress( const volatile void *in_Address, void *out_UncachedAddress ) 00219 { 00220 /* ->MISRA 11.3 */ /* ->SEC R2.7.1 */ 00221 /* ->QAC 0289 */ /* ->QAC 1002 : Image$$BEGIN_OF_CACHED_RAM_BARRIER$$Base */ 00222 errnum_t e; 00223 #if IS_MBED_USED 00224 #if defined ( __GNUC__ ) && ! defined( __CC_ARM ) 00225 uintptr_t address = (uintptr_t) in_Address; 00226 #else 00227 uintptr_t address = (uintptr_t) in_Address; 00228 uintptr_t nc_base = UNUSED_UNCACHED_LRAM_START; 00229 const uintptr_t uncached_from_cached = UNUSED_UNCACHED_LRAM_START - LRAM_START; 00230 #endif 00231 #else 00232 uintptr_t const address = (uintptr_t) in_Address; 00233 #endif 00234 00235 IF_DQ( out_UncachedAddress == NULL ) { 00236 e=E_OTHERS; 00237 goto fin; 00238 } 00239 00240 #if IS_MBED_USED 00241 #if defined ( __GNUC__ ) && ! defined( __CC_ARM ) 00242 e = 0; 00243 #else 00244 IF ( address < nc_base - uncached_from_cached ) { 00245 e = E_ACCESS_DENIED; 00246 } 00247 else if ( address < LRAM_END ) { 00248 address += uncached_from_cached; 00249 e = 0; 00250 } else IF ( address < nc_base ) { 00251 e = E_ACCESS_DENIED; 00252 } 00253 else if ( address < UNCACHED_LRAM_END ) { 00254 e = 0; 00255 } else { 00256 e = E_ACCESS_DENIED; 00257 } 00258 #endif 00259 #else 00260 IF ( (address >= (uintptr_t)&Image$$BEGIN_OF_CACHED_RAM_BARRIER$$Base) && 00261 (address < (uintptr_t)&Image$$BEGIN_OF_NOCACHE_RAM_BARRIER$$ZI$$Limit) ) { 00262 e = E_ACCESS_DENIED; 00263 } 00264 else if ( (address >= (uintptr_t)&Image$$BEGIN_OF_NOCACHE_RAM_BARRIER$$Base) && 00265 (address < (uintptr_t)&Image$$END_OF_INTERNAL_RAM_BARRIER$$ZI$$Limit) ) { 00266 e = 0; 00267 } else IF ( R_CUT_IF_ALWAYS_TRUE( (address >= GS_CACHED_START) &&) (address < GS_CACHED_END) ) { 00268 e = E_ACCESS_DENIED; 00269 } 00270 else IF ( (address >= UNUSED_UNCACHED_LRAM_START) && (address < GS_IO_START) ) { 00271 e = E_ACCESS_DENIED; 00272 } 00273 else { 00274 e = 0; 00275 } 00276 #endif 00277 00278 *(void **) out_UncachedAddress = (void *) address; 00279 00280 fin: 00281 return e; 00282 /* <-QAC 0289 *//* <-QAC 1002 */ 00283 /* <-MISRA 11.3 */ /* <-SEC R2.7.1 */ 00284 } 00285 00286 00287 /****************************************************************************** 00288 * Implement: R_OSPL_MEMORY_GetLevelOfFlush 00289 ******************************************************************************/ 00290 errnum_t R_OSPL_MEMORY_GetLevelOfFlush( const void *in_Address, int_fast32_t *out_Level ) 00291 { 00292 uintptr_t address = (uintptr_t) in_Address; 00293 00294 #ifdef R_OSPL_TEST_CODE 00295 if ( gs_Environment == R_OSPL_AXI_L2CACHED ) { 00296 #endif 00297 static const gs_address_table_line_t table[] = { 00298 /* .Address .Value */ 00299 { GS_EXTERNAL_START_0x00000000, 0 }, 00300 { GS_EXTERNAL_SDRAM_START_0x08000000, 1 }, 00301 { GS_EXTERNAL_SDRAM_START_0x08000000 + GS_SDRAM_SIZE, 0 }, 00302 { GS_INTERNAL_RAM_START_0x20000000, 1 }, 00303 { GS_INTERNAL_RAM_START_0x20000000 + LRAM_SIZE, 0 } 00304 }; 00305 00306 00307 if ( address < table[1].Address ) { 00308 *out_Level = table[0].Value; 00309 } else if ( address < table[2].Address ) { 00310 *out_Level = table[1].Value; 00311 } else if ( address < table[3].Address ) { 00312 *out_Level = table[2].Value; 00313 } else if ( address < table[4].Address ) { 00314 *out_Level = table[3].Value; 00315 } else { 00316 *out_Level = table[4].Value; 00317 } 00318 R_STATIC_ASSERT( R_COUNT_OF( table ) == 5, "" ); 00319 00320 #ifdef R_OSPL_TEST_CODE 00321 } else { 00322 static const gs_address_table_line_t table[] = { 00323 /* .Address .Value */ 00324 { GS_EXTERNAL_START_0x00000000, 0 }, 00325 { GS_EXTERNAL_SDRAM_START_0x08000000, 2 }, 00326 { GS_EXTERNAL_SDRAM_START_0x08000000 + GS_SDRAM_SIZE, 0 }, 00327 { GS_INTERNAL_RAM_START_0x20000000, 1 }, 00328 { GS_INTERNAL_RAM_START_0x20000000 + LRAM_SIZE, 0 }, 00329 /* { GS_EXTERNAL_SDRAM_MIRROR_START_0x48000000, 2 }, */ 00330 /* { GS_EXTERNAL_SDRAM_MIRROR_START_0x48000000 + GS_SDRAM_SIZE, 0 }, */ 00331 /* { GS_INTERNAL_RAM_MIRROR_START_0x60000000, 0 }, */ 00332 /* { GS_INTERNAL_RAM_MIRROR_START_0x60000000 + LRAM_SIZE, 0 } */ 00333 }; 00334 00335 00336 ASSERT_R( gs_Environment == R_OSPL_AXI_L2STRONGLY, R_NOOP() ); 00337 00338 if ( address < table[1].Address ) { 00339 *out_Level = table[0].Value; 00340 } else if ( address < table[2].Address ) { 00341 *out_Level = table[1].Value; 00342 } else if ( address < table[3].Address ) { 00343 *out_Level = table[2].Value; 00344 } else if ( address < table[4].Address ) { 00345 *out_Level = table[3].Value; 00346 } else { 00347 *out_Level = table[4].Value; 00348 } 00349 R_STATIC_ASSERT( R_COUNT_OF( table ) == 5, "" ); 00350 } 00351 #endif 00352 return 0; 00353 } 00354 00355 00356 /****************************************************************************** 00357 * Implement: R_OSPL_AXI_Get2ndCacheAttribute 00358 ******************************************************************************/ 00359 errnum_t R_OSPL_AXI_Get2ndCacheAttribute( uintptr_t const in_PhysicalAddress, 00360 r_ospl_axi_cache_attribute_t *const out_CacheAttribute ) 00361 { 00362 uintptr_t address = in_PhysicalAddress; 00363 00364 #ifdef R_OSPL_TEST_CODE 00365 if ( gs_Environment == R_OSPL_AXI_L2CACHED ) { 00366 #endif 00367 static const gs_address_table_line_c_t table[] = { 00368 /* .Address .Value */ 00369 { GS_EXTERNAL_START_0x00000000, R_OSPL_AXI_WRITE_BACK_W }, 00370 /*{ GS_EXTERNAL_SDRAM_START_0x08000000, R_OSPL_AXI_WRITE_BACK_W },*/ 00371 { GS_INTERNAL_RAM_START_0x20000000, R_OSPL_AXI_CACHE_ZERO }, 00372 /*{ GS_INTERNAL_REGISTERS_START_0x80000000, R_OSPL_AXI_CACHE_ZERO }*/ 00373 /* If external I/O existed, "*out_CacheAttribute = R_AXI_DEVICE;" */ 00374 }; 00375 00376 00377 if ( address < table[1].Address ) { 00378 *out_CacheAttribute = table[0].Value; 00379 } else { 00380 *out_CacheAttribute = table[1].Value; 00381 } 00382 R_STATIC_ASSERT( R_COUNT_OF( table ) == 2, "" ); 00383 00384 #ifdef R_OSPL_TEST_CODE 00385 } else { 00386 static const gs_address_table_line_c_t table[] = { 00387 /* .Address .Value */ 00388 { GS_EXTERNAL_START_0x00000000, R_OSPL_AXI_STRONGLY }, 00389 /*{ GS_EXTERNAL_SDRAM_START_0x08000000, R_OSPL_AXI_STRONGLY },*/ 00390 { GS_INTERNAL_RAM_START_0x20000000, R_OSPL_AXI_CACHE_ZERO }, 00391 /*{ GS_EXTERNAL_MIRROR_START_0x40000000, R_OSPL_AXI_STRONGLY },*/ 00392 /*{ GS_EXTERNAL_SDRAM_MIRROR_START_0x48000000,R_OSPL_AXI_STRONGLY },*/ 00393 /*{ GS_INTERNAL_RAM_MIRROR_START_0x60000000, R_OSPL_AXI_CACHE_ZERO },*/ 00394 /*{ GS_INTERNAL_REGISTERS_START_0x80000000, R_OSPL_AXI_CACHE_ZERO }*/ 00395 /* If external I/O existed, "*out_CacheAttribute = R_AXI_DEVICE;" */ 00396 }; 00397 00398 00399 ASSERT_R( gs_Environment == R_OSPL_AXI_L2STRONGLY, R_NOOP() ); 00400 00401 if ( address < table[1].Address ) { 00402 *out_CacheAttribute = table[0].Value; 00403 } else { 00404 *out_CacheAttribute = table[1].Value; 00405 } 00406 R_STATIC_ASSERT( R_COUNT_OF( table ) == 2, "" ); 00407 } 00408 #endif 00409 return 0; 00410 } 00411 00412 00413 /*********************************************************************** 00414 * Implement: R_OSPL_AXI_GetProtection 00415 ************************************************************************/ 00416 errnum_t R_OSPL_AXI_GetProtection( uintptr_t const in_PhysicalAddress, 00417 r_ospl_axi_protection_t *const out_Protection ) 00418 { 00419 *out_Protection = R_OSPL_AXI_NON_SECURE; /* Same as CPU(TTB) NS bit */ 00420 00421 return 0; 00422 } 00423 00424 00425 /*********************************************************************** 00426 * Implement: R_OSPL_AXI_SetEnvironment 00427 ************************************************************************/ 00428 #ifdef R_OSPL_TEST_CODE 00429 errnum_t R_OSPL_AXI_SetEnvironment( r_ospl_axi_envronment_t in_Environment ) 00430 { 00431 gs_Environment = in_Environment; 00432 return 0; 00433 } 00434 #endif 00435 00436
Generated on Tue Jul 12 2022 11:15:03 by 1.7.2