ComponentName.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /** @file
  2. UEFI Component Name(2) protocol implementation.
  3. Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "Ax88772.h"
  7. /**
  8. EFI Component Name Protocol declaration
  9. **/
  10. GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
  11. GetDriverName,
  12. GetControllerName,
  13. "eng"
  14. };
  15. /**
  16. EFI Component Name 2 Protocol declaration
  17. **/
  18. GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
  19. (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) GetDriverName,
  20. (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) GetControllerName,
  21. "en"
  22. };
  23. /**
  24. Driver name table declaration
  25. **/
  26. GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
  27. mDriverNameTable[] = {
  28. {"eng;en", L"AX88772 Ethernet Driver"},
  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 [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  40. EFI_COMPONENT_NAME_PROTOCOL instance.
  41. @param [in] pLanguage 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 3066 or ISO 639-2 language code format.
  49. @param [out] ppDriverName 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. GetDriverName (
  64. IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
  65. IN CHAR8 * pLanguage,
  66. OUT CHAR16 ** ppDriverName
  67. )
  68. {
  69. EFI_STATUS Status;
  70. DBG_ENTER ( );
  71. Status = LookupUnicodeString2 (
  72. pLanguage,
  73. pThis->SupportedLanguages,
  74. mDriverNameTable,
  75. ppDriverName,
  76. (BOOLEAN)(pThis == &gComponentName)
  77. );
  78. DBG_EXIT_HEX ( Status );
  79. return Status;
  80. }
  81. /**
  82. Retrieves a Unicode string that is the user readable name of the controller
  83. that is being managed by a driver.
  84. This function retrieves the user readable name of the controller specified by
  85. ControllerHandle and ChildHandle in the form of a Unicode string. If the
  86. driver specified by This has a user readable name in the language specified by
  87. Language, then a pointer to the controller name is returned in ControllerName,
  88. and EFI_SUCCESS is returned. If the driver specified by This is not currently
  89. managing the controller specified by ControllerHandle and ChildHandle,
  90. then EFI_UNSUPPORTED is returned. If the driver specified by This does not
  91. support the language specified by Language, then EFI_UNSUPPORTED is returned.
  92. @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
  93. EFI_COMPONENT_NAME_PROTOCOL instance.
  94. @param [in] ControllerHandle The handle of a controller that the driver
  95. specified by This is managing. This handle
  96. specifies the controller whose name is to be
  97. returned.
  98. @param [in] ChildHandle The handle of the child controller to retrieve
  99. the name of. This is an optional parameter that
  100. may be NULL. It will be NULL for device
  101. drivers. It will also be NULL for a bus drivers
  102. that wish to retrieve the name of the bus
  103. controller. It will not be NULL for a bus
  104. driver that wishes to retrieve the name of a
  105. child controller.
  106. @param [in] pLanguage A pointer to a Null-terminated ASCII string
  107. array indicating the language. This is the
  108. language of the driver name that the caller is
  109. requesting, and it must match one of the
  110. languages specified in SupportedLanguages. The
  111. number of languages supported by a driver is up
  112. to the driver writer. Language is specified in
  113. RFC 3066 or ISO 639-2 language code format.
  114. @param [out] ppControllerName A pointer to the Unicode string to return.
  115. This Unicode string is the name of the
  116. controller specified by ControllerHandle and
  117. ChildHandle in the language specified by
  118. Language from the point of view of the driver
  119. specified by This.
  120. @retval EFI_SUCCESS The Unicode string for the user readable name in
  121. the language specified by Language for the
  122. driver specified by This was returned in
  123. DriverName.
  124. @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
  125. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
  126. EFI_HANDLE.
  127. @retval EFI_INVALID_PARAMETER Language is NULL.
  128. @retval EFI_INVALID_PARAMETER ControllerName is NULL.
  129. @retval EFI_UNSUPPORTED The driver specified by This is not currently
  130. managing the controller specified by
  131. ControllerHandle and ChildHandle.
  132. @retval EFI_UNSUPPORTED The driver specified by This does not support
  133. the language specified by Language.
  134. **/
  135. EFI_STATUS
  136. EFIAPI
  137. GetControllerName (
  138. IN EFI_COMPONENT_NAME_PROTOCOL * pThis,
  139. IN EFI_HANDLE ControllerHandle,
  140. IN OPTIONAL EFI_HANDLE ChildHandle,
  141. IN CHAR8 * pLanguage,
  142. OUT CHAR16 ** ppControllerName
  143. )
  144. {
  145. EFI_STATUS Status;
  146. DBG_ENTER ( );
  147. //
  148. // Set the controller name
  149. //
  150. *ppControllerName = L"AX88772 10/100 Ethernet";
  151. Status = EFI_SUCCESS;
  152. //
  153. // Return the operation status
  154. //
  155. DBG_EXIT_HEX ( Status );
  156. return Status;
  157. }