Subversion Repositories HelenOS

Rev

Rev 2726 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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