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