Changeset e1d7bf0 in rtems


Ignore:
Timestamp:
Feb 26, 2014, 10:08:31 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
80186ca8
Parents:
e7549ff4
git-author:
Sebastian Huber <sebastian.huber@…> (02/26/14 10:08:31)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/28/14 08:06:16)
Message:

rtems: Add cache size functions

Add rtems_cache_get_data_cache_size() and
rtems_cache_get_instruction_cache_size().

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/shared/src/cache_manager.c

    re7549ff4 re1d7bf0  
    161161
    162162
     163size_t
     164rtems_cache_get_data_cache_size( uint32_t level )
     165{
     166#if defined(CPU_CACHE_SUPPORT_PROVIDES_CACHE_SIZE_FUNCTIONS)
     167  return _CPU_cache_get_data_cache_size( level );
     168#else
     169  return 0;
     170#endif
     171}
     172
    163173/*
    164174 * This function freezes the data cache; cache lines
     
    276286
    277287
     288size_t
     289rtems_cache_get_instruction_cache_size( uint32_t level )
     290{
     291#if defined(CPU_CACHE_SUPPORT_PROVIDES_CACHE_SIZE_FUNCTIONS)
     292  return _CPU_cache_get_instruction_cache_size( level );
     293#else
     294  return 0;
     295#endif
     296}
     297
     298
    278299/*
    279300 * This function freezes the instruction cache; cache lines
  • cpukit/rtems/include/rtems/rtems/cache.h

    re7549ff4 re1d7bf0  
    6060 */
    6161size_t rtems_cache_get_instruction_line_size( void );
     62
     63/**
     64 * @brief Returns the data cache size in bytes.
     65 *
     66 * @param[in] level The cache level of interest.  The cache level zero
     67 * specifies the entire data cache.
     68 *
     69 * @returns The data cache size in bytes of the specified level.
     70 */
     71size_t rtems_cache_get_data_cache_size( uint32_t level );
     72
     73/**
     74 * @brief Returns the instruction cache size in bytes.
     75 *
     76 * @param[in] level The cache level of interest.  The cache level zero
     77 * specifies the entire instruction cache.
     78 *
     79 * @returns The instruction cache size in bytes of the specified level.
     80 */
     81size_t rtems_cache_get_instruction_cache_size( uint32_t level );
    6282
    6383/**
  • testsuites/sptests/spcache01/init.c

    re7549ff4 re1d7bf0  
    164164  size_t data_size = sizeof(data);
    165165  uint64_t d[3];
    166 
    167   printf(
    168     "data cache line size %zi bytes\n",
    169     rtems_cache_get_data_line_size()
    170   );
     166  uint32_t cache_level;
     167  size_t cache_size;
     168
     169  printf(
     170    "data cache line size %zi bytes\n"
     171    "data cache size %zi bytes\n",
     172    rtems_cache_get_data_line_size(),
     173    rtems_cache_get_data_cache_size(0)
     174  );
     175
     176  cache_level = 1;
     177  cache_size = rtems_cache_get_data_cache_size(cache_level);
     178  while (cache_size > 0) {
     179    printf(
     180      "data cache level %" PRIu32 " size %zi bytes\n",
     181      cache_level,
     182      cache_size
     183    );
     184    ++cache_level;
     185    cache_size = rtems_cache_get_data_cache_size(cache_level);
     186  }
    171187
    172188  rtems_interrupt_lock_acquire(&lock, level);
     
    291307
    292308  printf(
    293     "instruction cache line size %zi bytes\n",
    294     rtems_cache_get_instruction_line_size()
    295   );
     309    "instruction cache line size %zi bytes\n"
     310    "instruction cache size %zi bytes\n",
     311    rtems_cache_get_instruction_line_size(),
     312    rtems_cache_get_instruction_cache_size(0)
     313  );
     314
     315  cache_level = 1;
     316  cache_size = rtems_cache_get_instruction_cache_size(cache_level);
     317  while (cache_size > 0) {
     318    printf(
     319      "instruction cache level %" PRIu32 " size %zi bytes\n",
     320      cache_level,
     321      cache_size
     322    );
     323    ++cache_level;
     324    cache_size = rtems_cache_get_instruction_cache_size(cache_level);
     325  }
    296326
    297327  rtems_interrupt_lock_acquire(&lock, level);
  • testsuites/sptests/spcache01/spcache01.scn

    re7549ff4 re1d7bf0  
    44data cache operations by line passed the test (copy-back cache detected)
    55data cache line size 32 bytes
     6data cache size 262144 bytes
     7data cache level 1 size 32768 bytes
     8data cache level 2 size 262144 bytes
    69load 4096 bytes with flush entire data
    710  duration with normal cache 12660 ns
     
    2932  duration with invalidated cache 2640 ns
    3033instruction cache line size 32 bytes
     34instruction cache size 262144 bytes
     35instruction cache level 1 size 32768 bytes
     36instruction cache level 2 size 262144 bytes
    3137invalidate entire instruction
    3238  duration with normal cache 5780 ns
Note: See TracChangeset for help on using the changeset viewer.