HttpUtilitiesDxe.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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,
  59. HttpUtilitiesProtocol,
  60. NULL
  61. );
  62. if (EFI_ERROR (Status)) {
  63. return Status;
  64. }
  65. }
  66. return EFI_SUCCESS;
  67. }
  68. /**
  69. This is the declaration of an EFI image entry point. This entry point is
  70. the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
  71. both device drivers and bus drivers.
  72. @param ImageHandle The firmware allocated handle for the UEFI image.
  73. @param SystemTable A pointer to the EFI System Table.
  74. @retval EFI_SUCCESS The operation completed successfully.
  75. @retval Others An unexpected error occurred.
  76. **/
  77. EFI_STATUS
  78. EFIAPI
  79. HttpUtilitiesDxeDriverEntryPoint (
  80. IN EFI_HANDLE ImageHandle,
  81. IN EFI_SYSTEM_TABLE *SystemTable
  82. )
  83. {
  84. EFI_STATUS Status;
  85. EFI_HANDLE Handle;
  86. Handle = NULL;
  87. //
  88. // Install the HttpUtilities Protocol onto Handle
  89. //
  90. Status = gBS->InstallMultipleProtocolInterfaces (
  91. &Handle,
  92. &gEfiHttpUtilitiesProtocolGuid,
  93. &mHttpUtilitiesProtocol,
  94. NULL
  95. );
  96. return Status;
  97. }