Re: [edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write.
Commit to EDKII at 18414. And EDKII 18415, I correct protocol usage description in INF. -Original Message- From: Masamitsu MURASE [mailto:masamitsu.mur...@gmail.com] Sent: Thursday, September 03, 2015 2:09 AM To: Gao, Liming; edk2-devel@lists.01.org Subject: [edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write. Dear Liming, MdePkg maintainers, Thank you very much for the reply, Liming. I modified the following points: >> 1) Refer to BaseDebugLibSerialPort instance, DebugPortProtocolWrite() API >> can have two parameters: Buffer and BufferLength. >> 2) DebugPortProtocolInit() API can be merged into DebugPortProtocolWrite(). >> 3) GLOBAL_REMOVE_IF_UNREFERENCED is not required to declare mDebugPort. >> mDebugPort is always be used. >> 4) mTimeOut is not required. WRITE_TIMEOUT can be directly specified into >> DebugPortProtocol->Write() API. Let me try again, please. MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write. UefiDebugLibDebugPortProtocol is an implementation of DebugLib. It calls EFI_DEBUGPORT_PROTOCOL.Write in DebugPrint and DebugAssert. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Masamitsu MURASE --- .../UefiDebugLibDebugPortProtocol/DebugLib.c | 329 + .../UefiDebugLibDebugPortProtocol.inf | 57 .../UefiDebugLibDebugPortProtocol.uni | Bin 0 -> 1812 bytes MdePkg/MdePkg.dsc | 1 + 4 files changed, 387 insertions(+) create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.uni diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c new file mode 100644 index 000..fdad2f5 --- /dev/null +++ b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c @@ -0,0 +1,329 @@ +/** @file + UEFI Debug Library that sends messages to EFI_DEBUGPORT_PROTOCOL.Write. + + Copyright (c) 2015, 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. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// +// Define the maximum debug and assert message length that this library +supports // #define MAX_DEBUG_MESSAGE_LENGTH 0x100 + +// +// Define the timeout for EFI_DEBUGPORT_PROTOCOL.Write // #define +WRITE_TIMEOUT 1000 + + +EFI_DEBUGPORT_PROTOCOL *mDebugPort = NULL; + +/** + Send message to DebugPort Protocol. + + If mDebugPort is NULL, i.e. EFI_DEBUGPORT_PROTOCOL is not located, + EFI_DEBUGPORT_PROTOCOL is located first. + Then, Buffer is sent via EFI_DEBUGPORT_PROTOCOL.Write. + + @param Buffer The message to be sent. + @param BufferLength The byte length of Buffer. +**/ +VOID +UefiDebugLibDebugPortProtocolWrite ( + IN CONST CHAR8 *Buffer, + INUINTN BufferLength + ) +{ + UINTN Length; + EFI_STATUS Status; + + // + // If mDebugPort is NULL, initialize first. + // + if (mDebugPort == NULL) { + Status = gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **)&mDebugPort); + if (EFI_ERROR (Status)) { + return; + } + + mDebugPort->Reset (mDebugPort); + } + + // + // EFI_DEBUGPORT_PROTOCOL.Write is called until all message is sent. + // + while (BufferLength > 0) { +Length = BufferLength; + +Status = mDebugPort->Write (mDebugPort, WRITE_TIMEOUT, &Length, (VOID *) Buffer); +if (EFI_ERROR (Status) || BufferLength < Length) { + break; +} + +Buffer += Length; +BufferLength -= Length; + } +} + +/** + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib + function GetDebugPrintErrorLevel (), then print the message specified + by Format and the associated variable argument list to the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + @param ... A variable
Re: [edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write.
Masamitsu: Could you attach the patch file to me? I can help you commit it. Reviewed-by: Liming Gao Thanks Liming -Original Message- From: Masamitsu MURASE [mailto:masamitsu.mur...@gmail.com] Sent: Thursday, September 03, 2015 2:09 AM To: Gao, Liming; edk2-devel@lists.01.org Subject: [edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write. Dear Liming, MdePkg maintainers, Thank you very much for the reply, Liming. I modified the following points: >> 1) Refer to BaseDebugLibSerialPort instance, DebugPortProtocolWrite() API >> can have two parameters: Buffer and BufferLength. >> 2) DebugPortProtocolInit() API can be merged into DebugPortProtocolWrite(). >> 3) GLOBAL_REMOVE_IF_UNREFERENCED is not required to declare mDebugPort. >> mDebugPort is always be used. >> 4) mTimeOut is not required. WRITE_TIMEOUT can be directly specified into >> DebugPortProtocol->Write() API. Let me try again, please. MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write. UefiDebugLibDebugPortProtocol is an implementation of DebugLib. It calls EFI_DEBUGPORT_PROTOCOL.Write in DebugPrint and DebugAssert. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Masamitsu MURASE --- .../UefiDebugLibDebugPortProtocol/DebugLib.c | 329 + .../UefiDebugLibDebugPortProtocol.inf | 57 .../UefiDebugLibDebugPortProtocol.uni | Bin 0 -> 1812 bytes MdePkg/MdePkg.dsc | 1 + 4 files changed, 387 insertions(+) create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.uni diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c new file mode 100644 index 000..fdad2f5 --- /dev/null +++ b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c @@ -0,0 +1,329 @@ +/** @file + UEFI Debug Library that sends messages to EFI_DEBUGPORT_PROTOCOL.Write. + + Copyright (c) 2015, 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. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// +// Define the maximum debug and assert message length that this library +supports // #define MAX_DEBUG_MESSAGE_LENGTH 0x100 + +// +// Define the timeout for EFI_DEBUGPORT_PROTOCOL.Write // #define +WRITE_TIMEOUT 1000 + + +EFI_DEBUGPORT_PROTOCOL *mDebugPort = NULL; + +/** + Send message to DebugPort Protocol. + + If mDebugPort is NULL, i.e. EFI_DEBUGPORT_PROTOCOL is not located, + EFI_DEBUGPORT_PROTOCOL is located first. + Then, Buffer is sent via EFI_DEBUGPORT_PROTOCOL.Write. + + @param Buffer The message to be sent. + @param BufferLength The byte length of Buffer. +**/ +VOID +UefiDebugLibDebugPortProtocolWrite ( + IN CONST CHAR8 *Buffer, + INUINTN BufferLength + ) +{ + UINTN Length; + EFI_STATUS Status; + + // + // If mDebugPort is NULL, initialize first. + // + if (mDebugPort == NULL) { + Status = gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **)&mDebugPort); + if (EFI_ERROR (Status)) { + return; + } + + mDebugPort->Reset (mDebugPort); + } + + // + // EFI_DEBUGPORT_PROTOCOL.Write is called until all message is sent. + // + while (BufferLength > 0) { +Length = BufferLength; + +Status = mDebugPort->Write (mDebugPort, WRITE_TIMEOUT, &Length, (VOID *) Buffer); +if (EFI_ERROR (Status) || BufferLength < Length) { + break; +} + +Buffer += Length; +BufferLength -= Length; + } +} + +/** + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib + function GetDebugPrintErrorLevel (), then print the message specified + by Format and the associated variable argument list to the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message
[edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write.
Dear Liming, MdePkg maintainers, Thank you very much for the reply, Liming. I modified the following points: >> 1) Refer to BaseDebugLibSerialPort instance, DebugPortProtocolWrite() API >> can have two parameters: Buffer and BufferLength. >> 2) DebugPortProtocolInit() API can be merged into DebugPortProtocolWrite(). >> 3) GLOBAL_REMOVE_IF_UNREFERENCED is not required to declare mDebugPort. >> mDebugPort is always be used. >> 4) mTimeOut is not required. WRITE_TIMEOUT can be directly specified into >> DebugPortProtocol->Write() API. Let me try again, please. MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write. UefiDebugLibDebugPortProtocol is an implementation of DebugLib. It calls EFI_DEBUGPORT_PROTOCOL.Write in DebugPrint and DebugAssert. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Masamitsu MURASE --- .../UefiDebugLibDebugPortProtocol/DebugLib.c | 329 + .../UefiDebugLibDebugPortProtocol.inf | 57 .../UefiDebugLibDebugPortProtocol.uni | Bin 0 -> 1812 bytes MdePkg/MdePkg.dsc | 1 + 4 files changed, 387 insertions(+) create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.uni diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c new file mode 100644 index 000..fdad2f5 --- /dev/null +++ b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c @@ -0,0 +1,329 @@ +/** @file + UEFI Debug Library that sends messages to EFI_DEBUGPORT_PROTOCOL.Write. + + Copyright (c) 2015, 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. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// +// Define the maximum debug and assert message length that this library supports +// +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 + +// +// Define the timeout for EFI_DEBUGPORT_PROTOCOL.Write +// +#define WRITE_TIMEOUT 1000 + + +EFI_DEBUGPORT_PROTOCOL *mDebugPort = NULL; + +/** + Send message to DebugPort Protocol. + + If mDebugPort is NULL, i.e. EFI_DEBUGPORT_PROTOCOL is not located, + EFI_DEBUGPORT_PROTOCOL is located first. + Then, Buffer is sent via EFI_DEBUGPORT_PROTOCOL.Write. + + @param Buffer The message to be sent. + @param BufferLength The byte length of Buffer. +**/ +VOID +UefiDebugLibDebugPortProtocolWrite ( + IN CONST CHAR8 *Buffer, + INUINTN BufferLength + ) +{ + UINTN Length; + EFI_STATUS Status; + + // + // If mDebugPort is NULL, initialize first. + // + if (mDebugPort == NULL) { + Status = gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **)&mDebugPort); + if (EFI_ERROR (Status)) { + return; + } + + mDebugPort->Reset (mDebugPort); + } + + // + // EFI_DEBUGPORT_PROTOCOL.Write is called until all message is sent. + // + while (BufferLength > 0) { +Length = BufferLength; + +Status = mDebugPort->Write (mDebugPort, WRITE_TIMEOUT, &Length, (VOID *) Buffer); +if (EFI_ERROR (Status) || BufferLength < Length) { + break; +} + +Buffer += Length; +BufferLength -= Length; + } +} + +/** + Prints a debug message to the debug output device if the specified error level is enabled. + + If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function + GetDebugPrintErrorLevel (), then print the message specified by Format and the + associated variable argument list to the debug output device. + + If Format is NULL, then ASSERT(). + + @param ErrorLevel The error level of the debug message. + @param Format Format string for the debug message to print. + @param ... A variable argument list whose contents are accessed + based on the format string specified by Format. + +**/ +VOID +EFIAPI +DebugPrint ( + IN UINTNErrorLevel, + IN CONST CHAR8 *Format, + ... + ) +{ + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; + VA_LISTMarker; + + // + // If Format is NULL, then ASSERT(). + // + ASSERT (Format != NULL); + + // + // Check driver debug mask value and global mask + // + if ((ErrorLevel & GetDeb
Re: [edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write.
Masamitsu: Thanks for your contribution. UefiDebugLibDebugPortProtocol library is a good solution for your usage model. I agree to add it into MdePkg. For this patch, I have some minor comments. 1) Refer to BaseDebugLibSerialPort instance, DebugPortProtocolWrite() API can have two parameters: Buffer and BufferLength. 2) DebugPortProtocolInit() API can be merged into DebugPortProtocolWrite(). 3) GLOBAL_REMOVE_IF_UNREFERENCED is not required to declare mDebugPort. mDebugPort is always be used. 4) mTimeOut is not required. WRITE_TIMEOUT can be directly specified into DebugPortProtocol->Write() API. Thanks Liming -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Masamitsu MURASE Sent: Sunday, August 30, 2015 9:54 PM To: edk2-devel@lists.01.org Subject: [edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write. Dear MdePkg maintainers, Let me send my request again because the attached file of the previous mail might be removed. I'm very sorry for inconvenience. If my post still has something wrong, let me know please. MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write. I propose a new DebugPrint implementation, UefiDebugLibDebugPortProtocol, which uses EFI_DEBUGPORT_PROTOCOL internally. This library calls EFI_DEBUGPORT_PROTOCOL.Write in DebugPrint and DebugAssert. MdePkg has several implementations for DebugPrint, such as UefiDebugLibConOut and BaseDebugLibSerialPort. For example, in the case of UefiDebugLibConOut, gST->ConOut->OutputString is called in DebugPrint. This library is similar to them, but it calls EFI_DEBUGPORT_PROTOCOL.Write instead of gST->ConOut->OutputString. Let me explain the background of my patch. Let's suppose that we are developers of UEFI firmware for Laptop computers. We sometimes face an issue caused by 3rd party's UEFI driver, such as GOP driver and PXE driver for a USB LAN device. In this case, it is really difficult for us to debug the issue smoothly because of the following reasons: - BaseDebugLibSerialPort cannot be used because almost all Laptops do not have SerialPort. Many PC vendors use their own debug device which outputs debug logs via I2C or USB-Serial and so on. It highly depends on each PC vendor and model. - UefiDebugLibConOut cannot be used when GOP is debugged. - Our customzied DebugLib, which outputs debug logs via our own debug device, sometimes isn't accepted by the 3rd party companies because they have to build each debug module for each customer if they accept such a solution. The above concerns are caused because DebugLib is statically linke to each UEFI modules. UefiDebugLibDebugPortProtocol solves the problems as follows: Debug logs are printed via EFI_DEBUGPORT_PROTOCOL.Write. Then, - 3rd party companies build their module with this UefiDebugLibDebugPortProtocol library. - We, PC vendor, build our UEFI firmware with the debug module provided by 3rd party. In this case, we simply install our own implementation of EFI_DEBUGPORT_PROTOCOL so that we can output debug logs via our own debug device. This brings the followings: - 3rd party can provide the single debug module to all customers. - PC vendor can easily specify the request of debug module to the 3rd party. We can simply say "Please build the debug module with UefiDebugLibDebugPortProtocol library". Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Masamitsu MURASE --- .../UefiDebugLibDebugPortProtocol/DebugLib.c | 341 + .../UefiDebugLibDebugPortProtocol.inf | 57 .../UefiDebugLibDebugPortProtocol.uni | Bin 0 -> 1812 bytes MdePkg/MdePkg.dsc | 1 + 4 files changed, 399 insertions(+) create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.uni diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c new file mode 100644 index 000..56ea690 --- /dev/null +++ b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c @@ -0,0 +1,341 @@ +/** @file + UEFI Debug Library that sends messages to EFI_DEBUGPORT_PROTOCOL.Write. + + Copyright (c) 2015, 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.
Re: [edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write.
Hi MdePkg maintainers, I'll be grateful if you can reply to me. I believe that this kind of feature helps debugging in PC vendors and 3rd party UEFI driver vendors. Regards, Murase --- Masamitsu MURASE https://github.com/masamitsu-murase -- Mail: masamitsu.mur...@gmail.com 村瀬 昌満 (MURASE Masamitsu) ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH] MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write.
Dear MdePkg maintainers, Let me send my request again because the attached file of the previous mail might be removed. I'm very sorry for inconvenience. If my post still has something wrong, let me know please. MdePkg: Add UefiDebugLibDebugPortProtocol to output logs via EFI_DEBUGPORT_PROTOCOL.Write. I propose a new DebugPrint implementation, UefiDebugLibDebugPortProtocol, which uses EFI_DEBUGPORT_PROTOCOL internally. This library calls EFI_DEBUGPORT_PROTOCOL.Write in DebugPrint and DebugAssert. MdePkg has several implementations for DebugPrint, such as UefiDebugLibConOut and BaseDebugLibSerialPort. For example, in the case of UefiDebugLibConOut, gST->ConOut->OutputString is called in DebugPrint. This library is similar to them, but it calls EFI_DEBUGPORT_PROTOCOL.Write instead of gST->ConOut->OutputString. Let me explain the background of my patch. Let's suppose that we are developers of UEFI firmware for Laptop computers. We sometimes face an issue caused by 3rd party's UEFI driver, such as GOP driver and PXE driver for a USB LAN device. In this case, it is really difficult for us to debug the issue smoothly because of the following reasons: - BaseDebugLibSerialPort cannot be used because almost all Laptops do not have SerialPort. Many PC vendors use their own debug device which outputs debug logs via I2C or USB-Serial and so on. It highly depends on each PC vendor and model. - UefiDebugLibConOut cannot be used when GOP is debugged. - Our customzied DebugLib, which outputs debug logs via our own debug device, sometimes isn't accepted by the 3rd party companies because they have to build each debug module for each customer if they accept such a solution. The above concerns are caused because DebugLib is statically linke to each UEFI modules. UefiDebugLibDebugPortProtocol solves the problems as follows: Debug logs are printed via EFI_DEBUGPORT_PROTOCOL.Write. Then, - 3rd party companies build their module with this UefiDebugLibDebugPortProtocol library. - We, PC vendor, build our UEFI firmware with the debug module provided by 3rd party. In this case, we simply install our own implementation of EFI_DEBUGPORT_PROTOCOL so that we can output debug logs via our own debug device. This brings the followings: - 3rd party can provide the single debug module to all customers. - PC vendor can easily specify the request of debug module to the 3rd party. We can simply say "Please build the debug module with UefiDebugLibDebugPortProtocol library". Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Masamitsu MURASE --- .../UefiDebugLibDebugPortProtocol/DebugLib.c | 341 + .../UefiDebugLibDebugPortProtocol.inf | 57 .../UefiDebugLibDebugPortProtocol.uni | Bin 0 -> 1812 bytes MdePkg/MdePkg.dsc | 1 + 4 files changed, 399 insertions(+) create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf create mode 100644 MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.uni diff --git a/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c new file mode 100644 index 000..56ea690 --- /dev/null +++ b/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLib.c @@ -0,0 +1,341 @@ +/** @file + UEFI Debug Library that sends messages to EFI_DEBUGPORT_PROTOCOL.Write. + + Copyright (c) 2015, 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. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +// +// Define the maximum debug and assert message length that this library supports +// +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 +#define WRITE_TIMEOUT 1000 + + +GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEBUGPORT_PROTOCOL *mDebugPort = NULL; +UINT32 mTimeOut = WRITE_TIMEOUT; + +/** + Initialize EFI_DEBUGPORT_PROTOCOL to use it in DebugPrint and DebugAssert. + + If EFI_DEBUGPORT_PROTOCOL can be located, Reset function is called for the instance. +**/ +EFI_STATUS +UefiDebugLibDebugPortProtocolInit(VOID) +{ + EFI_STATUS Status; + + Status = gBS->LocateProtocol(&gEfiDebugPortProtocolGuid, NULL, (VOID **)&mDebugPort); + if (!EFI_ERROR(Status)) { +mDebugP