ComponentName.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /** @file
  2. Implementation of EFI_COMPONENT_NAME_PROTOCOL and EFI_COMPONENT_NAME2_PROTOCOL protocol.
  3. for EFI Refish Discover Protocol
  4. (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include "RedfishDiscoverInternal.h"
  8. //
  9. // EFI Component Name Functions
  10. //
  11. /**
  12. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
  13. @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
  14. @param[in] Language A pointer to a three-character ISO 639-2 language identifier.
  15. This is the language of the driver name that that the caller
  16. is requesting, and it must match one of the languages specified
  17. in SupportedLanguages. The number of languages supported by a
  18. driver is up to the driver writer.
  19. @param[out] DriverName A pointer to the Unicode string to return. This Unicode string
  20. is the name of the driver specified by This in the language
  21. specified by Language.
  22. @retval EFI_SUCCESS The Unicode string for the Driver specified by This
  23. and the language specified by Language was returned
  24. in DriverName.
  25. @retval EFI_INVALID_PARAMETER Language is NULL.
  26. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  27. @retval EFI_UNSUPPORTED The driver specified by This does not support the
  28. language specified by Language.
  29. **/
  30. EFI_STATUS
  31. EFIAPI
  32. RedfishDiscoverComponentNameGetDriverName (
  33. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  34. IN CHAR8 *Language,
  35. OUT CHAR16 **DriverName
  36. );
  37. /**
  38. Retrieves a Unicode string that is the user readable name of the controller
  39. that is being managed by an EFI Driver.
  40. @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
  41. @param[in] ControllerHandle The handle of a controller that the driver specified by
  42. This is managing. This handle specifies the controller
  43. whose name is to be returned.
  44. @param[in] ChildHandle The handle of the child controller to retrieve the name
  45. of. This is an optional parameter that may be NULL. It
  46. will be NULL for device drivers. It will also be NULL
  47. for a bus drivers that wish to retrieve the name of the
  48. bus controller. It will not be NULL for a bus driver
  49. that wishes to retrieve the name of a child controller.
  50. @param[in] Language A pointer to a three character ISO 639-2 language
  51. identifier. This is the language of the controller name
  52. that the caller is requesting, and it must match one
  53. of the languages specified in SupportedLanguages. The
  54. number of languages supported by a driver is up to the
  55. driver writer.
  56. @param[out] ControllerName A pointer to the Unicode string to return. This Unicode
  57. string is the name of the controller specified by
  58. ControllerHandle and ChildHandle in the language specified
  59. by Language, from the point of view of the driver specified
  60. by This.
  61. @retval EFI_SUCCESS The Unicode string for the user-readable name in the
  62. language specified by Language for the driver
  63. specified by This was returned in DriverName.
  64. @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
  65. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
  66. @retval EFI_INVALID_PARAMETER Language is NULL.
  67. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  68. @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
  69. the controller specified by ControllerHandle and
  70. ChildHandle.
  71. @retval EFI_UNSUPPORTED The driver specified by This does not support the
  72. language specified by Language.
  73. **/
  74. EFI_STATUS
  75. EFIAPI
  76. RedfishDiscoverComponentNameGetControllerName (
  77. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  78. IN EFI_HANDLE ControllerHandle,
  79. IN EFI_HANDLE ChildHandle OPTIONAL,
  80. IN CHAR8 *Language,
  81. OUT CHAR16 **ControllerName
  82. );
  83. ///
  84. /// Component Name Protocol instance
  85. ///
  86. GLOBAL_REMOVE_IF_UNREFERENCED
  87. EFI_COMPONENT_NAME_PROTOCOL gRedfishDiscoverComponentName = {
  88. RedfishDiscoverComponentNameGetDriverName,
  89. RedfishDiscoverComponentNameGetControllerName,
  90. "eng"
  91. };
  92. ///
  93. /// Component Name 2 Protocol instance
  94. ///
  95. GLOBAL_REMOVE_IF_UNREFERENCED
  96. EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2 = {
  97. (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)RedfishDiscoverComponentNameGetDriverName,
  98. (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)RedfishDiscoverComponentNameGetControllerName,
  99. "en"
  100. };
  101. ///
  102. /// Table of driver names
  103. ///
  104. GLOBAL_REMOVE_IF_UNREFERENCED
  105. EFI_UNICODE_STRING_TABLE mRedfishDiscoverDriverNameTable[] = {
  106. { "eng;en", (CHAR16 *)L"Redfish Discover UEFI Driver" },
  107. { NULL, NULL }
  108. };
  109. GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gRedfishDiscoverControllerNameTable = NULL;
  110. /**
  111. Retrieves a Unicode string that is the user-readable name of the EFI Driver.
  112. @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
  113. @param[in] Language A pointer to a three-character ISO 639-2 language identifier.
  114. This is the language of the driver name that that the caller
  115. is requesting, and it must match one of the languages specified
  116. in SupportedLanguages. The number of languages supported by a
  117. driver is up to the driver writer.
  118. @param[out] DriverName A pointer to the Unicode string to return. This Unicode string
  119. is the name of the driver specified by This in the language
  120. specified by Language.
  121. @retval EFI_SUCCESS The Unicode string for the Driver specified by This
  122. and the language specified by Language was returned
  123. in DriverName.
  124. @retval EFI_INVALID_PARAMETER Language is NULL.
  125. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  126. @retval EFI_UNSUPPORTED The driver specified by This does not support the
  127. language specified by Language.
  128. **/
  129. EFI_STATUS
  130. EFIAPI
  131. RedfishDiscoverComponentNameGetDriverName (
  132. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  133. IN CHAR8 *Language,
  134. OUT CHAR16 **DriverName
  135. )
  136. {
  137. return LookupUnicodeString2 (
  138. Language,
  139. This->SupportedLanguages,
  140. mRedfishDiscoverDriverNameTable,
  141. DriverName,
  142. (BOOLEAN)(This == &gRedfishDiscoverComponentName)
  143. );
  144. }
  145. /**
  146. Retrieves a Unicode string that is the user readable name of the controller
  147. that is being managed by an EFI Driver.
  148. @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
  149. @param[in] ControllerHandle The handle of a controller that the driver specified by
  150. This is managing. This handle specifies the controller
  151. whose name is to be returned.
  152. @param[in] ChildHandle The handle of the child controller to retrieve the name
  153. of. This is an optional parameter that may be NULL. It
  154. will be NULL for device drivers. It will also be NULL
  155. for a bus drivers that wish to retrieve the name of the
  156. bus controller. It will not be NULL for a bus driver
  157. that wishes to retrieve the name of a child controller.
  158. @param[in] Language A pointer to a three character ISO 639-2 language
  159. identifier. This is the language of the controller name
  160. that the caller is requesting, and it must match one
  161. of the languages specified in SupportedLanguages. The
  162. number of languages supported by a driver is up to the
  163. driver writer.
  164. @param[out] ControllerName A pointer to the Unicode string to return. This Unicode
  165. string is the name of the controller specified by
  166. ControllerHandle and ChildHandle in the language specified
  167. by Language, from the point of view of the driver specified
  168. by This.
  169. @retval EFI_SUCCESS The Unicode string for the user-readable name in the
  170. language specified by Language for the driver
  171. specified by This was returned in DriverName.
  172. @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
  173. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
  174. @retval EFI_INVALID_PARAMETER Language is NULL.
  175. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  176. @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
  177. the controller specified by ControllerHandle and
  178. ChildHandle.
  179. @retval EFI_UNSUPPORTED The driver specified by This does not support the
  180. language specified by Language.
  181. **/
  182. EFI_STATUS
  183. EFIAPI
  184. RedfishDiscoverComponentNameGetControllerName (
  185. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  186. IN EFI_HANDLE ControllerHandle,
  187. IN EFI_HANDLE ChildHandle OPTIONAL,
  188. IN CHAR8 *Language,
  189. OUT CHAR16 **ControllerName
  190. )
  191. {
  192. return EFI_UNSUPPORTED;
  193. }