]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Protocol/PeCoffImageEmulator.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Include / Protocol / PeCoffImageEmulator.h
1 /** @file
2 Copyright (c) 2019, Linaro, Ltd. All rights reserved.<BR>
3 SPDX-License-Identifier: BSD-2-Clause-Patent
4
5 **/
6
7 #ifndef _PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H_
8 #define _PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID_H_
9
10 #define EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL_GUID \
11 { 0x96F46153, 0x97A7, 0x4793, { 0xAC, 0xC1, 0xFA, 0x19, 0xBF, 0x78, 0xEA, 0x97 } }
12
13 typedef struct _EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL;
14
15 /**
16 Check whether the emulator supports executing a certain PE/COFF image
17
18 @param[in] This This pointer for EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL
19 structure
20 @param[in] ImageType Whether the image is an application, a boot time
21 driver or a runtime driver.
22 @param[in] DevicePath Path to device where the image originated
23 (e.g., a PCI option ROM)
24
25 @retval TRUE The image is supported by the emulator
26 @retval FALSE The image is not supported by the emulator.
27 **/
28 typedef
29 BOOLEAN
30 (EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED)(
31 IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
32 IN UINT16 ImageType,
33 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL
34 );
35
36 /**
37 Register a supported PE/COFF image with the emulator. After this call
38 completes successfully, the PE/COFF image may be started as usual, and
39 it is the responsibility of the emulator implementation that any branch
40 into the code section of the image (including returns from functions called
41 from the foreign code) is executed as if it were running on the machine
42 type it was built for.
43
44 @param[in] This This pointer for
45 EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL structure
46 @param[in] ImageBase The base address in memory of the PE/COFF image
47 @param[in] ImageSize The size in memory of the PE/COFF image
48 @param[in,out] EntryPoint The entry point of the PE/COFF image. Passed by
49 reference so that the emulator may modify it.
50
51 @retval EFI_SUCCESS The image was registered with the emulator and
52 can be started as usual.
53 @retval other The image could not be registered.
54
55 If the PE/COFF machine type or image type are not supported by the emulator,
56 then ASSERT().
57 **/
58 typedef
59 EFI_STATUS
60 (EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE)(
61 IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
62 IN EFI_PHYSICAL_ADDRESS ImageBase,
63 IN UINT64 ImageSize,
64 IN OUT EFI_IMAGE_ENTRY_POINT *EntryPoint
65 );
66
67 /**
68 Unregister a PE/COFF image that has been registered with the emulator.
69 This should be done before the image is unloaded from memory.
70
71 @param[in] This This pointer for EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL
72 structure
73 @param[in] ImageBase The base address in memory of the PE/COFF image
74
75 @retval EFI_SUCCESS The image was unregistered with the emulator.
76 @retval other Image could not be unloaded.
77 **/
78 typedef
79 EFI_STATUS
80 (EFIAPI *EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGE)(
81 IN EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *This,
82 IN EFI_PHYSICAL_ADDRESS ImageBase
83 );
84
85 #define EDKII_PECOFF_IMAGE_EMULATOR_VERSION 0x1
86
87 typedef struct _EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL {
88 EDKII_PECOFF_IMAGE_EMULATOR_IS_IMAGE_SUPPORTED IsImageSupported;
89 EDKII_PECOFF_IMAGE_EMULATOR_REGISTER_IMAGE RegisterImage;
90 EDKII_PECOFF_IMAGE_EMULATOR_UNREGISTER_IMAGE UnregisterImage;
91
92 // Protocol version implemented by the emulator
93 UINT32 Version;
94 // The machine type implemented by the emulator
95 UINT16 MachineType;
96 } EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL;
97
98 extern EFI_GUID gEdkiiPeCoffImageEmulatorProtocolGuid;
99
100 #endif