ComponentName.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /** @file
  2. Install Base and Size Info Ppi for Firmware Volume Recovery.
  3. Copyright (c) 2013 - 2019 Intel Corporation. All rights reserved. <BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "SioDriver.h"
  7. ///
  8. /// Component Name Protocol instance
  9. ///
  10. GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL mSioComponentName = {
  11. SioComponentNameGetDriverName,
  12. SioComponentNameGetControllerName,
  13. "eng"
  14. };
  15. ///
  16. /// Component Name 2 Protocol instance
  17. ///
  18. GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL mSioComponentName2 = {
  19. (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SioComponentNameGetDriverName,
  20. (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)SioComponentNameGetControllerName,
  21. "en"
  22. };
  23. ///
  24. /// Table of driver names
  25. ///
  26. GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSioDriverNameTable[] = {
  27. {
  28. "eng;en",
  29. L"Super I/O Driver"
  30. },
  31. {
  32. NULL,
  33. NULL
  34. }
  35. };
  36. ///
  37. /// Table of Controller names
  38. ///
  39. GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSioControllerNameTable[] = {
  40. {
  41. "eng;en",
  42. L"Super I/O Controller"
  43. },
  44. {
  45. NULL,
  46. NULL
  47. }
  48. };
  49. /**
  50. Retrieves a Unicode string that is the user-readable name of the EFI 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 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. SioComponentNameGetDriverName (
  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. mSioDriverNameTable,
  80. DriverName,
  81. (BOOLEAN)(This == &mSioComponentName)
  82. );
  83. }
  84. /**
  85. Retrieves a Unicode string that is the user readable name of the controller
  86. that is being managed by an EFI 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 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 specified
  106. by Language, from the point of view of the driver specified
  107. 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 NULL.
  112. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
  113. @retval EFI_INVALID_PARAMETER Language is NULL.
  114. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  115. @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
  116. the controller specified by ControllerHandle and
  117. ChildHandle.
  118. @retval EFI_UNSUPPORTED The driver specified by This does not support the
  119. language specified by Language.
  120. **/
  121. EFI_STATUS
  122. EFIAPI
  123. SioComponentNameGetControllerName (
  124. IN EFI_COMPONENT_NAME_PROTOCOL *This,
  125. IN EFI_HANDLE ControllerHandle,
  126. IN EFI_HANDLE ChildHandle OPTIONAL,
  127. IN CHAR8 *Language,
  128. OUT CHAR16 **ControllerName
  129. )
  130. {
  131. EFI_STATUS Status;
  132. //
  133. // Make sure this driver is currently managing ControllHandle
  134. //
  135. Status = EfiTestManagedDevice (
  136. ControllerHandle,
  137. mSioDriver.DriverBindingHandle,
  138. &gEfiPciIoProtocolGuid
  139. );
  140. if (EFI_ERROR (Status)) {
  141. return Status;
  142. }
  143. //
  144. // ChildHandle must be NULL for a Device Driver
  145. //
  146. if (ChildHandle != NULL) {
  147. return EFI_UNSUPPORTED;
  148. }
  149. return LookupUnicodeString2 (
  150. Language,
  151. This->SupportedLanguages,
  152. mSioControllerNameTable,
  153. ControllerName,
  154. (BOOLEAN)(This == &mSioComponentName)
  155. );
  156. }