ComponentName.c 11 KB

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