[rtems-central commit] spec: Clarify leon3 shutdown

Sebastian Huber sebh at rtems.org
Fri Jul 21 07:13:10 UTC 2023


Module:    rtems-central
Branch:    master
Commit:    e23c2589d57a1c3dec85f6fca6523c8a971eed3b
Changeset: http://git.rtems.org/rtems-central/commit/?id=e23c2589d57a1c3dec85f6fca6523c8a971eed3b

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jul  6 17:15:36 2023 +0200

spec: Clarify leon3 shutdown

---

 .../sparc/leon3/req/fatal-shutdown-halt-smp.yml    | 20 ++++++
 spec/bsp/sparc/leon3/req/fatal-shutdown-halt.yml   |  9 +--
 spec/bsp/sparc/leon3/val/fatal-shutdown-halt.yml   | 76 ++++++++++++++++++++++
 ...tal-shutdown.yml => fatal-shutdown-request.yml} | 38 ++---------
 .../testsuites/bsps/fatal-sparc-leon3-shutdown.yml |  7 ++
 5 files changed, 110 insertions(+), 40 deletions(-)

diff --git a/spec/bsp/sparc/leon3/req/fatal-shutdown-halt-smp.yml b/spec/bsp/sparc/leon3/req/fatal-shutdown-halt-smp.yml
new file mode 100644
index 00000000..13c61d02
--- /dev/null
+++ b/spec/bsp/sparc/leon3/req/fatal-shutdown-halt-smp.yml
@@ -0,0 +1,20 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG
+enabled-by:
+  and:
+  - RTEMS_SMP
+  - bsps/sparc/leon3
+links:
+- role: interface-function
+  uid: /bsp/if/fatal-extension
+functional-type: function
+rationale: null
+references: []
+requirement-type: functional
+text: |
+  While the fatal source is not ${/score/interr/if/source-smp:/name} or the
+  fatal code is not ${/score/smp/if/fatal-shutdown-response:/name}, when the
+  shutdown request was issued, the ${/bsp/if/fatal-extension:/name} directive
+  shall halt the processor.
+type: requirement
diff --git a/spec/bsp/sparc/leon3/req/fatal-shutdown-halt.yml b/spec/bsp/sparc/leon3/req/fatal-shutdown-halt.yml
index 13c61d02..a38132f5 100644
--- a/spec/bsp/sparc/leon3/req/fatal-shutdown-halt.yml
+++ b/spec/bsp/sparc/leon3/req/fatal-shutdown-halt.yml
@@ -1,9 +1,9 @@
 SPDX-License-Identifier: CC-BY-SA-4.0
 copyrights:
-- Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG
+- Copyright (C) 2021, 2023 embedded brains GmbH & Co. KG
 enabled-by:
   and:
-  - RTEMS_SMP
+  - not: RTEMS_SMP
   - bsps/sparc/leon3
 links:
 - role: interface-function
@@ -13,8 +13,5 @@ rationale: null
 references: []
 requirement-type: functional
 text: |
-  While the fatal source is not ${/score/interr/if/source-smp:/name} or the
-  fatal code is not ${/score/smp/if/fatal-shutdown-response:/name}, when the
-  shutdown request was issued, the ${/bsp/if/fatal-extension:/name} directive
-  shall halt the processor.
+  The ${/bsp/if/fatal-extension:/name} directive shall halt the processor.
 type: requirement
diff --git a/spec/bsp/sparc/leon3/val/fatal-shutdown-halt.yml b/spec/bsp/sparc/leon3/val/fatal-shutdown-halt.yml
new file mode 100644
index 00000000..12fa0e07
--- /dev/null
+++ b/spec/bsp/sparc/leon3/val/fatal-shutdown-halt.yml
@@ -0,0 +1,76 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG
+enabled-by: bsps/sparc/leon3
+links: []
+test-actions:
+- action-brief: |
+    Check the effects of the leon3 BSP family shutdown procedure.
+  action-code: |
+    uint32_t counter;
+
+  checks:
+  - brief: |
+      Check that no dynamic fatal error extension was invoked.  This shows that
+      the leon3 BSP family shutdown procedure called the wrapped
+      _CPU_Fatal_halt() function of the test suite.
+    code: |
+      T_step_rsc_success( ${.:/step}, status );
+      counter = Add( &dynamic_fatal_extension_counter, 0 );
+      T_step_eq_u32( ${.:/step}, counter, 0 );
+    links:
+    - role: validation
+      uid: ../req/fatal-shutdown-halt
+    - role: validation
+      uid: ../req/fatal-shutdown-halt-smp
+  links: []
+test-brief: |
+  Tests the leon3 BSP family shutdown procedure.
+test-context: []
+test-context-support: null
+test-description: null
+test-header: null
+test-includes:
+- rtems/sysinit.h
+test-local-includes:
+- tx-support.h
+test-setup: null
+test-stop: null
+test-support: |
+  static Atomic_Uint dynamic_fatal_extension_counter;
+
+  static rtems_status_code status;
+
+  static unsigned int Add( Atomic_Uint *a, unsigned int b )
+  {
+    return _Atomic_Fetch_add_uint( a, b, ATOMIC_ORDER_RELAXED );
+  }
+
+  static void DynamicFatalHandler(
+    rtems_fatal_source source,
+    bool               always_set_to_false,
+    rtems_fatal_code   code
+  )
+  {
+    (void) source;
+    (void) code;
+    (void) always_set_to_false;
+    (void) Add( &dynamic_fatal_extension_counter, 1 );
+  }
+
+  static void Init${.:/test-ident}( void )
+  {
+    rtems_extensions_table table = { .fatal = DynamicFatalHandler };
+    rtems_id               id;
+
+    status = rtems_extension_create( OBJECT_NAME, &table, &id );
+  }
+
+  RTEMS_SYSINIT_ITEM(
+    Init${.:/test-ident},
+    RTEMS_SYSINIT_DEVICE_DRIVERS,
+    RTEMS_SYSINIT_ORDER_MIDDLE
+  );
+test-target: testsuites/validation/bsps/tc-fatal-sparc-leon3-shutdown-halt.c
+test-teardown: null
+type: test-case
diff --git a/spec/bsp/sparc/leon3/val/fatal-shutdown.yml b/spec/bsp/sparc/leon3/val/fatal-shutdown-request.yml
similarity index 70%
rename from spec/bsp/sparc/leon3/val/fatal-shutdown.yml
rename to spec/bsp/sparc/leon3/val/fatal-shutdown-request.yml
index be71f7ab..6d48e46e 100644
--- a/spec/bsp/sparc/leon3/val/fatal-shutdown.yml
+++ b/spec/bsp/sparc/leon3/val/fatal-shutdown-request.yml
@@ -41,24 +41,13 @@ test-actions:
     code: |
       T_step_eq_u32( ${.:/step}, shutdown_response_cpu_index, 1 );
     links: []
-  - brief: |
-      Check that no dynamic fatal error extension was invoked.  This shows that
-      the leon3 BSP family shutdown procedure called the wrapped
-      _CPU_Fatal_halt() function of the test suite.
-    code: |
-      T_step_rsc_success( ${.:/step}, status );
-      counter = Add( &dynamic_fatal_extension_counter, 0 );
-      T_step_eq_u32( ${.:/step}, dynamic_fatal_extension_counter, 0 );
-    links:
-    - role: validation
-      uid: ../req/fatal-shutdown-halt
   links:
   - role: validation
     uid: ../req/fatal-shutdown-request
   - role: validation
     uid: ../req/fatal-shutdown-response
 test-brief: |
-  Tests the leon3 BSP family shutdown procedure.
+  Tests the leon3 BSP family SMP-specific shutdown procedure.
 test-context: []
 test-context-support: null
 test-description: null
@@ -78,10 +67,6 @@ test-support: |
 
   static uint32_t shutdown_response_cpu_index = UINT32_MAX;
 
-  static Atomic_Uint dynamic_fatal_extension_counter;
-
-  static rtems_status_code status;
-
   static unsigned int Add( Atomic_Uint *a, unsigned int b )
   {
     return _Atomic_Fetch_add_uint( a, b, ATOMIC_ORDER_RELAXED );
@@ -104,35 +89,20 @@ test-support: |
     }
   }
 
-  static void DynamicFatalHandler(
-    rtems_fatal_source source,
-    bool               always_set_to_false,
-    rtems_fatal_code   code
-  )
-  {
-    (void) source;
-    (void) code;
-    (void) always_set_to_false;
-    (void) Add( &dynamic_fatal_extension_counter, 1 );
-  }
-
-  static void InitTestCase( void )
+  static void Init${.:/test-ident}( void )
   {
-    rtems_extensions_table table = { .fatal = DynamicFatalHandler };
     irqamp                *regs;
-    rtems_id               id;
 
     regs = LEON3_IrqCtrl_Regs;
     mpstat_during_sysinit = grlib_load_32( &regs->mpstat );
     SetFatalHandler( ShutdownFatalHandler, NULL );
-    status = rtems_extension_create( OBJECT_NAME, &table, &id );
   }
 
   RTEMS_SYSINIT_ITEM(
-    InitTestCase,
+    Init${.:/test-ident},
     RTEMS_SYSINIT_DEVICE_DRIVERS,
     RTEMS_SYSINIT_ORDER_MIDDLE
   );
-test-target: testsuites/validation/bsps/tc-fatal-sparc-leon3-shutdown.c
+test-target: testsuites/validation/bsps/tc-fatal-sparc-leon3-shutdown-request.c
 test-teardown: null
 type: test-case
diff --git a/spec/testsuites/bsps/fatal-sparc-leon3-shutdown.yml b/spec/testsuites/bsps/fatal-sparc-leon3-shutdown.yml
index 6053d89f..22b1a965 100644
--- a/spec/testsuites/bsps/fatal-sparc-leon3-shutdown.yml
+++ b/spec/testsuites/bsps/fatal-sparc-leon3-shutdown.yml
@@ -53,6 +53,7 @@ test-code: |
 
   #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
 
+  #if defined(RTEMS_SMP)
   #define CONFIGURE_MAXIMUM_PROCESSORS 2
 
   #include <rtems/score/scheduleredfsmp.h>
@@ -69,6 +70,7 @@ test-code: |
   #define CONFIGURE_SCHEDULER_ASSIGNMENTS \
     RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY ), \
     RTEMS_SCHEDULER_ASSIGN( 0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY )
+  #endif /* RTEMS_SMP */
 
   #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 0
 
@@ -84,12 +86,17 @@ test-code: |
 
   static void *ShutdownIdleBody( uintptr_t arg )
   {
+  #if defined(RTEMS_SMP)
     if ( rtems_scheduler_get_processor() == 0 ) {
       rtems_test_begin( rtems_test_name, TEST_STATE );
       rtems_fatal( RTEMS_FATAL_SOURCE_SMP, SMP_FATAL_SHUTDOWN );
     }
 
     return _CPU_Thread_Idle_body( arg );
+  #else
+    rtems_test_begin( rtems_test_name, TEST_STATE );
+    rtems_fatal( RTEMS_FATAL_SOURCE_APPLICATION, 123 );
+  #endif
   }
 
   #define CONFIGURE_IDLE_TASK_BODY ShutdownIdleBody



More information about the vc mailing list