ComponentName.c 15 KB

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