VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Universal/PrintDxe/Print.c@ 77662

Last change on this file since 77662 was 77662, checked in by vboxsync, 6 years ago

EFI: First step in UDK2018 merge. Does not build yet.

  • Property svn:eol-style set to native
File size: 5.5 KB
Line 
1/** @file
2 This driver produces Print2 protocols layered on top of the PrintLib from the MdePkg.
3
4Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
5This program and the accompanying materials
6are licensed and made available under the terms and conditions of the BSD License
7which accompanies this distribution. The full text of the license may be found at
8http://opensource.org/licenses/bsd-license.php
9
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
15#include <PiDxe.h>
16
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>
22
23/**
24 Implementaion of the UnicodeValueToString service in EFI_PRINT2_PROTOCOL.
25
26 If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().
27
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
31 pad, and commas.
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.
35
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.
39
40**/
41UINTN
42EFIAPI
43PrintDxeUnicodeValueToString (
44 IN OUT CHAR16 *Buffer,
45 IN UINTN Flags,
46 IN INT64 Value,
47 IN UINTN Width
48 )
49{
50#ifdef DISABLE_NEW_DEPRECATED_INTERFACES
51 //
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.
57 //
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"));
60 ASSERT (FALSE);
61 return 0;
62#else
63 return UnicodeValueToString (Buffer, Flags, Value, Width);
64#endif
65}
66
67/**
68 Implementaion of the AsciiValueToString service in EFI_PRINT2_PROTOCOL.
69
70 If the macro DISABLE_NEW_DEPRECATED_INTERFACES is defined, then ASSERT().
71
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
75 pad, and commas.
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.
79
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.
83
84**/
85UINTN
86EFIAPI
87PrintDxeAsciiValueToString (
88 OUT CHAR8 *Buffer,
89 IN UINTN Flags,
90 IN INT64 Value,
91 IN UINTN Width
92 )
93{
94#ifdef DISABLE_NEW_DEPRECATED_INTERFACES
95 //
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.
101 //
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"));
104 ASSERT (FALSE);
105 return 0;
106#else
107 return AsciiValueToString (Buffer, Flags, Value, Width);
108#endif
109}
110
111EFI_HANDLE mPrintThunkHandle = NULL;
112
113CONST EFI_PRINT2_PROTOCOL mPrint2Protocol = {
114 UnicodeBSPrint,
115 UnicodeSPrint,
116 UnicodeBSPrintAsciiFormat,
117 UnicodeSPrintAsciiFormat,
118 PrintDxeUnicodeValueToString,
119 AsciiBSPrint,
120 AsciiSPrint,
121 AsciiBSPrintUnicodeFormat,
122 AsciiSPrintUnicodeFormat,
123 PrintDxeAsciiValueToString
124};
125
126CONST EFI_PRINT2S_PROTOCOL mPrint2SProtocol = {
127 UnicodeBSPrint,
128 UnicodeSPrint,
129 UnicodeBSPrintAsciiFormat,
130 UnicodeSPrintAsciiFormat,
131 UnicodeValueToStringS,
132 AsciiBSPrint,
133 AsciiSPrint,
134 AsciiBSPrintUnicodeFormat,
135 AsciiSPrintUnicodeFormat,
136 AsciiValueToStringS
137};
138
139/**
140 The user Entry Point for Print module.
141
142 This is the entry point for Print DXE Driver. It installs the Print2 Protocol.
143
144 @param[in] ImageHandle The firmware allocated handle for the EFI image.
145 @param[in] SystemTable A pointer to the EFI System Table.
146
147 @retval EFI_SUCCESS The entry point is executed successfully.
148 @retval Others Some error occurs when executing this entry point.
149
150**/
151EFI_STATUS
152EFIAPI
153PrintEntryPoint (
154 IN EFI_HANDLE ImageHandle,
155 IN EFI_SYSTEM_TABLE *SystemTable
156 )
157{
158 EFI_STATUS Status;
159
160 Status = gBS->InstallMultipleProtocolInterfaces (
161 &mPrintThunkHandle,
162 &gEfiPrint2ProtocolGuid, &mPrint2Protocol,
163 &gEfiPrint2SProtocolGuid, &mPrint2SProtocol,
164 NULL
165 );
166 ASSERT_EFI_ERROR (Status);
167
168 return Status;
169}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette