source: mainline/boot/arch/ia64/loader/gefi/lib/event.c@ a4884c70

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a4884c70 was 7208b6c, checked in by Jakub Vana <jakub.vana@…>, 18 years ago

Basic IA64 boot and kernel suport for real machines

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