X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkNt32Pkg%2FSec%2FSecMain.c;h=4f668b1bc8553ba3d7bd11cb11e8156006247546;hp=2c3d08e06280030c510ff2ad0455124e73665eb1;hb=e237e7ae9fc23f32a25040d49cc9a16f2a7f3b4c;hpb=878ddf1fc3540a715f63594ed22b6929e881afb4 diff --git a/EdkNt32Pkg/Sec/SecMain.c b/EdkNt32Pkg/Sec/SecMain.c index 2c3d08e062..4f668b1bc8 100644 --- a/EdkNt32Pkg/Sec/SecMain.c +++ b/EdkNt32Pkg/Sec/SecMain.c @@ -33,6 +33,7 @@ Abstract: --*/ #include "SecMain.h" +#pragma warning(disable : 4996) // // Globals @@ -159,8 +160,8 @@ Returns: CHAR16 *MemorySizeStr; CHAR16 *FirmwareVolumesStr; - MemorySizeStr = (CHAR16 *)FixedPcdGetPtr (PcdWinNtMemorySize); - FirmwareVolumesStr = (CHAR16 *)FixedPcdGetPtr (PcdWinNtFirmwareVolume); + MemorySizeStr = (CHAR16 *)PcdGetPtr (PcdWinNtMemorySizeForSecMain); + FirmwareVolumesStr = (CHAR16 *)PcdGetPtr (PcdWinNtFirmwareVolume); printf ("\nEDK SEC Main NT Emulation Environment from www.TianoCore.org\n"); @@ -421,6 +422,69 @@ Returns: #define BYTES_PER_RECORD 512 +/** + Extracts ASSERT() information from a status code structure. + + Converts the status code specified by CodeType, Value, and Data to the ASSERT() + arguments specified by Filename, Description, and LineNumber. If CodeType is + an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and + Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract + Filename, Description, and LineNumber from the optional data area of the + status code buffer specified by Data. The optional data area of Data contains + a Null-terminated ASCII string for the FileName, followed by a Null-terminated + ASCII string for the Description, followed by a 32-bit LineNumber. If the + ASSERT() information could be extracted from Data, then return TRUE. + Otherwise, FALSE is returned. + + If Data is NULL, then ASSERT(). + If Filename is NULL, then ASSERT(). + If Description is NULL, then ASSERT(). + If LineNumber is NULL, then ASSERT(). + + @param CodeType The type of status code being converted. + @param Value The status code value being converted. + @param Data Pointer to status code data buffer. + @param Filename Pointer to the source file name that generated the ASSERT(). + @param Description Pointer to the description of the ASSERT(). + @param LineNumber Pointer to source line number that generated the ASSERT(). + + @retval TRUE The status code specified by CodeType, Value, and Data was + converted ASSERT() arguments specified by Filename, Description, + and LineNumber. + @retval FALSE The status code specified by CodeType, Value, and Data could + not be converted to ASSERT() arguments. + +**/ +STATIC +BOOLEAN +ReportStatusCodeExtractAssertInfo ( + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN CONST EFI_STATUS_CODE_DATA *Data, + OUT CHAR8 **Filename, + OUT CHAR8 **Description, + OUT UINT32 *LineNumber + ) +{ + EFI_DEBUG_ASSERT_DATA *AssertData; + + ASSERT (Data != NULL); + ASSERT (Filename != NULL); + ASSERT (Description != NULL); + ASSERT (LineNumber != NULL); + + if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && + ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) && + ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) { + AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1); + *Filename = (CHAR8 *)(AssertData + 1); + *Description = *Filename + AsciiStrLen (*Filename) + 1; + *LineNumber = AssertData->LineNumber; + return TRUE; + } + return FALSE; +} + EFI_STATUS EFIAPI SecPeiReportStatusCode ( @@ -473,24 +537,30 @@ Returns: // The first 12 * UINT64 bytes of the string are really an // arguement stack to support varargs on the Format string. // - DebugInfo = (EFI_DEBUG_INFO *) (Data + 1); - Marker = (VA_LIST) (DebugInfo + 1); - Format = (CHAR8 *) (((UINT64 *) Marker) + 12); + if (Data != NULL) { + DebugInfo = (EFI_DEBUG_INFO *) (Data + 1); + Marker = (VA_LIST) (DebugInfo + 1); + Format = (CHAR8 *) (((UINT64 *) Marker) + 12); - AsciiVSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker); - printf (PrintBuffer); + AsciiVSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker); + printf (PrintBuffer); + } else { + printf ("DEBUG \n"); + } } if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) ) { - if (ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) { + if (Data != NULL && ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) { // // Support ASSERT () macro // printf ("ASSERT %s(%d): %s\n", Filename, LineNumber, Description); - CpuBreakpoint (); + } else { + printf ("ASSERT \n"); } + CpuBreakpoint (); } return EFI_SUCCESS; @@ -531,12 +601,13 @@ Returns: // // Compute Top Of Memory for Stack and PEI Core Allocations // - TopOfMemory = LargestRegion + ((LargestRegionSize) & (~15)); + TopOfMemory = LargestRegion + LargestRegionSize; // // Allocate 128KB for the Stack // - TopOfStack = (VOID *) (UINTN) (TopOfMemory - sizeof (EFI_PEI_STARTUP_DESCRIPTOR)); + TopOfStack = (VOID *)((UINTN)TopOfMemory - sizeof (EFI_PEI_STARTUP_DESCRIPTOR) - CPU_STACK_ALIGNMENT); + TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT); TopOfMemory = TopOfMemory - STACK_SIZE; // @@ -1161,3 +1232,5 @@ _ModuleEntryPoint ( ) { } + +#pragma warning(default : 4996)