]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFsp2Pkg/FspSecCore/SecMain.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / IntelFsp2Pkg / FspSecCore / SecMain.h
1 /** @file
2
3 Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 **/
7
8 #ifndef _SEC_CORE_H_
9 #define _SEC_CORE_H_
10
11 #include <PiPei.h>
12 #include <Ppi/TemporaryRamSupport.h>
13
14 #include <Library/BaseLib.h>
15 #include <Library/IoLib.h>
16 #include <Library/DebugLib.h>
17 #include <Library/PcdLib.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/PciCf8Lib.h>
20 #include <Library/SerialPortLib.h>
21 #include <Library/FspSwitchStackLib.h>
22 #include <Library/FspCommonLib.h>
23 #include <Library/CpuLib.h>
24 #include <Library/UefiCpuLib.h>
25 #include <FspEas.h>
26
27 typedef
28 VOID
29 (EFIAPI *PEI_CORE_ENTRY)(
30 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
31 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
32 );
33
34 typedef struct _SEC_IDT_TABLE {
35 //
36 // Reserved 8 bytes preceding IDT to store EFI_PEI_SERVICES**, since IDT base
37 // address should be 8-byte alignment.
38 // Note: For IA32, only the 4 bytes immediately preceding IDT is used to store
39 // EFI_PEI_SERVICES**
40 //
41 UINT64 PeiService;
42 IA32_IDT_GATE_DESCRIPTOR IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)];
43 } SEC_IDT_TABLE;
44
45 /**
46 Switch the stack in the temporary memory to the one in the permanent memory.
47
48 This function must be invoked after the memory migration immediately. The relative
49 position of the stack in the temporary and permanent memory is same.
50
51 @param[in] TemporaryMemoryBase Base address of the temporary memory.
52 @param[in] PermenentMemoryBase Base address of the permanent memory.
53 **/
54 VOID
55 EFIAPI
56 SecSwitchStack (
57 IN UINTN TemporaryMemoryBase,
58 IN UINTN PermenentMemoryBase
59 );
60
61 /**
62 This service of the TEMPORARY_RAM_SUPPORT_PPI that migrates temporary RAM into
63 permanent memory.
64
65 @param[in] PeiServices Pointer to the PEI Services Table.
66 @param[in] TemporaryMemoryBase Source Address in temporary memory from which the SEC or PEIM will copy the
67 Temporary RAM contents.
68 @param[in] PermanentMemoryBase Destination Address in permanent memory into which the SEC or PEIM will copy the
69 Temporary RAM contents.
70 @param[in] CopySize Amount of memory to migrate from temporary to permanent memory.
71
72 @retval EFI_SUCCESS The data was successfully returned.
73 @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > TemporaryMemoryBase when
74 TemporaryMemoryBase > PermanentMemoryBase.
75
76 **/
77 EFI_STATUS
78 EFIAPI
79 SecTemporaryRamSupport (
80 IN CONST EFI_PEI_SERVICES **PeiServices,
81 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
82 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
83 IN UINTN CopySize
84 );
85
86 /**
87
88 Entry point to the C language phase of SEC. After the SEC assembly
89 code has initialized some temporary memory and set up the stack,
90 the control is transferred to this function.
91
92
93 @param[in] SizeOfRam Size of the temporary memory available for use.
94 @param[in] TempRamBase Base address of temporary ram
95 @param[in] BootFirmwareVolume Base address of the Boot Firmware Volume.
96 @param[in] PeiCore PeiCore entry point.
97 @param[in] BootLoaderStack BootLoader stack.
98 @param[in] ApiIdx the index of API.
99
100 @return This function never returns.
101
102 **/
103 VOID
104 EFIAPI
105 SecStartup (
106 IN UINT32 SizeOfRam,
107 IN UINT32 TempRamBase,
108 IN VOID *BootFirmwareVolume,
109 IN PEI_CORE_ENTRY PeiCore,
110 IN UINTN BootLoaderStack,
111 IN UINT32 ApiIdx
112 );
113
114 /**
115 Autogenerated function that calls the library constructors for all of the module's
116 dependent libraries. This function must be called by the SEC Core once a stack has
117 been established.
118
119 **/
120 VOID
121 EFIAPI
122 ProcessLibraryConstructorList (
123 VOID
124 );
125
126 /**
127
128 Return value of esp.
129
130 @return value of esp.
131
132 **/
133 UINTN
134 EFIAPI
135 AsmReadStackPointer (
136 VOID
137 );
138
139 #endif