image.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. image.h
  5. Abstract:
  6. This header contains definitions for UEFI core image services.
  7. Author:
  8. Evan Green 13-Mar-2014
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // ---------------------------------------------------------------- Definitions
  15. //
  16. //
  17. // ------------------------------------------------------ Data Type Definitions
  18. //
  19. //
  20. // -------------------------------------------------------------------- Globals
  21. //
  22. //
  23. // -------------------------------------------------------- Function Prototypes
  24. //
  25. EFIAPI
  26. EFI_STATUS
  27. EfiCoreLoadImage (
  28. BOOLEAN BootPolicy,
  29. EFI_HANDLE ParentImageHandle,
  30. EFI_DEVICE_PATH_PROTOCOL *DevicePath,
  31. VOID *SourceBuffer,
  32. UINTN SourceSize,
  33. EFI_HANDLE *ImageHandle
  34. );
  35. /*++
  36. Routine Description:
  37. This routine loads an EFI image into memory.
  38. Arguments:
  39. BootPolicy - Supplies a boolean indicating that the request originates
  40. from the boot manager, and that the boot manager is attempting to load
  41. the given file path as a boot selection. This is ignored if the source
  42. buffer is NULL.
  43. ParentImageHandle - Supplies the caller's image handle.
  44. DevicePath - Supplies a pointer to the device path from which the image is
  45. loaded.
  46. SourceBuffer - Supplies an optional pointer to the memory location
  47. containing a copy of the image to be loaded.
  48. SourceSize - Supplies the size in bytes of the source buffer.
  49. ImageHandle - Supplies a pointer where the loaded image handle will be
  50. returned on success.
  51. Return Value:
  52. EFI_SUCCESS on success.
  53. EFI_NOT_FOUND if both the source buffer and device path are NULL.
  54. EFI_INVALID_PARAMETER if one or more parameters are not valid.
  55. EFI_UNSUPPORTED if the image type is unsupported.
  56. EFI_OUT_OF_RESOURCES if an allocation failed.
  57. EFI_LOAD_ERROR if the image format was corrupt or not understood.
  58. EFI_DEVICE_ERROR if the underlying device returned a read error.
  59. EFI_ACCESS_DENIED if the platform policy prohibits the image from being
  60. loaded.
  61. EFI_SECURITY_VIOLATION if the image was successfully loaded, but the
  62. platform policy indicates the image should not be started.
  63. --*/
  64. EFIAPI
  65. EFI_STATUS
  66. EfiCoreUnloadImage (
  67. EFI_HANDLE ImageHandle
  68. );
  69. /*++
  70. Routine Description:
  71. This routine unloads an image.
  72. Arguments:
  73. ImageHandle - Supplies the handle of the image to unload.
  74. ExitStatus - Supplies the exit code.
  75. ExitDataSize - Supplies the size of the exit data. This is ignored if the
  76. exit status code is EFI_SUCCESS.
  77. ExitData - Supplies an optional pointer where a pointer will be returned
  78. that includes a null-terminated string describing the reason the
  79. application exited, optionally followed by additional binary data. This
  80. buffer must be allocated from AllocatePool.
  81. Return Value:
  82. EFI_SUCCESS if the image was unloaded.
  83. EFI_INVALID_PARAMETER if the image handle is not valid.
  84. --*/
  85. EFI_STATUS
  86. EfiCoreStartImage (
  87. EFI_HANDLE ImageHandle,
  88. UINTN *ExitDataSize,
  89. CHAR16 **ExitData
  90. );
  91. /*++
  92. Routine Description:
  93. This routine transfers control to a loaded image's entry point.
  94. Arguments:
  95. ImageHandle - Supplies the handle of the image to run.
  96. ExitDataSize - Supplies a pointer to the size, in bytes, of the exit data.
  97. ExitData - Supplies an optional pointer where a pointer will be returned
  98. that includes a null-terminated string, optionally followed by
  99. additional binary data.
  100. Return Value:
  101. EFI_INVALID_PARAMETER if the image handle is invalid or the image has
  102. already been started.
  103. EFI_SECURITY_VIOLATION if the platform policy specifies the image should
  104. not be started.
  105. Otherwise, returns the exit code from the image.
  106. --*/
  107. EFIAPI
  108. EFI_STATUS
  109. EfiCoreExit (
  110. EFI_HANDLE ImageHandle,
  111. EFI_STATUS ExitStatus,
  112. UINTN ExitDataSize,
  113. CHAR16 *ExitData
  114. );
  115. /*++
  116. Routine Description:
  117. This routine terminates an loaded EFI image and returns control to boot
  118. services.
  119. Arguments:
  120. ImageHandle - Supplies the handle of the image passed upon entry.
  121. ExitStatus - Supplies the exit code.
  122. ExitDataSize - Supplies the size of the exit data. This is ignored if the
  123. exit status code is EFI_SUCCESS.
  124. ExitData - Supplies an optional pointer where a pointer will be returned
  125. that includes a null-terminated string describing the reason the
  126. application exited, optionally followed by additional binary data. This
  127. buffer must be allocated from AllocatePool.
  128. Return Value:
  129. EFI_SUCCESS if the image was unloaded.
  130. EFI_INVALID_PARAMETER if the image has been loaded and started with
  131. LoadImage and StartImage, but the image is not currently executing.
  132. --*/
  133. EFI_STATUS
  134. EfiCoreInitializeImageServices (
  135. VOID *FirmwareBaseAddress,
  136. VOID *FirmwareLowestAddress,
  137. UINTN FirmwareSize
  138. );
  139. /*++
  140. Routine Description:
  141. This routine initializes image service support for the UEFI core.
  142. Arguments:
  143. FirmwareBaseAddress - Supplies the base address where the firmware was
  144. loaded into memory. Supply -1 to indicate that the image is loaded at
  145. its preferred base address and was not relocated.
  146. FirmwareLowestAddress - Supplies the lowest address where the firmware was
  147. loaded into memory.
  148. FirmwareSize - Supplies the size of the firmware image in memory, in bytes.
  149. Return Value:
  150. EFI Status code.
  151. --*/