1 | /** @file
|
---|
2 | This driver produces Print2 protocols layered on top of the PrintLib from the MdePkg.
|
---|
3 |
|
---|
4 | Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include <PiDxe.h>
|
---|
10 |
|
---|
11 | #include <Protocol/Print2.h>
|
---|
12 | #include <Library/PrintLib.h>
|
---|
13 | #include <Library/UefiBootServicesTableLib.h>
|
---|
14 | #include <Library/DebugLib.h>
|
---|
15 | #include <Library/UefiDriverEntryPoint.h>
|
---|
16 |
|
---|
17 | /**
|
---|
18 | Implementaion of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL.
|
---|
19 |
|
---|
20 | If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().
|
---|
21 |
|
---|
22 | @param Buffer The pointer to the output buffer for the produced
|
---|
23 | Null-terminated Unicode string.
|
---|
24 | @param Flags The bitmask of flags that specify left justification, zero
|
---|
25 | pad, and commas.
|
---|
26 | @param Value The 64-bit signed value to convert to a string.
|
---|
27 | @param Width The maximum number of Unicode characters to place in Buffer,
|
---|
28 | not including the Null-terminator.
|
---|
29 |
|
---|
30 | @return If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, return 0.
|
---|
31 | Otherwise, return the number of Unicode characters in Buffer not
|
---|
32 | including the Null-terminator.
|
---|
33 |
|
---|
34 | **/
|
---|
35 | UINTN
|
---|
36 | EFIAPI
|
---|
37 | PrintDxeUnicodeValueToString (
|
---|
38 | IN OUT CHAR16 *Buffer,
|
---|
39 | IN UINTN Flags,
|
---|
40 | IN INT64 Value,
|
---|
41 | IN UINTN Width
|
---|
42 | )
|
---|
43 | {
|
---|
44 | #ifdef DISABLE_NEW_DEPRECATED_INTERFACES
|
---|
45 | //
|
---|
46 | // If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then the
|
---|
47 | // PrintLib API UnicodeValueToString is already deprecated.
|
---|
48 | // In this case, ASSERT will be triggered and zero will be returned for the
|
---|
49 | // implementation of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL
|
---|
50 | // to indicate that the service is no longer supported.
|
---|
51 | //
|
---|
52 | DEBUG ((DEBUG_ERROR, "PrintDxe: The UnicodeValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
|
---|
53 | DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the UnicodeValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
|
---|
54 | ASSERT (FALSE);
|
---|
55 | return 0;
|
---|
56 | #else
|
---|
57 | return UnicodeValueToString (Buffer, Flags, Value, Width);
|
---|
58 | #endif
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | Implementaion of the AsciiValueToString service in EFI_PRINT2_PROTOCOL.
|
---|
63 |
|
---|
64 | If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().
|
---|
65 |
|
---|
66 | @param Buffer A pointer to the output buffer for the produced
|
---|
67 | Null-terminated ASCII string.
|
---|
68 | @param Flags The bitmask of flags that specify left justification, zero
|
---|
69 | pad, and commas.
|
---|
70 | @param Value The 64-bit signed value to convert to a string.
|
---|
71 | @param Width The maximum number of ASCII characters to place in Buffer,
|
---|
72 | not including the Null-terminator.
|
---|
73 |
|
---|
74 | @return If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, return 0.
|
---|
75 | Otherwise, return the number of ASCII characters in Buffer not
|
---|
76 | including the Null-terminator.
|
---|
77 |
|
---|
78 | **/
|
---|
79 | UINTN
|
---|
80 | EFIAPI
|
---|
81 | PrintDxeAsciiValueToString (
|
---|
82 | OUT CHAR8 *Buffer,
|
---|
83 | IN UINTN Flags,
|
---|
84 | IN INT64 Value,
|
---|
85 | IN UINTN Width
|
---|
86 | )
|
---|
87 | {
|
---|
88 | #ifdef DISABLE_NEW_DEPRECATED_INTERFACES
|
---|
89 | //
|
---|
90 | // If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then the
|
---|
91 | // PrintLib API AsciiValueToString is already deprecated.
|
---|
92 | // In this case, ASSERT will be triggered and zero will be returned for the
|
---|
93 | // implementation of the AsciiValueToString service in EFI_PRINT2_PROTOCOL
|
---|
94 | // to indicate that the service is no longer supported.
|
---|
95 | //
|
---|
96 | DEBUG ((DEBUG_ERROR, "PrintDxe: The AsciiValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
|
---|
97 | DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the AsciiValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
|
---|
98 | ASSERT (FALSE);
|
---|
99 | return 0;
|
---|
100 | #else
|
---|
101 | return AsciiValueToString (Buffer, Flags, Value, Width);
|
---|
102 | #endif
|
---|
103 | }
|
---|
104 |
|
---|
105 | EFI_HANDLE mPrintThunkHandle = NULL;
|
---|
106 |
|
---|
107 | CONST EFI_PRINT2_PROTOCOL mPrint2Protocol = {
|
---|
108 | UnicodeBSPrint,
|
---|
109 | UnicodeSPrint,
|
---|
110 | UnicodeBSPrintAsciiFormat,
|
---|
111 | UnicodeSPrintAsciiFormat,
|
---|
112 | PrintDxeUnicodeValueToString,
|
---|
113 | AsciiBSPrint,
|
---|
114 | AsciiSPrint,
|
---|
115 | AsciiBSPrintUnicodeFormat,
|
---|
116 | AsciiSPrintUnicodeFormat,
|
---|
117 | PrintDxeAsciiValueToString
|
---|
118 | };
|
---|
119 |
|
---|
120 | CONST EFI_PRINT2S_PROTOCOL mPrint2SProtocol = {
|
---|
121 | UnicodeBSPrint,
|
---|
122 | UnicodeSPrint,
|
---|
123 | UnicodeBSPrintAsciiFormat,
|
---|
124 | UnicodeSPrintAsciiFormat,
|
---|
125 | UnicodeValueToStringS,
|
---|
126 | AsciiBSPrint,
|
---|
127 | AsciiSPrint,
|
---|
128 | AsciiBSPrintUnicodeFormat,
|
---|
129 | AsciiSPrintUnicodeFormat,
|
---|
130 | AsciiValueToStringS
|
---|
131 | };
|
---|
132 |
|
---|
133 | /**
|
---|
134 | The user Entry Point for Print module.
|
---|
135 |
|
---|
136 | This is the entry point for Print DXE Driver. It installs the Print2 Protocol.
|
---|
137 |
|
---|
138 | @param[in] ImageHandle The firmware allocated handle for the EFI image.
|
---|
139 | @param[in] SystemTable A pointer to the EFI System Table.
|
---|
140 |
|
---|
141 | @retval EFI_SUCCESS The entry point is executed successfully.
|
---|
142 | @retval Others Some error occurs when executing this entry point.
|
---|
143 |
|
---|
144 | **/
|
---|
145 | EFI_STATUS
|
---|
146 | EFIAPI
|
---|
147 | PrintEntryPoint (
|
---|
148 | IN EFI_HANDLE ImageHandle,
|
---|
149 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
150 | )
|
---|
151 | {
|
---|
152 | EFI_STATUS Status;
|
---|
153 |
|
---|
154 | Status = gBS->InstallMultipleProtocolInterfaces (
|
---|
155 | &mPrintThunkHandle,
|
---|
156 | &gEfiPrint2ProtocolGuid, &mPrint2Protocol,
|
---|
157 | &gEfiPrint2SProtocolGuid, &mPrint2SProtocol,
|
---|
158 | NULL
|
---|
159 | );
|
---|
160 | ASSERT_EFI_ERROR (Status);
|
---|
161 |
|
---|
162 | return Status;
|
---|
163 | }
|
---|