diff options
Diffstat (limited to 'spec/score')
34 files changed, 609 insertions, 14 deletions
diff --git a/spec/score/cpu/if/fatal-halt.yml b/spec/score/cpu/if/fatal-halt.yml new file mode 100644 index 00000000..039c34e2 --- /dev/null +++ b/spec/score/cpu/if/fatal-halt.yml @@ -0,0 +1,12 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified +links: +- role: interface-placement + uid: header-impl +name: _CPU_Fatal_halt +references: {} +type: interface diff --git a/spec/score/cpu/if/group.yml b/spec/score/cpu/if/group.yml new file mode 100644 index 00000000..42db2e9b --- /dev/null +++ b/spec/score/cpu/if/group.yml @@ -0,0 +1,16 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +identifier: RTEMSScoreCPU +links: +- role: interface-ingroup + uid: ../../if/group +non-functional-type: design-group +rationale: null +references: [] +requirement-type: non-functional +text: | + The super core shall have a component containing the implementation specific + to the ${/glossary/target-arch:/term} and ${/glossary/target:/term}. +type: requirement diff --git a/spec/score/cpu/if/header-impl.yml b/spec/score/cpu/if/header-impl.yml new file mode 100644 index 00000000..7fcbd118 --- /dev/null +++ b/spec/score/cpu/if/header-impl.yml @@ -0,0 +1,13 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +brief: This header file defines interfaces of the CPU port. +copyrights: +- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: header-file +links: +- role: interface-placement + uid: ../../if/domain +path: rtems/score/cpuimpl.h +prefix: cpukit/include +type: interface diff --git a/spec/score/cpu/req/fatal-halt.yml b/spec/score/cpu/req/fatal-halt.yml new file mode 100644 index 00000000..89139239 --- /dev/null +++ b/spec/score/cpu/req/fatal-halt.yml @@ -0,0 +1,17 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: ../if/group +- role: interface-function + uid: ../if/fatal-halt +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + The ${../if/fatal-halt:/name} function shall halt or reset the + ${/glossary/target:/term}. +type: requirement diff --git a/spec/score/req/group.yml b/spec/score/if/group.yml index 4dca0df8..3c469477 100644 --- a/spec/score/req/group.yml +++ b/spec/score/if/group.yml @@ -11,6 +11,6 @@ rationale: null references: [] requirement-type: non-functional text: | - The software architecture shall have a component named super core containing - the implementation used by multiple ${/glossary/api:/plural}. + The super core shall be a software architecture component containing the + implementation used by multiple ${/glossary/api:/plural}. type: requirement diff --git a/spec/score/interr/if/init-task-construct-failed.yml b/spec/score/interr/if/init-task-construct-failed.yml new file mode 100644 index 00000000..0914d1f4 --- /dev/null +++ b/spec/score/interr/if/init-task-construct-failed.yml @@ -0,0 +1,13 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: header +name: INTERNAL_ERROR_RTEMS_INIT_TASK_CONSTRUCT_FAILED +references: + c-user: internal_errors +type: interface diff --git a/spec/score/interr/if/source-bsp.yml b/spec/score/interr/if/source-bsp.yml new file mode 100644 index 00000000..58ea7d65 --- /dev/null +++ b/spec/score/interr/if/source-bsp.yml @@ -0,0 +1,12 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: header +name: RTEMS_FATAL_SOURCE_BSP +references: {} +type: interface diff --git a/spec/score/interr/if/source-smp.yml b/spec/score/interr/if/source-smp.yml new file mode 100644 index 00000000..1ee4fdb6 --- /dev/null +++ b/spec/score/interr/if/source-smp.yml @@ -0,0 +1,12 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: header +name: RTEMS_FATAL_SOURCE_SMP +references: {} +type: interface diff --git a/spec/score/interr/if/thread-exitted.yml b/spec/score/interr/if/thread-exitted.yml new file mode 100644 index 00000000..3384a7cb --- /dev/null +++ b/spec/score/interr/if/thread-exitted.yml @@ -0,0 +1,13 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: header +name: INTERNAL_ERROR_THREAD_EXITTED +references: + c-user: internal_errors +type: interface diff --git a/spec/score/interr/if/thread-queue-deadlock.yml b/spec/score/interr/if/thread-queue-deadlock.yml new file mode 100644 index 00000000..131db252 --- /dev/null +++ b/spec/score/interr/if/thread-queue-deadlock.yml @@ -0,0 +1,13 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: header +name: INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK +references: + c-user: internal_errors +type: interface diff --git a/spec/score/interr/if/too-large-tls-size.yml b/spec/score/interr/if/too-large-tls-size.yml new file mode 100644 index 00000000..9d46006a --- /dev/null +++ b/spec/score/interr/if/too-large-tls-size.yml @@ -0,0 +1,13 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: header +name: INTERNAL_ERROR_TOO_LARGE_TLS_SIZE +references: + c-user: internal_errors +type: interface diff --git a/spec/score/mtx/req/group.yml b/spec/score/mtx/if/group.yml index 3e795876..8a6289dd 100644 --- a/spec/score/mtx/req/group.yml +++ b/spec/score/mtx/if/group.yml @@ -5,7 +5,7 @@ enabled-by: true identifier: RTEMSScoreMutex links: - role: interface-ingroup - uid: ../../req/group + uid: ../../if/group non-functional-type: design-group rationale: null references: [] diff --git a/spec/score/mtx/req/seize-try.yml b/spec/score/mtx/req/seize-try.yml index 18ada09b..aaee66a3 100644 --- a/spec/score/mtx/req/seize-try.yml +++ b/spec/score/mtx/req/seize-try.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Status states: diff --git a/spec/score/mtx/req/seize-wait.yml b/spec/score/mtx/req/seize-wait.yml index 6d3396fb..8de6df69 100644 --- a/spec/score/mtx/req/seize-wait.yml +++ b/spec/score/mtx/req/seize-wait.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Status states: diff --git a/spec/score/object/if/group.yml b/spec/score/object/if/group.yml new file mode 100644 index 00000000..7901c920 --- /dev/null +++ b/spec/score/object/if/group.yml @@ -0,0 +1,16 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +identifier: RTEMSScoreThreadQueue +links: +- role: interface-ingroup + uid: ../../if/group +non-functional-type: design-group +rationale: null +references: [] +requirement-type: non-functional +text: | + The super core shall have a component containing the object services + implementation. +type: requirement diff --git a/spec/score/object/req/allocator-mutex.yml b/spec/score/object/req/allocator-mutex.yml new file mode 100644 index 00000000..f39f2ddf --- /dev/null +++ b/spec/score/object/req/allocator-mutex.yml @@ -0,0 +1,15 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: ../if/group +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + The object services shall use a mutex to protect the object allocation and + deallocation. +type: requirement diff --git a/spec/score/object/req/fatal-allocator-mutex-deadlock.yml b/spec/score/object/req/fatal-allocator-mutex-deadlock.yml new file mode 100644 index 00000000..20304887 --- /dev/null +++ b/spec/score/object/req/fatal-allocator-mutex-deadlock.yml @@ -0,0 +1,19 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: /req/fatal-error +- role: requirement-refinement + uid: allocator-mutex +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + If obtaining the object allocator mutex would result in a deadlock, then the + system shall terminate with the ${/score/interr/if/internal-error-core:/name} + fatal source and the ${/score/interr/if/thread-queue-deadlock:/name} fatal + code. +type: requirement diff --git a/spec/score/sem/req/group.yml b/spec/score/sem/if/group.yml index 02776e61..978f3af0 100644 --- a/spec/score/sem/req/group.yml +++ b/spec/score/sem/if/group.yml @@ -5,7 +5,7 @@ enabled-by: true identifier: RTEMSScoreSemaphore links: - role: interface-ingroup - uid: ../../req/group + uid: ../../if/group non-functional-type: design-group rationale: null references: [] diff --git a/spec/score/sem/req/seize-try.yml b/spec/score/sem/req/seize-try.yml index 685f9921..cf9a0cb8 100644 --- a/spec/score/sem/req/seize-try.yml +++ b/spec/score/sem/req/seize-try.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Status states: diff --git a/spec/score/sem/req/seize-wait.yml b/spec/score/sem/req/seize-wait.yml index ba68fe51..3f77dadc 100644 --- a/spec/score/sem/req/seize-wait.yml +++ b/spec/score/sem/req/seize-wait.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Status states: diff --git a/spec/score/smp/if/fatal-shutdown-response.yml b/spec/score/smp/if/fatal-shutdown-response.yml new file mode 100644 index 00000000..147e685e --- /dev/null +++ b/spec/score/smp/if/fatal-shutdown-response.yml @@ -0,0 +1,12 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: header-impl +name: SMP_SHUTDOWN_RESPONSE +references: {} +type: interface diff --git a/spec/score/smp/if/header-impl.yml b/spec/score/smp/if/header-impl.yml new file mode 100644 index 00000000..a09e0dab --- /dev/null +++ b/spec/score/smp/if/header-impl.yml @@ -0,0 +1,14 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +brief: | + This header file provides interfaces of the SMP Handler implementation. +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: header-file +links: +- role: interface-placement + uid: ../../if/domain +path: rtems/score/smpimpl.h +prefix: cpukit/include +type: interface diff --git a/spec/score/thread/if/group.yml b/spec/score/thread/if/group.yml new file mode 100644 index 00000000..90add9f4 --- /dev/null +++ b/spec/score/thread/if/group.yml @@ -0,0 +1,15 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +identifier: RTEMSScoreThreadQueue +links: +- role: interface-ingroup + uid: ../../if/group +non-functional-type: design-group +rationale: null +references: [] +requirement-type: non-functional +text: | + The super core shall have a component containing the thread implementation. +type: requirement diff --git a/spec/score/thread/req/fatal-bad-thread-dispatch-disable-level.yml b/spec/score/thread/req/fatal-bad-thread-dispatch-disable-level.yml new file mode 100644 index 00000000..28d9a068 --- /dev/null +++ b/spec/score/thread/req/fatal-bad-thread-dispatch-disable-level.yml @@ -0,0 +1,17 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: /req/fatal-error +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + While the thread dispatch disable level is not equal to one, if a direct + thread dispatch is done, then the system shall terminate with the + ${/score/interr/if/internal-error-core:/name} fatal source and the + ${/score/interr/if/bad-thread-dispatch-disable-level:/name} fatal code. +type: requirement diff --git a/spec/score/thread/req/fatal-bad-thread-dispatch-environment.yml b/spec/score/thread/req/fatal-bad-thread-dispatch-environment.yml new file mode 100644 index 00000000..a8c3e08c --- /dev/null +++ b/spec/score/thread/req/fatal-bad-thread-dispatch-environment.yml @@ -0,0 +1,23 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: + and: + - RTEMS_SMP + - not: + - aarch64 + - arm + - riscv +links: +- role: requirement-refinement + uid: /req/fatal-error +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + Where the system needs inter-processor interrupts, if a thread dispatch is + done with maskable interrupts disabled, then the system shall terminate with + the ${/score/interr/if/internal-error-core:/name} fatal source and the + ${/score/interr/if/bad-thread-dispatch-environment:/name} fatal code. +type: requirement diff --git a/spec/score/thread/req/fatal-thread-exitted.yml b/spec/score/thread/req/fatal-thread-exitted.yml new file mode 100644 index 00000000..1dd763a5 --- /dev/null +++ b/spec/score/thread/req/fatal-thread-exitted.yml @@ -0,0 +1,17 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: requirement-refinement + uid: /req/fatal-error +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + If a thread body function returned and the thread exitted extension + invocation for the thread returned, then the system shall terminate with the + ${/score/interr/if/internal-error-core:/name} fatal source and the + ${/score/interr/if/thread-exitted:/name} fatal code. +type: requirement diff --git a/spec/score/thread/req/thread-dispatch-isr-disabled.yml b/spec/score/thread/req/thread-dispatch-isr-disabled.yml new file mode 100644 index 00000000..6f7906ee --- /dev/null +++ b/spec/score/thread/req/thread-dispatch-isr-disabled.yml @@ -0,0 +1,22 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: + and: + - RTEMS_SMP + - not: + - aarch64 + - arm + - riscv +links: +- role: requirement-refinement + uid: ../if/group +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + Where the system does not need inter-processor interrupts, when a thread + dispatch is done with maskable interrupts disabled, the thread dispatch shall + be carried out. +type: requirement diff --git a/spec/score/tq/req/group.yml b/spec/score/tq/if/group.yml index 06023444..a6437627 100644 --- a/spec/score/tq/req/group.yml +++ b/spec/score/tq/if/group.yml @@ -5,7 +5,7 @@ enabled-by: true identifier: RTEMSScoreThreadQueue links: - role: interface-ingroup - uid: ../../req/group + uid: ../../if/group non-functional-type: design-group rationale: null references: [] diff --git a/spec/score/tq/req/enqueue-ceiling.yml b/spec/score/tq/req/enqueue-ceiling.yml index b38ea3a5..1775e586 100644 --- a/spec/score/tq/req/enqueue-ceiling.yml +++ b/spec/score/tq/req/enqueue-ceiling.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Position states: diff --git a/spec/score/tq/req/enqueue-deadlock.yml b/spec/score/tq/req/enqueue-deadlock.yml index 44bd72d4..f2a96006 100644 --- a/spec/score/tq/req/enqueue-deadlock.yml +++ b/spec/score/tq/req/enqueue-deadlock.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Status states: diff --git a/spec/score/tq/req/enqueue-fifo.yml b/spec/score/tq/req/enqueue-fifo.yml index 0a879e28..f9fc91d9 100644 --- a/spec/score/tq/req/enqueue-fifo.yml +++ b/spec/score/tq/req/enqueue-fifo.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Position states: diff --git a/spec/score/tq/req/enqueue-mrsp.yml b/spec/score/tq/req/enqueue-mrsp.yml index faf0825b..376297ba 100644 --- a/spec/score/tq/req/enqueue-mrsp.yml +++ b/spec/score/tq/req/enqueue-mrsp.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Position states: diff --git a/spec/score/tq/req/enqueue-priority.yml b/spec/score/tq/req/enqueue-priority.yml index a8fd1f9b..600cacdc 100644 --- a/spec/score/tq/req/enqueue-priority.yml +++ b/spec/score/tq/req/enqueue-priority.yml @@ -5,7 +5,7 @@ enabled-by: true functional-type: action links: - role: requirement-refinement - uid: group + uid: ../if/group post-conditions: - name: Position states: diff --git a/spec/score/val/fatal.yml b/spec/score/val/fatal.yml new file mode 100644 index 00000000..0002ad87 --- /dev/null +++ b/spec/score/val/fatal.yml @@ -0,0 +1,291 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: [] +test-actions: +- action-brief: | + Construct a task with a task body which returns. Check that the right + fatal error occurs. + action-code: | + rtems_id id; + unsigned int counter; + + SetFatalExtension( FatalTaskExit ); + SetSelfPriority( PRIO_NORMAL ); + counter = ResetFatalInfo(); + id = CreateTask( "EXIT", PRIO_HIGH ); + StartTask( id, ExitTask, NULL ); + T_eq_uint( GetFatalCounter(), counter + 1 ); + T_eq_int( fatal_info.source, INTERNAL_ERROR_CORE ); + T_false( fatal_info.always_set_to_false ); + T_eq_ulong( fatal_info.code, INTERNAL_ERROR_THREAD_EXITTED ); + RestoreRunnerPriority(); + SetFatalExtension( NULL ); + checks: [] + links: + - role: validation + uid: ../thread/req/fatal-thread-exitted +- action-brief: | + Construct a task which performs a thread dispatch with maskable interrupts + disabled. Check that the right fatal error occurs or no fatal error + occurs. + action-code: | + rtems_id id; + unsigned int counter; + + SetFatalExtension( FatalBadThreadDispatchEnvironment ); + SetSelfPriority( PRIO_NORMAL ); + counter = ResetFatalInfo(); + id = CreateTask( "BENV", PRIO_HIGH ); + StartTask( id, ISRDisabledThreadDispatchTask, NULL ); + + if ( rtems_configuration_get_maximum_processors() > 1 ) { + T_eq_uint( GetFatalCounter(), counter + 1 ); + T_eq_int( fatal_info.source, INTERNAL_ERROR_CORE ); + T_false( fatal_info.always_set_to_false ); + T_eq_ulong( + fatal_info.code, + INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT + ); + } else { + T_eq_uint( GetFatalCounter(), counter ); + } + + RestoreRunnerPriority(); + SetFatalExtension( NULL ); + checks: [] + links: + - role: validation + uid: ../thread/req/fatal-bad-thread-dispatch-environment + - role: validation + uid: ../thread/req/thread-dispatch-isr-disabled +- action-brief: | + Construct a task which performs a direct thread dispatch with a thread + dispatch level not equal to one. Check that the right fatal error occurs. + action-code: | + rtems_id id; + unsigned int counter; + + SetFatalExtension( FatalBadThreadDispatchDisableLevel ); + SetSelfPriority( PRIO_NORMAL ); + counter = ResetFatalInfo(); + id = CreateTask( "BLVL", PRIO_HIGH ); + StartTask( id, BadLevelThreadDispatchTask, NULL ); + T_eq_uint( GetFatalCounter(), counter + 1 ); + T_eq_int( fatal_info.source, INTERNAL_ERROR_CORE ); + T_false( fatal_info.always_set_to_false ); + T_eq_ulong( + fatal_info.code, + INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL + ); + RestoreRunnerPriority(); + SetFatalExtension( NULL ); + checks: [] + links: + - role: validation + uid: ../thread/req/fatal-bad-thread-dispatch-disable-level +- action-brief: | + Create a mutex and construct a task which produces a deadlock which + involves the allocator mutex. + action-code: | + rtems_extensions_table extensions; + rtems_status_code sc; + rtems_id extension_id; + rtems_id task_id; + unsigned int counter; + + memset( &extensions, 0, sizeof( extensions ) ); + extensions.thread_create = ThreadCreateDeadlock; + + sc = rtems_extension_create( + rtems_build_name( 'T', 'E', 'X', 'T' ), + &extensions, + &extension_id + ); + T_rsc_success( sc ); + + deadlock_mutex = CreateMutex(); + + SetFatalExtension( FatalThreadQueueDeadlock ); + SetSelfPriority( PRIO_NORMAL ); + counter = ResetFatalInfo(); + + ObtainMutex( deadlock_mutex ); + + task_id = CreateTask( "WORK", PRIO_HIGH ); + StartTask( task_id, ThreadQueueDeadlockTask, NULL ); + + if ( setjmp( before_deadlock ) == 0 ) { + (void) CreateTask( "DLCK", PRIO_NORMAL ); + } + + ReleaseMutex( deadlock_mutex ); + + T_eq_uint( GetFatalCounter(), counter + 1 ); + T_eq_int( fatal_info.source, INTERNAL_ERROR_CORE ); + T_false( fatal_info.always_set_to_false ); + T_eq_ulong( + fatal_info.code, + INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK + ); + + RestoreRunnerPriority(); + SetFatalExtension( NULL ); + + sc = rtems_extension_delete( extension_id ); + T_rsc_success( sc ); + + DeleteMutex( deadlock_mutex ); + checks: [] + links: + - role: validation + uid: ../object/req/fatal-allocator-mutex-deadlock +test-brief: | + Tests some fatal errors. +test-context: [] +test-context-support: null +test-description: null +test-header: null +test-includes: +- rtems.h +- rtems/score/atomic.h +- rtems/score/isrlevel.h +- rtems/score/threaddispatch.h +- setjmp.h +- string.h +test-local-includes: +- tx-support.h +test-setup: null +test-stop: null +test-support: | + typedef struct { + Atomic_Uint counter; + rtems_fatal_source source; + bool always_set_to_false; + rtems_fatal_code code; + } FatalInfo; + + static FatalInfo fatal_info; + + static unsigned int GetFatalCounter( void ) + { + return _Atomic_Load_uint( &fatal_info.counter, ATOMIC_ORDER_RELAXED ); + } + + static unsigned int ResetFatalInfo( void ) + { + fatal_info.source = RTEMS_FATAL_SOURCE_APPLICATION; + fatal_info.always_set_to_false = true; + fatal_info.code = INTERNAL_ERROR_NO_MPCI; + + return GetFatalCounter(); + } + + static void Fatal( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code + ) + { + fatal_info.source = source; + fatal_info.always_set_to_false = always_set_to_false; + fatal_info.code = code; + _Atomic_Fetch_add_uint( &fatal_info.counter, 1, ATOMIC_ORDER_RELAXED ); + } + + static void FatalTaskExit( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code + ) + { + Fatal( source, always_set_to_false, code ); + rtems_task_exit(); + } + + static void ExitTask( rtems_task_argument arg ) + { + (void) arg; + } + + static void FatalBadThreadDispatchEnvironment( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code + ) + { + Fatal( source, always_set_to_false, code ); + _ISR_Set_level( 0 ); + _Thread_Dispatch_direct_no_return( _Per_CPU_Get() ); + } + + static void ISRDisabledThreadDispatchTask( rtems_task_argument arg ) + { + rtems_interrupt_level level; + + (void) arg; + rtems_interrupt_local_disable( level ); + (void) level; + rtems_task_exit(); + } + + static void FatalBadThreadDispatchDisableLevel( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code + ) + { + Per_CPU_Control *cpu_self; + + Fatal( source, always_set_to_false, code ); + cpu_self = _Per_CPU_Get(); + _Thread_Dispatch_unnest( cpu_self ); + _Thread_Dispatch_direct_no_return( cpu_self ); + } + + static void BadLevelThreadDispatchTask( rtems_task_argument arg ) + { + (void) arg; + _Thread_Dispatch_disable(); + rtems_task_exit(); + } + + static jmp_buf before_deadlock; + + static rtems_id deadlock_mutex; + + static bool ThreadCreateDeadlock( rtems_tcb *executing, rtems_tcb *created ) + { + (void) executing; + (void) created; + + ObtainMutex( deadlock_mutex ); + ReleaseMutex( deadlock_mutex ); + + return true; + } + + static void FatalThreadQueueDeadlock( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code + ) + { + Fatal( source, always_set_to_false, code ); + longjmp( before_deadlock, 1 ); + } + + static void ThreadQueueDeadlockTask( rtems_task_argument arg ) + { + rtems_id id; + + (void) arg; + id = CreateTask( "DORM", PRIO_NORMAL ); + DeleteTask( id ); + + rtems_task_exit(); + } +test-target: testsuites/validation/tc-score-fatal.c +test-teardown: null +type: test-case |