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
diff --git a/DuetPkg/DuetPkg.fdf b/DuetPkg/DuetPkg.fdf
index ef4b5fe..f6bcdd9 100644
--- a/DuetPkg/DuetPkg.fdf
+++ b/DuetPkg/DuetPkg.fdf
@@ -24,7 +24,6 @@
 ################################################################################

 [FV.DuetEfiMainFv]

 BlockSize          = 0x10000

-NumBlocks          = 0x2a

 FvAlignment        = 16         #FV alignment and FV attributes setting.

 ERASE_POLARITY     = 1

 MEMORY_MAPPED      = TRUE

diff --git a/DuetPkg/DuetPkgIa32.dsc b/DuetPkg/DuetPkgIa32.dsc
index 71c9aee..3d70dab 100644
--- a/DuetPkg/DuetPkgIa32.dsc
+++ b/DuetPkg/DuetPkgIa32.dsc
@@ -98,7 +98,8 @@
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf

   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.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

   

   #

diff --git a/DuetPkg/DuetPkgX64.dsc b/DuetPkg/DuetPkgX64.dsc
index 5f0ec2b..c2f60f6 100644
--- a/DuetPkg/DuetPkgX64.dsc
+++ b/DuetPkg/DuetPkgX64.dsc
@@ -98,7 +98,8 @@
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf

   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.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

   

   #

diff --git a/DuetPkg/DxeIpl/Debug.c b/DuetPkg/DxeIpl/Debug.c
index 3462815..950c06b 100644
--- a/DuetPkg/DxeIpl/Debug.c
+++ b/DuetPkg/DxeIpl/Debug.c
@@ -1,6 +1,6 @@
 /** @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                          

 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        

@@ -19,6 +19,7 @@
 **/

 

 #include "DxeIpl.h"

+#include <Library/SerialPortLib.h>

 #include "SerialStatusCode.h"

 #include "Debug.h"

 

@@ -51,57 +52,31 @@
 }

 

 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

 PrintString (

-  CHAR8 *String

+  IN CONST CHAR8  *FormatString,

+  ...

   )

 {

-  UINT32 Index;

+  UINTN           Index;

+  CHAR8           PrintBuffer[1000];

+  VA_LIST         Marker;

 

-  for (Index = 0; String[Index] != 0; Index++) {

-    if (String[Index] == '\n') {

-      mCursor = (UINT8 *)(UINTN)(0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));

+  VA_START (Marker, FormatString);

+  AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);

+  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 {

-      *mCursor = String[Index];

+      *mCursor = (UINT8) PrintBuffer[Index];

       mCursor += 2;

     }

   }

-  

+

   //

   // All information also output to serial port.

   //

-  DebugSerialPrint ((CHAR8*)String);

+  SerialPortWrite (PrintBuffer, Index);

 }

 

diff --git a/DuetPkg/DxeIpl/Debug.h b/DuetPkg/DxeIpl/Debug.h
index ec3997b..7fcad26 100644
--- a/DuetPkg/DxeIpl/Debug.h
+++ b/DuetPkg/DxeIpl/Debug.h
@@ -1,6 +1,6 @@
 /** @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                          

 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        

@@ -26,19 +26,10 @@
   CHAR8 Char

   );

 

-VOID 

-PrintValue (

-  UINT32 Value

-  );

-

 VOID

-PrintValue64 (

-  UINT64 Value

-  );

-

-VOID 

 PrintString (

-  CHAR8 *String

+  IN CONST CHAR8  *FormatString,

+  ...

   );

 

 VOID 

diff --git a/DuetPkg/DxeIpl/DxeInit.c b/DuetPkg/DxeIpl/DxeInit.c
index b10e273..223cbcd 100644
--- a/DuetPkg/DxeIpl/DxeInit.c
+++ b/DuetPkg/DxeIpl/DxeInit.c
@@ -1,6 +1,6 @@
 /** @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                          

 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        

@@ -137,55 +137,42 @@
   VOID                  *MemoryTopOnDescriptor;

   VOID                  *MemoryDescriptor;

   VOID                  *NvStorageBase;

-  CHAR8                 PrintBuffer[256];

   EFILDRHANDOFF         HandoffCopy;

 

   CopyMem ((VOID*) &HandoffCopy, (VOID*) Handoff, sizeof (EFILDRHANDOFF));

   Handoff = &HandoffCopy;

 

   ClearScreen();

-  PrintString("Enter DxeIpl ...\n");

-  

-/*

-  ClearScreen();

-  PrintString("handoff:\n");

-  PrintString("Handoff.BfvBase = ");   

-  PrintValue64((UINT64)(UINTN)Handoff->BfvBase);

-  PrintString(", ");   

-  PrintString("BfvLength = ");   

-  PrintValue64(Handoff->BfvSize);

-  PrintString("\n");   

-  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");   

-*/

+

+  PrintString (

+    "Enter DxeIpl ...\n"

+    "Handoff:\n"

+    "Handoff.BfvBase = %p, BfvLength = %x\n"

+    "Handoff.DxeIplImageBase = %p, DxeIplImageSize = %x\n"

+    "Handoff.DxeCoreImageBase = %p, DxeCoreImageSize = %x\n",

+    Handoff->BfvBase, Handoff->BfvSize,

+    Handoff->DxeIplImageBase, Handoff->DxeIplImageSize,

+    Handoff->DxeCoreImageBase, Handoff->DxeCoreImageSize

+    );

+

   //

   // Hob Generation Guild line:

   //   * Don't report FV as 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

-  PrintString("Prepare Cpu HOB information ...\n");

+  PrintString ("Prepare Cpu HOB information ...\n");

   PrepareHobCpu ();

 

   //

   // 1. BFV

   //

-  PrintString("Prepare BFV HOB information ...\n");

+  PrintString ("Prepare BFV HOB information ...\n");

   PrepareHobBfv (Handoff->BfvBase, Handoff->BfvSize);

 

   //

   // 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);

   

   //

@@ -193,17 +180,13 @@
   //

   

   //   3.1 NV data

-  PrintString("Prepare NV Storage information ...\n");

+  PrintString ("Prepare NV Storage information ...\n");

   NvStorageBase = PrepareHobNvStorage (MemoryTopOnDescriptor);

-  AsciiSPrint (PrintBuffer, 256, "NV Storage Base=0x%x\n", (UINTN)NvStorageBase);

-  PrintString (PrintBuffer);

-  

+  PrintString ("NV Storage Base = %p\n", NvStorageBase);

   //   3.2 Stack

   StackTop = NvStorageBase;

   StackBottom = PrepareHobStack (StackTop);

-  AsciiSPrint (PrintBuffer, 256, "Stack Top=0x%x, Stack Bottom=0x%x\n", 

-              (UINTN)StackTop, (UINTN)StackBottom);

-  PrintString (PrintBuffer);

+  PrintString ("Stack Top=0x%x, Stack Bottom=0x%x\n", StackTop, StackBottom);

   //   3.3 Page Table

   PageTableBase = PreparePageTable (StackBottom, gHob->Cpu.SizeOfMemorySpace);

   //   3.4 MemDesc (will be used in PlatformBds)

@@ -214,7 +197,7 @@
   //

   // 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 (

     Handoff->DxeCoreEntryPoint,

     (EFI_PHYSICAL_ADDRESS)(UINTN)Handoff->DxeCoreImageBase,

@@ -227,125 +210,57 @@
 

   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

   //

   ClearScreen();

-  PrintString("Hob Info\n");

-  PrintString("Phit.EfiMemoryTop = ");   

-  PrintValue64(gHob->Phit.EfiMemoryTop);

-  PrintString(" Phit.EfiMemoryBottom = ");   

-  PrintValue64(gHob->Phit.EfiMemoryBottom);

-  PrintString("\n");   

-  PrintString("Phit.EfiFreeMemoryTop = ");   

-  PrintValue64(gHob->Phit.EfiFreeMemoryTop);

-  PrintString(" Phit.EfiFreeMemoryBottom = ");   

-  PrintValue64(gHob->Phit.EfiFreeMemoryBottom);

-  PrintString("\n");   

-  PrintString("Bfv = ");   

-  PrintValue64(gHob->Bfv.BaseAddress);

-  PrintString(" BfvLength = ");   

-  PrintValue64(gHob->Bfv.Length);

-  PrintString("\n");

-  PrintString("NvStorageFvb = ");

-  PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Base);

-  PrintString(" Length = ");

-  PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Length);

-  PrintString("\n");

-  PrintString("NvFtwFvb = ");

-  PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Base);

-  PrintString(" Length = ");

-  PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Length);

-  PrintString("\n");

-  PrintString("BfvResource = ");

-  PrintValue64(gHob->BfvResource.PhysicalStart);

-  PrintString(" Length = ");

-  PrintValue64(gHob->BfvResource.ResourceLength);

-  PrintString("\n");

-  PrintString("NvStorageFvResource = ");

-  PrintValue64(gHob->NvStorageFvResource.PhysicalStart);

-  PrintString(" Length = ");

-  PrintValue64(gHob->NvStorageFvResource.ResourceLength);

-  PrintString("\n");

-  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();

-*/

+  PrintString (

+    "HobStart = %p\n"

+    "Memory Top = %lx, Bottom = %lx\n"

+    "Free Memory Top = %lx, Bottom = %lx\n"

+    "NvStorageFvb = %p, Length = %x\n"

+    "BfvResource = %lx, Length = %lx\n"

+    "NvStorageFvResource = %lx, Length = %lx\n"

+    "NvStorage = %lx, Length = %lx\n"

+    "NvFtwFvResource = %lx, Length = %lx\n"

+    "NvFtwWorking = %lx, Length = %lx\n"

+    "NvFtwSpare = %lx, Length = %lx\n"

+    "Stack = %lx, StackLength = %lx\n"

+    "PageTable = %p\n"

+    "MemoryFreeUnder1MB = %lx, MemoryFreeUnder1MBLength = %lx\n"

+    "MemoryAbove1MB = %lx, MemoryAbove1MBLength = %lx\n"

+    "MemoryAbove4GB = %lx, MemoryAbove4GBLength = %lx\n"

+    "DxeCore = %lx, DxeCoreLength = %lx\n"

+    "MemoryAllocation = %lx, MemoryLength = %lx\n"

+    "$",

+    gHob,

+    gHob->Phit.EfiMemoryTop, gHob->Phit.EfiMemoryBottom,

+    gHob->Phit.EfiFreeMemoryTop, gHob->Phit.EfiFreeMemoryBottom,

+    gHob->NvStorageFvb.FvbInfo.Entries[0].Base, (UINTN) gHob->NvFtwFvb.FvbInfo.Entries[0].Length,

+    gHob->BfvResource.PhysicalStart, gHob->BfvResource.ResourceLength,

+    gHob->NvStorageFvResource.PhysicalStart, gHob->NvStorageFvResource.ResourceLength,

+    gHob->NvStorage.FvbInfo.Entries[0].Base, gHob->NvStorage.FvbInfo.Entries[0].Length,

+    gHob->NvFtwFvResource.PhysicalStart, gHob->NvFtwFvResource.ResourceLength,

+    gHob->NvFtwWorking.FvbInfo.Entries[0].Base, gHob->NvFtwWorking.FvbInfo.Entries[0].Length,

+    gHob->NvFtwSpare.FvbInfo.Entries[0].Base, gHob->NvFtwSpare.FvbInfo.Entries[0].Length,

+    gHob->Stack.AllocDescriptor.MemoryBaseAddress, gHob->Stack.AllocDescriptor.MemoryLength,

+    PageTableBase,

+    gHob->MemoryFreeUnder1MB.PhysicalStart, gHob->MemoryFreeUnder1MB.ResourceLength,

+    gHob->MemoryAbove1MB.PhysicalStart, gHob->MemoryAbove1MB.ResourceLength,

+    gHob->MemoryAbove4GB.PhysicalStart, gHob->MemoryAbove4GB.ResourceLength,

+    gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress, gHob->DxeCore.MemoryAllocationHeader.MemoryLength,

+    gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress, gHob->MemoryAllocation.AllocDescriptor.MemoryLength

+    );

 

   ClearScreen();

-  PrintString("\n\n\n\n\n\n\n\n\n\n");

-  PrintString("                         WELCOME TO EFI WORLD!\n");

+  PrintString (

+    "\n\n\n\n\n\n\n\n\n\n"

+    "                         WELCOME TO EFI WORLD!\n"

+    );

   

   EnterDxeMain (StackTop, Handoff->DxeCoreEntryPoint, gHob, PageTableBase);

+  PrintString ("Fail to enter DXE main!\n");

  

-  PrintString("Fail to enter DXE main!\n");

   //

   // Should never get here

   //

diff --git a/DuetPkg/DxeIpl/DxeIpl.inf b/DuetPkg/DxeIpl/DxeIpl.inf
index 71a04f7..6c00084 100644
--- a/DuetPkg/DxeIpl/DxeIpl.inf
+++ b/DuetPkg/DxeIpl/DxeIpl.inf
@@ -1,6 +1,6 @@
 ## @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                          

 # 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        

@@ -33,6 +33,7 @@
   BaseLib

   BaseMemoryLib

   PrintLib

+  SerialPortLib

   ReportStatusCodeLib

   IoLib

 

@@ -63,13 +64,5 @@
   Ia32/Paging.c

   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]

   TRUE

diff --git a/DuetPkg/DxeIpl/PpisNeededByDxeCore.c b/DuetPkg/DxeIpl/PpisNeededByDxeCore.c
index 1ece7d8..e08a148 100644
--- a/DuetPkg/DxeIpl/PpisNeededByDxeCore.c
+++ b/DuetPkg/DxeIpl/PpisNeededByDxeCore.c
@@ -1,6 +1,6 @@
 /** @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                          

 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        

@@ -48,27 +48,8 @@
 

 --*/

 {

-  //EFI_PEI_PE_COFF_LOADER_PROTOCOL           *PeCoffLoader;

-  //EFI_DECOMPRESS_PROTOCOL                   *EfiDecompress;

-  //EFI_TIANO_DECOMPRESS_PROTOCOL             *TianoDecompress;

   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);

   Hob->SerialStatusCode.Interface = (EFI_PHYSICAL_ADDRESS) (UINTN) ReportStatusCode;

 

diff --git a/DuetPkg/DxeIpl/SerialStatusCode.c b/DuetPkg/DxeIpl/SerialStatusCode.c
index e936db5..27e8644 100644
--- a/DuetPkg/DxeIpl/SerialStatusCode.c
+++ b/DuetPkg/DxeIpl/SerialStatusCode.c
@@ -1,6 +1,6 @@
 /** @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                          

 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        

@@ -18,16 +18,9 @@
 

 **/

 

+#include <Library/SerialPortLib.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.

 //

@@ -602,68 +595,6 @@
 }

 

 

-

-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

 EFIAPI 

 SerialReportStatusCode (

@@ -697,7 +628,7 @@
   CHAR8                   *Format;

   BASE_LIST               Marker;

   UINT32                  ErrorLevel;

-  UINTN                   CharCount;

+  UINTN                   CharCount = 0;

 

   Buffer[0] = '\0';

 

@@ -706,7 +637,7 @@
     //

     // Processes PEI_ASSERT ()

     //

-    AsciiSPrint (

+    CharCount = AsciiSPrint (

       Buffer,

       sizeof (Buffer),

       "\nPEI_ASSERT!: %a (%d): %a\n",

@@ -720,7 +651,7 @@
     //

     // 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) { 

     //

@@ -744,7 +675,7 @@
     //

     // Callout to platform Lib function to do print.

     //

-    DebugSerialPrint (Buffer);

+    SerialPortWrite (Buffer, CharCount);

   }

 

   //

@@ -786,7 +717,7 @@
         //

         // Concatenate the instance

         //

-        AsciiSPrint (

+        CharCount = AsciiSPrint (

           Buffer,

           sizeof (Buffer),

           "%a:%a:%a:%d\n",

@@ -796,7 +727,7 @@
           Instance

           );

 

-        DebugSerialPrint (Buffer);

+        SerialPortWrite (Buffer, CharCount);

       }

     }

 

@@ -812,15 +743,11 @@
 

 Routine Description:

 

-  Initialize Serial Port

-

-    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.

+  Initialize Serial Port and Status Code Handler

 

 Arguments: 

 

-  None

+  ReportStatusCode - A pointer to the handler

 

 Returns: 

 

@@ -828,41 +755,6 @@
 

 --*/

 {

-  UINTN           Divisor;

-  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);

-

+  SerialPortInitialize();

   *ReportStatusCode = SerialReportStatusCode;

 }

diff --git a/DuetPkg/DxeIpl/SerialStatusCode.h b/DuetPkg/DxeIpl/SerialStatusCode.h
index d4989d1..7146927 100644
--- a/DuetPkg/DxeIpl/SerialStatusCode.h
+++ b/DuetPkg/DxeIpl/SerialStatusCode.h
@@ -1,6 +1,6 @@
 /** @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                          

 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        

@@ -31,50 +31,6 @@
 //

 

 

-//---------------------------------------------

-// 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

 InstallSerialStatusCode (

   IN EFI_REPORT_STATUS_CODE    *ReportStatusCode

diff --git a/DuetPkg/EfiLdr/Debug.c b/DuetPkg/EfiLdr/Debug.c
index a4a067c..f4cd7c1 100644
--- a/DuetPkg/EfiLdr/Debug.c
+++ b/DuetPkg/EfiLdr/Debug.c
@@ -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                          

 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        

@@ -19,11 +19,11 @@
 --*/

 #include "EfiLdr.h"

 #include "Debug.h"

-#include <Library/SerialPortLib.h>

 

 UINT8 *mCursor;

 UINT8 mHeaderIndex = 10;

 

+

 VOID

 PrintHeader (

   CHAR8 Char

@@ -48,82 +48,25 @@
   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

 PrintString (

-  CHAR8 *String

+  IN CONST CHAR8  *FormatString,

+  ...

   )

 {

-  UINT32 Index;

+  UINTN           Index;

+  CHAR8           PrintBuffer[256];

+  VA_LIST         Marker;

 

-  for (Index = 0; String[Index] != 0; Index++) {

-    if (String[Index] == '\n') {

-      mCursor = (UINT8 *)(UINTN)(0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));

+  VA_START (Marker, FormatString);

+  AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);

+  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 {

-      *mCursor = String[Index];

+      *mCursor = (UINT8) PrintBuffer[Index];

       mCursor += 2;

     }

   }

@@ -131,6 +74,6 @@
   //

   // All information also output to serial port.

   //

-  SerialPortWrite ((UINT8*) String, Index);

+  SerialPortWrite (PrintBuffer, Index);

 }

 

diff --git a/DuetPkg/EfiLdr/Debug.h b/DuetPkg/EfiLdr/Debug.h
index cd1d5d9..f6aa7a2 100644
--- a/DuetPkg/EfiLdr/Debug.h
+++ b/DuetPkg/EfiLdr/Debug.h
@@ -26,19 +26,10 @@
   CHAR8 Char

   );

 

-VOID 

-PrintValue (

-  UINT32 Value

-  );

-

 VOID

-PrintValue64 (

-  UINT64 Value

-  );

-

-VOID 

 PrintString (

-  CHAR8 *String

+  IN CONST CHAR8  *FormatString,

+  ...

   );

 

 VOID 

diff --git a/DuetPkg/EfiLdr/EfiLdr.h b/DuetPkg/EfiLdr/EfiLdr.h
index 9434a78..665f405 100644
--- a/DuetPkg/EfiLdr/EfiLdr.h
+++ b/DuetPkg/EfiLdr/EfiLdr.h
@@ -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                          

 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        

@@ -29,6 +29,7 @@
 #include <Library/BaseLib.h>

 #include <Library/BaseMemoryLib.h>

 #include <Library/PrintLib.h>

+#include <Library/SerialPortLib.h>

 

 #define INT15_E820_AddressRangeMemory   1

 #define INT15_E820_AddressRangeReserved 2

diff --git a/DuetPkg/EfiLdr/EfiLdr.inf b/DuetPkg/EfiLdr/EfiLdr.inf
index ea3977d..b5a46db 100644
--- a/DuetPkg/EfiLdr/EfiLdr.inf
+++ b/DuetPkg/EfiLdr/EfiLdr.inf
@@ -1,6 +1,6 @@
 ## @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                          

 # 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        

@@ -20,7 +20,6 @@
   INF_VERSION                    = 0x00010005

   BASE_NAME                      = EfiLoader

   FILE_GUID                      = A9620E5C-5FA1-40b7-8B21-50B632F88F38

-  #MODULE_TYPE                    = USER_DEFINED

   MODULE_TYPE                    = UEFI_APPLICATION

   VERSION_STRING                 = 1.0

 

@@ -53,8 +52,4 @@
   gTianoCustomDecompressGuid

 

 [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

diff --git a/DuetPkg/EfiLdr/EfiLoader.c b/DuetPkg/EfiLdr/EfiLoader.c
index f10db53..6913027 100644
--- a/DuetPkg/EfiLdr/EfiLoader.c
+++ b/DuetPkg/EfiLdr/EfiLoader.c
@@ -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                          

 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        

@@ -25,12 +25,14 @@
 #include "LzmaDecompress.h"

 

 VOID

-SystemHang(

-  VOID

+SystemHang (

+  CHAR8        *Message

   )

 {

-  CHAR8 PrintBuffer[256];

-  AsciiSPrint (PrintBuffer, 256, "## FATEL ERROR ##: Fail to load DUET images! System hang!\n");

+  PrintString (

+    "%s## FATAL ERROR ##: Fail to load DUET images! System hang!\n",

+    Message

+    );

   CpuDeadLoop();

 }

 

@@ -49,52 +51,45 @@
   UINTN                 BfvPageNumber;

   UINTN                 BfvBase;

   EFI_MAIN_ENTRYPOINT   EfiMainEntrypoint;

-  CHAR8                 PrintBuffer[256];

   EFILDRHANDOFF         Handoff;

+  UINTN                 Index;

 

   ClearScreen();

   

   PrintHeader ('A');

-  
-  AsciiSPrint (PrintBuffer, 256, "Enter DUET Loader...\n");

-  PrintString (PrintBuffer);

-

-  AsciiSPrint (PrintBuffer, 256, "BiosMemoryMapBaseAddress = 0x%x\n", BiosMemoryMapBaseAddress);

-  PrintString (PrintBuffer);

+  

+  PrintString ("Enter DUET Loader...\n");

+  PrintString ("BiosMemoryMapBaseAddress = %x\n", (UINTN) BiosMemoryMapBaseAddress);

 

   //

   // 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.

   //

-  BiosMemoryMap = (BIOS_MEMORY_MAP *)(UINTN)(BiosMemoryMapBaseAddress);

+  BiosMemoryMap = (BIOS_MEMORY_MAP *) (UINTN) BiosMemoryMapBaseAddress;

   NumberOfMemoryMapEntries = 0;

   GenMemoryMap (&NumberOfMemoryMapEntries, EfiMemoryDescriptor, BiosMemoryMap);

 

-  AsciiSPrint (PrintBuffer, 256, "Get %d entries of memory map!\n", NumberOfMemoryMapEntries);

-  PrintString (PrintBuffer);

+  PrintString ("Get %d entries of memory map!\n", NumberOfMemoryMapEntries);

 

   //

   // 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));

 

 

   //

   // Point to the 4th image (Bfv)

   //

-    

   EFILDRImage += 3;

 

   //

   // Decompress the image

   //

-

-  AsciiSPrint (PrintBuffer, 256, "Decompress BFV image, Image Address=0x%x Offset=0x%x\n", 

-               (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

-               EFILDRImage->Offset);

-  PrintString (PrintBuffer);

+  PrintString (

+    "Decompress BFV image, Image Address = %x Offset = %x\n", 

+    (UINTN) (EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

+    (UINTN) EFILDRImage->Offset

+    );

   Status = LzmaUefiDecompressGetInfo (

              (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

              EFILDRImage->Length,

@@ -103,14 +98,10 @@
              );

 

   if (EFI_ERROR (Status)) {

-    AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for BFV!\n");

-    PrintString (PrintBuffer);

-    SystemHang();

+    SystemHang ("Failed to get decompress information for BFV!\n");

   }

   

-  AsciiSPrint (PrintBuffer, 256, "BFV decompress: DestinationSize=0x%X, ScratchSize=0x%X!\n",

-               DestinationSize, ScratchSize);

-  PrintString (PrintBuffer);

+  PrintString ("BFV decompress: DestinationSize = %x, ScratchSize = %x\n", (UINTN) DestinationSize, (UINTN) ScratchSize);

   Status =  LzmaUefiDecompress (

     (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

     EFILDRImage->Length,

@@ -120,15 +111,13 @@
   

 

   if (EFI_ERROR (Status)) {

-    AsciiSPrint (PrintBuffer, 256, "Fail to decompress BFV!\n");

-    PrintString (PrintBuffer);

-    SystemHang();

+    SystemHang ("Failed to decompress BFV!\n");

   }

 

   BfvPageNumber = EFI_SIZE_TO_PAGES (DestinationSize);

   BfvBase = (UINTN) FindSpace (BfvPageNumber, &NumberOfMemoryMapEntries, EfiMemoryDescriptor, EfiRuntimeServicesData, EFI_MEMORY_WB);

   if (BfvBase == 0) {

-    SystemHang();

+    SystemHang ("Failed to find free space to hold decompressed BFV\n");

   }

   ZeroMem ((VOID *)(UINTN)BfvBase, BfvPageNumber * EFI_PAGE_SIZE);

   CopyMem ((VOID *)(UINTN)BfvBase, (VOID *)(UINTN)EFI_DECOMPRESSED_BUFFER_ADDRESS, DestinationSize);

@@ -144,10 +133,11 @@
   //

   // Decompress the image

   //

-  AsciiSPrint (PrintBuffer, 256, "Decompress DxeIpl image, Image Address=0x%x Offset=0x%x\n", 

-               (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

-               EFILDRImage->Offset);

-  PrintString (PrintBuffer);

+  PrintString (

+    "Decompress DxeIpl image, Image Address = %x Offset = %x\n", 

+    (UINTN) (EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

+    (UINTN) EFILDRImage->Offset

+    );

 

   Status = LzmaUefiDecompressGetInfo (

              (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

@@ -156,9 +146,7 @@
              &ScratchSize

              );

   if (EFI_ERROR (Status)) {

-    AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for DxeIpl!\n");

-    PrintString (PrintBuffer);

-    SystemHang();

+    SystemHang ("Failed to get decompress information for DxeIpl!\n");

   }

 

   Status = LzmaUefiDecompress (

@@ -168,13 +156,10 @@
              (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)

              );

   if (EFI_ERROR (Status)) {

-    AsciiSPrint (PrintBuffer, 256, "Fail to decompress DxeIpl image\n");

-    PrintString (PrintBuffer);

-    SystemHang();

+    SystemHang ("Failed to decompress DxeIpl image\n");

   }

 

-  AsciiSPrint (PrintBuffer, 256, "Start load DxeIpl PE image\n");

-  PrintString (PrintBuffer);  

+  PrintString ("Start load DxeIpl PE image\n");  

 

   //

   // Load and relocate the EFI PE/COFF Firmware Image 

@@ -186,33 +171,29 @@
              EfiMemoryDescriptor

              );

   if (EFI_ERROR (Status)) {

-    AsciiSPrint (PrintBuffer, 256, "Fail to load and relocate DxeIpl PE image!\n");

-    PrintString (PrintBuffer);

-    SystemHang();

+    SystemHang ("Failed to load and relocate DxeIpl PE image!\n");

   }

-  AsciiSPrint (PrintBuffer, 256, "DxeIpl PE image is successed loaded at 0x%x, entry=0x%x\n",

-               (UINTN)DxeIplImage.ImageBasePage, (UINTN)DxeIplImage.EntryPoint);

-  PrintString (PrintBuffer);  

-

-//  PrintString("Image.NoPages = ");   

-//  PrintValue(Image.NoPages);

-//  PrintString("\n");

+  PrintString (

+    "DxeIpl PE image is successed loaded at %lx, entry=%p\n",

+    DxeIplImage.ImageBasePage,

+    DxeIplImage.EntryPoint

+    );

 

 PrintHeader ('C');

 

   //

   // Point to the 3rd image (DxeMain)

   //

-    

   EFILDRImage++;

 

   //

   // Decompress the image

   //

-  AsciiSPrint (PrintBuffer, 256, "Decompress DXEMain FV image, Image Address=0x%x! Offset=0x%x\n", 

-               (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

-               EFILDRImage->Offset);

-  PrintString (PrintBuffer);

+  PrintString (

+    "Decompress DxeMain FV image, Image Address = %x Offset = %x\n",

+    (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

+    (UINTN) EFILDRImage->Offset

+    );

 

   Status = LzmaUefiDecompressGetInfo (

              (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),

@@ -221,9 +202,7 @@
              &ScratchSize

              );

   if (EFI_ERROR (Status)) {

-    AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for DXEMain FV image!\n");

-    PrintString (PrintBuffer);

-    SystemHang();

+    SystemHang ("Failed to get decompress information for DxeMain FV image!\n");

   }

 

   Status = LzmaUefiDecompress (

@@ -233,7 +212,7 @@
              (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)

              );

   if (EFI_ERROR (Status)) {

-    SystemHang();

+    SystemHang ("Failed to decompress DxeMain FV image!\n");

   }

 

   //

@@ -246,33 +225,26 @@
              EfiMemoryDescriptor

              );

   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",

-               (UINTN)DxeCoreImage.ImageBasePage, (UINTN)DxeCoreImage.EntryPoint);

-  PrintString (PrintBuffer);  

+  PrintString (

+    "DxeCore PE image is successed loaded at %lx, entry=%p\n",

+    DxeCoreImage.ImageBasePage,

+    DxeCoreImage.EntryPoint

+    );

 

 PrintHeader ('E');

 

   //

   // Display the table of memory descriptors.

   //

-

-//  PrintString("\nEFI Memory Descriptors\n");   

-/*

-  {

-  UINTN Index;

+  PrintString ("\nEFI Memory Descriptors\n");   

   for (Index = 0; Index < NumberOfMemoryMapEntries; Index++) {

-    PrintString("Type = ");   

-    PrintValue(EfiMemoryDescriptor[Index].Type);

-    PrintString("  Start = ");   

-    PrintValue((UINT32)(EfiMemoryDescriptor[Index].PhysicalStart));

-    PrintString("  NumberOfPages = ");   

-    PrintValue((UINT32)(EfiMemoryDescriptor[Index].NumberOfPages));

-    PrintString("\n");

+    PrintString (

+      "Type = %x Start = %08lx NumberOfPages = %08lx\n",

+      EfiMemoryDescriptor[Index].Type, EfiMemoryDescriptor[Index].PhysicalStart, EfiMemoryDescriptor[Index].NumberOfPages

+      );

   }

-  }

-*/

 

   //

   // Jump to EFI Firmware

@@ -290,10 +262,9 @@
     Handoff.DxeCoreImageSize  = DxeCoreImage.NoPages * EFI_PAGE_SIZE;

     Handoff.DxeCoreEntryPoint = (VOID *)(UINTN)DxeCoreImage.EntryPoint;

 

-    AsciiSPrint (PrintBuffer, 256, "Transfer to DxeIpl ...Address=0x%x\n", (UINTN)DxeIplImage.EntryPoint);

-    PrintString (PrintBuffer);

+    PrintString ("Transfer to DxeIpl ...EntryPoint = %p\n", DxeIplImage.EntryPoint);

     

-    EfiMainEntrypoint = (EFI_MAIN_ENTRYPOINT)(UINTN)DxeIplImage.EntryPoint;

+    EfiMainEntrypoint = (EFI_MAIN_ENTRYPOINT) DxeIplImage.EntryPoint;

     EfiMainEntrypoint (&Handoff);

   }

 

@@ -303,7 +274,7 @@
   // There was a problem loading the image, so HALT the system.

   //

 

-  SystemHang();

+  SystemHang ("Failed to jump to DxeIpl!\n");

 }

 

 EFI_STATUS

@@ -312,6 +283,7 @@
   UINT32    BiosMemoryMapBaseAddress

   )

 {

+  SerialPortInitialize ();

   EfiLoader(BiosMemoryMapBaseAddress);

   return EFI_SUCCESS;

 }