ComponentName.c 9.2 KB

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