diff options
author | mdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-05-31 00:19:54 +0000 |
---|---|---|
committer | mdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-05-31 00:19:54 +0000 |
commit | 1f53f7bb991c4299695a7aac2420ccae1b5fab1c (patch) | |
tree | 9791172cef8770da50284b0f2c602c8229ffde94 | |
parent | a776476a83373be231125795c5eeea05fa9bcf7d (diff) | |
download | edk2-platforms-1f53f7bb991c4299695a7aac2420ccae1b5fab1c.tar.xz |
Update SecMain for Nt32 to use WriteFile() for all status code related console output so the same mechanism is used for SEC, PEI, and DXE. Previously SEC and PEI were using printf() and DXE was using WriteFile() and the order of the messages was not correct in all cases. By using the same method for all status code output, the order of the messages is correct.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8411 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | Nt32Pkg/Sec/SecMain.c | 62 | ||||
-rw-r--r-- | Nt32Pkg/Sec/SecMain.h | 1 |
2 files changed, 45 insertions, 18 deletions
diff --git a/Nt32Pkg/Sec/SecMain.c b/Nt32Pkg/Sec/SecMain.c index 8e638e04da..f1cf33910c 100644 --- a/Nt32Pkg/Sec/SecMain.c +++ b/Nt32Pkg/Sec/SecMain.c @@ -106,6 +106,32 @@ EFI_STATUS SecNt32PeCoffRelocateImage (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
+
+VOID
+SecPrint (
+ CHAR8 *Format,
+ ...
+ )
+{
+ va_list Marker;
+ UINTN CharCount;
+ CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+
+ va_start (Marker, Format);
+
+// vsprintf (Buffer, Format, Marker);
+ _vsnprintf (Buffer, sizeof (Buffer), Format, Marker);
+
+ CharCount = strlen (Buffer);
+ WriteFile (
+ GetStdHandle (STD_OUTPUT_HANDLE),
+ Buffer,
+ CharCount,
+ (LPDWORD)&CharCount,
+ NULL
+ );
+}
+
INTN
EFIAPI
main (
@@ -146,7 +172,7 @@ Returns: MemorySizeStr = (CHAR16 *) FixedPcdGetPtr (PcdWinNtMemorySizeForSecMain);
FirmwareVolumesStr = (CHAR16 *) FixedPcdGetPtr (PcdWinNtFirmwareVolume);
- printf ("\nEDK SEC Main NT Emulation Environment from www.TianoCore.org\n");
+ SecPrint ("\nEDK II SEC Main NT Emulation Environment from www.TianoCore.org\n");
//
// Make some Windows calls to Set the process to the highest priority in the
@@ -161,7 +187,7 @@ Returns: gSystemMemoryCount = CountSeperatorsInString (MemorySizeStr, '!') + 1;
gSystemMemory = calloc (gSystemMemoryCount, sizeof (NT_SYSTEM_MEMORY));
if (gSystemMemory == NULL) {
- wprintf (L"ERROR : Can not allocate memory for %s. Exiting.\n", MemorySizeStr);
+ SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n", MemorySizeStr);
exit (1);
}
//
@@ -170,13 +196,13 @@ Returns: gFdInfoCount = CountSeperatorsInString (FirmwareVolumesStr, '!') + 1;
gFdInfo = calloc (gFdInfoCount, sizeof (NT_FD_INFO));
if (gFdInfo == NULL) {
- wprintf (L"ERROR : Can not allocate memory for %s. Exiting.\n", FirmwareVolumesStr);
+ SecPrint ("ERROR : Can not allocate memory for %S. Exiting.\n", FirmwareVolumesStr);
exit (1);
}
//
// Setup Boot Mode. If BootModeStr == "" then BootMode = 0 (BOOT_WITH_FULL_CONFIGURATION)
//
- printf (" BootMode 0x%02x\n", FixedPcdGet32 (PcdWinNtBootMode));
+ SecPrint (" BootMode 0x%02x\n", FixedPcdGet32 (PcdWinNtBootMode));
//
// Allocate 128K memory to emulate temp memory for PEI.
@@ -186,7 +212,7 @@ Returns: InitialStackMemorySize = STACK_SIZE;
InitialStackMemory = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAlloc (NULL, (SIZE_T) (InitialStackMemorySize), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (InitialStackMemory == 0) {
- printf ("ERROR : Can not allocate enough space for SecStack\n");
+ SecPrint ("ERROR : Can not allocate enough space for SecStack\n");
exit (1);
}
@@ -196,14 +222,14 @@ Returns: *StackPointer = 0x5AA55AA5;
}
- wprintf (L" SEC passing in %d bytes of temp RAM to PEI\n", InitialStackMemorySize);
+ SecPrint (" SEC passing in %d bytes of temp RAM to PEI\n", InitialStackMemorySize);
//
// Open All the firmware volumes and remember the info in the gFdInfo global
//
FileNamePtr = (CHAR16 *)malloc (StrLen ((CHAR16 *)FirmwareVolumesStr) * sizeof(CHAR16));
if (FileNamePtr == NULL) {
- printf ("ERROR : Can not allocate memory for firmware volume string\n");
+ SecPrint ("ERROR : Can not allocate memory for firmware volume string\n");
exit (1);
}
@@ -231,17 +257,17 @@ Returns: &gFdInfo[Index].Size
);
if (EFI_ERROR (Status)) {
- printf ("ERROR : Can not open Firmware Device File %S (0x%X). Exiting.\n", FileName, Status);
+ SecPrint ("ERROR : Can not open Firmware Device File %S (0x%X). Exiting.\n", FileName, Status);
exit (1);
}
- printf (" FD loaded from");
+ SecPrint (" FD loaded from");
//
// printf can't print filenames directly as the \ gets interperted as an
// escape character.
//
for (Index2 = 0; FileName[Index2] != '\0'; Index2++) {
- printf ("%c", FileName[Index2]);
+ SecPrint ("%c", FileName[Index2]);
}
if (PeiCoreFile == NULL) {
@@ -251,11 +277,11 @@ Returns: //
Status = SecFfsFindPeiCore ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) gFdInfo[Index].Address, &PeiCoreFile);
if (!EFI_ERROR (Status)) {
- printf (" contains SEC Core");
+ SecPrint (" contains SEC Core");
}
}
- printf ("\n");
+ SecPrint ("\n");
}
//
// Calculate memory regions and store the information in the gSystemMemory
@@ -280,7 +306,7 @@ Returns: MemorySizeStr = MemorySizeStr + Index1 + 1;
}
- printf ("\n");
+ SecPrint ("\n");
//
// Hand off to PEI Core
@@ -291,7 +317,7 @@ Returns: // If we get here, then the PEI Core returned. This is an error as PEI should
// always hand off to DXE.
//
- printf ("ERROR : PEI Core returned\n");
+ SecPrint ("ERROR : PEI Core returned\n");
exit (1);
}
@@ -451,14 +477,14 @@ Returns: //
// Processes ASSERT ()
//
- printf ("ASSERT %s(%d): %s\n", Filename, (int)LineNumber, Description);
+ SecPrint ("ASSERT %s(%d): %s\n", Filename, (int)LineNumber, Description);
} else if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
//
// Process DEBUG () macro
//
AsciiBSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker);
- printf (PrintBuffer);
+ SecPrint (PrintBuffer);
}
return EFI_SUCCESS;
@@ -995,9 +1021,9 @@ SecNt32PeCoffRelocateImage ( if ((Library != NULL) && (DllEntryPoint != NULL)) {
ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;
- wprintf (L"LoadLibraryEx (%s,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName);
+ SecPrint ("LoadLibraryEx (%S,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName);
} else {
- wprintf (L"WARNING: No source level debug %s. \n", DllFileName);
+ SecPrint ("WARNING: No source level debug %S. \n", DllFileName);
}
free (DllFileName);
diff --git a/Nt32Pkg/Sec/SecMain.h b/Nt32Pkg/Sec/SecMain.h index f2db1aa22e..a94f1c111e 100644 --- a/Nt32Pkg/Sec/SecMain.h +++ b/Nt32Pkg/Sec/SecMain.h @@ -39,6 +39,7 @@ Abstract: #include <IndustryStandard/PeImage.h>
+#define EFI_STATUS_CODE_DATA_MAX_SIZE 200
#define STACK_SIZE 0x20000
|