Import DxeCorePerformanceLib DxePerformanceLib PeiPerformanceLib and EdkDxePrintLib
[mirror_edk2.git] / MdeModulePkg / Library / EdkDxePrintLib / PrintLib.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 PrintLib.c
15
16 Abstract:
17
18 Print Library
19
20 --*/
21
22
23
24 //
25 // The package level header files this module uses
26 //
27 #include <PiDxe.h>
28 //
29 // The protocols, PPI and GUID defintions for this module
30 //
31 #include <Protocol/Print.h>
32 //
33 // The Library classes this module consumes
34 //
35 #include <Library/PrintLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37
38 static EFI_PRINT_PROTOCOL *gPrintProtocol = NULL;
39
40 UINTN
41 UnicodeVSPrint (
42 OUT CHAR16 *StartOfBuffer,
43 IN UINTN BufferSize,
44 IN const CHAR16 *FormatString,
45 IN VA_LIST Marker
46 )
47 /*++
48
49 Routine Description:
50
51 VSPrint function to process format and place the results in Buffer. Since a
52 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
53 this is the main print working routine
54
55 Arguments:
56
57 StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
58
59 BufferSize - Maximum number of characters to put into buffer. Zero means
60 no limit.
61
62 FormatString - Unicode format string see file header for more details.
63
64 Marker - Vararg list consumed by processing Format.
65
66 Returns:
67
68 Number of characters printed.
69
70 --*/
71 {
72 EFI_STATUS Status;
73
74 if (gPrintProtocol == NULL) {
75 Status = gBS->LocateProtocol (
76 &gEfiPrintProtocolGuid,
77 NULL,
78 (VOID **)&gPrintProtocol
79 );
80 if (EFI_ERROR (Status)) {
81 gPrintProtocol = NULL;
82 }
83 if (gPrintProtocol == NULL) {
84 return 0;
85 }
86 }
87 return gPrintProtocol->VSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
88 }
89
90 UINTN
91 UnicodeSPrint (
92 OUT CHAR16 *StartOfBuffer,
93 IN UINTN BufferSize,
94 IN const CHAR16 *FormatString,
95 ...
96 )
97
98 {
99 UINTN Return;
100 VA_LIST Marker;
101
102 VA_START (Marker, FormatString);
103 Return = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
104 VA_END (Marker);
105 return Return;
106 }
107
108 UINTN
109 AsciiVSPrint (
110 OUT CHAR8 *StartOfBuffer,
111 IN UINTN BufferSize,
112 IN const CHAR8 *FormatString,
113 IN VA_LIST Marker
114 )
115 /*++
116
117 Routine Description:
118
119 VSPrint function to process format and place the results in Buffer. Since a
120 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
121 this is the main print working routine
122
123 Arguments:
124
125 StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
126
127 BufferSize - Maximum number of characters to put into buffer. Zero means
128 no limit.
129
130 FormatString - Unicode format string see file header for more details.
131
132 Marker - Vararg list consumed by processing Format.
133
134 Returns:
135
136 Number of characters printed.
137
138 --*/
139 {
140 return 0;
141 }
142
143 UINTN
144 AsciiSPrint (
145 OUT CHAR8 *StartOfBuffer,
146 IN UINTN BufferSize,
147 IN const CHAR8 *FormatString,
148 ...
149 )
150
151 {
152 UINTN Return;
153 VA_LIST Marker;
154
155 VA_START (Marker, FormatString);
156 Return = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
157 VA_END (Marker);
158 return Return;
159 }