ComponentName.c 8.4 KB

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