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