WifiConnectionMgrComponentName.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /** @file
  2. UEFI Component Name(2) protocol implementation for WiFi Connection Manager.
  3. Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "WifiConnectionMgrDxe.h"
  7. extern EFI_GUID mEfiWifiMgrPrivateGuid;
  8. ///
  9. /// Component Name Protocol instance
  10. ///
  11. GLOBAL_REMOVE_IF_UNREFERENCED
  12. EFI_COMPONENT_NAME_PROTOCOL gWifiMgrDxeComponentName = {
  13. (EFI_COMPONENT_NAME_GET_DRIVER_NAME)WifiMgrDxeComponentNameGetDriverName,
  14. (EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)WifiMgrDxeComponentNameGetControllerName,
  15. "eng"
  16. };
  17. ///
  18. /// Component Name 2 Protocol instance
  19. ///
  20. GLOBAL_REMOVE_IF_UNREFERENCED
  21. EFI_COMPONENT_NAME2_PROTOCOL gWifiMgrDxeComponentName2 = {
  22. WifiMgrDxeComponentNameGetDriverName,
  23. WifiMgrDxeComponentNameGetControllerName,
  24. "en"
  25. };
  26. ///
  27. /// Table of driver names
  28. ///
  29. GLOBAL_REMOVE_IF_UNREFERENCED
  30. EFI_UNICODE_STRING_TABLE mWifiMgrDxeDriverNameTable[] = {
  31. {
  32. "eng;en",
  33. L"UEFI WiFi Connection Manager"
  34. },
  35. {
  36. NULL,
  37. NULL
  38. }
  39. };
  40. ///
  41. /// Table of controller names
  42. ///
  43. GLOBAL_REMOVE_IF_UNREFERENCED
  44. EFI_UNICODE_STRING_TABLE mWifiMgrDxeControllerNameTable[] = {
  45. {
  46. "eng;en",
  47. L"UEFI WiFi Connection Manager Controller"
  48. },
  49. {
  50. NULL,
  51. NULL
  52. }
  53. };
  54. /**
  55. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
  56. @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
  57. @param Language A pointer to a three-character ISO 639-2 language identifier.
  58. This is the language of the driver name that that the caller
  59. is requesting, and it must match one of the languages specified
  60. in SupportedLanguages. The number of languages supported by a
  61. driver is up to the driver writer.
  62. @param DriverName A pointer to the Unicode string to return. This Unicode string
  63. is the name of the driver specified by This in the language
  64. specified by Language.
  65. @retval EFI_SUCCESS The Unicode string for the Driver specified by This
  66. and the language specified by Language was returned
  67. in DriverName.
  68. @retval EFI_INVALID_PARAMETER Language is NULL.
  69. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  70. @retval EFI_UNSUPPORTED The driver specified by This does not support the
  71. language specified by Language.
  72. **/
  73. EFI_STATUS
  74. EFIAPI
  75. WifiMgrDxeComponentNameGetDriverName (
  76. IN EFI_COMPONENT_NAME2_PROTOCOL *This,
  77. IN CHAR8 *Language,
  78. OUT CHAR16 **DriverName
  79. )
  80. {
  81. return LookupUnicodeString2 (
  82. Language,
  83. This->SupportedLanguages,
  84. mWifiMgrDxeDriverNameTable,
  85. DriverName,
  86. (BOOLEAN)(This != &gWifiMgrDxeComponentName2)
  87. );
  88. }
  89. /**
  90. Retrieves a Unicode string that is the user readable name of the controller
  91. that is being managed by an EFI Driver.
  92. @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
  93. @param ControllerHandle The handle of a controller that the driver specified by
  94. This is managing. This handle specifies the controller
  95. whose name is to be returned.
  96. @param ChildHandle The handle of the child controller to retrieve the name
  97. of. This is an optional parameter that may be NULL. It
  98. will be NULL for device drivers. It will also be NULL
  99. for a bus drivers that wish to retrieve the name of the
  100. bus controller. It will not be NULL for a bus driver
  101. that wishes to retrieve the name of a child controller.
  102. @param Language A pointer to a three character ISO 639-2 language
  103. identifier. This is the language of the controller name
  104. that the caller is requesting, and it must match one
  105. of the languages specified in SupportedLanguages. The
  106. number of languages supported by a driver is up to the
  107. driver writer.
  108. @param ControllerName A pointer to the Unicode string to return. This Unicode
  109. string is the name of the controller specified by
  110. ControllerHandle and ChildHandle in the language specified
  111. by Language, from the point of view of the driver specified
  112. by This.
  113. @retval EFI_SUCCESS The Unicode string for the user-readable name in the
  114. language specified by Language for the driver
  115. specified by This was returned in DriverName.
  116. @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
  117. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
  118. @retval EFI_INVALID_PARAMETER Language is NULL.
  119. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  120. @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
  121. the controller specified by ControllerHandle and
  122. ChildHandle.
  123. @retval EFI_UNSUPPORTED The driver specified by This does not support the
  124. language specified by Language.
  125. **/
  126. EFI_STATUS
  127. EFIAPI
  128. WifiMgrDxeComponentNameGetControllerName (
  129. IN EFI_COMPONENT_NAME2_PROTOCOL *This,
  130. IN EFI_HANDLE ControllerHandle,
  131. IN EFI_HANDLE ChildHandle OPTIONAL,
  132. IN CHAR8 *Language,
  133. OUT CHAR16 **ControllerName
  134. )
  135. {
  136. EFI_STATUS Status;
  137. WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrPrivate;
  138. //
  139. // ChildHandle must be NULL for a Device Driver
  140. //
  141. if ((ControllerHandle == NULL) || (ChildHandle != NULL)) {
  142. return EFI_UNSUPPORTED;
  143. }
  144. //
  145. // Check Controller's handle
  146. //
  147. Status = gBS->OpenProtocol (
  148. ControllerHandle,
  149. &mEfiWifiMgrPrivateGuid,
  150. (VOID **)&WifiMgrPrivate,
  151. NULL,
  152. NULL,
  153. EFI_OPEN_PROTOCOL_GET_PROTOCOL
  154. );
  155. if (EFI_ERROR (Status)) {
  156. return EFI_UNSUPPORTED;
  157. }
  158. return LookupUnicodeString2 (
  159. Language,
  160. This->SupportedLanguages,
  161. mWifiMgrDxeControllerNameTable,
  162. ControllerName,
  163. (BOOLEAN)(This != &gWifiMgrDxeComponentName2)
  164. );
  165. }