ComponentName.c 6.7 KB

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