IioUdsDataDxe.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /** @file
  2. Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. //
  6. // Statements that include other files
  7. //
  8. #include "IioUdsDataDxe.h"
  9. #define STRING_WIDTH_40 40
  10. //
  11. // Instantiation of Driver's private data.
  12. //
  13. EFI_IIO_UDS_DRIVER_PRIVATE mIioUdsPrivateData;
  14. IIO_UDS *IioUdsData; // Pointer to UDS in Allocated Memory Pool
  15. /**
  16. Entry point for the driver.
  17. @param ImageHandle - Image Handle.
  18. @param SystemTable - EFI System Table.
  19. @retval EFI_SUCCESS - Function has completed successfully.
  20. **/
  21. EFI_STATUS
  22. EFIAPI
  23. IioUdsDataInit (
  24. IN EFI_HANDLE ImageHandle,
  25. IN EFI_SYSTEM_TABLE *SystemTable
  26. )
  27. {
  28. EFI_STATUS Status;
  29. EFI_HOB_GUID_TYPE *GuidHob;
  30. IIO_UDS *UdsHobPtr;
  31. EFI_GUID UniversalDataGuid = IIO_UNIVERSAL_DATA_GUID;
  32. //
  33. // Time to get the IIO_UDS HOB data stored in the PEI driver
  34. //
  35. GuidHob = GetFirstGuidHob (&UniversalDataGuid);
  36. ASSERT (GuidHob != NULL);
  37. if (GuidHob == NULL) {
  38. return EFI_NOT_FOUND;
  39. }
  40. UdsHobPtr = GET_GUID_HOB_DATA(GuidHob);
  41. //
  42. // Allocate Memory Pool for Universal Data Storage so that protocol can expose it
  43. //
  44. Status = gBS->AllocatePool ( EfiReservedMemoryType, sizeof (IIO_UDS), (VOID **) &IioUdsData );
  45. ASSERT_EFI_ERROR (Status);
  46. //
  47. // Initialize the Pool Memory with the data from the Hand-Off-Block
  48. //
  49. CopyMem(IioUdsData, UdsHobPtr, sizeof(IIO_UDS));
  50. //
  51. // Build the IIO_UDS driver instance for protocol publishing
  52. //
  53. ZeroMem (&mIioUdsPrivateData, sizeof (mIioUdsPrivateData));
  54. mIioUdsPrivateData.Signature = EFI_IIO_UDS_DRIVER_PRIVATE_SIGNATURE;
  55. mIioUdsPrivateData.IioUds.IioUdsPtr = IioUdsData;
  56. mIioUdsPrivateData.IioUds.EnableVc = NULL;
  57. //
  58. // Install the IioUds Protocol.
  59. //
  60. Status = gBS->InstallMultipleProtocolInterfaces (
  61. &mIioUdsPrivateData.Handle,
  62. &gEfiIioUdsProtocolGuid,
  63. &mIioUdsPrivateData.IioUds,
  64. NULL
  65. );
  66. ASSERT_EFI_ERROR (Status);
  67. return EFI_SUCCESS;
  68. }