/src/hbfa-fl/HBFA/UefiHostTestPkg/Library/UefiBootServicesTableLibHost/Tpl.c
Line | Count | Source (jump to first uncovered line) |
1 | | /** @file |
2 | | Task priority (TPL) functions. |
3 | | |
4 | | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> |
5 | | SPDX-License-Identifier: BSD-2-Clause-Patent |
6 | | |
7 | | **/ |
8 | | |
9 | | #include "DxeMain.h" |
10 | | |
11 | | #define VALID_TPL(a) ((a) <= TPL_HIGH_LEVEL) |
12 | | |
13 | | EFI_TPL gEfiCurrentTpl = TPL_APPLICATION; |
14 | | |
15 | | |
16 | | /** |
17 | | Raise the task priority level to the new level. |
18 | | High level is implemented by disabling processor interrupts. |
19 | | |
20 | | @param NewTpl New task priority level |
21 | | |
22 | | @return The previous task priority level |
23 | | |
24 | | **/ |
25 | | EFI_TPL |
26 | | EFIAPI |
27 | | CoreRaiseTpl ( |
28 | | IN EFI_TPL NewTpl |
29 | | ) |
30 | 875 | { |
31 | 875 | EFI_TPL OldTpl; |
32 | | |
33 | 875 | OldTpl = gEfiCurrentTpl; |
34 | 875 | if (OldTpl > NewTpl) { |
35 | 0 | DEBUG ((EFI_D_ERROR, "FATAL ERROR - RaiseTpl with OldTpl(0x%x) > NewTpl(0x%x)\n", OldTpl, NewTpl)); |
36 | 0 | ASSERT (FALSE); |
37 | 0 | } |
38 | 875 | ASSERT (VALID_TPL (NewTpl)); |
39 | | |
40 | | // |
41 | | // Set the new value |
42 | | // |
43 | 875 | gEfiCurrentTpl = NewTpl; |
44 | | |
45 | 875 | return OldTpl; |
46 | 875 | } |
47 | | |
48 | | |
49 | | |
50 | | |
51 | | /** |
52 | | Lowers the task priority to the previous value. If the new |
53 | | priority unmasks events at a higher priority, they are dispatched. |
54 | | |
55 | | @param NewTpl New, lower, task priority |
56 | | |
57 | | **/ |
58 | | VOID |
59 | | EFIAPI |
60 | | CoreRestoreTpl ( |
61 | | IN EFI_TPL NewTpl |
62 | | ) |
63 | 875 | { |
64 | 875 | EFI_TPL OldTpl; |
65 | | |
66 | 875 | OldTpl = gEfiCurrentTpl; |
67 | 875 | if (NewTpl > OldTpl) { |
68 | 0 | DEBUG ((EFI_D_ERROR, "FATAL ERROR - RestoreTpl with NewTpl(0x%x) > OldTpl(0x%x)\n", NewTpl, OldTpl)); |
69 | 0 | ASSERT (FALSE); |
70 | 0 | } |
71 | 875 | ASSERT (VALID_TPL (NewTpl)); |
72 | | |
73 | | // |
74 | | // Set the new value |
75 | | // |
76 | 875 | gEfiCurrentTpl = NewTpl; |
77 | 875 | } |