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