Changeset 038faca1 in rtems
- Timestamp:
- 11/25/14 15:47:20 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- cbc433c7
- Parents:
- b164303
- git-author:
- Sebastian Huber <sebastian.huber@…> (11/25/14 15:47:20)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (11/27/14 09:33:30)
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libcsupport/Makefile.am
rb164303 r038faca1 110 110 src/rtems_heap_greedy.c 111 111 MALLOC_C_FILES += src/cachealignedalloc.c 112 MALLOC_C_FILES += src/cachecoherentalloc.c 112 113 113 114 PASSWORD_GROUP_C_FILES = src/pwdgrp.c -
cpukit/rtems/include/rtems/rtems/cache.h
rb164303 r038faca1 192 192 void *rtems_cache_aligned_malloc ( size_t nbytes ); 193 193 194 /** 195 * @brief Allocates a memory area of size @a size bytes from cache coherent 196 * memory. 197 * 198 * A size value of zero will return a unique address which may be freed with 199 * rtems_cache_coherent_free(). 200 * 201 * The memory allocated by this function can be released with a call to 202 * rtems_cache_coherent_free(). 203 * 204 * By default the C program heap allocator is used. In case special memory 205 * areas must be used, then the BSP or the application must add cache coherent 206 * memory areas for the allocator via rtems_cache_coherent_add_area(). 207 * 208 * This function must be called from driver initialization or task context 209 * only. 210 * 211 * @param[in] alignment If the alignment parameter is not equal to zero, the 212 * allocated memory area will begin at an address aligned by this value. 213 * @param[in] boundary If the boundary parameter is not equal to zero, the 214 * allocated memory area will comply with a boundary constraint. The 215 * boundary value specifies the set of addresses which are aligned by the 216 * boundary value. The interior of the allocated memory area will not 217 * contain an element of this set. The begin or end address of the area may 218 * be a member of the set. 219 * 220 * @retval NULL If no memory is available or the parameters are inconsistent. 221 * @retval other A pointer to the begin of the allocated memory area. 222 */ 223 void *rtems_cache_coherent_allocate( 224 size_t size, 225 uintptr_t alignment, 226 uintptr_t boundary 227 ); 228 229 /** 230 * @brief Frees memory allocated by rtems_cache_coherent_allocate(). 231 * 232 * This function must be called from driver initialization or task context 233 * only. 234 * 235 * @param[in] ptr A pointer returned by rtems_cache_coherent_allocate(). 236 */ 237 void rtems_cache_coherent_free( void *ptr ); 238 239 /** 240 * @brief Adds a cache coherent memory area to the cache coherent allocator. 241 * 242 * This function must be called from BSP initialization, driver initialization 243 * or task context only. 244 * 245 * @param[in] area_begin The area begin address. 246 * @param[in] area_size The area size in bytes. 247 * 248 * @see rtems_cache_coherent_allocate(). 249 */ 250 void rtems_cache_coherent_add_area( 251 void *area_begin, 252 uintptr_t area_size 253 ); 254 194 255 #if defined( RTEMS_SMP ) 195 256 -
testsuites/sptests/spcache01/init.c
rb164303 r038faca1 23 23 #include <rtems.h> 24 24 #include <rtems/counter.h> 25 #include <rtems/score/sysstate.h> 25 26 26 27 #define TESTS_USE_PRINTF … … 410 411 } 411 412 413 #define AREA_SIZE 256 414 415 static char cache_coherent_area_0[AREA_SIZE]; 416 417 static char cache_coherent_area_1[AREA_SIZE]; 418 419 static char cache_coherent_area_2[AREA_SIZE]; 420 421 static void add_area(void *begin) 422 { 423 rtems_cache_coherent_add_area(NULL, 0); 424 rtems_cache_coherent_add_area(begin, AREA_SIZE); 425 } 426 427 static void test_cache_coherent_alloc(void) 428 { 429 void *p0; 430 void *p1; 431 System_state_Codes previous_state; 432 433 printf("test cache coherent allocation\n"); 434 435 p0 = rtems_cache_coherent_allocate(1, 0, 0); 436 rtems_test_assert(p0 != NULL); 437 438 rtems_cache_coherent_free(p0); 439 440 p0 = rtems_cache_coherent_allocate(1, 0, 0); 441 rtems_test_assert(p0 != NULL); 442 443 add_area(&cache_coherent_area_0[0]); 444 add_area(&cache_coherent_area_1[0]); 445 446 previous_state = _System_state_Get(); 447 _System_state_Set(previous_state + 1); 448 add_area(&cache_coherent_area_2[0]); 449 _System_state_Set(previous_state); 450 451 p1 = rtems_cache_coherent_allocate(1, 0, 0); 452 rtems_test_assert(p1 != NULL); 453 454 rtems_cache_coherent_free(p0); 455 rtems_cache_coherent_free(p1); 456 } 457 412 458 static void Init(rtems_task_argument arg) 413 459 { … … 417 463 test_timing(); 418 464 test_cache_aligned_alloc(); 465 test_cache_coherent_alloc(); 419 466 420 467 TEST_END(); -
testsuites/sptests/spcache01/spcache01.scn
rb164303 r038faca1 44 44 duration with invalidated cache 2600 ns 45 45 test rtems_cache_aligned_malloc() 46 test cache coherent allocation 46 47 *** END OF TEST SPCACHE 1 ***
Note: See TracChangeset
for help on using the changeset viewer.