ComponentName.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /** @file
  2. Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #include "EmuSimpleFileSystem.h"
  6. //
  7. // EFI Component Name Functions
  8. //
  9. EFI_STATUS
  10. EFIAPI
  11. EmuSimpleFileSystemComponentNameGetDriverName (
  12. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  13. IN CHAR8 *Language,
  14. OUT CHAR16 **DriverName
  15. );
  16. EFI_STATUS
  17. EFIAPI
  18. EmuSimpleFileSystemComponentNameGetControllerName (
  19. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  20. IN EFI_HANDLE ControllerHandle,
  21. IN EFI_HANDLE ChildHandle OPTIONAL,
  22. IN CHAR8 *Language,
  23. OUT CHAR16 **ControllerName
  24. );
  25. //
  26. // EFI Component Name Protocol
  27. //
  28. GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmuSimpleFileSystemComponentName = {
  29. EmuSimpleFileSystemComponentNameGetDriverName,
  30. EmuSimpleFileSystemComponentNameGetControllerName,
  31. "eng"
  32. };
  33. GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuSimpleFileSystemComponentName2 = {
  34. (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuSimpleFileSystemComponentNameGetDriverName,
  35. (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuSimpleFileSystemComponentNameGetControllerName,
  36. "en"
  37. };
  38. EFI_UNICODE_STRING_TABLE mEmuSimpleFileSystemDriverNameTable[] = {
  39. {
  40. "eng;en",
  41. L"Emu Simple File System Driver"
  42. },
  43. {
  44. NULL,
  45. NULL
  46. }
  47. };
  48. /**
  49. Retrieves a Unicode string that is the user readable name of the driver.
  50. This function retrieves the user readable name of a driver in the form of a
  51. Unicode string. If the driver specified by This has a user readable name in
  52. the language specified by Language, then a pointer to the driver name is
  53. returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
  54. by This does not support the language specified by Language,
  55. then EFI_UNSUPPORTED is returned.
  56. @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  57. EFI_COMPONENT_NAME_PROTOCOL instance.
  58. @param Language[in] A pointer to a Null-terminated ASCII string
  59. array indicating the language. This is the
  60. language of the driver name that the caller is
  61. requesting, and it must match one of the
  62. languages specified in SupportedLanguages. The
  63. number of languages supported by a driver is up
  64. to the driver writer. Language is specified
  65. in RFC 4646 or ISO 639-2 language code format.
  66. @param DriverName[out] A pointer to the Unicode string to return.
  67. This Unicode string is the name of the
  68. driver specified by This in the language
  69. specified by Language.
  70. @retval EFI_SUCCESS The Unicode string for the Driver specified by
  71. This and the language specified by Language was
  72. returned in DriverName.
  73. @retval EFI_INVALID_PARAMETER Language is NULL.
  74. @retval EFI_INVALID_PARAMETER DriverName is NULL.
  75. @retval EFI_UNSUPPORTED The driver specified by This does not support
  76. the language specified by Language.
  77. **/
  78. EFI_STATUS
  79. EFIAPI
  80. EmuSimpleFileSystemComponentNameGetDriverName (
  81. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  82. IN CHAR8 *Language,
  83. OUT CHAR16 **DriverName
  84. )
  85. {
  86. return LookupUnicodeString2 (
  87. Language,
  88. This->SupportedLanguages,
  89. mEmuSimpleFileSystemDriverNameTable,
  90. DriverName,
  91. (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)
  92. );
  93. }
  94. /**
  95. Retrieves a Unicode string that is the user readable name of the controller
  96. that is being managed by a driver.
  97. This function retrieves the user readable name of the controller specified by
  98. ControllerHandle and ChildHandle in the form of a Unicode string. If the
  99. driver specified by This has a user readable name in the language specified by
  100. Language, then a pointer to the controller name is returned in ControllerName,
  101. and EFI_SUCCESS is returned. If the driver specified by This is not currently
  102. managing the controller specified by ControllerHandle and ChildHandle,
  103. then EFI_UNSUPPORTED is returned. If the driver specified by This does not
  104. support the language specified by Language, then EFI_UNSUPPORTED is returned.
  105. @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  106. EFI_COMPONENT_NAME_PROTOCOL instance.
  107. @param ControllerHandle[in] The handle of a controller that the driver
  108. specified by This is managing. This handle
  109. specifies the controller whose name is to be
  110. returned.
  111. @param ChildHandle[in] The handle of the child controller to retrieve
  112. the name of. This is an optional parameter that
  113. may be NULL. It will be NULL for device
  114. drivers. It will also be NULL for a bus drivers
  115. that wish to retrieve the name of the bus
  116. controller. It will not be NULL for a bus
  117. driver that wishes to retrieve the name of a
  118. child controller.
  119. @param Language[in] A pointer to a Null-terminated ASCII string
  120. array indicating the language. This is the
  121. language of the driver name that the caller is
  122. requesting, and it must match one of the
  123. languages specified in SupportedLanguages. The
  124. number of languages supported by a driver is up
  125. to the driver writer. Language is specified in
  126. RFC 4646 or ISO 639-2 language code format.
  127. @param ControllerName[out] A pointer to the Unicode string to return.
  128. This Unicode string is the name of the
  129. controller specified by ControllerHandle and
  130. ChildHandle in the language specified by
  131. Language from the point of view of the driver
  132. specified by This.
  133. @retval EFI_SUCCESS The Unicode string for the user readable name in
  134. the language specified by Language for the
  135. driver specified by This was returned in
  136. DriverName.
  137. @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
  138. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
  139. EFI_HANDLE.
  140. @retval EFI_INVALID_PARAMETER Language is NULL.
  141. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  142. @retval EFI_UNSUPPORTED The driver specified by This is not currently
  143. managing the controller specified by
  144. ControllerHandle and ChildHandle.
  145. @retval EFI_UNSUPPORTED The driver specified by This does not support
  146. the language specified by Language.
  147. **/
  148. EFI_STATUS
  149. EFIAPI
  150. EmuSimpleFileSystemComponentNameGetControllerName (
  151. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  152. IN EFI_HANDLE ControllerHandle,
  153. IN EFI_HANDLE ChildHandle OPTIONAL,
  154. IN CHAR8 *Language,
  155. OUT CHAR16 **ControllerName
  156. )
  157. {
  158. EFI_STATUS Status;
  159. EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
  160. EMU_SIMPLE_FILE_SYSTEM_PRIVATE *Private;
  161. //
  162. // This is a device driver, so ChildHandle must be NULL.
  163. //
  164. if (ChildHandle != NULL) {
  165. return EFI_UNSUPPORTED;
  166. }
  167. //
  168. // Make sure this driver is currently managing ControllerHandle
  169. //
  170. Status = EfiTestManagedDevice (
  171. ControllerHandle,
  172. gEmuSimpleFileSystemDriverBinding.DriverBindingHandle,
  173. &gEmuIoThunkProtocolGuid
  174. );
  175. if (EFI_ERROR (Status)) {
  176. return EFI_UNSUPPORTED;
  177. }
  178. //
  179. // Get our context back
  180. //
  181. Status = gBS->OpenProtocol (
  182. ControllerHandle,
  183. &gEfiSimpleFileSystemProtocolGuid,
  184. (VOID **)&SimpleFileSystem,
  185. gEmuSimpleFileSystemDriverBinding.DriverBindingHandle,
  186. ControllerHandle,
  187. EFI_OPEN_PROTOCOL_GET_PROTOCOL
  188. );
  189. if (EFI_ERROR (Status)) {
  190. return EFI_UNSUPPORTED;
  191. }
  192. Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);
  193. return LookupUnicodeString2 (
  194. Language,
  195. This->SupportedLanguages,
  196. Private->ControllerNameTable,
  197. ControllerName,
  198. (BOOLEAN)(This == &gEmuSimpleFileSystemComponentName)
  199. );
  200. }