ComponentName.c 8.4 KB

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