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