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