1 /*++ 2 3 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR> 4 This program and the accompanying materials 5 are licensed and made available under the terms and conditions of the BSD License 6 which accompanies this distribution. The full text of the license may be found at 7 http://opensource.org/licenses/bsd-license.php 8 9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 12 Module Name: 13 14 EfiSmmDriverLib.h 15 16 Abstract: 17 18 Light weight lib to support EFI Smm drivers. 19 20 --*/ 21 22 #ifndef _EFI_SMM_DRIVER_LIB_H_ 23 #define _EFI_SMM_DRIVER_LIB_H_ 24 25 #include "Tiano.h" 26 #include "GetImage.h" 27 #include "EfiCommonLib.h" 28 #include EFI_GUID_DEFINITION (EventLegacyBios) 29 #include EFI_GUID_DEFINITION (EventGroup) 30 #include EFI_PROTOCOL_DEFINITION (FirmwareVolume) 31 #include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) 32 #include EFI_PROTOCOL_DEFINITION (SmmBase) 33 #include EFI_PROTOCOL_DEFINITION (SmmStatusCode) 34 // 35 // Driver Lib Globals. 36 // 37 extern EFI_BOOT_SERVICES *gBS; 38 extern EFI_SYSTEM_TABLE *gST; 39 extern EFI_RUNTIME_SERVICES *gRT; 40 extern EFI_SMM_BASE_PROTOCOL *gSMM; 41 extern EFI_SMM_STATUS_CODE_PROTOCOL *mSmmDebug; 42 extern UINTN gErrorLevel; 43 44 #define EfiCopyMem EfiCommonLibCopyMem 45 #define EfiSetMem EfiCommonLibSetMem 46 #define EfiZeroMem EfiCommonLibZeroMem 47 48 EFI_STATUS 49 EfiInitializeSmmDriverLib ( 50 IN EFI_HANDLE ImageHandle, 51 IN EFI_SYSTEM_TABLE *SystemTable, 52 IN OUT BOOLEAN *InSmm 53 ) 54 /*++ 55 56 Routine Description: 57 58 Intialize Smm Driver Lib if it has not yet been initialized. 59 60 Arguments: 61 62 ImageHandle - The firmware allocated handle for the EFI image. 63 64 SystemTable - A pointer to the EFI System Table. 65 66 InSmm - If InSmm is NULL, it will not register Image to SMM. 67 If InSmm is not NULL, it will register Image to SMM and 68 return information on currently in SMM mode or not. 69 70 Returns: 71 72 EFI_STATUS always returns EFI_SUCCESS 73 74 --*/ 75 ; 76 77 VOID 78 EfiDebugAssert ( 79 IN CHAR8 *FileName, 80 IN INTN LineNumber, 81 IN CHAR8 *Description 82 ) 83 /*++ 84 85 Routine Description: 86 87 Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT 88 information. If Error Logging hub is not loaded DEADLOOP (). 89 90 Arguments: 91 92 FileName - File name of failing routine. 93 94 LineNumber - Line number of failing ASSERT(). 95 96 Description - Description, usually the assertion, 97 98 Returns: 99 100 None 101 102 --*/ 103 ; 104 105 VOID 106 EfiDebugVPrint ( 107 IN UINTN ErrorLevel, 108 IN CHAR8 *Format, 109 IN VA_LIST Marker 110 ) 111 /*++ 112 113 Routine Description: 114 115 Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT 116 information. If Error Logging hub is not loaded do nothing. 117 118 Arguments: 119 120 ErrorLevel - If error level is set do the debug print. 121 122 Format - String to use for the print, followed by Print arguments. 123 124 Marker - VarArgs 125 126 Returns: 127 128 None 129 130 --*/ 131 ; 132 133 VOID 134 EfiDebugPrint ( 135 IN UINTN ErrorLevel, 136 IN CHAR8 *Format, 137 ... 138 ) 139 /*++ 140 141 Routine Description: 142 143 Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT 144 information. If Error Logging hub is not loaded do nothing. 145 146 Arguments: 147 148 ErrorLevel - If error level is set do the debug print. 149 150 Format - String to use for the print, followed by Print arguments. 151 152 ... - VAR args for Format 153 154 Returns: 155 156 None 157 158 --*/ 159 ; 160 161 EFI_STATUS 162 EFIAPI 163 SmmEfiCreateEventLegacyBoot ( 164 IN EFI_TPL NotifyTpl, 165 IN EFI_EVENT_NOTIFY NotifyFunction, 166 IN VOID *NotifyContext, 167 OUT EFI_EVENT *LegacyBootEvent 168 ) 169 /*++ 170 171 Routine Description: 172 Create a Legacy Boot Event. 173 Tiano extended the CreateEvent Type enum to add a legacy boot event type. 174 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was 175 added and now it's possible to not voilate the UEFI specification by 176 declaring a GUID for the legacy boot event class. This library supports 177 the EFI 1.10 form and UEFI 2.0 form and allows common code to work both ways. 178 179 Arguments: 180 LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) 181 182 Returns: 183 EFI_SUCCESS Event was created. 184 Other Event was not created. 185 186 --*/ 187 ; 188 189 EFI_STATUS 190 EFIAPI 191 SmmEfiCreateEventReadyToBoot ( 192 IN EFI_TPL NotifyTpl, 193 IN EFI_EVENT_NOTIFY NotifyFunction, 194 IN VOID *NotifyContext, 195 OUT EFI_EVENT *ReadyToBootEvent 196 ) 197 /*++ 198 199 Routine Description: 200 Create a Read to Boot Event. 201 202 Tiano extended the CreateEvent Type enum to add a ready to boot event type. 203 This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was 204 added and now it's possible to not voilate the UEFI specification and use 205 the ready to boot event class defined in UEFI 2.0. This library supports 206 the EFI 1.10 form and UEFI 2.0 form and allows common code to work both ways. 207 208 Arguments: 209 ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex) 210 211 Return: 212 EFI_SUCCESS - Event was created. 213 Other - Event was not created. 214 215 --*/ 216 ; 217 218 #endif 219