EmuThunk.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /** @file
  2. Emulator Thunk to abstract OS services from pure EFI code
  3. Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
  4. Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef __EMU_THUNK_PPI_H__
  8. #define __EMU_THUNK_PPI_H__
  9. #define EMU_THUNK_PPI_GUID \
  10. { 0xB958B78C, 0x1D3E, 0xEE40, { 0x8B, 0xF4, 0xF0, 0x63, 0x2D, 0x06, 0x39, 0x16 } }
  11. /*++
  12. Routine Description:
  13. This service is called from Index == 0 until it returns EFI_UNSUPPORTED.
  14. It allows discontinuous memory regions to be supported by the emulator.
  15. Arguments:
  16. Index - Which memory region to use
  17. MemoryBase - Return Base address of memory region
  18. MemorySize - Return size in bytes of the memory region
  19. Returns:
  20. EFI_SUCCESS - If memory region was mapped
  21. EFI_UNSUPPORTED - If Index is not supported
  22. **/
  23. typedef
  24. EFI_STATUS
  25. (EFIAPI *EMU_PEI_AUTOSCAN)(
  26. IN UINTN Index,
  27. OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
  28. OUT UINT64 *MemorySize
  29. );
  30. /*++
  31. Routine Description:
  32. Return the FD Size and base address. Since the FD is loaded from a
  33. file into host memory only the SEC will know it's address.
  34. Arguments:
  35. Index - Which FD, starts at zero.
  36. FdSize - Size of the FD in bytes
  37. FdBase - Start address of the FD. Assume it points to an FV Header
  38. FixUp - Difference between actual FD address and build address
  39. Returns:
  40. EFI_SUCCESS - Return the Base address and size of the FV
  41. EFI_UNSUPPORTED - Index does nto map to an FD in the system
  42. **/
  43. typedef
  44. EFI_STATUS
  45. (EFIAPI *EMU_PEI_FD_INFORMATION)(
  46. IN UINTN Index,
  47. IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
  48. IN OUT UINT64 *FdSize,
  49. IN OUT EFI_PHYSICAL_ADDRESS *FixUp
  50. );
  51. /*++
  52. Routine Description:
  53. Export of EMU_THUNK_PROTOCOL from the SEC.
  54. Returns:
  55. EFI_SUCCESS - Data returned
  56. **/
  57. typedef
  58. VOID *
  59. (EFIAPI *EMU_PEI_THUNK_INTERFACE)(
  60. VOID
  61. );
  62. /*++
  63. Routine Description:
  64. Loads and relocates a PE/COFF image into memory.
  65. Arguments:
  66. Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated
  67. ImageAddress - The base address of the relocated PE/COFF image
  68. ImageSize - The size of the relocated PE/COFF image
  69. EntryPoint - The entry point of the relocated PE/COFF image
  70. Returns:
  71. EFI_SUCCESS - The file was loaded and relocated
  72. EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file
  73. **/
  74. typedef
  75. EFI_STATUS
  76. (EFIAPI *EMU_PEI_LOAD_FILE)(
  77. VOID *Pe32Data,
  78. EFI_PHYSICAL_ADDRESS *ImageAddress,
  79. UINT64 *ImageSize,
  80. EFI_PHYSICAL_ADDRESS *EntryPoint
  81. );
  82. typedef struct {
  83. EMU_PEI_AUTOSCAN MemoryAutoScan;
  84. EMU_PEI_FD_INFORMATION FirmwareDevices;
  85. EMU_PEI_THUNK_INTERFACE Thunk;
  86. UINTN PersistentMemorySize;
  87. UINT8 PersistentMemory[0];
  88. } EMU_THUNK_PPI;
  89. extern EFI_GUID gEmuThunkPpiGuid;
  90. #endif