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