X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=DuetPkg%2FDxeIpl%2FSerialStatusCode.c;h=15959323834760e9796dbcb50caa9d4c5661cd4b;hb=3a7ec658e63cbb45f2ee35d02d54809c51bfd206;hp=02cc4d47cdd0e6b3942483306c378a7a30503124;hpb=18b84857507fc28b8fbfbcd434f9c48bbcaf4ac5;p=mirror_edk2.git diff --git a/DuetPkg/DxeIpl/SerialStatusCode.c b/DuetPkg/DxeIpl/SerialStatusCode.c index 02cc4d47cd..1595932383 100644 --- a/DuetPkg/DxeIpl/SerialStatusCode.c +++ b/DuetPkg/DxeIpl/SerialStatusCode.c @@ -1,7 +1,7 @@ /** @file -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+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 http://opensource.org/licenses/bsd-license.php @@ -18,16 +18,9 @@ Revision History: **/ +#include #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. // @@ -542,21 +535,6 @@ STATUS_CODE_LOOKUP_TABLE mOperationToken[] = { }; -// -// Private function declarations -// -UINT8 -CpuIoRead8 ( - UINT16 Port - ); - -VOID -CpuIoWrite8 ( - UINT16 Port, - UINT32 Data - ); - - EFI_STATUS MatchString ( IN STATUS_CODE_LOOKUP_TABLE *Table, @@ -617,72 +595,6 @@ Returns: } - -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 = CpuIoRead8 (gComBase + LSR_OFFSET); - } while ((Data & LSR_TXRDY) == 0); - - CpuIoWrite8 (gComBase, Character); -} - -VOID -DebugSerialPrint ( - IN UINT8 *OutputString - ) -/*++ - -Routine Description: - - Prints a string to the Serial port - -Arguments: - - OutputString - Ascii string to print to serial port. - -Returns: - - None - ---*/ -{ - EFI_STATUS Status; - - Status = EFI_SUCCESS; - - for ( ; *OutputString != 0; OutputString++) { - DebugSerialWrite (*OutputString); - } -} - EFI_STATUS EFIAPI SerialReportStatusCode ( @@ -714,46 +626,48 @@ Returns: CHAR8 *Filename; CHAR8 *Description; CHAR8 *Format; - VA_LIST Marker; + BASE_LIST Marker; UINT32 ErrorLevel; - UINTN CharCount; + UINTN CharCount = 0; Buffer[0] = '\0'; - if (ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) { + if (Data != NULL && + ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) { // // Processes PEI_ASSERT () // - AsciiSPrint ( + CharCount = AsciiSPrint ( Buffer, - EFI_STATUS_CODE_DATA_MAX_SIZE, + sizeof (Buffer), "\nPEI_ASSERT!: %a (%d): %a\n", Filename, LineNumber, Description ); - } else if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) { + } else if (Data != NULL && + ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) { // // Process PEI_DEBUG () macro to Serial // - AsciiVSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker); + CharCount = AsciiBSPrint (Buffer, sizeof (Buffer), Format, Marker); } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) { // // Process Errors // - CharCount = AsciiSPrint (Buffer, EFI_STATUS_CODE_DATA_MAX_SIZE, "ERROR: C%x:V%x I%x", CodeType, Value, Instance); + CharCount = AsciiSPrint (Buffer, sizeof (Buffer), "ERROR: C%x:V%x I%x", CodeType, Value, Instance); // // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers. // if (CallerId) { - CharCount += AsciiSPrint (&Buffer[CharCount - 1], (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof(Buffer[0]) * CharCount)), " %g", CallerId); + CharCount += AsciiSPrint (&Buffer[CharCount - 1], (sizeof (Buffer) - (sizeof(Buffer[0]) * CharCount)), " %g", CallerId); } if (Data) { - CharCount += AsciiSPrint (&Buffer[CharCount - 1], (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof(Buffer[0]) * CharCount)), " %x", Data); + CharCount += AsciiSPrint (&Buffer[CharCount - 1], (sizeof (Buffer) - (sizeof(Buffer[0]) * CharCount)), " %x", Data); } - CharCount += AsciiSPrint (&Buffer[CharCount - 1], (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof(Buffer[0]) * CharCount)), "\n"); + CharCount += AsciiSPrint (&Buffer[CharCount - 1], (sizeof (Buffer) - (sizeof(Buffer[0]) * CharCount)), "\n"); } @@ -761,7 +675,7 @@ Returns: // // Callout to platform Lib function to do print. // - DebugSerialPrint (Buffer); + SerialPortWrite ((UINT8 *) Buffer, CharCount); } // @@ -803,9 +717,9 @@ Returns: // // Concatenate the instance // - AsciiSPrint ( + CharCount = AsciiSPrint ( Buffer, - EFI_STATUS_CODE_DATA_MAX_SIZE, + sizeof (Buffer), "%a:%a:%a:%d\n", SeverityToken, SubClassToken, @@ -813,7 +727,7 @@ Returns: Instance ); - DebugSerialPrint (Buffer); + SerialPortWrite ((UINT8 *) Buffer, CharCount); } } @@ -829,15 +743,11 @@ InstallSerialStatusCode ( 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: @@ -845,41 +755,6 @@ Returns: --*/ { - 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)))); - CpuIoWrite8 (gComBase + LCR_OFFSET, OutputData); - - // - // Configure baud rate - // - CpuIoWrite8 (gComBase + BAUD_HIGH_OFFSET, (UINT8)(Divisor >> 8)); - CpuIoWrite8 (gComBase + BAUD_LOW_OFFSET, (UINT8)(Divisor & 0xff)); - - // - // Switch back to bank 0 - // - OutputData = (UINT8)((~DLAB<<7)|((gBreakSet<<6)|((gParity<<3)|((gStop<<2)| Data)))); - CpuIoWrite8 (gComBase + LCR_OFFSET, OutputData); - + SerialPortInitialize(); *ReportStatusCode = SerialReportStatusCode; }