1 /** @file 2 UEFI Component Name(2) protocol implementation for IPsec driver. 3 4 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 5 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php. 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 **/ 15 16 #include "IpSecImpl.h" 17 18 // 19 // EFI Component Name Functions 20 // 21 /** 22 Retrieves a Unicode string that is the user-readable name of the driver. 23 24 This function retrieves the user-readable name of a driver in the form of a 25 Unicode string. If the driver specified by This has a user-readable name in 26 the language specified by Language, then a pointer to the driver name is 27 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified 28 by This does not support the language specified by Language, 29 then EFI_UNSUPPORTED is returned. 30 31 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or 32 EFI_COMPONENT_NAME_PROTOCOL instance. 33 34 @param[in] Language A pointer to a Null-terminated ASCII string 35 array indicating the language. This is the 36 language of the driver name that the caller is 37 requesting, and it must match one of the 38 languages specified in SupportedLanguages. The 39 number of languages supported by a driver is up 40 to the driver writer. Language is specified 41 in RFC 4646 or ISO 639-2 language code format. 42 43 @param[out] DriverName A pointer to the Unicode string to return. 44 This Unicode string is the name of the 45 driver specified by This in the language 46 specified by Language. 47 48 @retval EFI_SUCCESS The Unicode string for the Driver specified by 49 This and the language specified by Language was 50 returned in DriverName. 51 52 @retval EFI_INVALID_PARAMETER Language is NULL. 53 54 @retval EFI_INVALID_PARAMETER DriverName is NULL. 55 56 @retval EFI_UNSUPPORTED The driver specified by This does not support 57 the language specified by Language. 58 59 **/ 60 EFI_STATUS 61 EFIAPI 62 IpSecComponentNameGetDriverName ( 63 IN EFI_COMPONENT_NAME_PROTOCOL *This, 64 IN CHAR8 *Language, 65 OUT CHAR16 **DriverName 66 ); 67 68 /** 69 Retrieves a Unicode string that is the user-readable name of the controller 70 that is being managed by a driver. 71 72 This function retrieves the user-readable name of the controller specified by 73 ControllerHandle and ChildHandle in the form of a Unicode string. If the 74 driver specified by This has a user-readable name in the language specified by 75 Language, then a pointer to the controller name is returned in ControllerName, 76 and EFI_SUCCESS is returned. If the driver specified by This is not currently 77 managing the controller specified by ControllerHandle and ChildHandle, 78 then EFI_UNSUPPORTED is returned. If the driver specified by This does not 79 support the language specified by Language, then EFI_UNSUPPORTED is returned. 80 81 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or 82 EFI_COMPONENT_NAME_PROTOCOL instance. 83 84 @param[in] ControllerHandle The handle of a controller that the driver 85 specified by This is managing. This handle 86 specifies the controller whose name is to be 87 returned. 88 89 @param[in] ChildHandle The handle of the child controller to retrieve 90 the name of. This is an optional parameter that 91 may be NULL. It will be NULL for device 92 drivers. It will also be NULL for a bus drivers 93 that wish to retrieve the name of the bus 94 controller. It will not be NULL for a bus 95 driver that wishes to retrieve the name of a 96 child controller. 97 98 @param[in] Language A pointer to a Null-terminated ASCII string 99 array indicating the language. This is the 100 language of the driver name that the caller is 101 requesting, and it must match one of the 102 languages specified in SupportedLanguages. The 103 number of languages supported by a driver is up 104 to the driver writer. Language is specified in 105 RFC 4646 or ISO 639-2 language code format. 106 107 @param[out] ControllerName A pointer to the Unicode string to return. 108 This Unicode string is the name of the 109 controller specified by ControllerHandle and 110 ChildHandle in the language specified by 111 Language from the point of view of the driver 112 specified by This. 113 114 @retval EFI_SUCCESS The Unicode string for the user-readable name in 115 the language specified by Language for the 116 driver specified by This was returned in 117 DriverName. 118 119 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. 120 121 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid 122 EFI_HANDLE. 123 124 @retval EFI_INVALID_PARAMETER Language is NULL. 125 126 @retval EFI_INVALID_PARAMETER ControllerName is NULL. 127 128 @retval EFI_UNSUPPORTED The driver specified by This is not currently 129 managing the controller specified by 130 ControllerHandle and ChildHandle. 131 132 @retval EFI_UNSUPPORTED The driver specified by This does not support 133 the language specified by Language. 134 135 **/ 136 EFI_STATUS 137 EFIAPI 138 IpSecComponentNameGetControllerName ( 139 IN EFI_COMPONENT_NAME_PROTOCOL *This, 140 IN EFI_HANDLE ControllerHandle, 141 IN EFI_HANDLE ChildHandle, OPTIONAL 142 IN CHAR8 *Language, 143 OUT CHAR16 **ControllerName 144 ); 145 146 // 147 // EFI Component Name Protocol 148 // 149 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIpSecComponentName = { 150 IpSecComponentNameGetDriverName, 151 IpSecComponentNameGetControllerName, 152 "eng" 153 }; 154 155 // 156 // EFI Component Name 2 Protocol 157 // 158 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIpSecComponentName2 = { 159 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IpSecComponentNameGetDriverName, 160 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IpSecComponentNameGetControllerName, 161 "en" 162 }; 163 164 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIpSecDriverNameTable[] = { 165 { 166 "eng;en", 167 L"IpSec Driver" 168 }, 169 { 170 NULL, 171 NULL 172 } 173 }; 174 175 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIpSecControllerNameTable[] = { 176 { 177 "eng;en", 178 L"IPsec Controller" 179 }, 180 { 181 NULL, 182 NULL 183 } 184 }; 185 186 /** 187 Retrieves a Unicode string that is the user-readable name of the driver. 188 189 This function retrieves the user-readable name of a driver in the form of a 190 Unicode string. If the driver specified by This has a user-readable name in 191 the language specified by Language, then a pointer to the driver name is 192 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified 193 by This does not support the language specified by Language, 194 then EFI_UNSUPPORTED is returned. 195 196 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or 197 EFI_COMPONENT_NAME_PROTOCOL instance. 198 199 @param[in] Language A pointer to a Null-terminated ASCII string 200 array indicating the language. This is the 201 language of the driver name that the caller is 202 requesting, and it must match one of the 203 languages specified in SupportedLanguages. The 204 number of languages supported by a driver is up 205 to the driver writer. Language is specified 206 in RFC 4646 or ISO 639-2 language code format. 207 208 @param[out] DriverName A pointer to the Unicode string to return. 209 This Unicode string is the name of the 210 driver specified by This in the language 211 specified by Language. 212 213 @retval EFI_SUCCESS The Unicode string for the Driver specified by 214 This, and the language specified by Language was 215 returned in DriverName. 216 217 @retval EFI_INVALID_PARAMETER Language is NULL. 218 219 @retval EFI_INVALID_PARAMETER DriverName is NULL. 220 221 @retval EFI_UNSUPPORTED The driver specified by This does not support 222 the language specified by Language. 223 224 **/ 225 EFI_STATUS 226 EFIAPI 227 IpSecComponentNameGetDriverName ( 228 IN EFI_COMPONENT_NAME_PROTOCOL *This, 229 IN CHAR8 *Language, 230 OUT CHAR16 **DriverName 231 ) 232 { 233 return LookupUnicodeString2 ( 234 Language, 235 This->SupportedLanguages, 236 mIpSecDriverNameTable, 237 DriverName, 238 (BOOLEAN) (This == &gIpSecComponentName) 239 ); 240 } 241 242 /** 243 Retrieves a Unicode string that is the user-readable name of the controller 244 that is being managed by a driver. 245 246 This function retrieves the user-readable name of the controller specified by 247 ControllerHandle and ChildHandle in the form of a Unicode string. If the 248 driver specified by This has a user-readable name in the language specified by 249 Language, then a pointer to the controller name is returned in ControllerName, 250 and EFI_SUCCESS is returned. If the driver specified by This is not currently 251 managing the controller specified by ControllerHandle and ChildHandle, 252 then EFI_UNSUPPORTED is returned. If the driver specified by This does not 253 support the language specified by Language, then EFI_UNSUPPORTED is returned. 254 255 @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or 256 EFI_COMPONENT_NAME_PROTOCOL instance. 257 258 @param[in] ControllerHandle The handle of a controller that the driver 259 specified by This is managing. This handle 260 specifies the controller whose name is to be 261 returned. 262 263 @param[in] ChildHandle The handle of the child controller to retrieve 264 the name of. This is an optional parameter that 265 may be NULL. It will be NULL for device 266 drivers. It will also be NULL for a bus drivers 267 that wish to retrieve the name of the bus 268 controller. It will not be NULL for a bus 269 driver that wishes to retrieve the name of a 270 child controller. 271 272 @param[in] Language A pointer to a Null-terminated ASCII string 273 array indicating the language. This is the 274 language of the driver name that the caller is 275 requesting, and it must match one of the 276 languages specified in SupportedLanguages. The 277 number of languages supported by a driver is up 278 to the driver writer. Language is specified in 279 RFC 4646 or ISO 639-2 language code format. 280 281 @param[out] ControllerName A pointer to the Unicode string to return. 282 This Unicode string is the name of the 283 controller specified by ControllerHandle and 284 ChildHandle in the language specified by 285 Language from the point of view of the driver 286 specified by This. 287 288 @retval EFI_SUCCESS The Unicode string for the user-readable name in 289 the language specified by Language for the 290 driver specified by This was returned in 291 DriverName. 292 293 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. 294 295 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid 296 EFI_HANDLE. 297 298 @retval EFI_INVALID_PARAMETER Language is NULL. 299 300 @retval EFI_INVALID_PARAMETER ControllerName is NULL. 301 302 @retval EFI_UNSUPPORTED The driver specified by This is not currently 303 managing the controller specified by 304 ControllerHandle and ChildHandle. 305 306 @retval EFI_UNSUPPORTED The driver specified by This does not support 307 the language specified by Language. 308 309 **/ 310 EFI_STATUS 311 EFIAPI 312 IpSecComponentNameGetControllerName ( 313 IN EFI_COMPONENT_NAME_PROTOCOL *This, 314 IN EFI_HANDLE ControllerHandle, 315 IN EFI_HANDLE ChildHandle, OPTIONAL 316 IN CHAR8 *Language, 317 OUT CHAR16 **ControllerName 318 ) 319 { 320 EFI_STATUS Status; 321 322 // 323 // ChildHandle must be NULL for a Device Driver 324 // 325 if (ChildHandle != NULL) { 326 return EFI_UNSUPPORTED; 327 } 328 329 // 330 // Make sure this driver is currently managing ControllerHandle 331 // 332 Status = gBS->OpenProtocol ( 333 ControllerHandle, 334 &gEfiIpSec2ProtocolGuid, 335 NULL, 336 NULL, 337 NULL, 338 EFI_OPEN_PROTOCOL_TEST_PROTOCOL 339 ); 340 if (EFI_ERROR (Status)) { 341 return Status; 342 } 343 344 return LookupUnicodeString2 ( 345 Language, 346 This->SupportedLanguages, 347 mIpSecControllerNameTable, 348 ControllerName, 349 (BOOLEAN) (This == &gIpSecComponentName) 350 ); 351 } 352