Changeset e0609ac in rtems


Ignore:
Timestamp:
Mar 3, 2014, 8:49:12 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
718124e
Parents:
8b50a55
git-author:
Sebastian Huber <sebastian.huber@…> (03/03/14 08:49:12)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/06/14 08:43:58)
Message:

bsps: SMP support for generic interrupt support

Location:
c/src/lib/libbsp/shared
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/shared/include/irq-generic.h

    r8b50a55 re0609ac  
    1010 * Based on concepts of Pavel Pisa, Till Straumann and Eric Valette.
    1111 *
    12  * Copyright (c) 2008-2012 embedded brains GmbH.
     12 * Copyright (c) 2008-2014 embedded brains GmbH.
    1313 *
    1414 *  embedded brains GmbH
    15  *  Obere Lagerstr. 30
     15 *  Dornierstr. 4
    1616 *  82178 Puchheim
    1717 *  Germany
     
    3030#include <rtems/irq-extension.h>
    3131
     32#ifdef RTEMS_SMP
     33  #include <rtems/score/atomic.h>
     34#endif
     35
    3236#include <bsp/irq.h>
    3337
     
    5357#ifndef BSP_INTERRUPT_HANDLER_TABLE_SIZE
    5458  #define BSP_INTERRUPT_HANDLER_TABLE_SIZE BSP_INTERRUPT_VECTOR_NUMBER
     59#endif
     60
     61/* Internal macros for SMP support, do not use externally */
     62#ifdef RTEMS_SMP
     63  #define bsp_interrupt_disable(level) do { (void) level; } while (0)
     64  #define bsp_interrupt_enable(level) do { } while (0)
     65  #define bsp_interrupt_fence(order) _Atomic_Fence(order)
     66#else
     67  #define bsp_interrupt_disable(level) rtems_interrupt_disable(level)
     68  #define bsp_interrupt_enable(level) rtems_interrupt_enable(level)
     69  #define bsp_interrupt_fence(order) do { } while (0)
    5570#endif
    5671
     
    239254{
    240255  if (bsp_interrupt_is_valid_vector(vector)) {
    241     bsp_interrupt_handler_entry *e =
     256    const bsp_interrupt_handler_entry *e =
    242257      &bsp_interrupt_handler_table [bsp_interrupt_handler_index(vector)];
    243258
    244259    do {
    245       (*e->handler)(e->arg);
     260      rtems_interrupt_handler handler;
     261      void *arg;
     262
     263      arg = e->arg;
     264      bsp_interrupt_fence(ATOMIC_ORDER_ACQUIRE);
     265      handler = e->handler;
     266      (*handler)(arg);
     267
    246268      e = e->next;
    247269    } while (e != NULL);
  • c/src/lib/libbsp/shared/src/irq-generic.c

    r8b50a55 re0609ac  
    1010 * Based on concepts of Pavel Pisa, Till Straumann and Eric Valette.
    1111 *
    12  * Copyright (c) 2008-2012 embedded brains GmbH.
     12 * Copyright (c) 2008-2014 embedded brains GmbH.
    1313 *
    1414 *  embedded brains GmbH
    15  *  Obere Lagerstr. 30
     15 *  Dornierstr. 4
    1616 *  82178 Puchheim
    1717 *  Germany
     
    4949  bsp_interrupt_handler_default(vector);
    5050}
     51
     52#ifdef RTEMS_SMP
     53  static void bsp_interrupt_handler_do_nothing(void *arg)
     54  {
     55    (void) arg;
     56  }
     57#endif
    5158
    5259static inline bool bsp_interrupt_is_handler_unique(rtems_vector_number index)
     
    94101{
    95102  e->handler = bsp_interrupt_handler_empty;
     103  bsp_interrupt_fence(ATOMIC_ORDER_RELEASE);
    96104  e->arg = (void *) vector;
    97105  e->info = NULL;
     
    235243     */
    236244    if (bsp_interrupt_allocate_handler_index(vector, &index)) {
    237       rtems_interrupt_disable(level);
     245      bsp_interrupt_disable(level);
     246      bsp_interrupt_handler_table [index].arg = arg;
     247      bsp_interrupt_fence(ATOMIC_ORDER_RELEASE);
    238248      bsp_interrupt_handler_table [index].handler = handler;
    239       bsp_interrupt_handler_table [index].arg = arg;
    240249      #ifdef BSP_INTERRUPT_USE_INDEX_TABLE
    241250        bsp_interrupt_handler_index_table [vector] = index;
    242251      #endif
    243       rtems_interrupt_enable(level);
     252      bsp_interrupt_enable(level);
    244253      bsp_interrupt_handler_table [index].info = info;
    245254    } else {
     
    300309
    301310    /* Link to list tail */
    302     rtems_interrupt_disable(level);
     311    bsp_interrupt_disable(level);
     312    bsp_interrupt_fence(ATOMIC_ORDER_RELEASE);
    303313    tail->next = current;
    304     rtems_interrupt_enable(level);
     314    bsp_interrupt_enable(level);
    305315  }
    306316
     
    388398      current = match->next;
    389399
    390       rtems_interrupt_disable(level);
    391       *match = *current;
    392       rtems_interrupt_enable(level);
     400      bsp_interrupt_disable(level);
     401      #ifdef RTEMS_SMP
     402        match->handler = bsp_interrupt_handler_do_nothing;
     403        bsp_interrupt_fence(ATOMIC_ORDER_RELEASE);
     404      #endif
     405      match->arg = current->arg;
     406      bsp_interrupt_fence(ATOMIC_ORDER_RELEASE);
     407      match->handler = current->handler;
     408      match->info = current->info;
     409      match->next = current->next;
     410      bsp_interrupt_enable(level);
    393411
    394412      bsp_interrupt_free_handler_entry(current);
     
    405423
    406424      /* Clear entry */
    407       rtems_interrupt_disable(level);
     425      bsp_interrupt_disable(level);
    408426      bsp_interrupt_clear_handler_entry(head, vector);
    409427      #ifdef BSP_INTERRUPT_USE_INDEX_TABLE
    410428        bsp_interrupt_handler_index_table [vector] = 0;
    411429      #endif
    412       rtems_interrupt_enable(level);
     430      bsp_interrupt_enable(level);
    413431
    414432      /* Allow shared handlers */
     
    425443       * So terminate the predecessor and free the match.
    426444       */
    427       rtems_interrupt_disable(level);
     445      bsp_interrupt_disable(level);
    428446      previous->next = NULL;
    429       rtems_interrupt_enable(level);
     447      bsp_interrupt_fence(ATOMIC_ORDER_RELEASE);
     448      bsp_interrupt_enable(level);
    430449
    431450      bsp_interrupt_free_handler_entry(match);
Note: See TracChangeset for help on using the changeset viewer.