1 | /** @file
|
---|
2 |
|
---|
3 | Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
|
---|
4 |
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef __UEFI_PAYLOAD_ENTRY_H__
|
---|
10 | #define __UEFI_PAYLOAD_ENTRY_H__
|
---|
11 |
|
---|
12 | #include <PiPei.h>
|
---|
13 |
|
---|
14 | #include <Library/BaseLib.h>
|
---|
15 | #include <Library/BaseMemoryLib.h>
|
---|
16 | #include <Library/MemoryAllocationLib.h>
|
---|
17 | #include <Library/DebugLib.h>
|
---|
18 | #include <Library/PeCoffLib.h>
|
---|
19 | #include <Library/HobLib.h>
|
---|
20 | #include <Library/PcdLib.h>
|
---|
21 | #include <Guid/MemoryAllocationHob.h>
|
---|
22 | #include <Library/IoLib.h>
|
---|
23 | #include <Library/PeCoffLib.h>
|
---|
24 | #include <Library/BlParseLib.h>
|
---|
25 | #include <Library/PlatformSupportLib.h>
|
---|
26 | #include <Library/CpuLib.h>
|
---|
27 | #include <IndustryStandard/Acpi.h>
|
---|
28 | #include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
|
---|
29 | #include <Guid/SerialPortInfoGuid.h>
|
---|
30 | #include <Guid/MemoryMapInfoGuid.h>
|
---|
31 | #include <Guid/AcpiBoardInfoGuid.h>
|
---|
32 | #include <Guid/GraphicsInfoHob.h>
|
---|
33 | #include <UniversalPayload/SmbiosTable.h>
|
---|
34 | #include <UniversalPayload/AcpiTable.h>
|
---|
35 | #include <UniversalPayload/UniversalPayload.h>
|
---|
36 | #include <UniversalPayload/ExtraData.h>
|
---|
37 | #include <UniversalPayload/SerialPortInfo.h>
|
---|
38 | #include <Guid/PcdDataBaseSignatureGuid.h>
|
---|
39 |
|
---|
40 | #define LEGACY_8259_MASK_REGISTER_MASTER 0x21
|
---|
41 | #define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
|
---|
42 | #define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
|
---|
43 | ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))
|
---|
44 |
|
---|
45 | #define E820_RAM 1
|
---|
46 | #define E820_RESERVED 2
|
---|
47 | #define E820_ACPI 3
|
---|
48 | #define E820_NVS 4
|
---|
49 | #define E820_UNUSABLE 5
|
---|
50 | #define E820_DISABLED 6
|
---|
51 | #define E820_PMEM 7
|
---|
52 | #define E820_UNDEFINED 8
|
---|
53 |
|
---|
54 | /**
|
---|
55 | Add a new HOB to the HOB List.
|
---|
56 |
|
---|
57 | @param HobType Type of the new HOB.
|
---|
58 | @param HobLength Length of the new HOB to allocate.
|
---|
59 |
|
---|
60 | @return NULL if there is no space to create a hob.
|
---|
61 | @return The address point to the new created hob.
|
---|
62 |
|
---|
63 | **/
|
---|
64 | VOID *
|
---|
65 | EFIAPI
|
---|
66 | CreateHob (
|
---|
67 | IN UINT16 HobType,
|
---|
68 | IN UINT16 HobLength
|
---|
69 | );
|
---|
70 |
|
---|
71 | /**
|
---|
72 | Update the Stack Hob if the stack has been moved
|
---|
73 |
|
---|
74 | @param BaseAddress The 64 bit physical address of the Stack.
|
---|
75 | @param Length The length of the stack in bytes.
|
---|
76 |
|
---|
77 | **/
|
---|
78 | VOID
|
---|
79 | EFIAPI
|
---|
80 | UpdateStackHob (
|
---|
81 | IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
---|
82 | IN UINT64 Length
|
---|
83 | );
|
---|
84 |
|
---|
85 | /**
|
---|
86 | Build a Handoff Information Table HOB
|
---|
87 |
|
---|
88 | This function initialize a HOB region from EfiMemoryBegin to
|
---|
89 | EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
|
---|
90 | be inside the HOB region.
|
---|
91 |
|
---|
92 | @param[in] EfiMemoryBottom Total memory start address
|
---|
93 | @param[in] EfiMemoryTop Total memory end address.
|
---|
94 | @param[in] EfiFreeMemoryBottom Free memory start address
|
---|
95 | @param[in] EfiFreeMemoryTop Free memory end address.
|
---|
96 |
|
---|
97 | @return The pointer to the handoff HOB table.
|
---|
98 |
|
---|
99 | **/
|
---|
100 | EFI_HOB_HANDOFF_INFO_TABLE *
|
---|
101 | EFIAPI
|
---|
102 | HobConstructor (
|
---|
103 | IN VOID *EfiMemoryBottom,
|
---|
104 | IN VOID *EfiMemoryTop,
|
---|
105 | IN VOID *EfiFreeMemoryBottom,
|
---|
106 | IN VOID *EfiFreeMemoryTop
|
---|
107 | );
|
---|
108 |
|
---|
109 | /**
|
---|
110 | Find DXE core from FV and build DXE core HOBs.
|
---|
111 |
|
---|
112 | @param[out] DxeCoreEntryPoint DXE core entry point
|
---|
113 |
|
---|
114 | @retval EFI_SUCCESS If it completed successfully.
|
---|
115 | @retval EFI_NOT_FOUND If it failed to load DXE FV.
|
---|
116 | **/
|
---|
117 | EFI_STATUS
|
---|
118 | LoadDxeCore (
|
---|
119 | OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint
|
---|
120 | );
|
---|
121 |
|
---|
122 | /**
|
---|
123 | Find DXE core from FV and build DXE core HOBs.
|
---|
124 |
|
---|
125 | @param[in] DxeFv The FV where to find the DXE core.
|
---|
126 | @param[out] DxeCoreEntryPoint DXE core entry point
|
---|
127 |
|
---|
128 | @retval EFI_SUCCESS If it completed successfully.
|
---|
129 | @retval EFI_NOT_FOUND If it failed to load DXE FV.
|
---|
130 | **/
|
---|
131 | EFI_STATUS
|
---|
132 | UniversalLoadDxeCore (
|
---|
133 | IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
|
---|
134 | OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint
|
---|
135 | );
|
---|
136 |
|
---|
137 | /**
|
---|
138 | Transfers control to DxeCore.
|
---|
139 |
|
---|
140 | This function performs a CPU architecture specific operations to execute
|
---|
141 | the entry point of DxeCore with the parameters of HobList.
|
---|
142 |
|
---|
143 | @param DxeCoreEntryPoint The entry point of DxeCore.
|
---|
144 | @param HobList The start of HobList passed to DxeCore.
|
---|
145 | **/
|
---|
146 | VOID
|
---|
147 | HandOffToDxeCore (
|
---|
148 | IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
|
---|
149 | IN EFI_PEI_HOB_POINTERS HobList
|
---|
150 | );
|
---|
151 |
|
---|
152 | EFI_STATUS
|
---|
153 | FixUpPcdDatabase (
|
---|
154 | IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv
|
---|
155 | );
|
---|
156 |
|
---|
157 | /**
|
---|
158 | This function searchs a given section type within a valid FFS file.
|
---|
159 |
|
---|
160 | @param FileHeader A pointer to the file header that contains the set of sections to
|
---|
161 | be searched.
|
---|
162 | @param SearchType The value of the section type to search.
|
---|
163 | @param SectionData A pointer to the discovered section, if successful.
|
---|
164 |
|
---|
165 | @retval EFI_SUCCESS The section was found.
|
---|
166 | @retval EFI_NOT_FOUND The section was not found.
|
---|
167 |
|
---|
168 | **/
|
---|
169 | EFI_STATUS
|
---|
170 | FileFindSection (
|
---|
171 | IN EFI_FFS_FILE_HEADER *FileHeader,
|
---|
172 | IN EFI_SECTION_TYPE SectionType,
|
---|
173 | OUT VOID **SectionData
|
---|
174 | );
|
---|
175 |
|
---|
176 | /**
|
---|
177 | This function searchs a given file type with a given Guid within a valid FV.
|
---|
178 | If input Guid is NULL, will locate the first section having the given file type
|
---|
179 |
|
---|
180 | @param FvHeader A pointer to firmware volume header that contains the set of files
|
---|
181 | to be searched.
|
---|
182 | @param FileType File type to be searched.
|
---|
183 | @param Guid Will ignore if it is NULL.
|
---|
184 | @param FileHeader A pointer to the discovered file, if successful.
|
---|
185 |
|
---|
186 | @retval EFI_SUCCESS Successfully found FileType
|
---|
187 | @retval EFI_NOT_FOUND File type can't be found.
|
---|
188 | **/
|
---|
189 | EFI_STATUS
|
---|
190 | FvFindFileByTypeGuid (
|
---|
191 | IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader,
|
---|
192 | IN EFI_FV_FILETYPE FileType,
|
---|
193 | IN EFI_GUID *Guid OPTIONAL,
|
---|
194 | OUT EFI_FFS_FILE_HEADER **FileHeader
|
---|
195 | );
|
---|
196 |
|
---|
197 | /**
|
---|
198 | Build ACPI board info HOB using infomation from ACPI table
|
---|
199 |
|
---|
200 | @param AcpiTableBase ACPI table start address in memory
|
---|
201 |
|
---|
202 | @retval A pointer to ACPI board HOB ACPI_BOARD_INFO. Null if build HOB failure.
|
---|
203 | **/
|
---|
204 | ACPI_BOARD_INFO *
|
---|
205 | BuildHobFromAcpi (
|
---|
206 | IN UINT64 AcpiTableBase
|
---|
207 | );
|
---|
208 |
|
---|
209 | #endif
|
---|