HttpUtilitiesDxe.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /** @file
  2. The DriverEntryPoint and Unload for HttpUtilities driver.
  3. Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "HttpUtilitiesDxe.h"
  7. /**
  8. Unloads an image.
  9. @param ImageHandle Handle that identifies the image to be unloaded.
  10. @retval EFI_SUCCESS The image has been unloaded.
  11. @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
  12. **/
  13. EFI_STATUS
  14. EFIAPI
  15. HttpUtilitiesDxeUnload (
  16. IN EFI_HANDLE ImageHandle
  17. )
  18. {
  19. EFI_STATUS Status;
  20. UINTN HandleNum;
  21. EFI_HANDLE *HandleBuffer;
  22. UINT32 Index;
  23. EFI_HTTP_UTILITIES_PROTOCOL *HttpUtilitiesProtocol;
  24. HandleBuffer = NULL;
  25. //
  26. // Locate all the handles with HttpUtilities protocol.
  27. //
  28. Status = gBS->LocateHandleBuffer (
  29. ByProtocol,
  30. &gEfiHttpUtilitiesProtocolGuid,
  31. NULL,
  32. &HandleNum,
  33. &HandleBuffer
  34. );
  35. if (EFI_ERROR (Status)) {
  36. return Status;
  37. }
  38. for (Index = 0; Index < HandleNum; Index++) {
  39. //
  40. // Firstly, find HttpUtilitiesProtocol interface
  41. //
  42. Status = gBS->OpenProtocol (
  43. HandleBuffer[Index],
  44. &gEfiHttpUtilitiesProtocolGuid,
  45. (VOID **) &HttpUtilitiesProtocol,
  46. ImageHandle,
  47. NULL,
  48. EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
  49. );
  50. if (EFI_ERROR (Status)) {
  51. return Status;
  52. }
  53. //
  54. // Then, uninstall HttpUtilities interface
  55. //
  56. Status = gBS->UninstallMultipleProtocolInterfaces (
  57. HandleBuffer[Index],
  58. &gEfiHttpUtilitiesProtocolGuid, HttpUtilitiesProtocol,
  59. NULL
  60. );
  61. if (EFI_ERROR (Status)) {
  62. return Status;
  63. }
  64. }
  65. return EFI_SUCCESS;
  66. }
  67. /**
  68. This is the declaration of an EFI image entry point. This entry point is
  69. the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
  70. both device drivers and bus drivers.
  71. @param ImageHandle The firmware allocated handle for the UEFI image.
  72. @param SystemTable A pointer to the EFI System Table.
  73. @retval EFI_SUCCESS The operation completed successfully.
  74. @retval Others An unexpected error occurred.
  75. **/
  76. EFI_STATUS
  77. EFIAPI
  78. HttpUtilitiesDxeDriverEntryPoint (
  79. IN EFI_HANDLE ImageHandle,
  80. IN EFI_SYSTEM_TABLE *SystemTable
  81. )
  82. {
  83. EFI_STATUS Status;
  84. EFI_HANDLE Handle;
  85. Handle = NULL;
  86. //
  87. // Install the HttpUtilities Protocol onto Handle
  88. //
  89. Status = gBS->InstallMultipleProtocolInterfaces (
  90. &Handle,
  91. &gEfiHttpUtilitiesProtocolGuid,
  92. &mHttpUtilitiesProtocol,
  93. NULL
  94. );
  95. return Status;
  96. }