<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2011-05-20)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
 <font color='#bb2222'><strong>jennifer</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2011-05-20 Jennifer Averett <Jennifer.Averett@OARcorp.com>

        PR 1787/cpukit
        * score/include/rtems/score/percpu.h,
        score/include/rtems/score/smplock.h, score/src/smp.c,
        score/src/smplock.c: Add nesting support to smp spinlock.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2839&r2=text&tr2=1.2840&diff_format=h">M</a></td><td width='1%'>1.2840</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/include/rtems/score/percpu.h.diff?r1=text&tr1=1.7&r2=text&tr2=1.8&diff_format=h">M</a></td><td width='1%'>1.8</td><td width='100%'>cpukit/score/include/rtems/score/percpu.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/include/rtems/score/smplock.h.diff?r1=text&tr1=1.1&r2=text&tr2=1.2&diff_format=h">M</a></td><td width='1%'>1.2</td><td width='100%'>cpukit/score/include/rtems/score/smplock.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/src/smp.c.diff?r1=text&tr1=1.3&r2=text&tr2=1.4&diff_format=h">M</a></td><td width='1%'>1.4</td><td width='100%'>cpukit/score/src/smp.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/score/src/smplock.c.diff?r1=text&tr1=1.1&r2=text&tr2=1.2&diff_format=h">M</a></td><td width='1%'>1.2</td><td width='100%'>cpukit/score/src/smplock.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2839 rtems/cpukit/ChangeLog:1.2840
--- rtems/cpukit/ChangeLog:1.2839       Thu May 19 01:31:41 2011
+++ rtems/cpukit/ChangeLog      Fri May 20 07:35:56 2011
</font><font color='#997700'>@@ -1,3 +1,10 @@
</font><font color='#000088'>+2011-05-20    Jennifer Averett <Jennifer.Averett@OARcorp.com>
+
+       PR 1787/cpukit
+       * score/include/rtems/score/percpu.h,
+       score/include/rtems/score/smplock.h, score/src/smp.c,
+       score/src/smplock.c: Add nesting support to smp spinlock.
+
</font> 2011-05-19        Ralf Corsépius <ralf.corsepius@rtems.org>
 
        * posix/Makefile.am: Remove posixtime.h.

<font color='#006600'>diff -u rtems/cpukit/score/include/rtems/score/percpu.h:1.7 rtems/cpukit/score/include/rtems/score/percpu.h:1.8
--- rtems/cpukit/score/include/rtems/score/percpu.h:1.7 Thu May 12 08:23:12 2011
+++ rtems/cpukit/score/include/rtems/score/percpu.h     Fri May 20 07:36:00 2011
</font><font color='#997700'>@@ -92,18 +92,17 @@
</font> typedef struct {
   #if defined(RTEMS_SMP)
     /** This element is used to lock this structure */
<font color='#880000'>-    SMP_lock_Control  lock;<span style="background-color: #FF0000"> </span>
</font><font color='#000088'>+    SMP_lock_spinlock_simple_Control  lock;<span style="background-color: #FF0000"> </span>
</font> 
     /** This indicates that the CPU is online. */
<font color='#880000'>-    uint32_t          state;<span style="background-color: #FF0000"> </span>
</font><font color='#000088'>+    uint32_t                          state;<span style="background-color: #FF0000"> </span>
</font> 
     /**
      *  This is the request for the interrupt.
      *<span style="background-color: #FF0000">  </span>
      *  @note This may become a chain protected by atomic instructions.
      */
<font color='#880000'>-    uint32_t          message;<span style="background-color: #FF0000"> </span>
-
</font><font color='#000088'>+    uint32_t                          message;<span style="background-color: #FF0000"> </span>
</font>   #endif
 
 #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \

<font color='#006600'>diff -u rtems/cpukit/score/include/rtems/score/smplock.h:1.1 rtems/cpukit/score/include/rtems/score/smplock.h:1.2
--- rtems/cpukit/score/include/rtems/score/smplock.h:1.1        Wed Mar 16 15:05:06 2011
+++ rtems/cpukit/score/include/rtems/score/smplock.h    Fri May 20 07:36:00 2011
</font><font color='#997700'>@@ -34,10 +34,23 @@
</font> 
 /**
  *  This type is used to lock elements for atomic access.
<font color='#880000'>- *
- *  @note This type may move to RTEMS.
</font><font color='#000088'>+ *  This spinlock is a simple non-nesting spinlock, and
+ *  may be used for short non-nesting accesses.<span style="background-color: #FF0000">  </span>
</font>  */
<font color='#880000'>-typedef volatile uint32_t SMP_lock_Control;
</font><font color='#000088'>+typedef uint32_t SMP_lock_spinlock_simple_Control;
+
+/**
+ *  This type is used to lock elements for atomic access.
+ *  This spinlock supports nesting, but is slightly more
+ *  complicated to use.  Please see the descriptions of
+ *  obtain and release prior to using in order to understand
+ *  the callers responsibilty of managing short interupt disable
+ *  times.
+ */
+typedef struct {
+  uint32_t  count;
+  int       cpu_id;
+} SMP_lock_spinlock_nested_Control;
</font> 
 /**
  *  @brief Initialize a Lock
<font color='#997700'>@@ -45,12 +58,9 @@
</font>  *  This method is used to initialize the lock at @a lock.
  *
  *  @param [in] lock is the address of the lock to obtain.
<font color='#880000'>- *
- *  @note This lock may be "too low" here.  It may need to move
- *         out of the BSP area.
</font>  */
<font color='#880000'>-void _SMP_lock_Spinlock_Initialize(
-  SMP_lock_Control *lock
</font><font color='#000088'>+void _SMP_lock_spinlock_simple_Initialize(
+  SMP_lock_spinlock_simple_Control *lock
</font> );
 
 /**
<font color='#997700'>@@ -62,12 +72,9 @@
</font>  *
  *  @return This method returns with processor interrupts disabled.
  *          The previous level is returned.
<font color='#880000'>- *
- *  @note This lock may be "too low" here.  It may need to move
- *         out of the BSP area.
</font>  */
<font color='#880000'>-ISR_Level _SMP_lock_Spinlock_Obtain(
-  SMP_lock_Control *lock
</font><font color='#000088'>+ISR_Level _SMP_lock_spinlock_simple_Obtain(
+  SMP_lock_spinlock_simple_Control *lock
</font> );
 
 /**
<font color='#997700'>@@ -76,13 +83,55 @@
</font>  *  This method is used to release the lock at @a lock.
  *
  *  @param [in] lock is the address of the lock to obtain.
<font color='#000088'>+ */
+void _SMP_lock_spinlock_simple_Release(
+  SMP_lock_spinlock_simple_Control  *lock,
+  ISR_Level                         level
+);
+
+/**
+ *  @brief Initialize a Lock
+ *
+ *  This method is used to initialize the lock at @a lock.
</font>  *
<font color='#880000'>- *  @note This lock may be "too low" here.  It may need to move
- *         out of the BSP area.
</font><font color='#000088'>+ *  @param [in] lock is the address of the lock to obtain.
+ */
+void _SMP_lock_spinlock_nested_Initialize(
+  SMP_lock_spinlock_nested_Control *lock
+);
+
+/**
+ *  @brief Obtain a Lock
+ *
+ *  This method is used to obtain the lock at @a lock.  ISR's are
+ *  disabled when this routine returns and it is the callers responsibility
+ *  to either:
+ *   1) Do something very short and then call<span style="background-color: #FF0000"> </span>
+ *      _SMP_lock_spinlock_nested_Release  or
+ *   2) Do something very sort, call isr enable, then when ready<span style="background-color: #FF0000"> </span>
+ *      call isr_disable and _SMP_lock_spinlock_nested_Release
+ *
+ *  @param [in] lock is the address of the lock to obtain.
+ *
+ *  @return This method returns with processor interrupts disabled.
+ *          The previous level is returned.
+ */
+ISR_Level _SMP_lock_spinlock_nested_Obtain(
+  SMP_lock_spinlock_nested_Control *lock
+);
+
+/**
+ *  @brief Release a Lock
+ *
+ *  This method is used to release the lock at @a lock.  Note:
+ *  ISR's are reenabled by this method and are expected to be
+ *  disabled upon entry to the method.
+ *
+ *  @param [in] lock is the address of the lock to obtain.
</font>  */
<font color='#880000'>-void _SMP_lock_Spinlock_Release(
-  SMP_lock_Control  *lock,
-  ISR_Level         level
</font><font color='#000088'>+void _SMP_lock_spinlock_nested_Release(
+  SMP_lock_spinlock_nested_Control  *lock,
+  ISR_Level                         level
</font> );
 
 #ifdef __cplusplus

<font color='#006600'>diff -u rtems/cpukit/score/src/smp.c:1.3 rtems/cpukit/score/src/smp.c:1.4
--- rtems/cpukit/score/src/smp.c:1.3    Wed Apr 27 12:18:59 2011
+++ rtems/cpukit/score/src/smp.c        Fri May 20 07:36:01 2011
</font><font color='#997700'>@@ -80,10 +80,10 @@
</font> 
   cpu = bsp_smp_processor_id();
 
<font color='#880000'>-  level = _SMP_lock_Spinlock_Obtain( &_Per_CPU_Information[cpu].lock );
</font><font color='#000088'>+  level = _SMP_lock_spinlock_simple_Obtain( &_Per_CPU_Information[cpu].lock );
</font>     message = _Per_CPU_Information[cpu].message;
     _Per_CPU_Information[cpu].message &= ~message;
<font color='#880000'>-  _SMP_lock_Spinlock_Release( &_Per_CPU_Information[cpu].lock, level );
</font><font color='#000088'>+  _SMP_lock_spinlock_simple_Release( &_Per_CPU_Information[cpu].lock, level );
</font> 
   #if defined(SMP_DEBUG)
     {
<font color='#997700'>@@ -126,9 +126,9 @@
</font> {
   ISR_Level level;
 
<font color='#880000'>-  level = _SMP_lock_Spinlock_Obtain( &_Per_CPU_Information[cpu].lock );
</font><font color='#000088'>+  level = _SMP_lock_spinlock_simple_Obtain( &_Per_CPU_Information[cpu].lock );
</font>     _Per_CPU_Information[cpu].message |= message;
<font color='#880000'>-  _SMP_lock_Spinlock_Release( &_Per_CPU_Information[cpu].lock, level );
</font><font color='#000088'>+  _SMP_lock_spinlock_simple_Release( &_Per_CPU_Information[cpu].lock, level );
</font>   bsp_smp_interrupt_cpu( cpu );
 }
 
<font color='#997700'>@@ -145,9 +145,9 @@
</font>   for ( dest_cpu=0 ; dest_cpu <  _SMP_Processor_count; dest_cpu++ ) {
     if ( cpu == dest_cpu )
       continue;
<font color='#880000'>-    level = _SMP_lock_Spinlock_Obtain( &_Per_CPU_Information[cpu].lock );
</font><font color='#000088'>+    level = _SMP_lock_spinlock_simple_Obtain( &_Per_CPU_Information[cpu].lock );
</font>       _Per_CPU_Information[dest_cpu].message |= message;
<font color='#880000'>-    _SMP_lock_Spinlock_Release( &_Per_CPU_Information[cpu].lock, level );
</font><font color='#000088'>+    _SMP_lock_spinlock_simple_Release( &_Per_CPU_Information[cpu].lock, level );
</font>   }
   bsp_smp_broadcast_interrupt();
 }

<font color='#006600'>diff -u rtems/cpukit/score/src/smplock.c:1.1 rtems/cpukit/score/src/smplock.c:1.2
--- rtems/cpukit/score/src/smplock.c:1.1        Wed Mar 16 15:05:06 2011
+++ rtems/cpukit/score/src/smplock.c    Fri May 20 07:36:01 2011
</font><font color='#997700'>@@ -15,35 +15,93 @@
</font> 
 #include <rtems/system.h>
 #include <rtems/score/smplock.h>
<font color='#000088'>+#include <rtems/score/smp.h>
</font> 
<font color='#880000'>-void _SMP_lock_Spinlock_Initialize(
-  SMP_lock_Control *lock
</font><font color='#000088'>+#if defined (RTEMS_DEBUG)
+  #include <rtems/bspIo.h>
+#endif
+
+void _SMP_lock_spinlock_simple_Initialize(
+  SMP_lock_spinlock_simple_Control *lock
</font> )
 {
   *lock = 0;
 }
 
<font color='#880000'>-ISR_Level _SMP_lock_Spinlock_Obtain(
-  SMP_lock_Control *lock
</font><font color='#000088'>+ISR_Level _SMP_lock_spinlock_simple_Obtain(
+  SMP_lock_spinlock_simple_Control *lock
+)
+{
+   ISR_Level  level;
+   uint32_t   value = 1;
+   uint32_t   previous;
+<span style="background-color: #FF0000"> </span>
+   /* Note: Disable provides an implicit memory barrier. */
+  _ISR_Disable( level );
+   do {
+     SMP_CPU_SWAP( lock, value, previous );
+   } while (previous == 1);
+
+  return level;
+}
+
+void _SMP_lock_spinlock_simple_Release(
+  SMP_lock_spinlock_simple_Control *lock,
+  ISR_Level                        level
+)
+{
+   *lock = 0;
+   _ISR_Enable( level );
+}
+
+void _SMP_lock_spinlock_nested_Initialize(
+  SMP_lock_spinlock_nested_Control *lock
+)
+{
+  lock->count = 0;
+  lock->cpu_id = 0;
+}
+
+ISR_Level _SMP_lock_spinlock_nested_Obtain(
+  SMP_lock_spinlock_nested_Control *lock
</font> )
 {
<font color='#880000'>-  ISR_Level  level;
</font><font color='#000088'>+  ISR_Level  level = 0;
</font>   uint32_t   value = 1;
   uint32_t   previous;
<font color='#000088'>+  int        cpu_id;
</font> 
   /* Note: Disable provides an implicit memory barrier. */
<font color='#880000'>-  _ISR_Disable( level );
-    do {
-      SMP_CPU_SWAP( lock, value, previous );
-    } while (previous == 1);
</font><font color='#000088'>+  _ISR_Disable( level );<span style="background-color: #FF0000"> </span>
+
+  cpu_id = bsp_smp_processor_id();
+
+  /* Deal with nested calls from one cpu */
+  if ( (lock->count > 0) && (cpu_id == lock->cpu_id) ) {
+    lock->count++;
+    return level;
+  }
+<span style="background-color: #FF0000">    </span>
+  do {
+    SMP_CPU_SWAP( lock, value, previous );
+  } while (previous == 1);
+
+  lock->count++;
+  lock->cpu_id = cpu_id;
+
</font>   return level;
 }
 
<font color='#880000'>-void _SMP_lock_Spinlock_Release(
-  SMP_lock_Control *lock,
-  ISR_Level        level
</font><font color='#000088'>+void _SMP_lock_spinlock_nested_Release(
+  SMP_lock_spinlock_nested_Control *lock,
+  ISR_Level                        level
</font> )
 {
<font color='#880000'>-  *lock = 0;
-  _ISR_Enable( level );
</font><font color='#000088'>+#if defined(RTEMS_DEBUG)
+  if ( lock->count == 0 )
+    printk ("Releasing spinlock when count is already zero?!?!\n");
+#endif
+  lock->count--;
+<span style="background-color: #FF0000">  </span>
+  _ISR_Enable( level );<span style="background-color: #FF0000"> </span>
</font> }
</pre>
<p> </p>

<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>