ComponentName.c 6.6 KB

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