]>
Commit | Line | Data |
---|---|---|
f62485d3 | 1 | /**@file\r |
2 | Library utility functions for Runtime driver.\r | |
3 | \r | |
4 | Copyright (c) 2006 Intel Corporation. <BR>\r | |
878ddf1f | 5 | All rights reserved. This program and the accompanying materials \r |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
f62485d3 | 13 | **/\r |
878ddf1f | 14 | \r |
15 | #include <RuntimeLibInternal.h>\r | |
16 | \r | |
f62485d3 | 17 | ///\r |
18 | /// Driver Lib Module Globals\r | |
19 | ///\r | |
878ddf1f | 20 | \r |
e8a3bee0 | 21 | STATIC EFI_EVENT mEfiVirtualNotifyEvent;\r |
22 | STATIC BOOLEAN mEfiGoneVirtual = FALSE;\r | |
23 | STATIC BOOLEAN mEfiAtRuntime = FALSE;\r | |
e8a3bee0 | 24 | EFI_RUNTIME_SERVICES *mRT;\r |
25 | \r | |
f62485d3 | 26 | /**\r |
27 | Set AtRuntime flag as TRUE after ExitBootServices\r | |
28 | \r | |
29 | @param[in] Event The Event that is being processed\r | |
30 | @param[in] Context Event Context\r | |
31 | **/\r | |
878ddf1f | 32 | VOID\r |
33 | EFIAPI\r | |
34 | RuntimeDriverExitBootServices (\r | |
35 | IN EFI_EVENT Event,\r | |
36 | IN VOID *Context\r | |
37 | )\r | |
878ddf1f | 38 | {\r |
e8a3bee0 | 39 | //\r |
40 | // Clear out BootService globals\r | |
41 | //\r | |
42 | gBS = NULL;\r | |
43 | \r | |
878ddf1f | 44 | mEfiAtRuntime = TRUE;\r |
45 | }\r | |
46 | \r | |
f62485d3 | 47 | /**\r |
48 | Fixup internal data so that EFI can be call in virtual mode.\r | |
49 | Call the passed in Child Notify event and convert any pointers in \r | |
50 | lib to virtual mode.\r | |
51 | \r | |
52 | @param[in] Event The Event that is being processed\r | |
53 | @param[in] Context Event Context\r | |
54 | **/\r | |
878ddf1f | 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 | |
878ddf1f | 62 | {\r |
63 | UINTN Index;\r | |
64 | EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r | |
65 | \r | |
66 | for (Index = 0; \r | |
67 | _gDriverSetVirtualAddressMapEvent[Index] != NULL;\r | |
68 | Index++) {\r | |
69 | ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r | |
70 | ChildNotifyEventHandler (Event, NULL);\r | |
71 | }\r | |
72 | \r | |
73 | //\r | |
74 | // Update global for Runtime Services Table and IO\r | |
75 | //\r | |
e8a3bee0 | 76 | EfiConvertPointer (0, (VOID **) &mRT);\r |
878ddf1f | 77 | \r |
878ddf1f | 78 | mEfiGoneVirtual = TRUE;\r |
79 | }\r | |
80 | \r | |
f62485d3 | 81 | /**\r |
82 | Intialize runtime Driver Lib if it has not yet been initialized. \r | |
83 | \r | |
84 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r | |
85 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
86 | \r | |
87 | @return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
88 | **/\r | |
878ddf1f | 89 | EFI_STATUS\r |
a5e465a7 | 90 | EFIAPI\r |
878ddf1f | 91 | RuntimeDriverLibConstruct (\r |
92 | IN EFI_HANDLE ImageHandle,\r | |
93 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
94 | )\r | |
878ddf1f | 95 | {\r |
96 | EFI_STATUS Status;\r | |
97 | \r | |
f62485d3 | 98 | ASSERT (SystemTable != NULL);\r |
878ddf1f | 99 | mRT = SystemTable->RuntimeServices;\r |
f62485d3 | 100 | ASSERT (mRT != NULL);\r |
101 | \r | |
878ddf1f | 102 | //\r |
103 | // Register SetVirtualAddressMap () notify function\r | |
104 | // \r | |
9cb053ef | 105 | ASSERT (gBS != NULL);\r |
106 | Status = gBS->CreateEvent (\r | |
107 | EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r | |
108 | EFI_TPL_NOTIFY,\r | |
109 | RuntimeLibVirtualNotifyEvent,\r | |
110 | NULL,\r | |
111 | &mEfiVirtualNotifyEvent\r | |
112 | );\r | |
f62485d3 | 113 | \r |
9cb053ef | 114 | ASSERT_EFI_ERROR (Status);\r |
878ddf1f | 115 | \r |
116 | return EFI_SUCCESS;\r | |
117 | }\r | |
118 | \r | |
f62485d3 | 119 | /**\r |
120 | This routine will free some resources which have been allocated in\r | |
121 | EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r | |
122 | it must call this routine to free the allocated resource before the exiting.\r | |
123 | \r | |
124 | @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully\r | |
125 | @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all\r | |
126 | **/\r | |
878ddf1f | 127 | EFI_STATUS\r |
a5e465a7 | 128 | EFIAPI\r |
878ddf1f | 129 | RuntimeDriverLibDeconstruct (\r |
f9081b64 | 130 | IN EFI_HANDLE ImageHandle,\r |
131 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
878ddf1f | 132 | )\r |
878ddf1f | 133 | {\r |
134 | EFI_STATUS Status;\r | |
135 | \r | |
878ddf1f | 136 | //\r |
137 | // Close SetVirtualAddressMap () notify function\r | |
138 | //\r | |
f1cd55fe | 139 | if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r |
f62485d3 | 140 | ASSERT (gBS != NULL);\r |
141 | Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r | |
142 | ASSERT_EFI_ERROR (Status);\r | |
f1cd55fe | 143 | }\r |
878ddf1f | 144 | \r |
145 | return EFI_SUCCESS;\r | |
146 | }\r | |
147 | \r | |
f62485d3 | 148 | /**\r |
149 | Return TRUE if ExitBootServices () has been called\r | |
150 | \r | |
151 | @retval TRUE If ExitBootServices () has been called\r | |
152 | **/\r | |
878ddf1f | 153 | BOOLEAN\r |
e8a3bee0 | 154 | EFIAPI\r |
878ddf1f | 155 | EfiAtRuntime (\r |
156 | VOID\r | |
157 | )\r | |
878ddf1f | 158 | {\r |
159 | return mEfiAtRuntime;\r | |
160 | }\r | |
161 | \r | |
f62485d3 | 162 | /**\r |
163 | Return TRUE if SetVirtualAddressMap () has been called\r | |
164 | \r | |
165 | @retval TRUE If SetVirtualAddressMap () has been called\r | |
166 | **/\r | |
878ddf1f | 167 | BOOLEAN\r |
e8a3bee0 | 168 | EFIAPI\r |
878ddf1f | 169 | EfiGoneVirtual (\r |
170 | VOID\r | |
171 | )\r | |
878ddf1f | 172 | {\r |
173 | return mEfiGoneVirtual;\r | |
174 | }\r | |
175 | \r |