]>
git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/DxeIpl/DxeInit.c
3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include "LegacyTable.h"
24 #include "HobGeneration.h"
25 #include "PpisNeededByDxeCore.h"
29 --------------------------------------------------------
30 Memory Map: (XX=32,64)
31 --------------------------------------------------------
41 EfiLdr (relocate by efiXX.COM)
43 Efivar.bin (Load by StartXX.COM)
45 StartXX.COM (E820 table, Temporary GDT, Temporary IDT)
47 EfiXX.COM (Temporary Interrupt Handler)
49 EfiLdr.efi + DxeIpl.Z + DxeMain.Z + BFV.Z
51 MemoryFreeUnder1M (For legacy driver DMA)
53 Temporary 4G PageTable for X64 (6 page)
66 MemoryAbove1MB.PhysicalStart <-----------------------------------------------------+
69 <- Phit.EfiMemoryBottom -------------------+ |
71 <- Phit.EfiFreeMemoryBottom | |
72 | MemoryFreeAbove1MB.ResourceLength
73 <- Phit.EfiFreeMemoryTop ------+ | |
74 MemoryDescriptor (For ACPINVS, ACPIReclaim) | 4M = CONSUMED_MEMORY |
76 Permament 4G PageTable for IA32 or MemoryAllocation | |
77 Permament 64G PageTable for X64 | | |
78 <------------------------------+ | |
79 Permament Stack (0x20 Pages = 128K) | |
80 <- Phit.EfiMemoryTop ----------+-----------+---------------+
84 <----------------------------------------------------------+
88 <- Top of Free Memory reported by E820 --------------------+
92 <- Memory Top on RealMemory
96 MemoryFreeAbove4G.Physicalstart <--------------------------------------------------+
99 MemoryFreeAbove4GB.ResourceLength
102 <--------------------------------------------------+
108 IN VOID
*DxeCoreEntryPoint
,
115 IN EFILDRHANDOFF
*Handoff
121 This is the entry point after this code has been loaded into memory.
128 Calls into EFI Firmware
135 VOID
*MemoryTopOnDescriptor
;
136 VOID
*MemoryDescriptor
;
138 CHAR8 PrintBuffer
[256];
140 PrintString("Enter DxeIpl ...\n");
143 PrintString("handoff:\n");
144 PrintString("Handoff.BfvBase = ");
145 PrintValue64((UINT64)(UINTN)Handoff->BfvBase);
147 PrintString("BfvLength = ");
148 PrintValue64(Handoff->BfvSize);
150 PrintString("Handoff.DxeIplImageBase = ");
151 PrintValue64((UINT64)(UINTN)Handoff->DxeIplImageBase);
153 PrintString("DxeIplImageSize = ");
154 PrintValue64(Handoff->DxeIplImageSize);
156 PrintString("Handoff.DxeCoreImageBase = ");
157 PrintValue64((UINT64)(UINTN)Handoff->DxeCoreImageBase);
159 PrintString("DxeCoreImageSize = ");
160 PrintValue64(Handoff->DxeCoreImageSize);
164 // Hob Generation Guild line:
165 // * Don't report FV as physical memory
166 // * MemoryAllocation Hob should only cover physical memory
167 // * Use ResourceDescriptor Hob to report physical memory or Firmware Device and they shouldn't be overlapped
173 PrepareHobBfv (Handoff
->BfvBase
, Handoff
->BfvSize
);
176 // 2. Updates Memory information, and get the top free address under 4GB
178 MemoryTopOnDescriptor
= PrepareHobMemory (Handoff
->MemDescCount
, Handoff
->MemDesc
);
181 // 3. Put [NV], [Stack], [PageTable], [MemDesc], [HOB] just below the [top free address under 4GB]
185 NvStorageBase
= PrepareHobNvStorage (MemoryTopOnDescriptor
);
186 AsciiSPrint (PrintBuffer
, 256, "NV Storage Base=0x%x\n", (UINTN
)NvStorageBase
);
187 PrintString (PrintBuffer
);
190 StackTop
= NvStorageBase
;
191 StackBottom
= PrepareHobStack (StackTop
);
192 AsciiSPrint (PrintBuffer
, 256, "Stack Top=0x%x, Stack Bottom=0x%x\n",
193 (UINTN
)StackTop
, (UINTN
)StackBottom
);
194 PrintString (PrintBuffer
);
196 PageTableBase
= PreparePageTable (StackBottom
, gHob
->Cpu
.SizeOfMemorySpace
);
197 // 3.4 MemDesc (will be used in PlatformBds)
198 MemoryDescriptor
= PrepareHobMemoryDescriptor (PageTableBase
, Handoff
->MemDescCount
, Handoff
->MemDesc
);
199 // 3.5 Copy the Hob itself to EfiMemoryBottom, and update the PHIT Hob
200 PrepareHobPhit (StackTop
, MemoryDescriptor
);
203 // 4. Register the memory occupied by DxeCore and DxeIpl together as DxeCore
206 Handoff
->DxeCoreEntryPoint
,
207 (EFI_PHYSICAL_ADDRESS
)(UINTN
)Handoff
->DxeCoreImageBase
,
208 (UINTN
)Handoff
->DxeIplImageBase
+ (UINTN
)Handoff
->DxeIplImageSize
- (UINTN
)Handoff
->DxeCoreImageBase
211 PrepareHobLegacyTable (gHob
);
212 PreparePpisNeededByDxeCore (gHob
);
214 CompleteHobGeneration ();
216 AsciiSPrint (PrintBuffer
, 256, "HobStart=0x%x\n", (UINTN
)gHob
);
217 PrintString (PrintBuffer
);
219 AsciiSPrint (PrintBuffer
, 256, "Memory Top=0x%x, Bottom=0x%x\n",
220 (UINTN
)gHob
->Phit
.EfiMemoryTop
, (UINTN
)gHob
->Phit
.EfiMemoryBottom
);
221 PrintString (PrintBuffer
);
223 AsciiSPrint (PrintBuffer
, 256, "Free Memory Top=0x%x, Bottom=0x%x\n",
224 (UINTN
)gHob
->Phit
.EfiFreeMemoryTop
, (UINTN
)gHob
->Phit
.EfiFreeMemoryBottom
);
225 PrintString (PrintBuffer
);
227 AsciiSPrint (PrintBuffer
, 256, "Nv Base=0x%x, Length=0x%x\n",
228 (UINTN
)gHob
->NvStorageFvb
.FvbInfo
.Entries
[0].Base
,
229 (UINTN
)gHob
->NvFtwFvb
.FvbInfo
.Entries
[0].Length
);
230 PrintString (PrintBuffer
);
236 PrintString("Hob Info\n");
237 PrintString("Phit.EfiMemoryTop = ");
238 PrintValue64(gHob->Phit.EfiMemoryTop);
239 PrintString(" Phit.EfiMemoryBottom = ");
240 PrintValue64(gHob->Phit.EfiMemoryBottom);
242 PrintString("Phit.EfiFreeMemoryTop = ");
243 PrintValue64(gHob->Phit.EfiFreeMemoryTop);
244 PrintString(" Phit.EfiFreeMemoryBottom = ");
245 PrintValue64(gHob->Phit.EfiFreeMemoryBottom);
247 PrintString("Bfv = ");
248 PrintValue64(gHob->Bfv.BaseAddress);
249 PrintString(" BfvLength = ");
250 PrintValue64(gHob->Bfv.Length);
252 PrintString("NvStorageFvb = ");
253 PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Base);
254 PrintString(" Length = ");
255 PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Length);
257 PrintString("NvFtwFvb = ");
258 PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Base);
259 PrintString(" Length = ");
260 PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Length);
262 PrintString("Stack = ");
263 PrintValue64(gHob->Stack.AllocDescriptor.MemoryBaseAddress);
264 PrintString(" StackLength = ");
265 PrintValue64(gHob->Stack.AllocDescriptor.MemoryLength);
267 PrintString("MemoryFreeUnder1MB = ");
268 PrintValue64(gHob->MemoryFreeUnder1MB.PhysicalStart);
269 PrintString(" MemoryFreeUnder1MBLength = ");
270 PrintValue64(gHob->MemoryFreeUnder1MB.ResourceLength);
272 PrintString("MemoryAbove1MB = ");
273 PrintValue64(gHob->MemoryAbove1MB.PhysicalStart);
274 PrintString(" MemoryAbove1MBLength = ");
275 PrintValue64(gHob->MemoryAbove1MB.ResourceLength);
277 PrintString("MemoryAbove4GB = ");
278 PrintValue64(gHob->MemoryAbove4GB.PhysicalStart);
279 PrintString(" MemoryAbove4GBLength = ");
280 PrintValue64(gHob->MemoryAbove4GB.ResourceLength);
282 PrintString("DxeCore = ");
283 PrintValue64(gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress);
284 PrintString(" DxeCoreLength = ");
285 PrintValue64(gHob->DxeCore.MemoryAllocationHeader.MemoryLength);
287 PrintString("MemoryAllocation = ");
288 PrintValue64(gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress);
289 PrintString(" MemoryLength = ");
290 PrintValue64(gHob->MemoryAllocation.AllocDescriptor.MemoryLength);
295 PrintString("\n\n\n\n\n\n\n\n\n\n");
296 PrintString(" WELCOME TO EFI WORLD!\n");
299 EnterDxeMain (StackTop
, Handoff
->DxeCoreEntryPoint
, gHob
, PageTableBase
);
302 // Should never get here