1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSScoreSMPLock |
---|
7 | * |
---|
8 | * @brief This source file contains the implementation of |
---|
9 | * _SMP_lock_Initialize(), _SMP_lock_Destroy(), _SMP_lock_Acquire(), |
---|
10 | * _SMP_lock_Release(), _SMP_lock_ISR_disable_and_acquire(), |
---|
11 | * _SMP_lock_Release_and_ISR_enable(), and _SMP_lock_Is_owner(). |
---|
12 | */ |
---|
13 | |
---|
14 | /* |
---|
15 | * Copyright (C) 2015, 2016 embedded brains GmbH & Co. KG |
---|
16 | * |
---|
17 | * Redistribution and use in source and binary forms, with or without |
---|
18 | * modification, are permitted provided that the following conditions |
---|
19 | * are met: |
---|
20 | * 1. Redistributions of source code must retain the above copyright |
---|
21 | * notice, this list of conditions and the following disclaimer. |
---|
22 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
23 | * notice, this list of conditions and the following disclaimer in the |
---|
24 | * documentation and/or other materials provided with the distribution. |
---|
25 | * |
---|
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
30 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
36 | * POSSIBILITY OF SUCH DAMAGE. |
---|
37 | */ |
---|
38 | |
---|
39 | #ifdef HAVE_CONFIG_H |
---|
40 | #include "config.h" |
---|
41 | #endif |
---|
42 | |
---|
43 | #include <rtems/score/smplock.h> |
---|
44 | |
---|
45 | #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) |
---|
46 | void _SMP_lock_Initialize( |
---|
47 | SMP_lock_Control *lock, |
---|
48 | const char *name |
---|
49 | ) |
---|
50 | { |
---|
51 | _SMP_lock_Initialize_inline( lock, name ); |
---|
52 | } |
---|
53 | |
---|
54 | void _SMP_lock_Destroy( SMP_lock_Control *lock ) |
---|
55 | { |
---|
56 | _SMP_lock_Destroy_inline( lock ); |
---|
57 | } |
---|
58 | #endif |
---|
59 | |
---|
60 | void _SMP_lock_Acquire( |
---|
61 | SMP_lock_Control *lock, |
---|
62 | SMP_lock_Context *context |
---|
63 | ) |
---|
64 | { |
---|
65 | _SMP_lock_Acquire_inline( lock, context ); |
---|
66 | } |
---|
67 | |
---|
68 | #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) |
---|
69 | void _SMP_lock_Release( |
---|
70 | SMP_lock_Control *lock, |
---|
71 | SMP_lock_Context *context |
---|
72 | ) |
---|
73 | { |
---|
74 | _SMP_lock_Release_inline( lock, context ); |
---|
75 | } |
---|
76 | #endif |
---|
77 | |
---|
78 | void _SMP_lock_ISR_disable_and_acquire( |
---|
79 | SMP_lock_Control *lock, |
---|
80 | SMP_lock_Context *context |
---|
81 | ) |
---|
82 | { |
---|
83 | _SMP_lock_ISR_disable_and_acquire_inline( lock, context ); |
---|
84 | } |
---|
85 | |
---|
86 | #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) |
---|
87 | void _SMP_lock_Release_and_ISR_enable( |
---|
88 | SMP_lock_Control *lock, |
---|
89 | SMP_lock_Context *context |
---|
90 | ) |
---|
91 | { |
---|
92 | _SMP_lock_Release_and_ISR_enable_inline( lock, context ); |
---|
93 | } |
---|
94 | #endif |
---|
95 | |
---|
96 | #if defined(RTEMS_DEBUG) |
---|
97 | bool _SMP_lock_Is_owner( const SMP_lock_Control *lock ) |
---|
98 | { |
---|
99 | return lock->owner == _SMP_lock_Who_am_I(); |
---|
100 | } |
---|
101 | #endif |
---|