HttpBootComponentName.c 6.8 KB

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