UefiBootServicesTableLibUnitTestImage.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /** @file
  2. Implementation of image related services in the UEFI Boot Services table for use in unit tests.
  3. Copyright (c) Microsoft Corporation
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "UefiBootServicesTableLibUnitTest.h"
  7. /**
  8. Loads an EFI image into memory and returns a handle to the image.
  9. @param BootPolicy If TRUE, indicates that the request originates
  10. from the boot manager, and that the boot
  11. manager is attempting to load FilePath as a
  12. boot selection.
  13. @param ParentImageHandle The caller's image handle.
  14. @param FilePath The specific file path from which the image is
  15. loaded.
  16. @param SourceBuffer If not NULL, a pointer to the memory location
  17. containing a copy of the image to be loaded.
  18. @param SourceSize The size in bytes of SourceBuffer.
  19. @param ImageHandle Pointer to the returned image handle that is
  20. created when the image is successfully loaded.
  21. @retval EFI_SUCCESS The image was loaded into memory.
  22. @retval EFI_NOT_FOUND The FilePath was not found.
  23. @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
  24. @retval EFI_UNSUPPORTED The image type is not supported, or the device
  25. path cannot be parsed to locate the proper
  26. protocol for loading the file.
  27. @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
  28. resources.
  29. @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
  30. understood.
  31. @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
  32. @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
  33. image from being loaded. NULL is returned in *ImageHandle.
  34. @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
  35. valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
  36. platform policy specifies that the image should not be started.
  37. **/
  38. EFI_STATUS
  39. EFIAPI
  40. UnitTestLoadImage (
  41. IN BOOLEAN BootPolicy,
  42. IN EFI_HANDLE ParentImageHandle,
  43. IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
  44. IN VOID *SourceBuffer OPTIONAL,
  45. IN UINTN SourceSize,
  46. OUT EFI_HANDLE *ImageHandle
  47. )
  48. {
  49. return EFI_NOT_AVAILABLE_YET;
  50. }
  51. /**
  52. Transfer control to a loaded image's entry point.
  53. @param ImageHandle Handle of image to be started.
  54. @param ExitDataSize Pointer of the size to ExitData
  55. @param ExitData Pointer to a pointer to a data buffer that
  56. includes a Null-terminated string,
  57. optionally followed by additional binary data.
  58. The string is a description that the caller may
  59. use to further indicate the reason for the
  60. image's exit.
  61. @retval EFI_INVALID_PARAMETER Invalid parameter
  62. @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
  63. @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
  64. @retval EFI_SUCCESS Successfully transfer control to the image's
  65. entry point.
  66. **/
  67. EFI_STATUS
  68. EFIAPI
  69. UnitTestStartImage (
  70. IN EFI_HANDLE ImageHandle,
  71. OUT UINTN *ExitDataSize,
  72. OUT CHAR16 **ExitData OPTIONAL
  73. )
  74. {
  75. return EFI_NOT_AVAILABLE_YET;
  76. }
  77. /**
  78. Terminates the currently loaded EFI image and returns control to boot services.
  79. @param ImageHandle Handle that identifies the image. This
  80. parameter is passed to the image on entry.
  81. @param Status The image's exit code.
  82. @param ExitDataSize The size, in bytes, of ExitData. Ignored if
  83. ExitStatus is EFI_SUCCESS.
  84. @param ExitData Pointer to a data buffer that includes a
  85. Null-terminated Unicode string, optionally
  86. followed by additional binary data. The string
  87. is a description that the caller may use to
  88. further indicate the reason for the image's
  89. exit.
  90. @retval EFI_INVALID_PARAMETER Image handle is NULL or it is not current
  91. image.
  92. @retval EFI_SUCCESS Successfully terminates the currently loaded
  93. EFI image.
  94. @retval EFI_ACCESS_DENIED Should never reach there.
  95. @retval EFI_OUT_OF_RESOURCES Could not allocate pool
  96. **/
  97. EFI_STATUS
  98. EFIAPI
  99. UnitTestExit (
  100. IN EFI_HANDLE ImageHandle,
  101. IN EFI_STATUS Status,
  102. IN UINTN ExitDataSize,
  103. IN CHAR16 *ExitData OPTIONAL
  104. )
  105. {
  106. return EFI_NOT_AVAILABLE_YET;
  107. }
  108. /**
  109. Unloads an image.
  110. @param ImageHandle Handle that identifies the image to be
  111. unloaded.
  112. @retval EFI_SUCCESS The image has been unloaded.
  113. @retval EFI_UNSUPPORTED The image has been started, and does not support
  114. unload.
  115. @retval EFI_INVALID_PARAMPETER ImageHandle is not a valid image handle.
  116. **/
  117. EFI_STATUS
  118. EFIAPI
  119. UnitTestUnloadImage (
  120. IN EFI_HANDLE ImageHandle
  121. )
  122. {
  123. return EFI_NOT_AVAILABLE_YET;
  124. }
  125. /**
  126. Terminates all boot services.
  127. @param ImageHandle Handle that identifies the exiting image.
  128. @param MapKey Key to the latest memory map.
  129. @retval EFI_SUCCESS Boot Services terminated
  130. @retval EFI_INVALID_PARAMETER MapKey is incorrect.
  131. **/
  132. EFI_STATUS
  133. EFIAPI
  134. UnitTestExitBootServices (
  135. IN EFI_HANDLE ImageHandle,
  136. IN UINTN MapKey
  137. )
  138. {
  139. return EFI_NOT_AVAILABLE_YET;
  140. }