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