]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update SecMain for Nt32 to use WriteFile() for all status code related console output...
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 31 May 2009 00:19:54 +0000 (00:19 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 31 May 2009 00:19:54 +0000 (00:19 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8411 6f19259b-4bc3-4df7-8a09-765794883524

Nt32Pkg/Sec/SecMain.c
Nt32Pkg/Sec/SecMain.h

index 8e638e04da770468d5e5b0bb54bfb064aeb11f4e..f1cf33910cbac69327da7d0107967bea050ffeb6 100644 (file)
@@ -106,6 +106,32 @@ EFI_STATUS
 SecNt32PeCoffRelocateImage (\r
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
   );\r
+\r
+VOID\r
+SecPrint (\r
+  CHAR8  *Format,\r
+  ...\r
+  )\r
+{\r
+  va_list  Marker;\r
+  UINTN    CharCount;\r
+  CHAR8    Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+\r
+  va_start (Marker, Format);\r
+  \r
+//  vsprintf (Buffer, Format, Marker);\r
+  _vsnprintf (Buffer, sizeof (Buffer), Format, Marker);\r
+\r
+  CharCount = strlen (Buffer);\r
+  WriteFile (\r
+    GetStdHandle (STD_OUTPUT_HANDLE), \r
+    Buffer,\r
+    CharCount,\r
+    (LPDWORD)&CharCount,\r
+    NULL\r
+    );\r
+}\r
+\r
 INTN\r
 EFIAPI\r
 main (\r
@@ -146,7 +172,7 @@ Returns:
   MemorySizeStr      = (CHAR16 *) FixedPcdGetPtr (PcdWinNtMemorySizeForSecMain);\r
   FirmwareVolumesStr = (CHAR16 *) FixedPcdGetPtr (PcdWinNtFirmwareVolume);\r
 \r
-  printf ("\nEDK SEC Main NT Emulation Environment from www.TianoCore.org\n");\r
+  SecPrint ("\nEDK II SEC Main NT Emulation Environment from www.TianoCore.org\n");\r
 \r
   //\r
   // Make some Windows calls to Set the process to the highest priority in the\r
@@ -161,7 +187,7 @@ Returns:
   gSystemMemoryCount  = CountSeperatorsInString (MemorySizeStr, '!') + 1;\r
   gSystemMemory       = calloc (gSystemMemoryCount, sizeof (NT_SYSTEM_MEMORY));\r
   if (gSystemMemory == NULL) {\r
-    wprintf (L"ERROR : Can not allocate memory for %s.  Exiting.\n", MemorySizeStr);\r
+    SecPrint ("ERROR : Can not allocate memory for %S.  Exiting.\n", MemorySizeStr);\r
     exit (1);\r
   }\r
   //\r
@@ -170,13 +196,13 @@ Returns:
   gFdInfoCount  = CountSeperatorsInString (FirmwareVolumesStr, '!') + 1;\r
   gFdInfo       = calloc (gFdInfoCount, sizeof (NT_FD_INFO));\r
   if (gFdInfo == NULL) {\r
-    wprintf (L"ERROR : Can not allocate memory for %s.  Exiting.\n", FirmwareVolumesStr);\r
+    SecPrint ("ERROR : Can not allocate memory for %S.  Exiting.\n", FirmwareVolumesStr);\r
     exit (1);\r
   }\r
   //\r
   // Setup Boot Mode. If BootModeStr == "" then BootMode = 0 (BOOT_WITH_FULL_CONFIGURATION)\r
   //\r
-  printf ("  BootMode 0x%02x\n", FixedPcdGet32 (PcdWinNtBootMode));\r
+  SecPrint ("  BootMode 0x%02x\n", FixedPcdGet32 (PcdWinNtBootMode));\r
 \r
   //\r
   //  Allocate 128K memory to emulate temp memory for PEI.\r
@@ -186,7 +212,7 @@ Returns:
   InitialStackMemorySize  = STACK_SIZE;\r
   InitialStackMemory = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAlloc (NULL, (SIZE_T) (InitialStackMemorySize), MEM_COMMIT, PAGE_EXECUTE_READWRITE);\r
   if (InitialStackMemory == 0) {\r
-    printf ("ERROR : Can not allocate enough space for SecStack\n");\r
+    SecPrint ("ERROR : Can not allocate enough space for SecStack\n");\r
     exit (1);\r
   }\r
 \r
@@ -196,14 +222,14 @@ Returns:
     *StackPointer = 0x5AA55AA5;\r
   }\r
   \r
-  wprintf (L"  SEC passing in %d bytes of temp RAM to PEI\n", InitialStackMemorySize);\r
+  SecPrint ("  SEC passing in %d bytes of temp RAM to PEI\n", InitialStackMemorySize);\r
 \r
   //\r
   // Open All the firmware volumes and remember the info in the gFdInfo global\r
   //\r
   FileNamePtr = (CHAR16 *)malloc (StrLen ((CHAR16 *)FirmwareVolumesStr) * sizeof(CHAR16));\r
   if (FileNamePtr == NULL) {\r
-    printf ("ERROR : Can not allocate memory for firmware volume string\n");\r
+    SecPrint ("ERROR : Can not allocate memory for firmware volume string\n");\r
     exit (1);\r
   }\r
 \r
@@ -231,17 +257,17 @@ Returns:
               &gFdInfo[Index].Size\r
               );\r
     if (EFI_ERROR (Status)) {\r
-      printf ("ERROR : Can not open Firmware Device File %S (0x%X).  Exiting.\n", FileName, Status);\r
+      SecPrint ("ERROR : Can not open Firmware Device File %S (0x%X).  Exiting.\n", FileName, Status);\r
       exit (1);\r
     }\r
 \r
-    printf ("  FD loaded from");\r
+    SecPrint ("  FD loaded from");\r
     //\r
     // printf can't print filenames directly as the \ gets interperted as an\r
     //  escape character.\r
     //\r
     for (Index2 = 0; FileName[Index2] != '\0'; Index2++) {\r
-      printf ("%c", FileName[Index2]);\r
+      SecPrint ("%c", FileName[Index2]);\r
     }\r
 \r
     if (PeiCoreFile == NULL) {\r
@@ -251,11 +277,11 @@ Returns:
       //\r
       Status = SecFfsFindPeiCore ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) gFdInfo[Index].Address, &PeiCoreFile);\r
       if (!EFI_ERROR (Status)) {\r
-        printf (" contains SEC Core");\r
+        SecPrint (" contains SEC Core");\r
       }\r
     }\r
 \r
-    printf ("\n");\r
+    SecPrint ("\n");\r
   }\r
   //\r
   // Calculate memory regions and store the information in the gSystemMemory\r
@@ -280,7 +306,7 @@ Returns:
     MemorySizeStr = MemorySizeStr + Index1 + 1;\r
   }\r
 \r
-  printf ("\n");\r
+  SecPrint ("\n");\r
 \r
   //\r
   // Hand off to PEI Core\r
@@ -291,7 +317,7 @@ Returns:
   // If we get here, then the PEI Core returned. This is an error as PEI should\r
   //  always hand off to DXE.\r
   //\r
-  printf ("ERROR : PEI Core returned\n");\r
+  SecPrint ("ERROR : PEI Core returned\n");\r
   exit (1);\r
 }\r
 \r
@@ -451,14 +477,14 @@ Returns:
     //\r
     // Processes ASSERT ()\r
     //\r
-    printf ("ASSERT %s(%d): %s\n", Filename, (int)LineNumber, Description);\r
+    SecPrint ("ASSERT %s(%d): %s\n", Filename, (int)LineNumber, Description);\r
 \r
   } else if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {\r
     //\r
     // Process DEBUG () macro \r
     //\r
     AsciiBSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker);\r
-    printf (PrintBuffer);\r
+    SecPrint (PrintBuffer);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -995,9 +1021,9 @@ SecNt32PeCoffRelocateImage (
 \r
     if ((Library != NULL) && (DllEntryPoint != NULL)) {\r
       ImageContext->EntryPoint  = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;\r
-      wprintf (L"LoadLibraryEx (%s,\n               NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName);\r
+      SecPrint ("LoadLibraryEx (%S,\n               NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName);\r
     } else {\r
-      wprintf (L"WARNING: No source level debug %s. \n", DllFileName);\r
+      SecPrint ("WARNING: No source level debug %S. \n", DllFileName);\r
     }\r
 \r
     free (DllFileName);\r
index f2db1aa22e63d9f6efe01d1386eeb38e5c25d1bc..a94f1c111e376e187533d8fdd0d6fb69f6be8187 100644 (file)
@@ -39,6 +39,7 @@ Abstract:
 \r
 #include <IndustryStandard/PeImage.h>\r
 \r
+#define EFI_STATUS_CODE_DATA_MAX_SIZE 200\r
 \r
 #define STACK_SIZE                0x20000      \r
 \r