]>
Commit | Line | Data |
---|---|---|
1 | /*++\r | |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | RuntimeLib.c\r | |
15 | \r | |
16 | --*/\r | |
17 | \r | |
18 | #include <RuntimeLibInternal.h>\r | |
19 | \r | |
20 | //\r | |
21 | // Driver Lib Module Globals\r | |
22 | //\r | |
23 | static EFI_EVENT mEfiVirtualNotifyEvent;\r | |
24 | EFI_RUNTIME_SERVICES *mRT;\r | |
25 | \r | |
26 | VOID\r | |
27 | EFIAPI\r | |
28 | RuntimeDriverExitBootServices (\r | |
29 | IN EFI_EVENT Event,\r | |
30 | IN VOID *Context\r | |
31 | )\r | |
32 | /*++\r | |
33 | \r | |
34 | Routine Description:\r | |
35 | \r | |
36 | Set AtRuntime flag as TRUE after ExitBootServices\r | |
37 | \r | |
38 | Arguments:\r | |
39 | \r | |
40 | Event - The Event that is being processed\r | |
41 | \r | |
42 | Context - Event Context\r | |
43 | \r | |
44 | Returns: \r | |
45 | \r | |
46 | None\r | |
47 | \r | |
48 | --*/\r | |
49 | {\r | |
50 | if (EfiAtRuntime()) {\r | |
51 | return;\r | |
52 | }\r | |
53 | }\r | |
54 | \r | |
55 | STATIC\r | |
56 | VOID\r | |
57 | EFIAPI\r | |
58 | RuntimeLibVirtualNotifyEvent (\r | |
59 | IN EFI_EVENT Event,\r | |
60 | IN VOID *Context\r | |
61 | )\r | |
62 | /*++\r | |
63 | \r | |
64 | Routine Description:\r | |
65 | \r | |
66 | Fixup internal data so that EFI can be call in virtual mode.\r | |
67 | Call the passed in Child Notify event and convert any pointers in \r | |
68 | lib to virtual mode.\r | |
69 | \r | |
70 | Arguments:\r | |
71 | \r | |
72 | Event - The Event that is being processed\r | |
73 | \r | |
74 | Context - Event Context\r | |
75 | \r | |
76 | Returns: \r | |
77 | \r | |
78 | None\r | |
79 | \r | |
80 | --*/\r | |
81 | {\r | |
82 | UINTN Index;\r | |
83 | EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r | |
84 | \r | |
85 | for (Index = 0; _gDriverSetVirtualAddressMapEvent[Index] != NULL; Index++) {\r | |
86 | ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r | |
87 | ChildNotifyEventHandler (Event, NULL);\r | |
88 | }\r | |
89 | \r | |
90 | //\r | |
91 | // Update global for Runtime Services Table\r | |
92 | //\r | |
93 | EfiConvertPointer (0, (VOID **) &mRT);\r | |
94 | }\r | |
95 | \r | |
96 | EFI_STATUS\r | |
97 | EFIAPI\r | |
98 | RuntimeDriverLibConstruct (\r | |
99 | IN EFI_HANDLE ImageHandle,\r | |
100 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
101 | )\r | |
102 | /*++\r | |
103 | \r | |
104 | Routine Description:\r | |
105 | \r | |
106 | Intialize runtime Driver Lib if it has not yet been initialized. \r | |
107 | \r | |
108 | Arguments:\r | |
109 | \r | |
110 | ImageHandle - The firmware allocated handle for the EFI image.\r | |
111 | \r | |
112 | SystemTable - A pointer to the EFI System Table.\r | |
113 | \r | |
114 | GoVirtualChildEvent - Caller can register a virtual notification event.\r | |
115 | \r | |
116 | Returns: \r | |
117 | \r | |
118 | EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
119 | \r | |
120 | --*/\r | |
121 | {\r | |
122 | EFI_STATUS Status;\r | |
123 | \r | |
124 | mRT = SystemTable->RuntimeServices;\r | |
125 | \r | |
126 | //\r | |
127 | // Register SetVirtualAddressMap () notify function\r | |
128 | //\r | |
129 | if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r | |
130 | Status = gBS->CreateEvent (\r | |
131 | EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r | |
132 | EFI_TPL_NOTIFY,\r | |
133 | RuntimeLibVirtualNotifyEvent,\r | |
134 | NULL,\r | |
135 | &mEfiVirtualNotifyEvent\r | |
136 | );\r | |
137 | ASSERT_EFI_ERROR (Status);\r | |
138 | }\r | |
139 | \r | |
140 | return EFI_SUCCESS;\r | |
141 | }\r | |
142 | \r | |
143 | EFI_STATUS\r | |
144 | EFIAPI\r | |
145 | RuntimeDriverLibDeconstruct (\r | |
146 | IN EFI_HANDLE ImageHandle,\r | |
147 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
148 | )\r | |
149 | /*++\r | |
150 | \r | |
151 | Routine Description:\r | |
152 | \r | |
153 | This routine will free some resources which have been allocated in\r | |
154 | EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r | |
155 | it must call this routine to free the allocated resource before the exiting.\r | |
156 | \r | |
157 | Arguments:\r | |
158 | \r | |
159 | None\r | |
160 | \r | |
161 | Returns: \r | |
162 | \r | |
163 | EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully\r | |
164 | EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r | |
165 | \r | |
166 | --*/\r | |
167 | {\r | |
168 | EFI_STATUS Status;\r | |
169 | \r | |
170 | //\r | |
171 | // Close SetVirtualAddressMap () notify function\r | |
172 | //\r | |
173 | if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r | |
174 | Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r | |
175 | ASSERT_EFI_ERROR (Status);\r | |
176 | }\r | |
177 | \r | |
178 | return EFI_SUCCESS;\r | |
179 | }\r | |
180 | \r | |
181 | BOOLEAN\r | |
182 | EFIAPI\r | |
183 | EfiAtRuntime (\r | |
184 | VOID\r | |
185 | )\r | |
186 | /*++\r | |
187 | \r | |
188 | Routine Description:\r | |
189 | Return TRUE if ExitBootService () has been called\r | |
190 | \r | |
191 | Arguments:\r | |
192 | NONE\r | |
193 | \r | |
194 | Returns: \r | |
195 | TRUE - If ExitBootService () has been called\r | |
196 | \r | |
197 | --*/\r | |
198 | {\r | |
199 | EFI_GUID Guid;\r | |
200 | SAL_RETURN_REGS ReturnReg;\r | |
201 | \r | |
202 | *((UINT64 *) &Guid) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_LO;\r | |
203 | *(((UINT64 *)&Guid) + 1) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_HI;\r | |
204 | \r | |
205 | ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);\r | |
206 | \r | |
207 | return (BOOLEAN) (ReturnReg.r9 == 1);\r | |
208 | }\r | |
209 | \r | |
210 | BOOLEAN\r | |
211 | EFIAPI\r | |
212 | EfiGoneVirtual (\r | |
213 | VOID\r | |
214 | )\r | |
215 | /*++\r | |
216 | \r | |
217 | Routine Description:\r | |
218 | Return TRUE if SetVirtualAddressMap () has been called\r | |
219 | \r | |
220 | Arguments:\r | |
221 | NONE\r | |
222 | \r | |
223 | Returns: \r | |
224 | TRUE - If SetVirtualAddressMap () has been called\r | |
225 | \r | |
226 | --*/\r | |
227 | {\r | |
228 | EFI_GUID Guid;\r | |
229 | SAL_RETURN_REGS ReturnReg;\r | |
230 | \r | |
231 | *((UINT64 *) &Guid) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_LO;\r | |
232 | *(((UINT64 *)&Guid) + 1) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_HI;\r | |
233 | \r | |
234 | ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);\r | |
235 | \r | |
236 | return (BOOLEAN) (ReturnReg.r9 == 1);\r | |
237 | }\r | |
238 | \r |