Change DUET DxeIpl to use SerialPort instead of manipulating serial port directly.

Signed-off-by: niruiyu
Reviewed-by: jyao1

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11876 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
niruiyu 2011-06-23 08:31:18 +00:00
parent f6bd06633d
commit b68b78e66c
15 changed files with 180 additions and 574 deletions

View File

@ -24,7 +24,6 @@
################################################################################ ################################################################################
[FV.DuetEfiMainFv] [FV.DuetEfiMainFv]
BlockSize = 0x10000 BlockSize = 0x10000
NumBlocks = 0x2a
FvAlignment = 16 #FV alignment and FV attributes setting. FvAlignment = 16 #FV alignment and FV attributes setting.
ERASE_POLARITY = 1 ERASE_POLARITY = 1
MEMORY_MAPPED = TRUE MEMORY_MAPPED = TRUE

View File

@ -98,7 +98,8 @@
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
# #

View File

@ -98,7 +98,8 @@
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
# #

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -19,6 +19,7 @@ Revision History:
**/ **/
#include "DxeIpl.h" #include "DxeIpl.h"
#include <Library/SerialPortLib.h>
#include "SerialStatusCode.h" #include "SerialStatusCode.h"
#include "Debug.h" #include "Debug.h"
@ -50,51 +51,25 @@ ClearScreen (
mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160); mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);
} }
VOID
PrintValue (
UINT32 Value
)
{
UINT32 Index;
CHAR8 Char;
CHAR8 String[9];
for (Index = 0; Index < 8; Index++) {
Char = (UINT8)(((Value >> ((7 - Index) * 4)) & 0x0f) + '0');
if (Char > '9') {
Char = (UINT8) (Char - '0' - 10 + 'A');
}
String[Index] = Char;
}
String[sizeof (String) - 1] = '\0';
PrintString (String);
}
VOID
PrintValue64 (
UINT64 Value
)
{
PrintValue ((UINT32) RShiftU64 (Value, 32));
PrintValue ((UINT32) Value);
}
VOID VOID
PrintString ( PrintString (
CHAR8 *String IN CONST CHAR8 *FormatString,
...
) )
{ {
UINT32 Index; UINTN Index;
CHAR8 PrintBuffer[1000];
VA_LIST Marker;
for (Index = 0; String[Index] != 0; Index++) { VA_START (Marker, FormatString);
if (String[Index] == '\n') { AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);
mCursor = (UINT8 *)(UINTN)(0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160)); VA_END (Marker);
for (Index = 0; PrintBuffer[Index] != 0; Index++) {
if (PrintBuffer[Index] == '\n') {
mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));
} else { } else {
*mCursor = String[Index]; *mCursor = (UINT8) PrintBuffer[Index];
mCursor += 2; mCursor += 2;
} }
} }
@ -102,6 +77,6 @@ PrintString (
// //
// All information also output to serial port. // All information also output to serial port.
// //
DebugSerialPrint ((CHAR8*)String); SerialPortWrite (PrintBuffer, Index);
} }

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -26,19 +26,10 @@ PrintHeader (
CHAR8 Char CHAR8 Char
); );
VOID
PrintValue (
UINT32 Value
);
VOID
PrintValue64 (
UINT64 Value
);
VOID VOID
PrintString ( PrintString (
CHAR8 *String IN CONST CHAR8 *FormatString,
...
); );
VOID VOID

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -137,55 +137,42 @@ Returns:
VOID *MemoryTopOnDescriptor; VOID *MemoryTopOnDescriptor;
VOID *MemoryDescriptor; VOID *MemoryDescriptor;
VOID *NvStorageBase; VOID *NvStorageBase;
CHAR8 PrintBuffer[256];
EFILDRHANDOFF HandoffCopy; EFILDRHANDOFF HandoffCopy;
CopyMem ((VOID*) &HandoffCopy, (VOID*) Handoff, sizeof (EFILDRHANDOFF)); CopyMem ((VOID*) &HandoffCopy, (VOID*) Handoff, sizeof (EFILDRHANDOFF));
Handoff = &HandoffCopy; Handoff = &HandoffCopy;
ClearScreen(); ClearScreen();
PrintString("Enter DxeIpl ...\n");
/* PrintString (
ClearScreen(); "Enter DxeIpl ...\n"
PrintString("handoff:\n"); "Handoff:\n"
PrintString("Handoff.BfvBase = "); "Handoff.BfvBase = %p, BfvLength = %x\n"
PrintValue64((UINT64)(UINTN)Handoff->BfvBase); "Handoff.DxeIplImageBase = %p, DxeIplImageSize = %x\n"
PrintString(", "); "Handoff.DxeCoreImageBase = %p, DxeCoreImageSize = %x\n",
PrintString("BfvLength = "); Handoff->BfvBase, Handoff->BfvSize,
PrintValue64(Handoff->BfvSize); Handoff->DxeIplImageBase, Handoff->DxeIplImageSize,
PrintString("\n"); Handoff->DxeCoreImageBase, Handoff->DxeCoreImageSize
PrintString("Handoff.DxeIplImageBase = "); );
PrintValue64((UINT64)(UINTN)Handoff->DxeIplImageBase);
PrintString(", ");
PrintString("DxeIplImageSize = ");
PrintValue64(Handoff->DxeIplImageSize);
PrintString("\n");
PrintString("Handoff.DxeCoreImageBase = ");
PrintValue64((UINT64)(UINTN)Handoff->DxeCoreImageBase);
PrintString(", ");
PrintString("DxeCoreImageSize = ");
PrintValue64(Handoff->DxeCoreImageSize);
PrintString("\n");
*/
// //
// Hob Generation Guild line: // Hob Generation Guild line:
// * Don't report FV as physical memory // * Don't report FV as physical memory
// * MemoryAllocation Hob should only cover physical memory // * MemoryAllocation Hob should only cover physical memory
// * Use ResourceDescriptor Hob to report physical memory or Firmware Device and they shouldn't be overlapped // * Use ResourceDescriptor Hob to report physical memory or Firmware Device and they shouldn't be overlapped
PrintString("Prepare Cpu HOB information ...\n"); PrintString ("Prepare Cpu HOB information ...\n");
PrepareHobCpu (); PrepareHobCpu ();
// //
// 1. BFV // 1. BFV
// //
PrintString("Prepare BFV HOB information ...\n"); PrintString ("Prepare BFV HOB information ...\n");
PrepareHobBfv (Handoff->BfvBase, Handoff->BfvSize); PrepareHobBfv (Handoff->BfvBase, Handoff->BfvSize);
// //
// 2. Updates Memory information, and get the top free address under 4GB // 2. Updates Memory information, and get the top free address under 4GB
// //
PrintString("Prepare Memory HOB information ...\n"); PrintString ("Prepare Memory HOB information ...\n");
MemoryTopOnDescriptor = PrepareHobMemory (Handoff->MemDescCount, Handoff->MemDesc); MemoryTopOnDescriptor = PrepareHobMemory (Handoff->MemDescCount, Handoff->MemDesc);
// //
@ -193,17 +180,13 @@ Returns:
// //
// 3.1 NV data // 3.1 NV data
PrintString("Prepare NV Storage information ...\n"); PrintString ("Prepare NV Storage information ...\n");
NvStorageBase = PrepareHobNvStorage (MemoryTopOnDescriptor); NvStorageBase = PrepareHobNvStorage (MemoryTopOnDescriptor);
AsciiSPrint (PrintBuffer, 256, "NV Storage Base=0x%x\n", (UINTN)NvStorageBase); PrintString ("NV Storage Base = %p\n", NvStorageBase);
PrintString (PrintBuffer);
// 3.2 Stack // 3.2 Stack
StackTop = NvStorageBase; StackTop = NvStorageBase;
StackBottom = PrepareHobStack (StackTop); StackBottom = PrepareHobStack (StackTop);
AsciiSPrint (PrintBuffer, 256, "Stack Top=0x%x, Stack Bottom=0x%x\n", PrintString ("Stack Top=0x%x, Stack Bottom=0x%x\n", StackTop, StackBottom);
(UINTN)StackTop, (UINTN)StackBottom);
PrintString (PrintBuffer);
// 3.3 Page Table // 3.3 Page Table
PageTableBase = PreparePageTable (StackBottom, gHob->Cpu.SizeOfMemorySpace); PageTableBase = PreparePageTable (StackBottom, gHob->Cpu.SizeOfMemorySpace);
// 3.4 MemDesc (will be used in PlatformBds) // 3.4 MemDesc (will be used in PlatformBds)
@ -214,7 +197,7 @@ Returns:
// //
// 4. Register the memory occupied by DxeCore and DxeIpl together as DxeCore // 4. Register the memory occupied by DxeCore and DxeIpl together as DxeCore
// //
PrintString("Prepare DxeCore memory Hob ...\n"); PrintString ("Prepare DxeCore memory Hob ...\n");
PrepareHobDxeCore ( PrepareHobDxeCore (
Handoff->DxeCoreEntryPoint, Handoff->DxeCoreEntryPoint,
(EFI_PHYSICAL_ADDRESS)(UINTN)Handoff->DxeCoreImageBase, (EFI_PHYSICAL_ADDRESS)(UINTN)Handoff->DxeCoreImageBase,
@ -227,125 +210,57 @@ Returns:
CompleteHobGeneration (); CompleteHobGeneration ();
AsciiSPrint (PrintBuffer, 256, "HobStart=0x%x\n", (UINTN)gHob);
PrintString (PrintBuffer);
AsciiSPrint (PrintBuffer, 256, "Memory Top=0x%x, Bottom=0x%x\n",
(UINTN)gHob->Phit.EfiMemoryTop, (UINTN)gHob->Phit.EfiMemoryBottom);
PrintString (PrintBuffer);
AsciiSPrint (PrintBuffer, 256, "Free Memory Top=0x%x, Bottom=0x%x\n",
(UINTN)gHob->Phit.EfiFreeMemoryTop, (UINTN)gHob->Phit.EfiFreeMemoryBottom);
PrintString (PrintBuffer);
AsciiSPrint (PrintBuffer, 256, "Nv Base=0x%x, Length=0x%x\n",
(UINTN)gHob->NvStorageFvb.FvbInfo.Entries[0].Base,
(UINTN)gHob->NvFtwFvb.FvbInfo.Entries[0].Length);
PrintString (PrintBuffer);
/*
// //
// Print Hob Info // Print Hob Info
// //
ClearScreen(); ClearScreen();
PrintString("Hob Info\n"); PrintString (
PrintString("Phit.EfiMemoryTop = "); "HobStart = %p\n"
PrintValue64(gHob->Phit.EfiMemoryTop); "Memory Top = %lx, Bottom = %lx\n"
PrintString(" Phit.EfiMemoryBottom = "); "Free Memory Top = %lx, Bottom = %lx\n"
PrintValue64(gHob->Phit.EfiMemoryBottom); "NvStorageFvb = %p, Length = %x\n"
PrintString("\n"); "BfvResource = %lx, Length = %lx\n"
PrintString("Phit.EfiFreeMemoryTop = "); "NvStorageFvResource = %lx, Length = %lx\n"
PrintValue64(gHob->Phit.EfiFreeMemoryTop); "NvStorage = %lx, Length = %lx\n"
PrintString(" Phit.EfiFreeMemoryBottom = "); "NvFtwFvResource = %lx, Length = %lx\n"
PrintValue64(gHob->Phit.EfiFreeMemoryBottom); "NvFtwWorking = %lx, Length = %lx\n"
PrintString("\n"); "NvFtwSpare = %lx, Length = %lx\n"
PrintString("Bfv = "); "Stack = %lx, StackLength = %lx\n"
PrintValue64(gHob->Bfv.BaseAddress); "PageTable = %p\n"
PrintString(" BfvLength = "); "MemoryFreeUnder1MB = %lx, MemoryFreeUnder1MBLength = %lx\n"
PrintValue64(gHob->Bfv.Length); "MemoryAbove1MB = %lx, MemoryAbove1MBLength = %lx\n"
PrintString("\n"); "MemoryAbove4GB = %lx, MemoryAbove4GBLength = %lx\n"
PrintString("NvStorageFvb = "); "DxeCore = %lx, DxeCoreLength = %lx\n"
PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Base); "MemoryAllocation = %lx, MemoryLength = %lx\n"
PrintString(" Length = "); "$",
PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Length); gHob,
PrintString("\n"); gHob->Phit.EfiMemoryTop, gHob->Phit.EfiMemoryBottom,
PrintString("NvFtwFvb = "); gHob->Phit.EfiFreeMemoryTop, gHob->Phit.EfiFreeMemoryBottom,
PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Base); gHob->NvStorageFvb.FvbInfo.Entries[0].Base, (UINTN) gHob->NvFtwFvb.FvbInfo.Entries[0].Length,
PrintString(" Length = "); gHob->BfvResource.PhysicalStart, gHob->BfvResource.ResourceLength,
PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Length); gHob->NvStorageFvResource.PhysicalStart, gHob->NvStorageFvResource.ResourceLength,
PrintString("\n"); gHob->NvStorage.FvbInfo.Entries[0].Base, gHob->NvStorage.FvbInfo.Entries[0].Length,
PrintString("BfvResource = "); gHob->NvFtwFvResource.PhysicalStart, gHob->NvFtwFvResource.ResourceLength,
PrintValue64(gHob->BfvResource.PhysicalStart); gHob->NvFtwWorking.FvbInfo.Entries[0].Base, gHob->NvFtwWorking.FvbInfo.Entries[0].Length,
PrintString(" Length = "); gHob->NvFtwSpare.FvbInfo.Entries[0].Base, gHob->NvFtwSpare.FvbInfo.Entries[0].Length,
PrintValue64(gHob->BfvResource.ResourceLength); gHob->Stack.AllocDescriptor.MemoryBaseAddress, gHob->Stack.AllocDescriptor.MemoryLength,
PrintString("\n"); PageTableBase,
PrintString("NvStorageFvResource = "); gHob->MemoryFreeUnder1MB.PhysicalStart, gHob->MemoryFreeUnder1MB.ResourceLength,
PrintValue64(gHob->NvStorageFvResource.PhysicalStart); gHob->MemoryAbove1MB.PhysicalStart, gHob->MemoryAbove1MB.ResourceLength,
PrintString(" Length = "); gHob->MemoryAbove4GB.PhysicalStart, gHob->MemoryAbove4GB.ResourceLength,
PrintValue64(gHob->NvStorageFvResource.ResourceLength); gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress, gHob->DxeCore.MemoryAllocationHeader.MemoryLength,
PrintString("\n"); gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress, gHob->MemoryAllocation.AllocDescriptor.MemoryLength
PrintString("NvStorage = "); );
PrintValue64(gHob->NvStorage.FvbInfo.Entries[0].Base);
PrintString(" Length = ");
PrintValue64(gHob->NvStorage.FvbInfo.Entries[0].Length);
PrintString("\n");
PrintString("NvFtwFvResource = ");
PrintValue64(gHob->NvFtwFvResource.PhysicalStart);
PrintString(" Length = ");
PrintValue64(gHob->NvFtwFvResource.ResourceLength);
PrintString("\n");
PrintString("NvFtwWorking = ");
PrintValue64(gHob->NvFtwWorking.FvbInfo.Entries[0].Base);
PrintString(" Length = ");
PrintValue64(gHob->NvFtwWorking.FvbInfo.Entries[0].Length);
PrintString("\n");
PrintString("NvFtwSpare = ");
PrintValue64(gHob->NvFtwSpare.FvbInfo.Entries[0].Base);
PrintString(" Length = ");
PrintValue64(gHob->NvFtwSpare.FvbInfo.Entries[0].Length);
PrintString("\n");
PrintString("Stack = ");
PrintValue64(gHob->Stack.AllocDescriptor.MemoryBaseAddress);
PrintString(" StackLength = ");
PrintValue64(gHob->Stack.AllocDescriptor.MemoryLength);
PrintString("\n");
PrintString("PageTable = ");
PrintValue64((UINTN)PageTableBase);
PrintString("\n");
PrintString("MemoryFreeUnder1MB = ");
PrintValue64(gHob->MemoryFreeUnder1MB.PhysicalStart);
PrintString(" MemoryFreeUnder1MBLength = ");
PrintValue64(gHob->MemoryFreeUnder1MB.ResourceLength);
PrintString("\n");
PrintString("MemoryAbove1MB = ");
PrintValue64(gHob->MemoryAbove1MB.PhysicalStart);
PrintString(" MemoryAbove1MBLength = ");
PrintValue64(gHob->MemoryAbove1MB.ResourceLength);
PrintString("\n");
PrintString("MemoryAbove4GB = ");
PrintValue64(gHob->MemoryAbove4GB.PhysicalStart);
PrintString(" MemoryAbove4GBLength = ");
PrintValue64(gHob->MemoryAbove4GB.ResourceLength);
PrintString("\n");
PrintString("DxeCore = ");
PrintValue64(gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress);
PrintString(" DxeCoreLength = ");
PrintValue64(gHob->DxeCore.MemoryAllocationHeader.MemoryLength);
PrintString("\n");
PrintString("MemoryAllocation = ");
PrintValue64(gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress);
PrintString(" MemoryLength = ");
PrintValue64(gHob->MemoryAllocation.AllocDescriptor.MemoryLength);
PrintString("\n");
EFI_DEADLOOP();
*/
ClearScreen(); ClearScreen();
PrintString("\n\n\n\n\n\n\n\n\n\n"); PrintString (
PrintString(" WELCOME TO EFI WORLD!\n"); "\n\n\n\n\n\n\n\n\n\n"
" WELCOME TO EFI WORLD!\n"
);
EnterDxeMain (StackTop, Handoff->DxeCoreEntryPoint, gHob, PageTableBase); EnterDxeMain (StackTop, Handoff->DxeCoreEntryPoint, gHob, PageTableBase);
PrintString ("Fail to enter DXE main!\n");
PrintString("Fail to enter DXE main!\n");
// //
// Should never get here // Should never get here
// //

View File

@ -1,6 +1,6 @@
## @file ## @file
# #
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -33,6 +33,7 @@
BaseLib BaseLib
BaseMemoryLib BaseMemoryLib
PrintLib PrintLib
SerialPortLib
ReportStatusCodeLib ReportStatusCodeLib
IoLib IoLib
@ -63,13 +64,5 @@
Ia32/Paging.c Ia32/Paging.c
Ia32/VirtualMemory.h Ia32/VirtualMemory.h
#[BuildOptions]
#MSFT:*_*_IA32_DLINK_FLAGS = /out:"$(BIN_DIR)\SecMain.exe" /base:0x10000000 /pdb:"$(BIN_DIR)\SecMain.pdb" /LIBPATH:"$(VCINSTALLDIR)\Lib" /LIBPATH:"$(VCINSTALLDIR)\PlatformSdk\Lib" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:I386 /LTCG Kernel32.lib MSVCRTD.lib Gdi32.lib User32.lib Winmm.lib
#MSFT:*_*_IA32_CC_FLAGS = /nologo /W4 /WX /Gy /c /D UNICODE /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
#MSFT:*_*_IA32_PP_FLAGS = /nologo /E /TC /FI$(DEST_DIR_DEBUG)/AutoGen.h
#MSFT:*_*_IA32_ASM_FLAGS = /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi
#MSFT:*_*_IA32_ASMLINK_FLAGS = /link /nologo /tiny
#GCC:*_UNIXGCC_IA32_CC_FLAGS = -O2 -falign-functions -falign-jumps -falign-loops -freorder-blocks -freorder-blocks-and-partition -falign-labels -fshort-wchar -fno-strict-aliasing -Wall -Wno-missing-braces -c -include AutoGen.h
[Depex] [Depex]
TRUE TRUE

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -48,27 +48,8 @@ Returns:
--*/ --*/
{ {
//EFI_PEI_PE_COFF_LOADER_PROTOCOL *PeCoffLoader;
//EFI_DECOMPRESS_PROTOCOL *EfiDecompress;
//EFI_TIANO_DECOMPRESS_PROTOCOL *TianoDecompress;
EFI_REPORT_STATUS_CODE ReportStatusCode; EFI_REPORT_STATUS_CODE ReportStatusCode;
//InstallEfiPeiFlushInstructionCache (&FlushInstructionCache);
//Hob->FlushInstructionCache.Interface = FlushInstructionCache;
// R9 do not need this protocol.
// InstallEfiPeiTransferControl (&TransferControl);
// Hob->TransferControl.Interface = TransferControl;
//InstallEfiPeiPeCoffLoader (NULL, &PeCoffLoader, NULL);
//Hob->PeCoffLoader.Interface = PeCoffLoader;
//InstallEfiDecompress (&EfiDecompress);
//Hob->EfiDecompress.Interface = EfiDecompress;
//InstallTianoDecompress (&TianoDecompress);
//Hob->TianoDecompress.Interface = TianoDecompress;
InstallSerialStatusCode (&ReportStatusCode); InstallSerialStatusCode (&ReportStatusCode);
Hob->SerialStatusCode.Interface = (EFI_PHYSICAL_ADDRESS) (UINTN) ReportStatusCode; Hob->SerialStatusCode.Interface = (EFI_PHYSICAL_ADDRESS) (UINTN) ReportStatusCode;

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -18,16 +18,9 @@ Revision History:
**/ **/
#include <Library/SerialPortLib.h>
#include "SerialStatusCode.h" #include "SerialStatusCode.h"
UINT16 gComBase = 0x3f8;
UINTN gBps = 115200;
UINT8 gData = 8;
UINT8 gStop = 1;
UINT8 gParity = 0;
UINT8 gBreakSet = 0;
// //
// All of the lookup tables are only needed in debug. // All of the lookup tables are only needed in debug.
// //
@ -602,68 +595,6 @@ Returns:
} }
VOID
DebugSerialWrite (
IN UINT8 Character
)
/*++
Routine Description:
DebugSerialWrite - Outputs a character to the Serial port
Repeatedly polls the TXRDY bit of the Line Status Register
until the Transmitter Holding Register is empty. The character
is then written to the Serial port.
Arguments:
Character - Character to write
Returns:
None
--*/
{
UINT8 Data;
//
// Wait for the serail port to be ready.
//
do {
Data = IoRead8 (gComBase + LSR_OFFSET);
} while ((Data & LSR_TXRDY) == 0);
IoWrite8 (gComBase, Character);
}
VOID
DebugSerialPrint (
IN CHAR8 *OutputString
)
/*++
Routine Description:
Prints a string to the Serial port
Arguments:
OutputString - Ascii string to print to serial port.
Returns:
None
--*/
{
for ( ; *OutputString != 0; OutputString++) {
DebugSerialWrite (*OutputString);
}
}
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SerialReportStatusCode ( SerialReportStatusCode (
@ -697,7 +628,7 @@ Returns:
CHAR8 *Format; CHAR8 *Format;
BASE_LIST Marker; BASE_LIST Marker;
UINT32 ErrorLevel; UINT32 ErrorLevel;
UINTN CharCount; UINTN CharCount = 0;
Buffer[0] = '\0'; Buffer[0] = '\0';
@ -706,7 +637,7 @@ Returns:
// //
// Processes PEI_ASSERT () // Processes PEI_ASSERT ()
// //
AsciiSPrint ( CharCount = AsciiSPrint (
Buffer, Buffer,
sizeof (Buffer), sizeof (Buffer),
"\nPEI_ASSERT!: %a (%d): %a\n", "\nPEI_ASSERT!: %a (%d): %a\n",
@ -720,7 +651,7 @@ Returns:
// //
// Process PEI_DEBUG () macro to Serial // Process PEI_DEBUG () macro to Serial
// //
AsciiBSPrint (Buffer, sizeof (Buffer), Format, Marker); CharCount = AsciiBSPrint (Buffer, sizeof (Buffer), Format, Marker);
} else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
// //
@ -744,7 +675,7 @@ Returns:
// //
// Callout to platform Lib function to do print. // Callout to platform Lib function to do print.
// //
DebugSerialPrint (Buffer); SerialPortWrite (Buffer, CharCount);
} }
// //
@ -786,7 +717,7 @@ Returns:
// //
// Concatenate the instance // Concatenate the instance
// //
AsciiSPrint ( CharCount = AsciiSPrint (
Buffer, Buffer,
sizeof (Buffer), sizeof (Buffer),
"%a:%a:%a:%d\n", "%a:%a:%a:%d\n",
@ -796,7 +727,7 @@ Returns:
Instance Instance
); );
DebugSerialPrint (Buffer); SerialPortWrite (Buffer, CharCount);
} }
} }
@ -812,15 +743,11 @@ InstallSerialStatusCode (
Routine Description: Routine Description:
Initialize Serial Port Initialize Serial Port and Status Code Handler
The Baud Rate Divisor registers are programmed and the LCR
is used to configure the communications format. Hard coded
UART config comes from globals in DebugSerialPlatform lib.
Arguments: Arguments:
None ReportStatusCode - A pointer to the handler
Returns: Returns:
@ -828,41 +755,6 @@ Returns:
--*/ --*/
{ {
UINTN Divisor; SerialPortInitialize();
UINT8 OutputData;
UINT8 Data;
//
// Some init is done by the platform status code initialization.
//
//
// Map 5..8 to 0..3
//
Data = (UINT8) (gData - (UINT8)5);
//
// Calculate divisor for baud generator
//
Divisor = 115200 / gBps;
//
// Set communications format
//
OutputData = (UINT8)((DLAB << 7) | ((gBreakSet << 6) | ((gParity << 3) | ((gStop << 2) | Data))));
IoWrite8 (gComBase + LCR_OFFSET, OutputData);
//
// Configure baud rate
//
IoWrite8 (gComBase + BAUD_HIGH_OFFSET, (UINT8)(Divisor >> 8));
IoWrite8 (gComBase + BAUD_LOW_OFFSET, (UINT8)(Divisor & 0xff));
//
// Switch back to bank 0
//
OutputData = (UINT8)((~DLAB<<7)|((gBreakSet<<6)|((gParity<<3)|((gStop<<2)| Data))));
IoWrite8 (gComBase + LCR_OFFSET, OutputData);
*ReportStatusCode = SerialReportStatusCode; *ReportStatusCode = SerialReportStatusCode;
} }

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -31,50 +31,6 @@ Revision History:
// //
//---------------------------------------------
// UART Register Offsets
//---------------------------------------------
#define BAUD_LOW_OFFSET 0x00
#define BAUD_HIGH_OFFSET 0x01
#define IER_OFFSET 0x01
#define LCR_SHADOW_OFFSET 0x01
#define FCR_SHADOW_OFFSET 0x02
#define IR_CONTROL_OFFSET 0x02
#define FCR_OFFSET 0x02
#define EIR_OFFSET 0x02
#define BSR_OFFSET 0x03
#define LCR_OFFSET 0x03
#define MCR_OFFSET 0x04
#define LSR_OFFSET 0x05
#define MSR_OFFSET 0x06
//---------------------------------------------
// UART Register Bit Defines
//---------------------------------------------
#define LSR_TXRDY 0x20
#define LSR_RXDA 0x01
#define DLAB 0x01
//
// Globals for Serial Port settings
//
extern UINT16 gComBase;
extern UINTN gBps;
extern UINT8 gData;
extern UINT8 gStop;
extern UINT8 gParity;
extern UINT8 gBreakSet;
VOID
DebugSerialPrint (
IN CHAR8 *OutputString
);
VOID
DebugSerialWrite (
IN UINT8 Character
);
VOID VOID
InstallSerialStatusCode ( InstallSerialStatusCode (
IN EFI_REPORT_STATUS_CODE *ReportStatusCode IN EFI_REPORT_STATUS_CODE *ReportStatusCode

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -19,11 +19,11 @@ Revision History:
--*/ --*/
#include "EfiLdr.h" #include "EfiLdr.h"
#include "Debug.h" #include "Debug.h"
#include <Library/SerialPortLib.h>
UINT8 *mCursor; UINT8 *mCursor;
UINT8 mHeaderIndex = 10; UINT8 mHeaderIndex = 10;
VOID VOID
PrintHeader ( PrintHeader (
CHAR8 Char CHAR8 Char
@ -48,82 +48,25 @@ ClearScreen (
mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160); mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);
} }
VOID
PrintU32Base10 (
UINT32 Value
)
{
UINT32 Index;
CHAR8 Char;
CHAR8 String[11];
UINTN StringPos;
UINT32 B10Div;
B10Div = 1000000000;
for (Index = 0, StringPos = 0; Index < 10; Index++) {
Char = (UINT8) (((Value / B10Div) % 10) + '0');
if ((StringPos > 0) || (Char != '0')) {
String[StringPos] = Char;
StringPos++;
}
B10Div = B10Div / 10;
}
if (StringPos == 0) {
String[0] = '0';
StringPos++;
}
String[StringPos] = '\0';
PrintString (String);
}
VOID
PrintValue (
UINT32 Value
)
{
UINT32 Index;
CHAR8 Char;
CHAR8 String[9];
for (Index = 0; Index < 8; Index++) {
Char = (UINT8)(((Value >> ((7 - Index) * 4)) & 0x0f) + '0');
if (Char > '9') {
Char = (UINT8) (Char - '0' - 10 + 'A');
}
String[Index] = Char;
}
String[sizeof (String) - 1] = '\0';
PrintString (String);
}
VOID
PrintValue64 (
UINT64 Value
)
{
PrintValue ((UINT32) RShiftU64 (Value, 32));
PrintValue ((UINT32) Value);
}
VOID VOID
PrintString ( PrintString (
CHAR8 *String IN CONST CHAR8 *FormatString,
...
) )
{ {
UINT32 Index; UINTN Index;
CHAR8 PrintBuffer[256];
VA_LIST Marker;
for (Index = 0; String[Index] != 0; Index++) { VA_START (Marker, FormatString);
if (String[Index] == '\n') { AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);
mCursor = (UINT8 *)(UINTN)(0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160)); VA_END (Marker);
for (Index = 0; PrintBuffer[Index] != 0; Index++) {
if (PrintBuffer[Index] == '\n') {
mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));
} else { } else {
*mCursor = String[Index]; *mCursor = (UINT8) PrintBuffer[Index];
mCursor += 2; mCursor += 2;
} }
} }
@ -131,6 +74,6 @@ PrintString (
// //
// All information also output to serial port. // All information also output to serial port.
// //
SerialPortWrite ((UINT8*) String, Index); SerialPortWrite (PrintBuffer, Index);
} }

View File

@ -26,19 +26,10 @@ PrintHeader (
CHAR8 Char CHAR8 Char
); );
VOID
PrintValue (
UINT32 Value
);
VOID
PrintValue64 (
UINT64 Value
);
VOID VOID
PrintString ( PrintString (
CHAR8 *String IN CONST CHAR8 *FormatString,
...
); );
VOID VOID

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -29,6 +29,7 @@ Revision History:
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/PrintLib.h> #include <Library/PrintLib.h>
#include <Library/SerialPortLib.h>
#define INT15_E820_AddressRangeMemory 1 #define INT15_E820_AddressRangeMemory 1
#define INT15_E820_AddressRangeReserved 2 #define INT15_E820_AddressRangeReserved 2

View File

@ -1,6 +1,6 @@
## @file ## @file
# #
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at # which accompanies this distribution. The full text of the license may be found at
@ -20,7 +20,6 @@
INF_VERSION = 0x00010005 INF_VERSION = 0x00010005
BASE_NAME = EfiLoader BASE_NAME = EfiLoader
FILE_GUID = A9620E5C-5FA1-40b7-8B21-50B632F88F38 FILE_GUID = A9620E5C-5FA1-40b7-8B21-50B632F88F38
#MODULE_TYPE = USER_DEFINED
MODULE_TYPE = UEFI_APPLICATION MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0 VERSION_STRING = 1.0
@ -53,8 +52,4 @@
gTianoCustomDecompressGuid gTianoCustomDecompressGuid
[BuildOptions] [BuildOptions]
MSFT:*_*_IA32_CC_FLAGS = /nologo /W4 /WX /Gy /c /D UNICODE /O1ib2 /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF /Gs8192 /Zi /Gm /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
MSFT:*_*_IA32_PP_FLAGS == /nologo /E /TC /FI$(DEST_DIR_DEBUG)/AutoGen.h
MSFT:*_*_IA32_ASM_FLAGS == /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi
MSFT:*_*_IA32_ASMLINK_FLAGS == /link /nologo /tiny
MSFT:*_*_*_DLINK_FLAGS = /BASE:0x10000 MSFT:*_*_*_DLINK_FLAGS = /BASE:0x10000

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -25,12 +25,14 @@ Revision History:
#include "LzmaDecompress.h" #include "LzmaDecompress.h"
VOID VOID
SystemHang( SystemHang (
VOID CHAR8 *Message
) )
{ {
CHAR8 PrintBuffer[256]; PrintString (
AsciiSPrint (PrintBuffer, 256, "## FATEL ERROR ##: Fail to load DUET images! System hang!\n"); "%s## FATAL ERROR ##: Fail to load DUET images! System hang!\n",
Message
);
CpuDeadLoop(); CpuDeadLoop();
} }
@ -49,52 +51,45 @@ EfiLoader (
UINTN BfvPageNumber; UINTN BfvPageNumber;
UINTN BfvBase; UINTN BfvBase;
EFI_MAIN_ENTRYPOINT EfiMainEntrypoint; EFI_MAIN_ENTRYPOINT EfiMainEntrypoint;
CHAR8 PrintBuffer[256];
EFILDRHANDOFF Handoff; EFILDRHANDOFF Handoff;
UINTN Index;
ClearScreen(); ClearScreen();
PrintHeader ('A'); PrintHeader ('A');
AsciiSPrint (PrintBuffer, 256, "Enter DUET Loader...\n"); PrintString ("Enter DUET Loader...\n");
PrintString (PrintBuffer); PrintString ("BiosMemoryMapBaseAddress = %x\n", (UINTN) BiosMemoryMapBaseAddress);
AsciiSPrint (PrintBuffer, 256, "BiosMemoryMapBaseAddress = 0x%x\n", BiosMemoryMapBaseAddress);
PrintString (PrintBuffer);
// //
// Add all EfiConventionalMemory descriptors to the table. If there are partial pages, then // Add all EfiConventionalMemory descriptors to the table. If there are partial pages, then
// round the start address up to the next page, and round the length down to a page boundry. // round the start address up to the next page, and round the length down to a page boundry.
// //
BiosMemoryMap = (BIOS_MEMORY_MAP *)(UINTN)(BiosMemoryMapBaseAddress); BiosMemoryMap = (BIOS_MEMORY_MAP *) (UINTN) BiosMemoryMapBaseAddress;
NumberOfMemoryMapEntries = 0; NumberOfMemoryMapEntries = 0;
GenMemoryMap (&NumberOfMemoryMapEntries, EfiMemoryDescriptor, BiosMemoryMap); GenMemoryMap (&NumberOfMemoryMapEntries, EfiMemoryDescriptor, BiosMemoryMap);
AsciiSPrint (PrintBuffer, 256, "Get %d entries of memory map!\n", NumberOfMemoryMapEntries); PrintString ("Get %d entries of memory map!\n", NumberOfMemoryMapEntries);
PrintString (PrintBuffer);
// //
// Get information on where the image is in memory // Get information on where the image is in memory
// //
//EFILDRHeader = (EFILDR_HEADER *)(UINTN)(EFILDR_HEADER_ADDRESS);
EFILDRImage = (EFILDR_IMAGE *)(UINTN)(EFILDR_HEADER_ADDRESS + sizeof(EFILDR_HEADER)); EFILDRImage = (EFILDR_IMAGE *)(UINTN)(EFILDR_HEADER_ADDRESS + sizeof(EFILDR_HEADER));
// //
// Point to the 4th image (Bfv) // Point to the 4th image (Bfv)
// //
EFILDRImage += 3; EFILDRImage += 3;
// //
// Decompress the image // Decompress the image
// //
PrintString (
AsciiSPrint (PrintBuffer, 256, "Decompress BFV image, Image Address=0x%x Offset=0x%x\n", "Decompress BFV image, Image Address = %x Offset = %x\n",
(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset), (UINTN) (EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),
EFILDRImage->Offset); (UINTN) EFILDRImage->Offset
PrintString (PrintBuffer); );
Status = LzmaUefiDecompressGetInfo ( Status = LzmaUefiDecompressGetInfo (
(VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset), (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),
EFILDRImage->Length, EFILDRImage->Length,
@ -103,14 +98,10 @@ EfiLoader (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for BFV!\n"); SystemHang ("Failed to get decompress information for BFV!\n");
PrintString (PrintBuffer);
SystemHang();
} }
AsciiSPrint (PrintBuffer, 256, "BFV decompress: DestinationSize=0x%X, ScratchSize=0x%X!\n", PrintString ("BFV decompress: DestinationSize = %x, ScratchSize = %x\n", (UINTN) DestinationSize, (UINTN) ScratchSize);
DestinationSize, ScratchSize);
PrintString (PrintBuffer);
Status = LzmaUefiDecompress ( Status = LzmaUefiDecompress (
(VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset), (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),
EFILDRImage->Length, EFILDRImage->Length,
@ -120,15 +111,13 @@ EfiLoader (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiSPrint (PrintBuffer, 256, "Fail to decompress BFV!\n"); SystemHang ("Failed to decompress BFV!\n");
PrintString (PrintBuffer);
SystemHang();
} }
BfvPageNumber = EFI_SIZE_TO_PAGES (DestinationSize); BfvPageNumber = EFI_SIZE_TO_PAGES (DestinationSize);
BfvBase = (UINTN) FindSpace (BfvPageNumber, &NumberOfMemoryMapEntries, EfiMemoryDescriptor, EfiRuntimeServicesData, EFI_MEMORY_WB); BfvBase = (UINTN) FindSpace (BfvPageNumber, &NumberOfMemoryMapEntries, EfiMemoryDescriptor, EfiRuntimeServicesData, EFI_MEMORY_WB);
if (BfvBase == 0) { if (BfvBase == 0) {
SystemHang(); SystemHang ("Failed to find free space to hold decompressed BFV\n");
} }
ZeroMem ((VOID *)(UINTN)BfvBase, BfvPageNumber * EFI_PAGE_SIZE); ZeroMem ((VOID *)(UINTN)BfvBase, BfvPageNumber * EFI_PAGE_SIZE);
CopyMem ((VOID *)(UINTN)BfvBase, (VOID *)(UINTN)EFI_DECOMPRESSED_BUFFER_ADDRESS, DestinationSize); CopyMem ((VOID *)(UINTN)BfvBase, (VOID *)(UINTN)EFI_DECOMPRESSED_BUFFER_ADDRESS, DestinationSize);
@ -144,10 +133,11 @@ EfiLoader (
// //
// Decompress the image // Decompress the image
// //
AsciiSPrint (PrintBuffer, 256, "Decompress DxeIpl image, Image Address=0x%x Offset=0x%x\n", PrintString (
(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset), "Decompress DxeIpl image, Image Address = %x Offset = %x\n",
EFILDRImage->Offset); (UINTN) (EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),
PrintString (PrintBuffer); (UINTN) EFILDRImage->Offset
);
Status = LzmaUefiDecompressGetInfo ( Status = LzmaUefiDecompressGetInfo (
(VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset), (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),
@ -156,9 +146,7 @@ EfiLoader (
&ScratchSize &ScratchSize
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for DxeIpl!\n"); SystemHang ("Failed to get decompress information for DxeIpl!\n");
PrintString (PrintBuffer);
SystemHang();
} }
Status = LzmaUefiDecompress ( Status = LzmaUefiDecompress (
@ -168,13 +156,10 @@ EfiLoader (
(VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000) (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiSPrint (PrintBuffer, 256, "Fail to decompress DxeIpl image\n"); SystemHang ("Failed to decompress DxeIpl image\n");
PrintString (PrintBuffer);
SystemHang();
} }
AsciiSPrint (PrintBuffer, 256, "Start load DxeIpl PE image\n"); PrintString ("Start load DxeIpl PE image\n");
PrintString (PrintBuffer);
// //
// Load and relocate the EFI PE/COFF Firmware Image // Load and relocate the EFI PE/COFF Firmware Image
@ -186,33 +171,29 @@ EfiLoader (
EfiMemoryDescriptor EfiMemoryDescriptor
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiSPrint (PrintBuffer, 256, "Fail to load and relocate DxeIpl PE image!\n"); SystemHang ("Failed to load and relocate DxeIpl PE image!\n");
PrintString (PrintBuffer);
SystemHang();
} }
AsciiSPrint (PrintBuffer, 256, "DxeIpl PE image is successed loaded at 0x%x, entry=0x%x\n", PrintString (
(UINTN)DxeIplImage.ImageBasePage, (UINTN)DxeIplImage.EntryPoint); "DxeIpl PE image is successed loaded at %lx, entry=%p\n",
PrintString (PrintBuffer); DxeIplImage.ImageBasePage,
DxeIplImage.EntryPoint
// PrintString("Image.NoPages = "); );
// PrintValue(Image.NoPages);
// PrintString("\n");
PrintHeader ('C'); PrintHeader ('C');
// //
// Point to the 3rd image (DxeMain) // Point to the 3rd image (DxeMain)
// //
EFILDRImage++; EFILDRImage++;
// //
// Decompress the image // Decompress the image
// //
AsciiSPrint (PrintBuffer, 256, "Decompress DXEMain FV image, Image Address=0x%x! Offset=0x%x\n", PrintString (
"Decompress DxeMain FV image, Image Address = %x Offset = %x\n",
(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset), (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),
EFILDRImage->Offset); (UINTN) EFILDRImage->Offset
PrintString (PrintBuffer); );
Status = LzmaUefiDecompressGetInfo ( Status = LzmaUefiDecompressGetInfo (
(VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset), (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),
@ -221,9 +202,7 @@ PrintHeader ('C');
&ScratchSize &ScratchSize
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for DXEMain FV image!\n"); SystemHang ("Failed to get decompress information for DxeMain FV image!\n");
PrintString (PrintBuffer);
SystemHang();
} }
Status = LzmaUefiDecompress ( Status = LzmaUefiDecompress (
@ -233,7 +212,7 @@ PrintHeader ('C');
(VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000) (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
SystemHang(); SystemHang ("Failed to decompress DxeMain FV image!\n");
} }
// //
@ -246,33 +225,26 @@ PrintHeader ('C');
EfiMemoryDescriptor EfiMemoryDescriptor
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
SystemHang(); SystemHang ("Failed to load/relocate DxeMain!\n");
} }
AsciiSPrint (PrintBuffer, 256, "DxeCore PE image is successed loaded at 0x%x, entry=0x%x\n", PrintString (
(UINTN)DxeCoreImage.ImageBasePage, (UINTN)DxeCoreImage.EntryPoint); "DxeCore PE image is successed loaded at %lx, entry=%p\n",
PrintString (PrintBuffer); DxeCoreImage.ImageBasePage,
DxeCoreImage.EntryPoint
);
PrintHeader ('E'); PrintHeader ('E');
// //
// Display the table of memory descriptors. // Display the table of memory descriptors.
// //
PrintString ("\nEFI Memory Descriptors\n");
// PrintString("\nEFI Memory Descriptors\n");
/*
{
UINTN Index;
for (Index = 0; Index < NumberOfMemoryMapEntries; Index++) { for (Index = 0; Index < NumberOfMemoryMapEntries; Index++) {
PrintString("Type = "); PrintString (
PrintValue(EfiMemoryDescriptor[Index].Type); "Type = %x Start = %08lx NumberOfPages = %08lx\n",
PrintString(" Start = "); EfiMemoryDescriptor[Index].Type, EfiMemoryDescriptor[Index].PhysicalStart, EfiMemoryDescriptor[Index].NumberOfPages
PrintValue((UINT32)(EfiMemoryDescriptor[Index].PhysicalStart)); );
PrintString(" NumberOfPages = ");
PrintValue((UINT32)(EfiMemoryDescriptor[Index].NumberOfPages));
PrintString("\n");
} }
}
*/
// //
// Jump to EFI Firmware // Jump to EFI Firmware
@ -290,10 +262,9 @@ PrintHeader ('E');
Handoff.DxeCoreImageSize = DxeCoreImage.NoPages * EFI_PAGE_SIZE; Handoff.DxeCoreImageSize = DxeCoreImage.NoPages * EFI_PAGE_SIZE;
Handoff.DxeCoreEntryPoint = (VOID *)(UINTN)DxeCoreImage.EntryPoint; Handoff.DxeCoreEntryPoint = (VOID *)(UINTN)DxeCoreImage.EntryPoint;
AsciiSPrint (PrintBuffer, 256, "Transfer to DxeIpl ...Address=0x%x\n", (UINTN)DxeIplImage.EntryPoint); PrintString ("Transfer to DxeIpl ...EntryPoint = %p\n", DxeIplImage.EntryPoint);
PrintString (PrintBuffer);
EfiMainEntrypoint = (EFI_MAIN_ENTRYPOINT)(UINTN)DxeIplImage.EntryPoint; EfiMainEntrypoint = (EFI_MAIN_ENTRYPOINT) DxeIplImage.EntryPoint;
EfiMainEntrypoint (&Handoff); EfiMainEntrypoint (&Handoff);
} }
@ -303,7 +274,7 @@ PrintHeader ('F');
// There was a problem loading the image, so HALT the system. // There was a problem loading the image, so HALT the system.
// //
SystemHang(); SystemHang ("Failed to jump to DxeIpl!\n");
} }
EFI_STATUS EFI_STATUS
@ -312,6 +283,7 @@ _ModuleEntryPoint (
UINT32 BiosMemoryMapBaseAddress UINT32 BiosMemoryMapBaseAddress
) )
{ {
SerialPortInitialize ();
EfiLoader(BiosMemoryMapBaseAddress); EfiLoader(BiosMemoryMapBaseAddress);
return EFI_SUCCESS; return EFI_SUCCESS;
} }