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