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 | event.c |
7 | event.c |
8 | 8 | ||
9 | Abstract: |
9 | Abstract: |
10 | 10 | ||
11 | 11 | ||
12 | 12 | ||
13 | 13 | ||
14 | Revision History |
14 | Revision History |
15 | 15 | ||
16 | --*/ |
16 | --*/ |
17 | 17 | ||
18 | #include "lib.h" |
18 | #include "lib.h" |
19 | 19 | ||
20 | 20 | ||
21 | EFI_EVENT |
21 | EFI_EVENT |
22 | LibCreateProtocolNotifyEvent ( |
22 | LibCreateProtocolNotifyEvent ( |
23 | IN EFI_GUID *ProtocolGuid, |
23 | IN EFI_GUID *ProtocolGuid, |
24 | IN EFI_TPL NotifyTpl, |
24 | IN EFI_TPL NotifyTpl, |
25 | IN EFI_EVENT_NOTIFY NotifyFunction, |
25 | IN EFI_EVENT_NOTIFY NotifyFunction, |
26 | IN VOID *NotifyContext, |
26 | IN VOID *NotifyContext, |
27 | OUT VOID *Registration |
27 | OUT VOID *Registration |
28 | ) |
28 | ) |
29 | { |
29 | { |
30 | EFI_STATUS Status; |
30 | EFI_STATUS Status; |
31 | EFI_EVENT Event; |
31 | EFI_EVENT Event; |
32 | 32 | ||
33 | // |
33 | // |
34 | // Create the event |
34 | // Create the event |
35 | // |
35 | // |
36 | 36 | ||
37 | Status = BS->CreateEvent ( |
37 | Status = BS->CreateEvent ( |
38 | EVT_NOTIFY_SIGNAL, |
38 | EVT_NOTIFY_SIGNAL, |
39 | NotifyTpl, |
39 | NotifyTpl, |
40 | NotifyFunction, |
40 | NotifyFunction, |
41 | NotifyContext, |
41 | NotifyContext, |
42 | &Event |
42 | &Event |
43 | ); |
43 | ); |
44 | ASSERT (!EFI_ERROR(Status)); |
44 | ASSERT (!EFI_ERROR(Status)); |
45 | 45 | ||
46 | // |
46 | // |
47 | // Register for protocol notifactions on this event |
47 | // Register for protocol notifactions on this event |
48 | // |
48 | // |
49 | 49 | ||
50 | Status = BS->RegisterProtocolNotify ( |
50 | Status = BS->RegisterProtocolNotify ( |
51 | ProtocolGuid, |
51 | ProtocolGuid, |
52 | Event, |
52 | Event, |
53 | Registration |
53 | Registration |
54 | ); |
54 | ); |
55 | 55 | ||
56 | ASSERT (!EFI_ERROR(Status)); |
56 | ASSERT (!EFI_ERROR(Status)); |
57 | 57 | ||
58 | // |
58 | // |
59 | // Kick the event so we will perform an initial pass of |
59 | // Kick the event so we will perform an initial pass of |
60 | // current installed drivers |
60 | // current installed drivers |
61 | // |
61 | // |
62 | 62 | ||
63 | BS->SignalEvent (Event); |
63 | BS->SignalEvent (Event); |
64 | return Event; |
64 | return Event; |
65 | } |
65 | } |
66 | 66 | ||
67 | 67 | ||
68 | EFI_STATUS |
68 | EFI_STATUS |
69 | WaitForSingleEvent ( |
69 | WaitForSingleEvent ( |
70 | IN EFI_EVENT Event, |
70 | IN EFI_EVENT Event, |
71 | IN UINT64 Timeout OPTIONAL |
71 | IN UINT64 Timeout OPTIONAL |
72 | ) |
72 | ) |
73 | { |
73 | { |
74 | EFI_STATUS Status; |
74 | EFI_STATUS Status; |
75 | UINTN Index; |
75 | UINTN Index; |
76 | EFI_EVENT TimerEvent; |
76 | EFI_EVENT TimerEvent; |
77 | EFI_EVENT WaitList[2]; |
77 | EFI_EVENT WaitList[2]; |
78 | 78 | ||
79 | if (Timeout) { |
79 | if (Timeout) { |
80 | // |
80 | // |
81 | // Create a timer event |
81 | // Create a timer event |
82 | // |
82 | // |
83 | 83 | ||
84 | Status = BS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent); |
84 | Status = BS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent); |
85 | if (!EFI_ERROR(Status)) { |
85 | if (!EFI_ERROR(Status)) { |
86 | 86 | ||
87 | // |
87 | // |
88 | // Set the timer event |
88 | // Set the timer event |
89 | // |
89 | // |
90 | 90 | ||
91 | BS->SetTimer (TimerEvent, TimerRelative, Timeout); |
91 | BS->SetTimer (TimerEvent, TimerRelative, Timeout); |
92 | 92 | ||
93 | // |
93 | // |
94 | // Wait for the original event or the timer |
94 | // Wait for the original event or the timer |
95 | // |
95 | // |
96 | 96 | ||
97 | WaitList[0] = Event; |
97 | WaitList[0] = Event; |
98 | WaitList[1] = TimerEvent; |
98 | WaitList[1] = TimerEvent; |
99 | Status = BS->WaitForEvent (2, WaitList, &Index); |
99 | Status = BS->WaitForEvent (2, WaitList, &Index); |
100 | BS->CloseEvent (TimerEvent); |
100 | BS->CloseEvent (TimerEvent); |
101 | 101 | ||
102 | // |
102 | // |
103 | // If the timer expired, change the return to timed out |
103 | // If the timer expired, change the return to timed out |
104 | // |
104 | // |
105 | 105 | ||
106 | if (!EFI_ERROR(Status) && Index == 1) { |
106 | if (!EFI_ERROR(Status) && Index == 1) { |
107 | Status = EFI_TIMEOUT; |
107 | Status = EFI_TIMEOUT; |
108 | } |
108 | } |
109 | } |
109 | } |
110 | 110 | ||
111 | } else { |
111 | } else { |
112 | 112 | ||
113 | // |
113 | // |
114 | // No timeout... just wait on the event |
114 | // No timeout... just wait on the event |
115 | // |
115 | // |
116 | 116 | ||
117 | Status = BS->WaitForEvent (1, &Event, &Index); |
117 | Status = BS->WaitForEvent (1, &Event, &Index); |
118 | ASSERT (!EFI_ERROR(Status)); |
118 | ASSERT (!EFI_ERROR(Status)); |
119 | ASSERT (Index == 0); |
119 | ASSERT (Index == 0); |
120 | } |
120 | } |
121 | 121 | ||
122 | return Status; |
122 | return Status; |
123 | } |
123 | } |
124 | 124 | ||
125 | VOID |
125 | VOID |
126 | WaitForEventWithTimeout ( |
126 | WaitForEventWithTimeout ( |
127 | IN EFI_EVENT Event, |
127 | IN EFI_EVENT Event, |
128 | IN UINTN Timeout, |
128 | IN UINTN Timeout, |
129 | IN UINTN Row, |
129 | IN UINTN Row, |
130 | IN UINTN Column, |
130 | IN UINTN Column, |
131 | IN CHAR16 *String, |
131 | IN CHAR16 *String, |
132 | IN EFI_INPUT_KEY TimeoutKey, |
132 | IN EFI_INPUT_KEY TimeoutKey, |
133 | OUT EFI_INPUT_KEY *Key |
133 | OUT EFI_INPUT_KEY *Key |
134 | ) |
134 | ) |
135 | { |
135 | { |
136 | EFI_STATUS Status; |
136 | EFI_STATUS Status; |
137 | 137 | ||
138 | do { |
138 | do { |
139 | PrintAt (Column, Row, String, Timeout); |
139 | PrintAt (Column, Row, String, Timeout); |
140 | Status = WaitForSingleEvent (Event, 10000000); |
140 | Status = WaitForSingleEvent (Event, 10000000); |
141 | if (Status == EFI_SUCCESS) { |
141 | if (Status == EFI_SUCCESS) { |
142 | if (!EFI_ERROR(ST->ConIn->ReadKeyStroke (ST->ConIn, Key))) { |
142 | if (!EFI_ERROR(ST->ConIn->ReadKeyStroke (ST->ConIn, Key))) { |
143 | return; |
143 | return; |
144 | } |
144 | } |
145 | } |
145 | } |
146 | } while (Timeout > 0); |
146 | } while (Timeout > 0); |
147 | *Key = TimeoutKey; |
147 | *Key = TimeoutKey; |
148 | } |
148 | } |
149 | 149 | ||
150 | 150 |