LCOV - code coverage report
Current view: top level - arch/arm/core/aarch32/cortex_m - thread_abort.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5 7 71.4 %
Date: 2022-08-18 11:36:24 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 4 75.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2016 Wind River Systems, Inc.
       3                 :            :  *
       4                 :            :  * SPDX-License-Identifier: Apache-2.0
       5                 :            :  */
       6                 :            : 
       7                 :            : /**
       8                 :            :  * @file
       9                 :            :  * @brief ARM Cortex-M k_thread_abort() routine
      10                 :            :  *
      11                 :            :  * The ARM Cortex-M architecture provides its own k_thread_abort() to deal
      12                 :            :  * with different CPU modes (handler vs thread) when a thread aborts. When its
      13                 :            :  * entry point returns or when it aborts itself, the CPU is in thread mode and
      14                 :            :  * must call z_swap() (which triggers a service call), but when in handler
      15                 :            :  * mode, the CPU must exit handler mode to cause the context switch, and thus
      16                 :            :  * must queue the PendSV exception.
      17                 :            :  */
      18                 :            : 
      19                 :            : #include <kernel.h>
      20                 :            : #include <toolchain.h>
      21                 :            : #include <linker/sections.h>
      22                 :            : #include <ksched.h>
      23                 :            : #include <kswap.h>
      24                 :            : #include <wait_q.h>
      25                 :            : #include <sys/__assert.h>
      26                 :            : 
      27                 :          2 : void z_impl_k_thread_abort(k_tid_t thread)
      28                 :            : {
      29         [ +  + ]:          2 :         if (_current == thread) {
      30         [ -  + ]:          1 :                 if (arch_is_in_isr()) {
      31                 :            :                         /* ARM is unlike most arches in that this is true
      32                 :            :                          * even for non-peripheral interrupts, even though
      33                 :            :                          * for these types of faults there is not an implicit
      34                 :            :                          * reschedule on the way out. See #21923.
      35                 :            :                          *
      36                 :            :                          * We have to reschedule since the current thread
      37                 :            :                          * should no longer run after we return, so
      38                 :            :                          * Trigger PendSV, in case we are in one of the
      39                 :            :                          * situations where the isr check is true but there
      40                 :            :                          * is not an implicit scheduler invocation.
      41                 :            :                          */
      42                 :          0 :                         SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;
      43                 :            :                         /* Clear any system calls that may be pending
      44                 :            :                          * as they have a higher priority than the PendSV
      45                 :            :                          * handler and will check the stack of the thread
      46                 :            :                          * being aborted.
      47                 :            :                          */
      48                 :          0 :                         SCB->SHCSR &= ~SCB_SHCSR_SVCALLPENDED_Msk;
      49                 :            :                 }
      50                 :            :         }
      51                 :            : 
      52                 :          2 :         z_thread_abort(thread);
      53                 :          1 : }

Generated by: LCOV version 1.14