blob: a33bec34caf6f86767db89d5bdf48cddd17ec63b [file] [log] [blame]
Greg Hartman76d05dc2016-11-23 15:51:27 -08001/*++
2
3Copyright (c) 1998 Intel Corporation
4
5Module Name:
6
7 lock.c
8
9Abstract:
10
11 Implements FLOCK
12
13
14
15Revision History
16
17--*/
18
19
20#include "lib.h"
21
22
23VOID
24InitializeLock (
25 IN OUT FLOCK *Lock,
26 IN EFI_TPL Priority
27 )
28/*++
29
30Routine Description:
31
32 Initialize a basic mutual exclusion lock. Each lock
33 provides mutual exclusion access at it's task priority
34 level. Since there is no-premption (at any TPL) or
35 multiprocessor support, acquiring the lock only consists
36 of raising to the locks TPL.
37
38 Note on a debug build the lock is acquired and released
39 to help ensure proper usage.
40
41Arguments:
42
43 Lock - The FLOCK structure to initialize
44
45 Priority - The task priority level of the lock
46
47
48Returns:
49
50 An initialized F Lock structure.
51
52--*/
53{
54 Lock->Tpl = Priority;
55 Lock->OwnerTpl = 0;
56 Lock->Lock = 0;
57}
58
59
60VOID
61AcquireLock (
62 IN FLOCK *Lock
63 )
64/*++
65
66Routine Description:
67
68 Raising to the task priority level of the mutual exclusion
69 lock, and then acquires ownership of the lock.
70
71Arguments:
72
73 Lock - The lock to acquire
74
75Returns:
76
77 Lock owned
78
79--*/
80{
81 RtAcquireLock (Lock);
82}
83
84
85VOID
86ReleaseLock (
87 IN FLOCK *Lock
88 )
89/*++
90
91Routine Description:
92
93 Releases ownership of the mutual exclusion lock, and
94 restores the previous task priority level.
95
96Arguments:
97
98 Lock - The lock to release
99
100Returns:
101
102 Lock unowned
103
104--*/
105{
106 RtReleaseLock (Lock);
107}