2 This driver produces Print2 protocols layered on top of the PrintLib from the MdePkg.
4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Protocol/Print2.h>
18 #include <Library/PrintLib.h>
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/UefiDriverEntryPoint.h>
24 Implementaion of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL.
26 If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().
28 @param Buffer The pointer to the output buffer for the produced
29 Null-terminated Unicode string.
30 @param Flags The bitmask of flags that specify left justification, zero
32 @param Value The 64-bit signed value to convert to a string.
33 @param Width The maximum number of Unicode characters to place in Buffer,
34 not including the Null-terminator.
36 @return If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, return 0.
37 Otherwise, return the number of Unicode characters in Buffer not
38 including the Null-terminator.
43 PrintDxeUnicodeValueToString (
44 IN OUT CHAR16
*Buffer
,
50 #ifdef DISABLE_NEW_DEPRECATED_INTERFACES
52 // If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then the
53 // PrintLib API UnicodeValueToString is already deprecated.
54 // In this case, ASSERT will be triggered and zero will be returned for the
55 // implementation of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL
56 // to indicate that the service is no longer supported.
58 DEBUG ((DEBUG_ERROR
, "PrintDxe: The UnicodeValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
59 DEBUG ((DEBUG_ERROR
, "PrintDxe: Please consider using the UnicodeValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
63 return UnicodeValueToString (Buffer
, Flags
, Value
, Width
);
68 Implementaion of the AsciiValueToString service in EFI_PRINT2_PROTOCOL.
70 If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().
72 @param Buffer A pointer to the output buffer for the produced
73 Null-terminated ASCII string.
74 @param Flags The bitmask of flags that specify left justification, zero
76 @param Value The 64-bit signed value to convert to a string.
77 @param Width The maximum number of ASCII characters to place in Buffer,
78 not including the Null-terminator.
80 @return If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, return 0.
81 Otherwise, return the number of ASCII characters in Buffer not
82 including the Null-terminator.
87 PrintDxeAsciiValueToString (
94 #ifdef DISABLE_NEW_DEPRECATED_INTERFACES
96 // If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then the
97 // PrintLib API AsciiValueToString is already deprecated.
98 // In this case, ASSERT will be triggered and zero will be returned for the
99 // implementation of the AsciiValueToString service in EFI_PRINT2_PROTOCOL
100 // to indicate that the service is no longer supported.
102 DEBUG ((DEBUG_ERROR
, "PrintDxe: The AsciiValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
103 DEBUG ((DEBUG_ERROR
, "PrintDxe: Please consider using the AsciiValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
107 return AsciiValueToString (Buffer
, Flags
, Value
, Width
);
111 EFI_HANDLE mPrintThunkHandle
= NULL
;
113 CONST EFI_PRINT2_PROTOCOL mPrint2Protocol
= {
116 UnicodeBSPrintAsciiFormat
,
117 UnicodeSPrintAsciiFormat
,
118 PrintDxeUnicodeValueToString
,
121 AsciiBSPrintUnicodeFormat
,
122 AsciiSPrintUnicodeFormat
,
123 PrintDxeAsciiValueToString
126 CONST EFI_PRINT2S_PROTOCOL mPrint2SProtocol
= {
129 UnicodeBSPrintAsciiFormat
,
130 UnicodeSPrintAsciiFormat
,
131 UnicodeValueToStringS
,
134 AsciiBSPrintUnicodeFormat
,
135 AsciiSPrintUnicodeFormat
,
140 The user Entry Point for Print module.
142 This is the entry point for Print DXE Driver. It installs the Print2 Protocol.
144 @param[in] ImageHandle The firmware allocated handle for the EFI image.
145 @param[in] SystemTable A pointer to the EFI System Table.
147 @retval EFI_SUCCESS The entry point is executed successfully.
148 @retval Others Some error occurs when executing this entry point.
154 IN EFI_HANDLE ImageHandle
,
155 IN EFI_SYSTEM_TABLE
*SystemTable
160 Status
= gBS
->InstallMultipleProtocolInterfaces (
162 &gEfiPrint2ProtocolGuid
, &mPrint2Protocol
,
163 &gEfiPrint2SProtocolGuid
, &mPrint2SProtocol
,
166 ASSERT_EFI_ERROR (Status
);