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