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 |
|
---|
21 | @param Buffer The pointer to the output buffer for the produced
|
---|
22 | Null-terminated Unicode string.
|
---|
23 | @param Flags The bitmask of flags that specify left justification, zero
|
---|
24 | pad, and commas.
|
---|
25 | @param Value The 64-bit signed value to convert to a string.
|
---|
26 | @param Width The maximum number of Unicode characters to place in Buffer,
|
---|
27 | not including the Null-terminator.
|
---|
28 |
|
---|
29 | @return 0.
|
---|
30 |
|
---|
31 |
|
---|
32 | **/
|
---|
33 | UINTN
|
---|
34 | EFIAPI
|
---|
35 | PrintDxeUnicodeValueToString (
|
---|
36 | IN OUT CHAR16 *Buffer,
|
---|
37 | IN UINTN Flags,
|
---|
38 | IN INT64 Value,
|
---|
39 | IN UINTN Width
|
---|
40 | )
|
---|
41 | {
|
---|
42 | DEBUG ((DEBUG_ERROR, "PrintDxe: The UnicodeValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
|
---|
43 | DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the UnicodeValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
|
---|
44 | ASSERT (FALSE);
|
---|
45 | return 0;
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | Implementaion of the AsciiValueToString service in EFI_PRINT2_PROTOCOL.
|
---|
50 |
|
---|
51 | @param Buffer A pointer to the output buffer for the produced
|
---|
52 | Null-terminated ASCII string.
|
---|
53 | @param Flags The bitmask of flags that specify left justification, zero
|
---|
54 | pad, and commas.
|
---|
55 | @param Value The 64-bit signed value to convert to a string.
|
---|
56 | @param Width The maximum number of ASCII characters to place in Buffer,
|
---|
57 | not including the Null-terminator.
|
---|
58 |
|
---|
59 | @return 0.
|
---|
60 |
|
---|
61 | **/
|
---|
62 | UINTN
|
---|
63 | EFIAPI
|
---|
64 | PrintDxeAsciiValueToString (
|
---|
65 | OUT CHAR8 *Buffer,
|
---|
66 | IN UINTN Flags,
|
---|
67 | IN INT64 Value,
|
---|
68 | IN UINTN Width
|
---|
69 | )
|
---|
70 | {
|
---|
71 | DEBUG ((DEBUG_ERROR, "PrintDxe: The AsciiValueToString service in EFI_PRINT2_PROTOCOL is no longer supported for security reason.\n"));
|
---|
72 | DEBUG ((DEBUG_ERROR, "PrintDxe: Please consider using the AsciiValueToStringS service in EFI_PRINT2S_PROTOCOL.\n"));
|
---|
73 | ASSERT (FALSE);
|
---|
74 | return 0;
|
---|
75 | }
|
---|
76 |
|
---|
77 | EFI_HANDLE mPrintThunkHandle = NULL;
|
---|
78 |
|
---|
79 | CONST EFI_PRINT2_PROTOCOL mPrint2Protocol = {
|
---|
80 | UnicodeBSPrint,
|
---|
81 | UnicodeSPrint,
|
---|
82 | UnicodeBSPrintAsciiFormat,
|
---|
83 | UnicodeSPrintAsciiFormat,
|
---|
84 | PrintDxeUnicodeValueToString,
|
---|
85 | AsciiBSPrint,
|
---|
86 | AsciiSPrint,
|
---|
87 | AsciiBSPrintUnicodeFormat,
|
---|
88 | AsciiSPrintUnicodeFormat,
|
---|
89 | PrintDxeAsciiValueToString
|
---|
90 | };
|
---|
91 |
|
---|
92 | CONST EFI_PRINT2S_PROTOCOL mPrint2SProtocol = {
|
---|
93 | UnicodeBSPrint,
|
---|
94 | UnicodeSPrint,
|
---|
95 | UnicodeBSPrintAsciiFormat,
|
---|
96 | UnicodeSPrintAsciiFormat,
|
---|
97 | UnicodeValueToStringS,
|
---|
98 | AsciiBSPrint,
|
---|
99 | AsciiSPrint,
|
---|
100 | AsciiBSPrintUnicodeFormat,
|
---|
101 | AsciiSPrintUnicodeFormat,
|
---|
102 | AsciiValueToStringS
|
---|
103 | };
|
---|
104 |
|
---|
105 | /**
|
---|
106 | The user Entry Point for Print module.
|
---|
107 |
|
---|
108 | This is the entry point for Print DXE Driver. It installs the Print2 Protocol.
|
---|
109 |
|
---|
110 | @param[in] ImageHandle The firmware allocated handle for the EFI image.
|
---|
111 | @param[in] SystemTable A pointer to the EFI System Table.
|
---|
112 |
|
---|
113 | @retval EFI_SUCCESS The entry point is executed successfully.
|
---|
114 | @retval Others Some error occurs when executing this entry point.
|
---|
115 |
|
---|
116 | **/
|
---|
117 | EFI_STATUS
|
---|
118 | EFIAPI
|
---|
119 | PrintEntryPoint (
|
---|
120 | IN EFI_HANDLE ImageHandle,
|
---|
121 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
122 | )
|
---|
123 | {
|
---|
124 | EFI_STATUS Status;
|
---|
125 |
|
---|
126 | Status = gBS->InstallMultipleProtocolInterfaces (
|
---|
127 | &mPrintThunkHandle,
|
---|
128 | &gEfiPrint2ProtocolGuid,
|
---|
129 | &mPrint2Protocol,
|
---|
130 | &gEfiPrint2SProtocolGuid,
|
---|
131 | &mPrint2SProtocol,
|
---|
132 | NULL
|
---|
133 | );
|
---|
134 | ASSERT_EFI_ERROR (Status);
|
---|
135 |
|
---|
136 | return Status;
|
---|
137 | }
|
---|