]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/DxeIpl/DxeInit.c
Regenerate Fat binaries for the bug fix of LookupUnicodeString2() in UefiLib (r4655).
[mirror_edk2.git] / DuetPkg / DxeIpl / DxeInit.c
CommitLineData
ca162103 1/*++\r
2\r
3Copyright (c) 2006 - 2007, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13 DxeInit.c\r
14\r
15Abstract:\r
16\r
17Revision History:\r
18\r
19--*/\r
20\r
21#include "DxeIpl.h"\r
22\r
23#include "LegacyTable.h"\r
24#include "HobGeneration.h"\r
25#include "PpisNeededByDxeCore.h"\r
26#include "Debug.h"\r
27\r
28/*\r
29--------------------------------------------------------\r
30 Memory Map: (XX=32,64)\r
31--------------------------------------------------------\r
320x0\r
33 IVT\r
340x400\r
35 BDA\r
360x500\r
37\r
380x7C00\r
39 BootSector\r
400x10000\r
41 EfiLdr (relocate by efiXX.COM)\r
420x15000\r
43 Efivar.bin (Load by StartXX.COM)\r
440x20000\r
45 StartXX.COM (E820 table, Temporary GDT, Temporary IDT)\r
460x21000\r
47 EfiXX.COM (Temporary Interrupt Handler)\r
480x22000\r
49 EfiLdr.efi + DxeIpl.Z + DxeMain.Z + BFV.Z\r
500x86000\r
51 MemoryFreeUnder1M (For legacy driver DMA)\r
520x90000\r
53 Temporary 4G PageTable for X64 (6 page)\r
540x9F800\r
55 EBDA\r
560xA0000\r
57 VGA\r
580xC0000\r
59 OPROM\r
600xE0000\r
61 FIRMEWARE\r
620x100000 (1M)\r
63 Temporary Stack (1M)\r
640x200000\r
65\r
66MemoryAbove1MB.PhysicalStart <-----------------------------------------------------+\r
67 ... |\r
68 ... |\r
69 <- Phit.EfiMemoryBottom -------------------+ |\r
70 HOB | |\r
71 <- Phit.EfiFreeMemoryBottom | |\r
72 | MemoryFreeAbove1MB.ResourceLength\r
73 <- Phit.EfiFreeMemoryTop ------+ | |\r
74 MemoryDescriptor (For ACPINVS, ACPIReclaim) | 4M = CONSUMED_MEMORY |\r
75 | | |\r
76 Permament 4G PageTable for IA32 or MemoryAllocation | |\r
77 Permament 64G PageTable for X64 | | |\r
78 <------------------------------+ | |\r
79 Permament Stack (0x20 Pages = 128K) | |\r
80 <- Phit.EfiMemoryTop ----------+-----------+---------------+\r
81 DxeCore |\r
82 DxeCore\r
83 DxeIpl |\r
84 <----------------------------------------------------------+\r
85 NvFV + FtwFV |\r
86 MMIO\r
87 BFV |\r
88 <- Top of Free Memory reported by E820 --------------------+\r
89 ACPINVS or\r
90 ACPIReclaim or\r
91 Reserved\r
92 <- Memory Top on RealMemory\r
93\r
940x100000000 (4G)\r
95\r
96MemoryFreeAbove4G.Physicalstart <--------------------------------------------------+\r
97 |\r
98 |\r
99 MemoryFreeAbove4GB.ResourceLength\r
100 |\r
101 |\r
102 <--------------------------------------------------+\r
103*/\r
104\r
105VOID\r
106EnterDxeMain (\r
107 IN VOID *StackTop,\r
108 IN VOID *DxeCoreEntryPoint,\r
109 IN VOID *Hob,\r
110 IN VOID *PageTable\r
111 );\r
112\r
113VOID\r
114DxeInit (\r
115 IN EFILDRHANDOFF *Handoff\r
116 )\r
117/*++\r
118\r
119 Routine Description:\r
120\r
121 This is the entry point after this code has been loaded into memory. \r
122\r
123Arguments:\r
124\r
125\r
126Returns:\r
127\r
128 Calls into EFI Firmware\r
129\r
130--*/\r
131{\r
132 VOID *StackTop;\r
133 VOID *StackBottom;\r
134 VOID *PageTableBase;\r
135 VOID *MemoryTopOnDescriptor;\r
136 VOID *MemoryDescriptor;\r
137 VOID *NvStorageBase;\r
138\r
139/*\r
140 ClearScreen();\r
141 PrintString("handoff:\n");\r
142 PrintString("Handoff.BfvBase = "); \r
143 PrintValue64((UINT64)(UINTN)Handoff->BfvBase);\r
144 PrintString(", "); \r
145 PrintString("BfvLength = "); \r
146 PrintValue64(Handoff->BfvSize);\r
147 PrintString("\n"); \r
148 PrintString("Handoff.DxeIplImageBase = "); \r
149 PrintValue64((UINT64)(UINTN)Handoff->DxeIplImageBase);\r
150 PrintString(", "); \r
151 PrintString("DxeIplImageSize = "); \r
152 PrintValue64(Handoff->DxeIplImageSize);\r
153 PrintString("\n"); \r
154 PrintString("Handoff.DxeCoreImageBase = "); \r
155 PrintValue64((UINT64)(UINTN)Handoff->DxeCoreImageBase);\r
156 PrintString(", "); \r
157 PrintString("DxeCoreImageSize = "); \r
158 PrintValue64(Handoff->DxeCoreImageSize);\r
159 PrintString("\n"); \r
160*/\r
161 //\r
162 // Hob Generation Guild line:\r
163 // * Don't report FV as physical memory\r
164 // * MemoryAllocation Hob should only cover physical memory\r
165 // * Use ResourceDescriptor Hob to report physical memory or Firmware Device and they shouldn't be overlapped\r
166 \r
167 PrepareHobCpu ();\r
168 //\r
169 // 1. BFV\r
170 //\r
171 PrepareHobBfv (Handoff->BfvBase, Handoff->BfvSize);\r
172\r
173 //\r
174 // 2. Updates Memory information, and get the top free address under 4GB\r
175 //\r
176 MemoryTopOnDescriptor = PrepareHobMemory (Handoff->MemDescCount, Handoff->MemDesc);\r
177\r
178 //\r
179 // 3. Put [NV], [Stack], [PageTable], [MemDesc], [HOB] just below the [top free address under 4GB]\r
180 //\r
181 \r
182 // 3.1 NV data\r
183 NvStorageBase = PrepareHobNvStorage (MemoryTopOnDescriptor);\r
184 // 3.2 Stack\r
185 StackTop = NvStorageBase;\r
186 StackBottom = PrepareHobStack (StackTop);\r
187 // 3.3 Page Table\r
188 PageTableBase = PreparePageTable (StackBottom, gHob->Cpu.SizeOfMemorySpace);\r
189 // 3.4 MemDesc (will be used in PlatformBds)\r
190 MemoryDescriptor = PrepareHobMemoryDescriptor (PageTableBase, Handoff->MemDescCount, Handoff->MemDesc);\r
191 // 3.5 Copy the Hob itself to EfiMemoryBottom, and update the PHIT Hob\r
192 PrepareHobPhit (StackTop, MemoryDescriptor);\r
193\r
194 //\r
195 // 4. Register the memory occupied by DxeCore and DxeIpl together as DxeCore\r
196 //\r
197 PrepareHobDxeCore (\r
198 Handoff->DxeCoreEntryPoint,\r
199 (EFI_PHYSICAL_ADDRESS)(UINTN)Handoff->DxeCoreImageBase,\r
200 (UINTN)Handoff->DxeIplImageBase + (UINTN)Handoff->DxeIplImageSize - (UINTN)Handoff->DxeCoreImageBase\r
201 );\r
202\r
203 PrepareHobLegacyTable (gHob);\r
204 PreparePpisNeededByDxeCore (gHob);\r
205\r
206 CompleteHobGeneration ();\r
207\r
208/*\r
209 //\r
210 // Print Hob Info\r
211 //\r
212 ClearScreen();\r
213 PrintString("Hob Info\n");\r
214 PrintString("Phit.EfiMemoryTop = "); \r
215 PrintValue64(gHob->Phit.EfiMemoryTop);\r
216 PrintString(" Phit.EfiMemoryBottom = "); \r
217 PrintValue64(gHob->Phit.EfiMemoryBottom);\r
218 PrintString("\n"); \r
219 PrintString("Phit.EfiFreeMemoryTop = "); \r
220 PrintValue64(gHob->Phit.EfiFreeMemoryTop);\r
221 PrintString(" Phit.EfiFreeMemoryBottom = "); \r
222 PrintValue64(gHob->Phit.EfiFreeMemoryBottom);\r
223 PrintString("\n"); \r
224 PrintString("Bfv = "); \r
225 PrintValue64(gHob->Bfv.BaseAddress);\r
226 PrintString(" BfvLength = "); \r
227 PrintValue64(gHob->Bfv.Length);\r
228 PrintString("\n");\r
229 PrintString("NvStorageFvb = ");\r
230 PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Base);\r
231 PrintString(" Length = ");\r
232 PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Length);\r
233 PrintString("\n");\r
234 PrintString("NvFtwFvb = ");\r
235 PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Base);\r
236 PrintString(" Length = ");\r
237 PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Length);\r
238 PrintString("\n");\r
239 PrintString("Stack = "); \r
240 PrintValue64(gHob->Stack.AllocDescriptor.MemoryBaseAddress);\r
241 PrintString(" StackLength = "); \r
242 PrintValue64(gHob->Stack.AllocDescriptor.MemoryLength);\r
243 PrintString("\n"); \r
244 PrintString("MemoryFreeUnder1MB = "); \r
245 PrintValue64(gHob->MemoryFreeUnder1MB.PhysicalStart);\r
246 PrintString(" MemoryFreeUnder1MBLength = "); \r
247 PrintValue64(gHob->MemoryFreeUnder1MB.ResourceLength);\r
248 PrintString("\n"); \r
249 PrintString("MemoryAbove1MB = "); \r
250 PrintValue64(gHob->MemoryAbove1MB.PhysicalStart);\r
251 PrintString(" MemoryAbove1MBLength = "); \r
252 PrintValue64(gHob->MemoryAbove1MB.ResourceLength);\r
253 PrintString("\n"); \r
254 PrintString("MemoryAbove4GB = "); \r
255 PrintValue64(gHob->MemoryAbove4GB.PhysicalStart);\r
256 PrintString(" MemoryAbove4GBLength = "); \r
257 PrintValue64(gHob->MemoryAbove4GB.ResourceLength);\r
258 PrintString("\n"); \r
259 PrintString("DxeCore = "); \r
260 PrintValue64(gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress);\r
261 PrintString(" DxeCoreLength = "); \r
262 PrintValue64(gHob->DxeCore.MemoryAllocationHeader.MemoryLength);\r
263 PrintString("\n"); \r
264 PrintString("MemoryAllocation = "); \r
265 PrintValue64(gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress);\r
266 PrintString(" MemoryLength = "); \r
267 PrintValue64(gHob->MemoryAllocation.AllocDescriptor.MemoryLength);\r
268 PrintString("\n"); \r
269 EFI_DEADLOOP();\r
270*/\r
271\r
272 ClearScreen();\r
273 PrintString("\n\n\n\n\n\n\n\n\n\n");\r
274 PrintString(" WELCOME TO EFI WORLD!\n");\r
275\r
276 EnterDxeMain (StackTop, Handoff->DxeCoreEntryPoint, gHob, PageTableBase);\r
277\r
278 //\r
279 // Should never get here\r
280 //\r
281 CpuDeadLoop ();\r
282}\r
283\r