TlsAuthConfigDxe.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /** @file
  2. The DriverEntryPoint for TlsAuthConfigDxe driver.
  3. Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "TlsAuthConfigImpl.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. TlsAuthConfigDxeUnload (
  16. IN EFI_HANDLE ImageHandle
  17. )
  18. {
  19. EFI_STATUS Status;
  20. TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData;
  21. Status = gBS->HandleProtocol (
  22. ImageHandle,
  23. &gEfiCallerIdGuid,
  24. (VOID **)&PrivateData
  25. );
  26. if (EFI_ERROR (Status)) {
  27. return Status;
  28. }
  29. ASSERT (PrivateData->Signature == TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE);
  30. gBS->UninstallMultipleProtocolInterfaces (
  31. ImageHandle,
  32. &gEfiCallerIdGuid,
  33. PrivateData,
  34. NULL
  35. );
  36. TlsAuthConfigFormUnload (PrivateData);
  37. return EFI_SUCCESS;
  38. }
  39. /**
  40. This is the declaration of an EFI image entry point. This entry point is
  41. the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
  42. both device drivers and bus drivers.
  43. @param ImageHandle The firmware allocated handle for the UEFI image.
  44. @param SystemTable A pointer to the EFI System Table.
  45. @retval EFI_SUCCESS The operation completed successfully.
  46. @retval Others An unexpected error occurred.
  47. **/
  48. EFI_STATUS
  49. EFIAPI
  50. TlsAuthConfigDxeDriverEntryPoint (
  51. IN EFI_HANDLE ImageHandle,
  52. IN EFI_SYSTEM_TABLE *SystemTable
  53. )
  54. {
  55. EFI_STATUS Status;
  56. TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData;
  57. PrivateData = NULL;
  58. //
  59. // If already started, return.
  60. //
  61. Status = gBS->OpenProtocol (
  62. ImageHandle,
  63. &gEfiCallerIdGuid,
  64. NULL,
  65. ImageHandle,
  66. ImageHandle,
  67. EFI_OPEN_PROTOCOL_TEST_PROTOCOL
  68. );
  69. if (!EFI_ERROR (Status)) {
  70. return EFI_ALREADY_STARTED;
  71. }
  72. //
  73. // Initialize the private data structure.
  74. //
  75. PrivateData = AllocateZeroPool (sizeof (TLS_AUTH_CONFIG_PRIVATE_DATA));
  76. if (PrivateData == NULL) {
  77. return EFI_OUT_OF_RESOURCES;
  78. }
  79. //
  80. // Initialize the HII configuration form.
  81. //
  82. Status = TlsAuthConfigFormInit (PrivateData);
  83. if (EFI_ERROR (Status)) {
  84. goto ON_ERROR;
  85. }
  86. //
  87. // Install private GUID.
  88. //
  89. Status = gBS->InstallMultipleProtocolInterfaces (
  90. &ImageHandle,
  91. &gEfiCallerIdGuid,
  92. PrivateData,
  93. NULL
  94. );
  95. if (EFI_ERROR (Status)) {
  96. goto ON_ERROR;
  97. }
  98. return EFI_SUCCESS;
  99. ON_ERROR:
  100. TlsAuthConfigFormUnload (PrivateData);
  101. return Status;
  102. }