]>
Commit | Line | Data |
---|---|---|
ebcc8fb7 | 1 | /**@file\r |
2 | Library utility functions for Runtime driver.\r | |
3 | \r | |
4 | Copyright (c) 2006 Intel Corporation. <BR>\r | |
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 | |
13 | **/\r | |
14 | \r | |
15 | #include <RuntimeLibInternal.h>\r | |
16 | \r | |
17 | ///\r | |
18 | /// Driver Lib Module Globals\r | |
19 | ///\r | |
20 | \r | |
21 | STATIC EFI_EVENT mEfiVirtualNotifyEvent;\r | |
21998b67 | 22 | STATIC EFI_EVENT mEfiExitBootServicesEvent;\r |
ebcc8fb7 | 23 | STATIC BOOLEAN mEfiGoneVirtual = FALSE;\r |
24 | STATIC BOOLEAN mEfiAtRuntime = FALSE;\r | |
25 | EFI_RUNTIME_SERVICES *mRT;\r | |
26 | \r | |
27 | /**\r | |
28 | Set AtRuntime flag as TRUE after ExitBootServices\r | |
29 | \r | |
30 | @param[in] Event The Event that is being processed\r | |
31 | @param[in] Context Event Context\r | |
32 | **/\r | |
21998b67 | 33 | STATIC\r |
ebcc8fb7 | 34 | VOID\r |
35 | EFIAPI\r | |
21998b67 | 36 | RuntimeLibExitBootServicesEvent (\r |
ebcc8fb7 | 37 | IN EFI_EVENT Event,\r |
38 | IN VOID *Context\r | |
39 | )\r | |
40 | {\r | |
41 | //\r | |
42 | // Clear out BootService globals\r | |
43 | //\r | |
44 | gBS = NULL;\r | |
45 | \r | |
46 | mEfiAtRuntime = TRUE;\r | |
47 | }\r | |
48 | \r | |
49 | /**\r | |
50 | Fixup internal data so that EFI can be call in virtual mode.\r | |
51 | Call the passed in Child Notify event and convert any pointers in\r | |
52 | lib to virtual mode.\r | |
53 | \r | |
54 | @param[in] Event The Event that is being processed\r | |
55 | @param[in] Context Event Context\r | |
56 | **/\r | |
57 | STATIC\r | |
58 | VOID\r | |
59 | EFIAPI\r | |
60 | RuntimeLibVirtualNotifyEvent (\r | |
61 | IN EFI_EVENT Event,\r | |
62 | IN VOID *Context\r | |
63 | )\r | |
64 | {\r | |
ebcc8fb7 | 65 | //\r |
66 | // Update global for Runtime Services Table and IO\r | |
67 | //\r | |
68 | EfiConvertPointer (0, (VOID **) &mRT);\r | |
69 | \r | |
70 | mEfiGoneVirtual = TRUE;\r | |
71 | }\r | |
72 | \r | |
73 | /**\r | |
74 | Intialize runtime Driver Lib if it has not yet been initialized.\r | |
75 | \r | |
76 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r | |
77 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
78 | \r | |
79 | @return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
80 | **/\r | |
81 | EFI_STATUS\r | |
82 | EFIAPI\r | |
83 | RuntimeDriverLibConstruct (\r | |
84 | IN EFI_HANDLE ImageHandle,\r | |
85 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
86 | )\r | |
87 | {\r | |
88 | EFI_STATUS Status;\r | |
89 | \r | |
90 | ASSERT (SystemTable != NULL);\r | |
91 | mRT = SystemTable->RuntimeServices;\r | |
92 | ASSERT (mRT != NULL);\r | |
93 | \r | |
94 | //\r | |
95 | // Register SetVirtualAddressMap () notify function\r | |
96 | //\r | |
97 | ASSERT (gBS != NULL);\r | |
98 | Status = gBS->CreateEvent (\r | |
99 | EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r | |
100 | TPL_NOTIFY,\r | |
101 | RuntimeLibVirtualNotifyEvent,\r | |
102 | NULL,\r | |
103 | &mEfiVirtualNotifyEvent\r | |
104 | );\r | |
105 | \r | |
106 | ASSERT_EFI_ERROR (Status);\r | |
107 | \r | |
21998b67 | 108 | Status = gBS->CreateEvent (\r |
109 | EVT_SIGNAL_EXIT_BOOT_SERVICES,\r | |
110 | TPL_NOTIFY,\r | |
111 | RuntimeLibExitBootServicesEvent,\r | |
112 | NULL,\r | |
113 | &mEfiExitBootServicesEvent\r | |
114 | );\r | |
115 | \r | |
116 | ASSERT_EFI_ERROR (Status);\r | |
117 | \r | |
ebcc8fb7 | 118 | return Status;\r |
119 | }\r | |
120 | \r | |
121 | /**\r | |
122 | This routine will free some resources which have been allocated in\r | |
123 | EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,\r | |
124 | it must call this routine to free the allocated resource before the exiting.\r | |
125 | \r | |
126 | @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully\r | |
127 | @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all\r | |
128 | **/\r | |
129 | EFI_STATUS\r | |
130 | EFIAPI\r | |
131 | RuntimeDriverLibDeconstruct (\r | |
132 | IN EFI_HANDLE ImageHandle,\r | |
133 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
134 | )\r | |
135 | {\r | |
136 | EFI_STATUS Status;\r | |
137 | \r | |
138 | //\r | |
139 | // Close SetVirtualAddressMap () notify function\r | |
140 | //\r | |
141 | ASSERT (gBS != NULL);\r | |
142 | Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r | |
143 | ASSERT_EFI_ERROR (Status);\r | |
144 | \r | |
21998b67 | 145 | Status = gBS->CloseEvent (mEfiExitBootServicesEvent);\r |
146 | ASSERT_EFI_ERROR (Status);\r | |
147 | \r | |
ebcc8fb7 | 148 | return Status;\r |
149 | }\r | |
150 | \r | |
151 | /**\r | |
152 | Return TRUE if ExitBootServices () has been called\r | |
153 | \r | |
154 | @retval TRUE If ExitBootServices () has been called\r | |
155 | **/\r | |
156 | BOOLEAN\r | |
157 | EFIAPI\r | |
158 | EfiAtRuntime (\r | |
159 | VOID\r | |
160 | )\r | |
161 | {\r | |
162 | return mEfiAtRuntime;\r | |
163 | }\r | |
164 | \r | |
165 | /**\r | |
166 | Return TRUE if SetVirtualAddressMap () has been called\r | |
167 | \r | |
168 | @retval TRUE If SetVirtualAddressMap () has been called\r | |
169 | **/\r | |
170 | BOOLEAN\r | |
171 | EFIAPI\r | |
172 | EfiGoneVirtual (\r | |
173 | VOID\r | |
174 | )\r | |
175 | {\r | |
176 | return mEfiGoneVirtual;\r | |
177 | }\r | |
178 | \r |