/src/hbfa-fl/HBFA/UefiHostTestPkg/Library/UefiBootServicesTableLibHost/Library.c
Line | Count | Source (jump to first uncovered line) |
1 | | /** @file |
2 | | DXE Core library services. |
3 | | |
4 | | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> |
5 | | SPDX-License-Identifier: BSD-2-Clause-Patent |
6 | | |
7 | | **/ |
8 | | |
9 | | #include "DxeMain.h" |
10 | | |
11 | | // |
12 | | // Lock Stuff |
13 | | // |
14 | | /** |
15 | | Initialize a basic mutual exclusion lock. Each lock |
16 | | provides mutual exclusion access at it's task priority |
17 | | level. Since there is no-premption (at any TPL) or |
18 | | multiprocessor support, acquiring the lock only consists |
19 | | of raising to the locks TPL. |
20 | | |
21 | | @param Lock The EFI_LOCK structure to initialize |
22 | | |
23 | | @retval EFI_SUCCESS Lock Owned. |
24 | | @retval EFI_ACCESS_DENIED Reentrant Lock Acquisition, Lock not Owned. |
25 | | |
26 | | **/ |
27 | | EFI_STATUS |
28 | | CoreAcquireLockOrFail ( |
29 | | IN EFI_LOCK *Lock |
30 | | ) |
31 | 0 | { |
32 | 0 | ASSERT (Lock != NULL); |
33 | 0 | ASSERT (Lock->Lock != EfiLockUninitialized); |
34 | |
|
35 | 0 | if (Lock->Lock == EfiLockAcquired) { |
36 | | // |
37 | | // Lock is already owned, so bail out |
38 | | // |
39 | 0 | return EFI_ACCESS_DENIED; |
40 | 0 | } |
41 | | |
42 | 0 | Lock->OwnerTpl = CoreRaiseTpl (Lock->Tpl); |
43 | |
|
44 | 0 | Lock->Lock = EfiLockAcquired; |
45 | 0 | return EFI_SUCCESS; |
46 | 0 | } |
47 | | |
48 | | |
49 | | |
50 | | /** |
51 | | Raising to the task priority level of the mutual exclusion |
52 | | lock, and then acquires ownership of the lock. |
53 | | |
54 | | @param Lock The lock to acquire |
55 | | |
56 | | @return Lock owned |
57 | | |
58 | | **/ |
59 | | VOID |
60 | | CoreAcquireLock ( |
61 | | IN EFI_LOCK *Lock |
62 | | ) |
63 | 0 | { |
64 | 0 | ASSERT (Lock != NULL); |
65 | 0 | ASSERT (Lock->Lock == EfiLockReleased); |
66 | |
|
67 | 0 | Lock->OwnerTpl = CoreRaiseTpl (Lock->Tpl); |
68 | 0 | Lock->Lock = EfiLockAcquired; |
69 | 0 | } |
70 | | |
71 | | |
72 | | |
73 | | /** |
74 | | Releases ownership of the mutual exclusion lock, and |
75 | | restores the previous task priority level. |
76 | | |
77 | | @param Lock The lock to release |
78 | | |
79 | | @return Lock unowned |
80 | | |
81 | | **/ |
82 | | VOID |
83 | | CoreReleaseLock ( |
84 | | IN EFI_LOCK *Lock |
85 | | ) |
86 | 0 | { |
87 | 0 | EFI_TPL Tpl; |
88 | |
|
89 | 0 | ASSERT (Lock != NULL); |
90 | 0 | ASSERT (Lock->Lock == EfiLockAcquired); |
91 | |
|
92 | 0 | Tpl = Lock->OwnerTpl; |
93 | |
|
94 | 0 | Lock->Lock = EfiLockReleased; |
95 | |
|
96 | 0 | CoreRestoreTpl (Tpl); |
97 | 0 | } |
98 | | |
99 | | |
100 | | |