]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Change DUET DxeIpl to use SerialPort instead of manipulating serial port directly.
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 23 Jun 2011 08:31:18 +0000 (08:31 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 23 Jun 2011 08:31:18 +0000 (08:31 +0000)
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

15 files changed:
DuetPkg/DuetPkg.fdf
DuetPkg/DuetPkgIa32.dsc
DuetPkg/DuetPkgX64.dsc
DuetPkg/DxeIpl/Debug.c
DuetPkg/DxeIpl/Debug.h
DuetPkg/DxeIpl/DxeInit.c
DuetPkg/DxeIpl/DxeIpl.inf
DuetPkg/DxeIpl/PpisNeededByDxeCore.c
DuetPkg/DxeIpl/SerialStatusCode.c
DuetPkg/DxeIpl/SerialStatusCode.h
DuetPkg/EfiLdr/Debug.c
DuetPkg/EfiLdr/Debug.h
DuetPkg/EfiLdr/EfiLdr.h
DuetPkg/EfiLdr/EfiLdr.inf
DuetPkg/EfiLdr/EfiLoader.c

index ef4b5fee0b546d962019bdac0c7487d411128212..f6bcdd9fdb63b6695b7da787155182eef70e7006 100644 (file)
@@ -24,7 +24,6 @@
 ################################################################################\r
 [FV.DuetEfiMainFv]\r
 BlockSize          = 0x10000\r
-NumBlocks          = 0x2a\r
 FvAlignment        = 16         #FV alignment and FV attributes setting.\r
 ERASE_POLARITY     = 1\r
 MEMORY_MAPPED      = TRUE\r
index 71c9aee5969de992732eb838280c975412dac34a..3d70dab369bc164418602d80ebcfccdc3d06e813 100644 (file)
@@ -98,7 +98,8 @@
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
-  SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf\r
+  PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf\r
+  SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf\r
   MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf\r
   \r
   #\r
index 5f0ec2bdf102840d8be67fc0a0016fe47b3de8ac..c2f60f61ae024699f9a762be0be48a68225386e5 100644 (file)
@@ -98,7 +98,8 @@
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
-  SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf\r
+  PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf\r
+  SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf\r
   MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf\r
   \r
   #\r
index 34628156403f656b78c4b0886a05b99624669674..950c06b118a802a8e3ac6f95cb14e6fcdb6bc8e4 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -19,6 +19,7 @@ Revision History:
 **/\r
 \r
 #include "DxeIpl.h"\r
+#include <Library/SerialPortLib.h>\r
 #include "SerialStatusCode.h"\r
 #include "Debug.h"\r
 \r
@@ -50,58 +51,32 @@ ClearScreen (
   mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);\r
 }\r
 \r
-VOID\r
-PrintValue (\r
-  UINT32 Value\r
-  )\r
-{\r
-  UINT32 Index;\r
-  CHAR8  Char;\r
-  CHAR8  String[9];\r
-\r
-  for (Index = 0; Index < 8; Index++) {\r
-    Char = (UINT8)(((Value >> ((7 - Index) * 4)) & 0x0f) + '0');\r
-    if (Char > '9') {\r
-      Char = (UINT8) (Char - '0' - 10 + 'A');\r
-    }\r
-    String[Index] = Char;\r
-  }\r
-\r
-  String[sizeof (String) - 1] = '\0';\r
-\r
-  PrintString (String);\r
-}\r
-\r
-VOID\r
-PrintValue64 (\r
-  UINT64 Value\r
-  )\r
-{\r
-  PrintValue ((UINT32) RShiftU64 (Value, 32));\r
-  PrintValue ((UINT32) Value);\r
-}\r
-\r
-\r
-\r
 VOID\r
 PrintString (\r
-  CHAR8 *String\r
+  IN CONST CHAR8  *FormatString,\r
+  ...\r
   )\r
 {\r
-  UINT32 Index;\r
+  UINTN           Index;\r
+  CHAR8           PrintBuffer[1000];\r
+  VA_LIST         Marker;\r
 \r
-  for (Index = 0; String[Index] != 0; Index++) {\r
-    if (String[Index] == '\n') {\r
-      mCursor = (UINT8 *)(UINTN)(0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));\r
+  VA_START (Marker, FormatString);\r
+  AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);\r
+  VA_END (Marker);\r
+\r
+  for (Index = 0; PrintBuffer[Index] != 0; Index++) {\r
+    if (PrintBuffer[Index] == '\n') {\r
+      mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));\r
     } else {\r
-      *mCursor = String[Index];\r
+      *mCursor = (UINT8) PrintBuffer[Index];\r
       mCursor += 2;\r
     }\r
   }\r
-  \r
+\r
   //\r
   // All information also output to serial port.\r
   //\r
-  DebugSerialPrint ((CHAR8*)String);\r
+  SerialPortWrite (PrintBuffer, Index);\r
 }\r
 \r
index ec3997b9fd2638582a72a56d832022c219f70031..7fcad268ee232194deabb6f06ad20dd3a444e2b1 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -26,19 +26,10 @@ PrintHeader (
   CHAR8 Char\r
   );\r
 \r
-VOID \r
-PrintValue (\r
-  UINT32 Value\r
-  );\r
-\r
 VOID\r
-PrintValue64 (\r
-  UINT64 Value\r
-  );\r
-\r
-VOID \r
 PrintString (\r
-  CHAR8 *String\r
+  IN CONST CHAR8  *FormatString,\r
+  ...\r
   );\r
 \r
 VOID \r
index b10e273f0ce968442374990e163cf3ffbaf5c8d0..223cbcd49e7010fa2f0ffcb0781e648b4f29ec07 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -137,55 +137,42 @@ Returns:
   VOID                  *MemoryTopOnDescriptor;\r
   VOID                  *MemoryDescriptor;\r
   VOID                  *NvStorageBase;\r
-  CHAR8                 PrintBuffer[256];\r
   EFILDRHANDOFF         HandoffCopy;\r
 \r
   CopyMem ((VOID*) &HandoffCopy, (VOID*) Handoff, sizeof (EFILDRHANDOFF));\r
   Handoff = &HandoffCopy;\r
 \r
   ClearScreen();\r
-  PrintString("Enter DxeIpl ...\n");\r
-  \r
-/*\r
-  ClearScreen();\r
-  PrintString("handoff:\n");\r
-  PrintString("Handoff.BfvBase = ");   \r
-  PrintValue64((UINT64)(UINTN)Handoff->BfvBase);\r
-  PrintString(", ");   \r
-  PrintString("BfvLength = ");   \r
-  PrintValue64(Handoff->BfvSize);\r
-  PrintString("\n");   \r
-  PrintString("Handoff.DxeIplImageBase = ");   \r
-  PrintValue64((UINT64)(UINTN)Handoff->DxeIplImageBase);\r
-  PrintString(", ");   \r
-  PrintString("DxeIplImageSize = ");   \r
-  PrintValue64(Handoff->DxeIplImageSize);\r
-  PrintString("\n");   \r
-  PrintString("Handoff.DxeCoreImageBase = ");   \r
-  PrintValue64((UINT64)(UINTN)Handoff->DxeCoreImageBase);\r
-  PrintString(", ");   \r
-  PrintString("DxeCoreImageSize = ");   \r
-  PrintValue64(Handoff->DxeCoreImageSize);\r
-  PrintString("\n");   \r
-*/\r
+\r
+  PrintString (\r
+    "Enter DxeIpl ...\n"\r
+    "Handoff:\n"\r
+    "Handoff.BfvBase = %p, BfvLength = %x\n"\r
+    "Handoff.DxeIplImageBase = %p, DxeIplImageSize = %x\n"\r
+    "Handoff.DxeCoreImageBase = %p, DxeCoreImageSize = %x\n",\r
+    Handoff->BfvBase, Handoff->BfvSize,\r
+    Handoff->DxeIplImageBase, Handoff->DxeIplImageSize,\r
+    Handoff->DxeCoreImageBase, Handoff->DxeCoreImageSize\r
+    );\r
+\r
   //\r
   // Hob Generation Guild line:\r
   //   * Don't report FV as physical memory\r
   //   * MemoryAllocation Hob should only cover physical memory\r
   //   * Use ResourceDescriptor Hob to report physical memory or Firmware Device and they shouldn't be overlapped\r
-  PrintString("Prepare Cpu HOB information ...\n");\r
+  PrintString ("Prepare Cpu HOB information ...\n");\r
   PrepareHobCpu ();\r
 \r
   //\r
   // 1. BFV\r
   //\r
-  PrintString("Prepare BFV HOB information ...\n");\r
+  PrintString ("Prepare BFV HOB information ...\n");\r
   PrepareHobBfv (Handoff->BfvBase, Handoff->BfvSize);\r
 \r
   //\r
   // 2. Updates Memory information, and get the top free address under 4GB\r
   //\r
-  PrintString("Prepare Memory HOB information ...\n");\r
+  PrintString ("Prepare Memory HOB information ...\n");\r
   MemoryTopOnDescriptor = PrepareHobMemory (Handoff->MemDescCount, Handoff->MemDesc);\r
   \r
   //\r
@@ -193,17 +180,13 @@ Returns:
   //\r
   \r
   //   3.1 NV data\r
-  PrintString("Prepare NV Storage information ...\n");\r
+  PrintString ("Prepare NV Storage information ...\n");\r
   NvStorageBase = PrepareHobNvStorage (MemoryTopOnDescriptor);\r
-  AsciiSPrint (PrintBuffer, 256, "NV Storage Base=0x%x\n", (UINTN)NvStorageBase);\r
-  PrintString (PrintBuffer);\r
-  \r
+  PrintString ("NV Storage Base = %p\n", NvStorageBase);\r
   //   3.2 Stack\r
   StackTop = NvStorageBase;\r
   StackBottom = PrepareHobStack (StackTop);\r
-  AsciiSPrint (PrintBuffer, 256, "Stack Top=0x%x, Stack Bottom=0x%x\n", \r
-              (UINTN)StackTop, (UINTN)StackBottom);\r
-  PrintString (PrintBuffer);\r
+  PrintString ("Stack Top=0x%x, Stack Bottom=0x%x\n", StackTop, StackBottom);\r
   //   3.3 Page Table\r
   PageTableBase = PreparePageTable (StackBottom, gHob->Cpu.SizeOfMemorySpace);\r
   //   3.4 MemDesc (will be used in PlatformBds)\r
@@ -214,7 +197,7 @@ Returns:
   //\r
   // 4. Register the memory occupied by DxeCore and DxeIpl together as DxeCore\r
   //\r
-  PrintString("Prepare DxeCore memory Hob ...\n");\r
+  PrintString ("Prepare DxeCore memory Hob ...\n");\r
   PrepareHobDxeCore (\r
     Handoff->DxeCoreEntryPoint,\r
     (EFI_PHYSICAL_ADDRESS)(UINTN)Handoff->DxeCoreImageBase,\r
@@ -227,125 +210,57 @@ Returns:
 \r
   CompleteHobGeneration ();\r
 \r
-  AsciiSPrint (PrintBuffer, 256, "HobStart=0x%x\n", (UINTN)gHob);\r
-  PrintString (PrintBuffer);\r
-\r
-  AsciiSPrint (PrintBuffer, 256, "Memory Top=0x%x, Bottom=0x%x\n", \r
-              (UINTN)gHob->Phit.EfiMemoryTop, (UINTN)gHob->Phit.EfiMemoryBottom);\r
-  PrintString (PrintBuffer);\r
-\r
-  AsciiSPrint (PrintBuffer, 256, "Free Memory Top=0x%x, Bottom=0x%x\n", \r
-              (UINTN)gHob->Phit.EfiFreeMemoryTop, (UINTN)gHob->Phit.EfiFreeMemoryBottom);\r
-  PrintString (PrintBuffer);\r
-\r
-  AsciiSPrint (PrintBuffer, 256, "Nv Base=0x%x, Length=0x%x\n", \r
-              (UINTN)gHob->NvStorageFvb.FvbInfo.Entries[0].Base, \r
-              (UINTN)gHob->NvFtwFvb.FvbInfo.Entries[0].Length);\r
-  PrintString (PrintBuffer);\r
-/*\r
   //\r
   // Print Hob Info\r
   //\r
   ClearScreen();\r
-  PrintString("Hob Info\n");\r
-  PrintString("Phit.EfiMemoryTop = ");   \r
-  PrintValue64(gHob->Phit.EfiMemoryTop);\r
-  PrintString(" Phit.EfiMemoryBottom = ");   \r
-  PrintValue64(gHob->Phit.EfiMemoryBottom);\r
-  PrintString("\n");   \r
-  PrintString("Phit.EfiFreeMemoryTop = ");   \r
-  PrintValue64(gHob->Phit.EfiFreeMemoryTop);\r
-  PrintString(" Phit.EfiFreeMemoryBottom = ");   \r
-  PrintValue64(gHob->Phit.EfiFreeMemoryBottom);\r
-  PrintString("\n");   \r
-  PrintString("Bfv = ");   \r
-  PrintValue64(gHob->Bfv.BaseAddress);\r
-  PrintString(" BfvLength = ");   \r
-  PrintValue64(gHob->Bfv.Length);\r
-  PrintString("\n");\r
-  PrintString("NvStorageFvb = ");\r
-  PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Base);\r
-  PrintString(" Length = ");\r
-  PrintValue64(gHob->NvStorageFvb.FvbInfo.Entries[0].Length);\r
-  PrintString("\n");\r
-  PrintString("NvFtwFvb = ");\r
-  PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Base);\r
-  PrintString(" Length = ");\r
-  PrintValue64(gHob->NvFtwFvb.FvbInfo.Entries[0].Length);\r
-  PrintString("\n");\r
-  PrintString("BfvResource = ");\r
-  PrintValue64(gHob->BfvResource.PhysicalStart);\r
-  PrintString(" Length = ");\r
-  PrintValue64(gHob->BfvResource.ResourceLength);\r
-  PrintString("\n");\r
-  PrintString("NvStorageFvResource = ");\r
-  PrintValue64(gHob->NvStorageFvResource.PhysicalStart);\r
-  PrintString(" Length = ");\r
-  PrintValue64(gHob->NvStorageFvResource.ResourceLength);\r
-  PrintString("\n");\r
-  PrintString("NvStorage = ");\r
-  PrintValue64(gHob->NvStorage.FvbInfo.Entries[0].Base);\r
-  PrintString(" Length = ");\r
-  PrintValue64(gHob->NvStorage.FvbInfo.Entries[0].Length);\r
-  PrintString("\n");\r
-  PrintString("NvFtwFvResource = ");\r
-  PrintValue64(gHob->NvFtwFvResource.PhysicalStart);\r
-  PrintString(" Length = ");\r
-  PrintValue64(gHob->NvFtwFvResource.ResourceLength);\r
-  PrintString("\n");\r
-  PrintString("NvFtwWorking = ");\r
-  PrintValue64(gHob->NvFtwWorking.FvbInfo.Entries[0].Base);\r
-  PrintString(" Length = ");\r
-  PrintValue64(gHob->NvFtwWorking.FvbInfo.Entries[0].Length);\r
-  PrintString("\n");\r
-  PrintString("NvFtwSpare = ");\r
-  PrintValue64(gHob->NvFtwSpare.FvbInfo.Entries[0].Base);\r
-  PrintString(" Length = ");\r
-  PrintValue64(gHob->NvFtwSpare.FvbInfo.Entries[0].Length);\r
-  PrintString("\n");\r
-  PrintString("Stack = ");   \r
-  PrintValue64(gHob->Stack.AllocDescriptor.MemoryBaseAddress);\r
-  PrintString(" StackLength = ");   \r
-  PrintValue64(gHob->Stack.AllocDescriptor.MemoryLength);\r
-  PrintString("\n");   \r
-  PrintString("PageTable = ");   \r
-  PrintValue64((UINTN)PageTableBase);\r
-  PrintString("\n");     \r
-  PrintString("MemoryFreeUnder1MB = ");   \r
-  PrintValue64(gHob->MemoryFreeUnder1MB.PhysicalStart);\r
-  PrintString(" MemoryFreeUnder1MBLength = ");   \r
-  PrintValue64(gHob->MemoryFreeUnder1MB.ResourceLength);\r
-  PrintString("\n");   \r
-  PrintString("MemoryAbove1MB = ");   \r
-  PrintValue64(gHob->MemoryAbove1MB.PhysicalStart);\r
-  PrintString(" MemoryAbove1MBLength = ");   \r
-  PrintValue64(gHob->MemoryAbove1MB.ResourceLength);\r
-  PrintString("\n");   \r
-  PrintString("MemoryAbove4GB = ");   \r
-  PrintValue64(gHob->MemoryAbove4GB.PhysicalStart);\r
-  PrintString(" MemoryAbove4GBLength = ");   \r
-  PrintValue64(gHob->MemoryAbove4GB.ResourceLength);\r
-  PrintString("\n");   \r
-  PrintString("DxeCore = ");   \r
-  PrintValue64(gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress);\r
-  PrintString(" DxeCoreLength = ");   \r
-  PrintValue64(gHob->DxeCore.MemoryAllocationHeader.MemoryLength);\r
-  PrintString("\n");   \r
-  PrintString("MemoryAllocation = ");   \r
-  PrintValue64(gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress);\r
-  PrintString(" MemoryLength = ");   \r
-  PrintValue64(gHob->MemoryAllocation.AllocDescriptor.MemoryLength);\r
-  PrintString("\n");   \r
-  EFI_DEADLOOP();\r
-*/\r
+  PrintString (\r
+    "HobStart = %p\n"\r
+    "Memory Top = %lx, Bottom = %lx\n"\r
+    "Free Memory Top = %lx, Bottom = %lx\n"\r
+    "NvStorageFvb = %p, Length = %x\n"\r
+    "BfvResource = %lx, Length = %lx\n"\r
+    "NvStorageFvResource = %lx, Length = %lx\n"\r
+    "NvStorage = %lx, Length = %lx\n"\r
+    "NvFtwFvResource = %lx, Length = %lx\n"\r
+    "NvFtwWorking = %lx, Length = %lx\n"\r
+    "NvFtwSpare = %lx, Length = %lx\n"\r
+    "Stack = %lx, StackLength = %lx\n"\r
+    "PageTable = %p\n"\r
+    "MemoryFreeUnder1MB = %lx, MemoryFreeUnder1MBLength = %lx\n"\r
+    "MemoryAbove1MB = %lx, MemoryAbove1MBLength = %lx\n"\r
+    "MemoryAbove4GB = %lx, MemoryAbove4GBLength = %lx\n"\r
+    "DxeCore = %lx, DxeCoreLength = %lx\n"\r
+    "MemoryAllocation = %lx, MemoryLength = %lx\n"\r
+    "$",\r
+    gHob,\r
+    gHob->Phit.EfiMemoryTop, gHob->Phit.EfiMemoryBottom,\r
+    gHob->Phit.EfiFreeMemoryTop, gHob->Phit.EfiFreeMemoryBottom,\r
+    gHob->NvStorageFvb.FvbInfo.Entries[0].Base, (UINTN) gHob->NvFtwFvb.FvbInfo.Entries[0].Length,\r
+    gHob->BfvResource.PhysicalStart, gHob->BfvResource.ResourceLength,\r
+    gHob->NvStorageFvResource.PhysicalStart, gHob->NvStorageFvResource.ResourceLength,\r
+    gHob->NvStorage.FvbInfo.Entries[0].Base, gHob->NvStorage.FvbInfo.Entries[0].Length,\r
+    gHob->NvFtwFvResource.PhysicalStart, gHob->NvFtwFvResource.ResourceLength,\r
+    gHob->NvFtwWorking.FvbInfo.Entries[0].Base, gHob->NvFtwWorking.FvbInfo.Entries[0].Length,\r
+    gHob->NvFtwSpare.FvbInfo.Entries[0].Base, gHob->NvFtwSpare.FvbInfo.Entries[0].Length,\r
+    gHob->Stack.AllocDescriptor.MemoryBaseAddress, gHob->Stack.AllocDescriptor.MemoryLength,\r
+    PageTableBase,\r
+    gHob->MemoryFreeUnder1MB.PhysicalStart, gHob->MemoryFreeUnder1MB.ResourceLength,\r
+    gHob->MemoryAbove1MB.PhysicalStart, gHob->MemoryAbove1MB.ResourceLength,\r
+    gHob->MemoryAbove4GB.PhysicalStart, gHob->MemoryAbove4GB.ResourceLength,\r
+    gHob->DxeCore.MemoryAllocationHeader.MemoryBaseAddress, gHob->DxeCore.MemoryAllocationHeader.MemoryLength,\r
+    gHob->MemoryAllocation.AllocDescriptor.MemoryBaseAddress, gHob->MemoryAllocation.AllocDescriptor.MemoryLength\r
+    );\r
 \r
   ClearScreen();\r
-  PrintString("\n\n\n\n\n\n\n\n\n\n");\r
-  PrintString("                         WELCOME TO EFI WORLD!\n");\r
+  PrintString (\r
+    "\n\n\n\n\n\n\n\n\n\n"\r
+    "                         WELCOME TO EFI WORLD!\n"\r
+    );\r
   \r
   EnterDxeMain (StackTop, Handoff->DxeCoreEntryPoint, gHob, PageTableBase);\r
+  PrintString ("Fail to enter DXE main!\n");\r
  \r
-  PrintString("Fail to enter DXE main!\n");\r
   //\r
   // Should never get here\r
   //\r
index 71a04f7e83fd344787a5c353f3e318c36f628542..6c000845131680ce098edec3ce64d98e1b2f3ffb 100644 (file)
@@ -1,6 +1,6 @@
 ## @file\r
 # \r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials                          \r
 # are licensed and made available under the terms and conditions of the BSD License         \r
 # which accompanies this distribution.  The full text of the license may be found at        \r
@@ -33,6 +33,7 @@
   BaseLib\r
   BaseMemoryLib\r
   PrintLib\r
+  SerialPortLib\r
   ReportStatusCodeLib\r
   IoLib\r
 \r
   Ia32/Paging.c\r
   Ia32/VirtualMemory.h\r
 \r
-#[BuildOptions]\r
-  #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\r
-  #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\r
-  #MSFT:*_*_IA32_PP_FLAGS = /nologo /E /TC /FI$(DEST_DIR_DEBUG)/AutoGen.h\r
-  #MSFT:*_*_IA32_ASM_FLAGS = /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi\r
-  #MSFT:*_*_IA32_ASMLINK_FLAGS       = /link /nologo /tiny  \r
-  #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\r
-\r
 [Depex]\r
   TRUE\r
index 1ece7d815006e7127255d7da3cbe374054c80beb..e08a148543ad7ea6fcb22e55fe35b78cc28f2f1f 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -48,27 +48,8 @@ Returns:
 \r
 --*/\r
 {\r
-  //EFI_PEI_PE_COFF_LOADER_PROTOCOL           *PeCoffLoader;\r
-  //EFI_DECOMPRESS_PROTOCOL                   *EfiDecompress;\r
-  //EFI_TIANO_DECOMPRESS_PROTOCOL             *TianoDecompress;\r
   EFI_REPORT_STATUS_CODE                    ReportStatusCode;\r
 \r
-  //InstallEfiPeiFlushInstructionCache (&FlushInstructionCache);\r
-  //Hob->FlushInstructionCache.Interface = FlushInstructionCache;\r
-\r
-  // R9 do not need this protocol.\r
-  // InstallEfiPeiTransferControl (&TransferControl);\r
-  // Hob->TransferControl.Interface = TransferControl;\r
-\r
-  //InstallEfiPeiPeCoffLoader (NULL, &PeCoffLoader, NULL);\r
-  //Hob->PeCoffLoader.Interface = PeCoffLoader;\r
-\r
-  //InstallEfiDecompress (&EfiDecompress);\r
-  //Hob->EfiDecompress.Interface = EfiDecompress;\r
-\r
-  //InstallTianoDecompress (&TianoDecompress);\r
-  //Hob->TianoDecompress.Interface = TianoDecompress;\r
-\r
   InstallSerialStatusCode (&ReportStatusCode);\r
   Hob->SerialStatusCode.Interface = (EFI_PHYSICAL_ADDRESS) (UINTN) ReportStatusCode;\r
 \r
index e936db5b59016a8a0ebf0f04af4b60f170b70fe1..27e8644b38cb3e01dde4847b3500d85b4cd5f1b2 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -18,16 +18,9 @@ Revision History:
 \r
 **/\r
 \r
+#include <Library/SerialPortLib.h>\r
 #include "SerialStatusCode.h"\r
 \r
-\r
-UINT16  gComBase = 0x3f8;\r
-UINTN   gBps = 115200;\r
-UINT8   gData = 8;\r
-UINT8   gStop = 1;\r
-UINT8   gParity = 0;\r
-UINT8   gBreakSet = 0;\r
-\r
 //\r
 // All of the lookup tables are only needed in debug.\r
 //\r
@@ -602,68 +595,6 @@ Returns:
 }\r
 \r
 \r
-\r
-VOID\r
-DebugSerialWrite (\r
-  IN UINT8  Character\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- DebugSerialWrite - Outputs a character to the Serial port\r
-\r
-  Repeatedly polls the TXRDY bit of the Line Status Register\r
-  until the Transmitter Holding Register is empty.  The character\r
-  is then written to the Serial port.\r
-\r
-Arguments:\r
-\r
-  Character   - Character to write\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  UINT8   Data;\r
-\r
-  //\r
-  // Wait for the serail port to be ready.\r
-  //\r
-  do {\r
-    Data = IoRead8 (gComBase + LSR_OFFSET);\r
-  } while ((Data & LSR_TXRDY) == 0);\r
-    \r
-  IoWrite8 (gComBase, Character);\r
-}\r
-\r
-VOID\r
-DebugSerialPrint (\r
-  IN CHAR8    *OutputString\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Prints a string to the Serial port\r
-\r
-Arguments:\r
-\r
-  OutputString - Ascii string to print to serial port.\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
-{\r
-  for ( ; *OutputString != 0; OutputString++) {\r
-    DebugSerialWrite (*OutputString);\r
-  }\r
-}\r
-\r
 EFI_STATUS\r
 EFIAPI \r
 SerialReportStatusCode (\r
@@ -697,7 +628,7 @@ Returns:
   CHAR8                   *Format;\r
   BASE_LIST               Marker;\r
   UINT32                  ErrorLevel;\r
-  UINTN                   CharCount;\r
+  UINTN                   CharCount = 0;\r
 \r
   Buffer[0] = '\0';\r
 \r
@@ -706,7 +637,7 @@ Returns:
     //\r
     // Processes PEI_ASSERT ()\r
     //\r
-    AsciiSPrint (\r
+    CharCount = AsciiSPrint (\r
       Buffer,\r
       sizeof (Buffer),\r
       "\nPEI_ASSERT!: %a (%d): %a\n",\r
@@ -720,7 +651,7 @@ Returns:
     //\r
     // Process PEI_DEBUG () macro to Serial\r
     //\r
-    AsciiBSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
+    CharCount = AsciiBSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
 \r
   } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { \r
     //\r
@@ -744,7 +675,7 @@ Returns:
     //\r
     // Callout to platform Lib function to do print.\r
     //\r
-    DebugSerialPrint (Buffer);\r
+    SerialPortWrite (Buffer, CharCount);\r
   }\r
 \r
   //\r
@@ -786,7 +717,7 @@ Returns:
         //\r
         // Concatenate the instance\r
         //\r
-        AsciiSPrint (\r
+        CharCount = AsciiSPrint (\r
           Buffer,\r
           sizeof (Buffer),\r
           "%a:%a:%a:%d\n",\r
@@ -796,7 +727,7 @@ Returns:
           Instance\r
           );\r
 \r
-        DebugSerialPrint (Buffer);\r
+        SerialPortWrite (Buffer, CharCount);\r
       }\r
     }\r
 \r
@@ -812,15 +743,11 @@ InstallSerialStatusCode (
 \r
 Routine Description:\r
 \r
-  Initialize Serial Port\r
-\r
-    The Baud Rate Divisor registers are programmed and the LCR \r
-    is used to configure the communications format. Hard coded\r
-    UART config comes from globals in DebugSerialPlatform lib.\r
+  Initialize Serial Port and Status Code Handler\r
 \r
 Arguments: \r
 \r
-  None\r
+  ReportStatusCode - A pointer to the handler\r
 \r
 Returns: \r
 \r
@@ -828,41 +755,6 @@ Returns:
 \r
 --*/\r
 {\r
-  UINTN           Divisor;\r
-  UINT8           OutputData;\r
-  UINT8           Data;\r
-\r
-  //\r
-  // Some init is done by the platform status code initialization.\r
-  //\r
-  \r
-  //\r
-  // Map 5..8 to 0..3\r
-  //\r
-  Data = (UINT8) (gData - (UINT8)5);\r
-\r
-  //\r
-  // Calculate divisor for baud generator\r
-  //\r
-  Divisor = 115200 / gBps; \r
-  \r
-  //\r
-  // Set communications format\r
-  //\r
-  OutputData = (UINT8)((DLAB << 7) | ((gBreakSet << 6) | ((gParity << 3) | ((gStop << 2) | Data))));\r
-  IoWrite8 (gComBase + LCR_OFFSET, OutputData);\r
-\r
-  //\r
-  // Configure baud rate\r
-  //\r
-  IoWrite8 (gComBase + BAUD_HIGH_OFFSET, (UINT8)(Divisor >> 8));\r
-  IoWrite8 (gComBase + BAUD_LOW_OFFSET, (UINT8)(Divisor & 0xff));\r
-\r
-  //\r
-  // Switch back to bank 0\r
-  //\r
-  OutputData = (UINT8)((~DLAB<<7)|((gBreakSet<<6)|((gParity<<3)|((gStop<<2)| Data))));\r
-  IoWrite8 (gComBase + LCR_OFFSET, OutputData);\r
-\r
+  SerialPortInitialize();\r
   *ReportStatusCode = SerialReportStatusCode;\r
 }\r
index d4989d1db7a41e82343f6086369149754afcda10..7146927011bacc94e7b3eabdce04ebaab767ec74 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -31,50 +31,6 @@ Revision History:
 //\r
 \r
 \r
-//---------------------------------------------\r
-// UART Register Offsets\r
-//---------------------------------------------\r
-#define BAUD_LOW_OFFSET         0x00\r
-#define BAUD_HIGH_OFFSET        0x01\r
-#define IER_OFFSET              0x01\r
-#define LCR_SHADOW_OFFSET       0x01\r
-#define FCR_SHADOW_OFFSET       0x02\r
-#define IR_CONTROL_OFFSET       0x02\r
-#define FCR_OFFSET              0x02\r
-#define EIR_OFFSET              0x02\r
-#define BSR_OFFSET              0x03\r
-#define LCR_OFFSET              0x03\r
-#define MCR_OFFSET              0x04\r
-#define LSR_OFFSET              0x05\r
-#define MSR_OFFSET              0x06\r
-\r
-//---------------------------------------------\r
-// UART Register Bit Defines\r
-//---------------------------------------------\r
-#define LSR_TXRDY               0x20\r
-#define LSR_RXDA                0x01\r
-#define DLAB                    0x01\r
-\r
-//\r
-// Globals for Serial Port settings\r
-//\r
-extern UINT16  gComBase;\r
-extern UINTN   gBps;\r
-extern UINT8   gData;\r
-extern UINT8   gStop;\r
-extern UINT8   gParity;\r
-extern UINT8   gBreakSet;\r
-\r
-VOID\r
-DebugSerialPrint (\r
-  IN CHAR8    *OutputString\r
-  );\r
-\r
-VOID\r
-DebugSerialWrite (\r
-  IN UINT8  Character\r
-  );\r
-\r
 VOID\r
 InstallSerialStatusCode (\r
   IN EFI_REPORT_STATUS_CODE    *ReportStatusCode\r
index a4a067ca6e87f4fd7fbdae6705c937eff86fd027..f4cd7c15ed6c0addd6ba21028479efe232534cbf 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -19,11 +19,11 @@ Revision History:
 --*/\r
 #include "EfiLdr.h"\r
 #include "Debug.h"\r
-#include <Library/SerialPortLib.h>\r
 \r
 UINT8 *mCursor;\r
 UINT8 mHeaderIndex = 10;\r
 \r
+\r
 VOID\r
 PrintHeader (\r
   CHAR8 Char\r
@@ -48,82 +48,25 @@ ClearScreen (
   mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);\r
 }\r
 \r
-\r
-VOID \r
-PrintU32Base10 (\r
-  UINT32 Value\r
-  )\r
-{\r
-  UINT32 Index;\r
-  CHAR8  Char;\r
-  CHAR8  String[11];\r
-  UINTN  StringPos;\r
-  UINT32 B10Div;\r
-\r
-  B10Div = 1000000000;\r
-  for (Index = 0, StringPos = 0; Index < 10; Index++) {\r
-    Char = (UINT8) (((Value / B10Div) % 10) + '0');\r
-    if ((StringPos > 0) || (Char != '0')) {\r
-      String[StringPos] = Char;\r
-      StringPos++;\r
-    }\r
-    B10Div = B10Div / 10;\r
-  }\r
-\r
-  if (StringPos == 0) {\r
-      String[0] = '0';\r
-      StringPos++;\r
-  }\r
-\r
-  String[StringPos] = '\0';\r
-\r
-  PrintString (String);\r
-}\r
-\r
-\r
-VOID\r
-PrintValue (\r
-  UINT32 Value\r
-  )\r
-{\r
-  UINT32 Index;\r
-  CHAR8  Char;\r
-  CHAR8  String[9];\r
-\r
-  for (Index = 0; Index < 8; Index++) {\r
-    Char = (UINT8)(((Value >> ((7 - Index) * 4)) & 0x0f) + '0');\r
-    if (Char > '9') {\r
-      Char = (UINT8) (Char - '0' - 10 + 'A');\r
-    }\r
-    String[Index] = Char;\r
-  }\r
-\r
-  String[sizeof (String) - 1] = '\0';\r
-\r
-  PrintString (String);\r
-}\r
-\r
-VOID\r
-PrintValue64 (\r
-  UINT64 Value\r
-  )\r
-{\r
-  PrintValue ((UINT32) RShiftU64 (Value, 32));\r
-  PrintValue ((UINT32) Value);\r
-}\r
-\r
 VOID\r
 PrintString (\r
-  CHAR8 *String\r
+  IN CONST CHAR8  *FormatString,\r
+  ...\r
   )\r
 {\r
-  UINT32 Index;\r
+  UINTN           Index;\r
+  CHAR8           PrintBuffer[256];\r
+  VA_LIST         Marker;\r
+\r
+  VA_START (Marker, FormatString);\r
+  AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);\r
+  VA_END (Marker);\r
 \r
-  for (Index = 0; String[Index] != 0; Index++) {\r
-    if (String[Index] == '\n') {\r
-      mCursor = (UINT8 *)(UINTN)(0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));\r
+  for (Index = 0; PrintBuffer[Index] != 0; Index++) {\r
+    if (PrintBuffer[Index] == '\n') {\r
+      mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));\r
     } else {\r
-      *mCursor = String[Index];\r
+      *mCursor = (UINT8) PrintBuffer[Index];\r
       mCursor += 2;\r
     }\r
   }\r
@@ -131,6 +74,6 @@ PrintString (
   //\r
   // All information also output to serial port.\r
   //\r
-  SerialPortWrite ((UINT8*) String, Index);\r
+  SerialPortWrite (PrintBuffer, Index);\r
 }\r
 \r
index cd1d5d951c2b1b100a8f25bb3b3928ba8839e265..f6aa7a2cf73bd99edacb46ce1d55b8f66167ef00 100644 (file)
@@ -26,19 +26,10 @@ PrintHeader (
   CHAR8 Char\r
   );\r
 \r
-VOID \r
-PrintValue (\r
-  UINT32 Value\r
-  );\r
-\r
 VOID\r
-PrintValue64 (\r
-  UINT64 Value\r
-  );\r
-\r
-VOID \r
 PrintString (\r
-  CHAR8 *String\r
+  IN CONST CHAR8  *FormatString,\r
+  ...\r
   );\r
 \r
 VOID \r
index 9434a780fc21e5a3d56f10b44181a75251da859f..665f4058550735edac0d93dbee18409a2be95006 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -29,6 +29,7 @@ Revision History:
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/PrintLib.h>\r
+#include <Library/SerialPortLib.h>\r
 \r
 #define INT15_E820_AddressRangeMemory   1\r
 #define INT15_E820_AddressRangeReserved 2\r
index ea3977d8882bd38dabf139151b5e16b2362300a3..b5a46db870f77a6797695da9baf6c80aa3b2ad42 100644 (file)
@@ -1,6 +1,6 @@
 ## @file\r
 # \r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials                          \r
 # are licensed and made available under the terms and conditions of the BSD License         \r
 # which accompanies this distribution.  The full text of the license may be found at        \r
@@ -20,7 +20,6 @@
   INF_VERSION                    = 0x00010005\r
   BASE_NAME                      = EfiLoader\r
   FILE_GUID                      = A9620E5C-5FA1-40b7-8B21-50B632F88F38\r
-  #MODULE_TYPE                    = USER_DEFINED\r
   MODULE_TYPE                    = UEFI_APPLICATION\r
   VERSION_STRING                 = 1.0\r
 \r
@@ -53,8 +52,4 @@
   gTianoCustomDecompressGuid\r
 \r
 [BuildOptions]\r
-  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\r
-  MSFT:*_*_IA32_PP_FLAGS == /nologo /E /TC /FI$(DEST_DIR_DEBUG)/AutoGen.h\r
-  MSFT:*_*_IA32_ASM_FLAGS == /nologo /W3 /WX /c /coff /Cx /Zd /W0 /Zi\r
-  MSFT:*_*_IA32_ASMLINK_FLAGS == /link /nologo /tiny  \r
   MSFT:*_*_*_DLINK_FLAGS = /BASE:0x10000\r
index f10db53552a6eaa0d26d7d4100ade9d34f37aa53..6913027650748ce29c6e17974c09099ec9922e4d 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -25,12 +25,14 @@ Revision History:
 #include "LzmaDecompress.h"\r
 \r
 VOID\r
-SystemHang(\r
-  VOID\r
+SystemHang (\r
+  CHAR8        *Message\r
   )\r
 {\r
-  CHAR8 PrintBuffer[256];\r
-  AsciiSPrint (PrintBuffer, 256, "## FATEL ERROR ##: Fail to load DUET images! System hang!\n");\r
+  PrintString (\r
+    "%s## FATAL ERROR ##: Fail to load DUET images! System hang!\n",\r
+    Message\r
+    );\r
   CpuDeadLoop();\r
 }\r
 \r
@@ -49,52 +51,45 @@ EfiLoader (
   UINTN                 BfvPageNumber;\r
   UINTN                 BfvBase;\r
   EFI_MAIN_ENTRYPOINT   EfiMainEntrypoint;\r
-  CHAR8                 PrintBuffer[256];\r
   EFILDRHANDOFF         Handoff;\r
+  UINTN                 Index;\r
 \r
   ClearScreen();\r
   \r
   PrintHeader ('A');\r
-  
-  AsciiSPrint (PrintBuffer, 256, "Enter DUET Loader...\n");\r
-  PrintString (PrintBuffer);\r
-\r
-  AsciiSPrint (PrintBuffer, 256, "BiosMemoryMapBaseAddress = 0x%x\n", BiosMemoryMapBaseAddress);\r
-  PrintString (PrintBuffer);\r
+  \r
+  PrintString ("Enter DUET Loader...\n");\r
+  PrintString ("BiosMemoryMapBaseAddress = %x\n", (UINTN) BiosMemoryMapBaseAddress);\r
 \r
   //\r
   // Add all EfiConventionalMemory descriptors to the table.  If there are partial pages, then\r
   // round the start address up to the next page, and round the length down to a page boundry.\r
   //\r
-  BiosMemoryMap = (BIOS_MEMORY_MAP *)(UINTN)(BiosMemoryMapBaseAddress);\r
+  BiosMemoryMap = (BIOS_MEMORY_MAP *) (UINTN) BiosMemoryMapBaseAddress;\r
   NumberOfMemoryMapEntries = 0;\r
   GenMemoryMap (&NumberOfMemoryMapEntries, EfiMemoryDescriptor, BiosMemoryMap);\r
 \r
-  AsciiSPrint (PrintBuffer, 256, "Get %d entries of memory map!\n", NumberOfMemoryMapEntries);\r
-  PrintString (PrintBuffer);\r
+  PrintString ("Get %d entries of memory map!\n", NumberOfMemoryMapEntries);\r
 \r
   //\r
   // Get information on where the image is in memory\r
   //\r
-\r
-  //EFILDRHeader = (EFILDR_HEADER *)(UINTN)(EFILDR_HEADER_ADDRESS);\r
   EFILDRImage  = (EFILDR_IMAGE *)(UINTN)(EFILDR_HEADER_ADDRESS + sizeof(EFILDR_HEADER));\r
 \r
 \r
   //\r
   // Point to the 4th image (Bfv)\r
   //\r
-    \r
   EFILDRImage += 3;\r
 \r
   //\r
   // Decompress the image\r
   //\r
-\r
-  AsciiSPrint (PrintBuffer, 256, "Decompress BFV image, Image Address=0x%x Offset=0x%x\n", \r
-               (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-               EFILDRImage->Offset);\r
-  PrintString (PrintBuffer);\r
+  PrintString (\r
+    "Decompress BFV image, Image Address = %x Offset = %x\n", \r
+    (UINTN) (EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
+    (UINTN) EFILDRImage->Offset\r
+    );\r
   Status = LzmaUefiDecompressGetInfo (\r
              (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
              EFILDRImage->Length,\r
@@ -103,14 +98,10 @@ EfiLoader (
              );\r
 \r
   if (EFI_ERROR (Status)) {\r
-    AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for BFV!\n");\r
-    PrintString (PrintBuffer);\r
-    SystemHang();\r
+    SystemHang ("Failed to get decompress information for BFV!\n");\r
   }\r
   \r
-  AsciiSPrint (PrintBuffer, 256, "BFV decompress: DestinationSize=0x%X, ScratchSize=0x%X!\n",\r
-               DestinationSize, ScratchSize);\r
-  PrintString (PrintBuffer);\r
+  PrintString ("BFV decompress: DestinationSize = %x, ScratchSize = %x\n", (UINTN) DestinationSize, (UINTN) ScratchSize);\r
   Status =  LzmaUefiDecompress (\r
     (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
     EFILDRImage->Length,\r
@@ -120,15 +111,13 @@ EfiLoader (
   \r
 \r
   if (EFI_ERROR (Status)) {\r
-    AsciiSPrint (PrintBuffer, 256, "Fail to decompress BFV!\n");\r
-    PrintString (PrintBuffer);\r
-    SystemHang();\r
+    SystemHang ("Failed to decompress BFV!\n");\r
   }\r
 \r
   BfvPageNumber = EFI_SIZE_TO_PAGES (DestinationSize);\r
   BfvBase = (UINTN) FindSpace (BfvPageNumber, &NumberOfMemoryMapEntries, EfiMemoryDescriptor, EfiRuntimeServicesData, EFI_MEMORY_WB);\r
   if (BfvBase == 0) {\r
-    SystemHang();\r
+    SystemHang ("Failed to find free space to hold decompressed BFV\n");\r
   }\r
   ZeroMem ((VOID *)(UINTN)BfvBase, BfvPageNumber * EFI_PAGE_SIZE);\r
   CopyMem ((VOID *)(UINTN)BfvBase, (VOID *)(UINTN)EFI_DECOMPRESSED_BUFFER_ADDRESS, DestinationSize);\r
@@ -144,10 +133,11 @@ EfiLoader (
   //\r
   // Decompress the image\r
   //\r
-  AsciiSPrint (PrintBuffer, 256, "Decompress DxeIpl image, Image Address=0x%x Offset=0x%x\n", \r
-               (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-               EFILDRImage->Offset);\r
-  PrintString (PrintBuffer);\r
+  PrintString (\r
+    "Decompress DxeIpl image, Image Address = %x Offset = %x\n", \r
+    (UINTN) (EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
+    (UINTN) EFILDRImage->Offset\r
+    );\r
 \r
   Status = LzmaUefiDecompressGetInfo (\r
              (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
@@ -156,9 +146,7 @@ EfiLoader (
              &ScratchSize\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for DxeIpl!\n");\r
-    PrintString (PrintBuffer);\r
-    SystemHang();\r
+    SystemHang ("Failed to get decompress information for DxeIpl!\n");\r
   }\r
 \r
   Status = LzmaUefiDecompress (\r
@@ -168,13 +156,10 @@ EfiLoader (
              (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    AsciiSPrint (PrintBuffer, 256, "Fail to decompress DxeIpl image\n");\r
-    PrintString (PrintBuffer);\r
-    SystemHang();\r
+    SystemHang ("Failed to decompress DxeIpl image\n");\r
   }\r
 \r
-  AsciiSPrint (PrintBuffer, 256, "Start load DxeIpl PE image\n");\r
-  PrintString (PrintBuffer);  \r
+  PrintString ("Start load DxeIpl PE image\n");  \r
 \r
   //\r
   // Load and relocate the EFI PE/COFF Firmware Image \r
@@ -186,33 +171,29 @@ EfiLoader (
              EfiMemoryDescriptor\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    AsciiSPrint (PrintBuffer, 256, "Fail to load and relocate DxeIpl PE image!\n");\r
-    PrintString (PrintBuffer);\r
-    SystemHang();\r
+    SystemHang ("Failed to load and relocate DxeIpl PE image!\n");\r
   }\r
-  AsciiSPrint (PrintBuffer, 256, "DxeIpl PE image is successed loaded at 0x%x, entry=0x%x\n",\r
-               (UINTN)DxeIplImage.ImageBasePage, (UINTN)DxeIplImage.EntryPoint);\r
-  PrintString (PrintBuffer);  \r
-\r
-//  PrintString("Image.NoPages = ");   \r
-//  PrintValue(Image.NoPages);\r
-//  PrintString("\n");\r
+  PrintString (\r
+    "DxeIpl PE image is successed loaded at %lx, entry=%p\n",\r
+    DxeIplImage.ImageBasePage,\r
+    DxeIplImage.EntryPoint\r
+    );\r
 \r
 PrintHeader ('C');\r
 \r
   //\r
   // Point to the 3rd image (DxeMain)\r
   //\r
-    \r
   EFILDRImage++;\r
 \r
   //\r
   // Decompress the image\r
   //\r
-  AsciiSPrint (PrintBuffer, 256, "Decompress DXEMain FV image, Image Address=0x%x! Offset=0x%x\n", \r
-               (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
-               EFILDRImage->Offset);\r
-  PrintString (PrintBuffer);\r
+  PrintString (\r
+    "Decompress DxeMain FV image, Image Address = %x Offset = %x\n",\r
+    (UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
+    (UINTN) EFILDRImage->Offset\r
+    );\r
 \r
   Status = LzmaUefiDecompressGetInfo (\r
              (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset),\r
@@ -221,9 +202,7 @@ PrintHeader ('C');
              &ScratchSize\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    AsciiSPrint (PrintBuffer, 256, "Fail to get decompress information for DXEMain FV image!\n");\r
-    PrintString (PrintBuffer);\r
-    SystemHang();\r
+    SystemHang ("Failed to get decompress information for DxeMain FV image!\n");\r
   }\r
 \r
   Status = LzmaUefiDecompress (\r
@@ -233,7 +212,7 @@ PrintHeader ('C');
              (VOID *)(UINTN)((EFI_DECOMPRESSED_BUFFER_ADDRESS + DestinationSize + 0x1000) & 0xfffff000)\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    SystemHang();\r
+    SystemHang ("Failed to decompress DxeMain FV image!\n");\r
   }\r
 \r
   //\r
@@ -246,33 +225,26 @@ PrintHeader ('C');
              EfiMemoryDescriptor\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    SystemHang();\r
+    SystemHang ("Failed to load/relocate DxeMain!\n");\r
   }\r
-  AsciiSPrint (PrintBuffer, 256, "DxeCore PE image is successed loaded at 0x%x, entry=0x%x\n",\r
-               (UINTN)DxeCoreImage.ImageBasePage, (UINTN)DxeCoreImage.EntryPoint);\r
-  PrintString (PrintBuffer);  \r
+  PrintString (\r
+    "DxeCore PE image is successed loaded at %lx, entry=%p\n",\r
+    DxeCoreImage.ImageBasePage,\r
+    DxeCoreImage.EntryPoint\r
+    );\r
 \r
 PrintHeader ('E');\r
 \r
   //\r
   // Display the table of memory descriptors.\r
   //\r
-\r
-//  PrintString("\nEFI Memory Descriptors\n");   \r
-/*\r
-  {\r
-  UINTN Index;\r
+  PrintString ("\nEFI Memory Descriptors\n");   \r
   for (Index = 0; Index < NumberOfMemoryMapEntries; Index++) {\r
-    PrintString("Type = ");   \r
-    PrintValue(EfiMemoryDescriptor[Index].Type);\r
-    PrintString("  Start = ");   \r
-    PrintValue((UINT32)(EfiMemoryDescriptor[Index].PhysicalStart));\r
-    PrintString("  NumberOfPages = ");   \r
-    PrintValue((UINT32)(EfiMemoryDescriptor[Index].NumberOfPages));\r
-    PrintString("\n");\r
-  }\r
+    PrintString (\r
+      "Type = %x Start = %08lx NumberOfPages = %08lx\n",\r
+      EfiMemoryDescriptor[Index].Type, EfiMemoryDescriptor[Index].PhysicalStart, EfiMemoryDescriptor[Index].NumberOfPages\r
+      );\r
   }\r
-*/\r
 \r
   //\r
   // Jump to EFI Firmware\r
@@ -290,10 +262,9 @@ PrintHeader ('E');
     Handoff.DxeCoreImageSize  = DxeCoreImage.NoPages * EFI_PAGE_SIZE;\r
     Handoff.DxeCoreEntryPoint = (VOID *)(UINTN)DxeCoreImage.EntryPoint;\r
 \r
-    AsciiSPrint (PrintBuffer, 256, "Transfer to DxeIpl ...Address=0x%x\n", (UINTN)DxeIplImage.EntryPoint);\r
-    PrintString (PrintBuffer);\r
+    PrintString ("Transfer to DxeIpl ...EntryPoint = %p\n", DxeIplImage.EntryPoint);\r
     \r
-    EfiMainEntrypoint = (EFI_MAIN_ENTRYPOINT)(UINTN)DxeIplImage.EntryPoint;\r
+    EfiMainEntrypoint = (EFI_MAIN_ENTRYPOINT) DxeIplImage.EntryPoint;\r
     EfiMainEntrypoint (&Handoff);\r
   }\r
 \r
@@ -303,7 +274,7 @@ PrintHeader ('F');
   // There was a problem loading the image, so HALT the system.\r
   //\r
 \r
-  SystemHang();\r
+  SystemHang ("Failed to jump to DxeIpl!\n");\r
 }\r
 \r
 EFI_STATUS\r
@@ -312,6 +283,7 @@ _ModuleEntryPoint (
   UINT32    BiosMemoryMapBaseAddress\r
   )\r
 {\r
+  SerialPortInitialize ();\r
   EfiLoader(BiosMemoryMapBaseAddress);\r
   return EFI_SUCCESS;\r
 }\r