ComponentName.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /** @file
  2. Copyright (c) 2010, Apple, Inc. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. Module Name:
  5. ComponentName.c
  6. Abstract:
  7. -**/
  8. #include "EmuSnpDxe.h"
  9. //
  10. // EFI Component Name Functions
  11. //
  12. /**
  13. Retrieves a Unicode string that is the user readable name of the driver.
  14. This function retrieves the user readable name of a driver in the form of a
  15. Unicode string. If the driver specified by This has a user readable name in
  16. the language specified by Language, then a pointer to the driver name is
  17. returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
  18. by This does not support the language specified by Language,
  19. then EFI_UNSUPPORTED is returned.
  20. @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  21. EFI_COMPONENT_NAME_PROTOCOL instance.
  22. @param Language[in] A pointer to a Null-terminated ASCII string
  23. array indicating the language. This is the
  24. language of the driver name that the caller is
  25. requesting, and it must match one of the
  26. languages specified in SupportedLanguages. The
  27. number of languages supported by a driver is up
  28. to the driver writer. Language is specified
  29. in RFC 4646 or ISO 639-2 language code format.
  30. @param DriverName[out] A pointer to the Unicode string to return.
  31. This Unicode string is the name of the
  32. driver specified by This in the language
  33. specified by Language.
  34. @retval EFI_SUCCESS The Unicode string for the Driver specified by
  35. This and the language specified by Language was
  36. returned in DriverName.
  37. @retval EFI_INVALID_PARAMETER Language is NULL.
  38. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  39. @retval EFI_UNSUPPORTED The driver specified by This does not support
  40. the language specified by Language.
  41. **/
  42. EFI_STATUS
  43. EFIAPI
  44. EmuSnpDriverComponentNameGetDriverName (
  45. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  46. IN CHAR8 *Language,
  47. OUT CHAR16 **DriverName
  48. );
  49. /**
  50. Retrieves a Unicode string that is the user readable name of the controller
  51. that is being managed by a driver.
  52. This function retrieves the user readable name of the controller specified by
  53. ControllerHandle and ChildHandle in the form of a Unicode string. If the
  54. driver specified by This has a user readable name in the language specified by
  55. Language, then a pointer to the controller name is returned in ControllerName,
  56. and EFI_SUCCESS is returned. If the driver specified by This is not currently
  57. managing the controller specified by ControllerHandle and ChildHandle,
  58. then EFI_UNSUPPORTED is returned. If the driver specified by This does not
  59. support the language specified by Language, then EFI_UNSUPPORTED is returned.
  60. @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  61. EFI_COMPONENT_NAME_PROTOCOL instance.
  62. @param ControllerHandle[in] The handle of a controller that the driver
  63. specified by This is managing. This handle
  64. specifies the controller whose name is to be
  65. returned.
  66. @param ChildHandle[in] The handle of the child controller to retrieve
  67. the name of. This is an optional parameter that
  68. may be NULL. It will be NULL for device
  69. drivers. It will also be NULL for a bus drivers
  70. that wish to retrieve the name of the bus
  71. controller. It will not be NULL for a bus
  72. driver that wishes to retrieve the name of a
  73. child controller.
  74. @param Language[in] A pointer to a Null-terminated ASCII string
  75. array indicating the language. This is the
  76. language of the driver name that the caller is
  77. requesting, and it must match one of the
  78. languages specified in SupportedLanguages. The
  79. number of languages supported by a driver is up
  80. to the driver writer. Language is specified in
  81. RFC 4646 or ISO 639-2 language code format.
  82. @param ControllerName[out] A pointer to the Unicode string to return.
  83. This Unicode string is the name of the
  84. controller specified by ControllerHandle and
  85. ChildHandle in the language specified by
  86. Language from the point of view of the driver
  87. specified by This.
  88. @retval EFI_SUCCESS The Unicode string for the user readable name in
  89. the language specified by Language for the
  90. driver specified by This was returned in
  91. DriverName.
  92. @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
  93. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
  94. EFI_HANDLE.
  95. @retval EFI_INVALID_PARAMETER Language is NULL.
  96. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  97. @retval EFI_UNSUPPORTED The driver specified by This is not currently
  98. managing the controller specified by
  99. ControllerHandle and ChildHandle.
  100. @retval EFI_UNSUPPORTED The driver specified by This does not support
  101. the language specified by Language.
  102. **/
  103. EFI_STATUS
  104. EFIAPI
  105. EmuSnpDriverComponentNameGetControllerName (
  106. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  107. IN EFI_HANDLE ControllerHandle,
  108. IN EFI_HANDLE ChildHandle OPTIONAL,
  109. IN CHAR8 *Language,
  110. OUT CHAR16 **ControllerName
  111. );
  112. //
  113. // EFI Component Name Protocol
  114. //
  115. GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuSnpDriverComponentName = {
  116. EmuSnpDriverComponentNameGetDriverName,
  117. EmuSnpDriverComponentNameGetControllerName,
  118. "eng"
  119. };
  120. //
  121. // EFI Component Name 2 Protocol
  122. //
  123. GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSnpDriverComponentName2 = {
  124. (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuSnpDriverComponentNameGetDriverName,
  125. (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuSnpDriverComponentNameGetControllerName,
  126. "en"
  127. };
  128. GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmuSnpDriverNameTable[] = {
  129. {
  130. "eng;en",
  131. L"Emu SNP Driver"
  132. },
  133. {
  134. NULL,
  135. NULL
  136. }
  137. };
  138. /**
  139. Retrieves a Unicode string that is the user readable name of the driver.
  140. This function retrieves the user readable name of a driver in the form of a
  141. Unicode string. If the driver specified by This has a user readable name in
  142. the language specified by Language, then a pointer to the driver name is
  143. returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
  144. by This does not support the language specified by Language,
  145. then EFI_UNSUPPORTED is returned.
  146. @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  147. EFI_COMPONENT_NAME_PROTOCOL instance.
  148. @param Language[in] A pointer to a Null-terminated ASCII string
  149. array indicating the language. This is the
  150. language of the driver name that the caller is
  151. requesting, and it must match one of the
  152. languages specified in SupportedLanguages. The
  153. number of languages supported by a driver is up
  154. to the driver writer. Language is specified
  155. in RFC 4646 or ISO 639-2 language code format.
  156. @param DriverName[out] A pointer to the Unicode string to return.
  157. This Unicode string is the name of the
  158. driver specified by This in the language
  159. specified by Language.
  160. @retval EFI_SUCCESS The Unicode string for the Driver specified by
  161. This and the language specified by Language was
  162. returned in DriverName.
  163. @retval EFI_INVALID_PARAMETER Language is NULL.
  164. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  165. @retval EFI_UNSUPPORTED The driver specified by This does not support
  166. the language specified by Language.
  167. **/
  168. EFI_STATUS
  169. EFIAPI
  170. EmuSnpDriverComponentNameGetDriverName (
  171. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  172. IN CHAR8 *Language,
  173. OUT CHAR16 **DriverName
  174. )
  175. {
  176. return LookupUnicodeString2 (
  177. Language,
  178. This->SupportedLanguages,
  179. mEmuSnpDriverNameTable,
  180. DriverName,
  181. (BOOLEAN)(This == &gEmuSnpDriverComponentName)
  182. );
  183. }
  184. /**
  185. Retrieves a Unicode string that is the user readable name of the controller
  186. that is being managed by a driver.
  187. This function retrieves the user readable name of the controller specified by
  188. ControllerHandle and ChildHandle in the form of a Unicode string. If the
  189. driver specified by This has a user readable name in the language specified by
  190. Language, then a pointer to the controller name is returned in ControllerName,
  191. and EFI_SUCCESS is returned. If the driver specified by This is not currently
  192. managing the controller specified by ControllerHandle and ChildHandle,
  193. then EFI_UNSUPPORTED is returned. If the driver specified by This does not
  194. support the language specified by Language, then EFI_UNSUPPORTED is returned.
  195. @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  196. EFI_COMPONENT_NAME_PROTOCOL instance.
  197. @param ControllerHandle[in] The handle of a controller that the driver
  198. specified by This is managing. This handle
  199. specifies the controller whose name is to be
  200. returned.
  201. @param ChildHandle[in] The handle of the child controller to retrieve
  202. the name of. This is an optional parameter that
  203. may be NULL. It will be NULL for device
  204. drivers. It will also be NULL for a bus drivers
  205. that wish to retrieve the name of the bus
  206. controller. It will not be NULL for a bus
  207. driver that wishes to retrieve the name of a
  208. child controller.
  209. @param Language[in] A pointer to a Null-terminated ASCII string
  210. array indicating the language. This is the
  211. language of the driver name that the caller is
  212. requesting, and it must match one of the
  213. languages specified in SupportedLanguages. The
  214. number of languages supported by a driver is up
  215. to the driver writer. Language is specified in
  216. RFC 4646 or ISO 639-2 language code format.
  217. @param ControllerName[out] A pointer to the Unicode string to return.
  218. This Unicode string is the name of the
  219. controller specified by ControllerHandle and
  220. ChildHandle in the language specified by
  221. Language from the point of view of the driver
  222. specified by This.
  223. @retval EFI_SUCCESS The Unicode string for the user readable name in
  224. the language specified by Language for the
  225. driver specified by This was returned in
  226. DriverName.
  227. @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
  228. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
  229. EFI_HANDLE.
  230. @retval EFI_INVALID_PARAMETER Language is NULL.
  231. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  232. @retval EFI_UNSUPPORTED The driver specified by This is not currently
  233. managing the controller specified by
  234. ControllerHandle and ChildHandle.
  235. @retval EFI_UNSUPPORTED The driver specified by This does not support
  236. the language specified by Language.
  237. **/
  238. EFI_STATUS
  239. EFIAPI
  240. EmuSnpDriverComponentNameGetControllerName (
  241. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  242. IN EFI_HANDLE ControllerHandle,
  243. IN EFI_HANDLE ChildHandle OPTIONAL,
  244. IN CHAR8 *Language,
  245. OUT CHAR16 **ControllerName
  246. )
  247. {
  248. return EFI_UNSUPPORTED;
  249. }