PlatformFlashAccessLibNull.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /** @file
  2. Platform flash device access library NULL instance.
  3. Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiDxe.h>
  7. #include <Library/BaseMemoryLib.h>
  8. #include <Library/PlatformFlashAccessLib.h>
  9. UINT64 mInternalFdAddress;
  10. /**
  11. Perform flash write operation with progress indicator. The start and end
  12. completion percentage values are passed into this function. If the requested
  13. flash write operation is broken up, then completion percentage between the
  14. start and end values may be passed to the provided Progress function. The
  15. caller of this function is required to call the Progress function for the
  16. start and end completion percentage values. This allows the Progress,
  17. StartPercentage, and EndPercentage parameters to be ignored if the requested
  18. flash write operation can not be broken up
  19. @param[in] FirmwareType The type of firmware.
  20. @param[in] FlashAddress The address of flash device to be accessed.
  21. @param[in] FlashAddressType The type of flash device address.
  22. @param[in] Buffer The pointer to the data buffer.
  23. @param[in] Length The length of data buffer in bytes.
  24. @param[in] Progress A function used report the progress of the
  25. firmware update. This is an optional parameter
  26. that may be NULL.
  27. @param[in] StartPercentage The start completion percentage value that may
  28. be used to report progress during the flash
  29. write operation.
  30. @param[in] EndPercentage The end completion percentage value that may
  31. be used to report progress during the flash
  32. write operation.
  33. @retval EFI_SUCCESS The operation returns successfully.
  34. @retval EFI_WRITE_PROTECTED The flash device is read only.
  35. @retval EFI_UNSUPPORTED The flash device access is unsupported.
  36. @retval EFI_INVALID_PARAMETER The input parameter is not valid.
  37. **/
  38. EFI_STATUS
  39. EFIAPI
  40. PerformFlashWriteWithProgress (
  41. IN PLATFORM_FIRMWARE_TYPE FirmwareType,
  42. IN EFI_PHYSICAL_ADDRESS FlashAddress,
  43. IN FLASH_ADDRESS_TYPE FlashAddressType,
  44. IN VOID *Buffer,
  45. IN UINTN Length,
  46. IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress OPTIONAL,
  47. IN UINTN StartPercentage,
  48. IN UINTN EndPercentage
  49. )
  50. {
  51. if (FlashAddressType == FlashAddressTypeRelativeAddress) {
  52. FlashAddress = FlashAddress + mInternalFdAddress;
  53. }
  54. CopyMem ((VOID *)(UINTN)(FlashAddress), Buffer, Length);
  55. return EFI_SUCCESS;
  56. }
  57. /**
  58. Perform flash write operation.
  59. @param[in] FirmwareType The type of firmware.
  60. @param[in] FlashAddress The address of flash device to be accessed.
  61. @param[in] FlashAddressType The type of flash device address.
  62. @param[in] Buffer The pointer to the data buffer.
  63. @param[in] Length The length of data buffer in bytes.
  64. @retval EFI_SUCCESS The operation returns successfully.
  65. @retval EFI_WRITE_PROTECTED The flash device is read only.
  66. @retval EFI_UNSUPPORTED The flash device access is unsupported.
  67. @retval EFI_INVALID_PARAMETER The input parameter is not valid.
  68. **/
  69. EFI_STATUS
  70. EFIAPI
  71. PerformFlashWrite (
  72. IN PLATFORM_FIRMWARE_TYPE FirmwareType,
  73. IN EFI_PHYSICAL_ADDRESS FlashAddress,
  74. IN FLASH_ADDRESS_TYPE FlashAddressType,
  75. IN VOID *Buffer,
  76. IN UINTN Length
  77. )
  78. {
  79. return PerformFlashWriteWithProgress (
  80. FirmwareType,
  81. FlashAddress,
  82. FlashAddressType,
  83. Buffer,
  84. Length,
  85. NULL,
  86. 0,
  87. 0
  88. );
  89. }