ComponentName.c 15 KB

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