EmuThunk.h 2.9 KB

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