Changeset 9b91c84 in rtems


Ignore:
Timestamp:
Apr 5, 2017, 9:29:02 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
6b5fd3a
Parents:
46f05b9
Message:

smpcache01: Fix test to run on QorIQ T4240

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/smptests/smpcache01/init.c

    r46f05b9 r9b91c84  
    11/*
    22 * Copyright (c) 2014 Aeroflex Gaisler AB.  All rights reserved.
     3 * Copyright (c) 2017 embedded brains GmbH.
    34 *
    45 * The license and distribution terms for this file may be
     
    1617#include <rtems.h>
    1718#include <limits.h>
     19#include <setjmp.h>
    1820#include <string.h>
    1921
     
    3133  SMP_barrier_Control barrier;
    3234  uint32_t count[CPU_COUNT];
     35  bool do_longjmp[CPU_COUNT];
     36  jmp_buf instruction_invalidate_return_context[CPU_COUNT];
    3337} test_context;
    3438
     
    99103)
    100104{
    101   rtems_cache_invalidate_multiple_instruction_lines( &function_to_flush,
    102       4 /* arbitrary size */ );
    103 }
    104 
    105 static void test_broadcast_action(
    106   size_t set_size,
    107   const cpu_set_t *cpu_set,
    108   SMP_barrier_State *bs
    109 )
     105  uint32_t self = rtems_get_current_processor();
     106
     107  ctx.do_longjmp[self] = true;
     108
     109  if (setjmp(ctx.instruction_invalidate_return_context[self]) == 0) {
     110    rtems_cache_invalidate_multiple_instruction_lines( &function_to_flush,
     111        4 /* arbitrary size */ );
     112  }
     113
     114  ctx.do_longjmp[self] = false;
     115}
     116
     117static void barrier( SMP_barrier_State *bs )
     118{
     119  _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );
     120}
     121
     122static void broadcast_test_init( void )
    110123{
    111124  ctx.count[rtems_get_current_processor()] = 0;
    112   _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );
    113 
     125}
     126
     127static void broadcast_test_body(
     128  size_t set_size,
     129  const cpu_set_t *cpu_set,
     130  SMP_barrier_State *bs
     131)
     132{
    114133  _SMP_Multicast_action( set_size, cpu_set, test_action, &ctx );
    115 
    116   _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );
    117 
    118   rtems_test_assert( ctx.count[rtems_get_current_processor()] ==
    119       rtems_get_processor_count() );
     134}
     135
     136static void broadcast_test_fini( void )
     137{
     138  rtems_test_assert(
     139    ctx.count[rtems_get_current_processor()] == rtems_get_processor_count()
     140  );
    120141}
    121142
     
    126147  test_cache_invalidate_entire_instruction,
    127148  test_cache_invalidate_multiple_instruction_lines,
    128   test_broadcast_action
     149  broadcast_test_body
    129150};
    130 
    131 static void call_test(
    132   size_t set_size,
    133   const cpu_set_t *cpu_set,
    134   SMP_barrier_State *bs,
    135   size_t i
    136 )
    137 {
    138   _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );
    139   ( *test_cases[ i ] )( set_size, cpu_set, bs );
    140   _SMP_barrier_Wait( &ctx.barrier, bs, rtems_get_processor_count() );
    141 }
    142151
    143152static void call_tests( size_t set_size,
     
    146155  size_t i;
    147156
     157  broadcast_test_init();
     158
    148159  for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
    149     call_test( set_size, cpu_set, bs, i );
    150   }
     160    barrier( bs );
     161    ( *test_cases[ i ] )( set_size, cpu_set, bs );
     162    barrier( bs );
     163  }
     164
     165  broadcast_test_fini();
    151166}
    152167
     
    156171  size_t i;
    157172
     173  broadcast_test_init();
     174
    158175  for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
    159176    ISR_Level isr_level;
    160177
    161178    _ISR_Local_disable( isr_level );
    162 
    163     call_test( set_size, cpu_set, bs, i );
    164 
     179    barrier( bs );
     180    ( *test_cases[ i ] )( set_size, cpu_set, bs );
    165181    _ISR_Local_enable( isr_level );
    166   }
     182    barrier( bs );
     183  }
     184
     185  broadcast_test_fini();
    167186}
    168187
     
    172191  size_t i;
    173192
     193  broadcast_test_init();
     194
    174195  for (i = 0; i < RTEMS_ARRAY_SIZE( test_cases ); ++i) {
    175196    Per_CPU_Control *cpu_self;
    176197
    177198    cpu_self = _Thread_Dispatch_disable();
    178 
    179     call_test( set_size, cpu_set, bs, i );
    180 
     199    barrier( bs );
     200    ( *test_cases[ i ] )( set_size, cpu_set, bs );
     201    barrier( bs );
    181202    _Thread_Dispatch_enable( cpu_self );
    182203  }
     204
     205  broadcast_test_fini();
    183206}
    184207
     
    266289}
    267290
     291static void fatal_extension(
     292  rtems_fatal_source source,
     293  bool always_set_to_false,
     294  rtems_fatal_code error
     295)
     296{
     297  uint32_t self = rtems_get_current_processor();
     298
     299  if (source == RTEMS_FATAL_SOURCE_EXCEPTION && ctx.do_longjmp[self]) {
     300    _ISR_Set_level(0);
     301    longjmp(ctx.instruction_invalidate_return_context[self], 1);
     302  }
     303}
     304
    268305#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
    269306#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
     
    275312#define CONFIGURE_MAXIMUM_TIMERS 1
    276313
    277 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
     314#define CONFIGURE_INITIAL_EXTENSIONS \
     315  { .fatal = fatal_extension }, \
     316  RTEMS_TEST_INITIAL_EXTENSION
    278317
    279318#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
Note: See TracChangeset for help on using the changeset viewer.