]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Library/EdkDxePrintLib/PrintLib.c
Initial import.
[mirror_edk2.git] / EdkModulePkg / 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 static EFI_PRINT_PROTOCOL *gPrintProtocol = NULL;
25
26 UINTN
27 UnicodeVSPrint (
28 OUT CHAR16 *StartOfBuffer,
29 IN UINTN BufferSize,
30 IN const CHAR16 *FormatString,
31 IN VA_LIST Marker
32 )
33 /*++
34
35 Routine Description:
36
37 VSPrint function to process format and place the results in Buffer. Since a
38 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
39 this is the main print working routine
40
41 Arguments:
42
43 StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
44
45 BufferSize - Maximum number of characters to put into buffer. Zero means
46 no limit.
47
48 FormatString - Unicode format string see file header for more details.
49
50 Marker - Vararg list consumed by processing Format.
51
52 Returns:
53
54 Number of characters printed.
55
56 --*/
57 {
58 EFI_STATUS Status;
59
60 if (gPrintProtocol == NULL) {
61 Status = gBS->LocateProtocol (
62 &gEfiPrintProtocolGuid,
63 NULL,
64 (VOID **)&gPrintProtocol
65 );
66 if (EFI_ERROR (Status)) {
67 gPrintProtocol = NULL;
68 }
69 if (gPrintProtocol == NULL) {
70 return 0;
71 }
72 }
73 return gPrintProtocol->VSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
74 }
75
76 UINTN
77 UnicodeSPrint (
78 OUT CHAR16 *StartOfBuffer,
79 IN UINTN BufferSize,
80 IN const CHAR16 *FormatString,
81 ...
82 )
83
84 {
85 UINTN Return;
86 VA_LIST Marker;
87
88 VA_START (Marker, FormatString);
89 Return = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
90 VA_END (Marker);
91 return Return;
92 }
93
94 UINTN
95 AsciiVSPrint (
96 OUT CHAR8 *StartOfBuffer,
97 IN UINTN BufferSize,
98 IN const CHAR8 *FormatString,
99 IN VA_LIST Marker
100 )
101 /*++
102
103 Routine Description:
104
105 VSPrint function to process format and place the results in Buffer. Since a
106 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
107 this is the main print working routine
108
109 Arguments:
110
111 StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
112
113 BufferSize - Maximum number of characters to put into buffer. Zero means
114 no limit.
115
116 FormatString - Unicode format string see file header for more details.
117
118 Marker - Vararg list consumed by processing Format.
119
120 Returns:
121
122 Number of characters printed.
123
124 --*/
125 {
126 return 0;
127 }
128
129 UINTN
130 AsciiSPrint (
131 OUT CHAR8 *StartOfBuffer,
132 IN UINTN BufferSize,
133 IN const CHAR8 *FormatString,
134 ...
135 )
136
137 {
138 UINTN Return;
139 VA_LIST Marker;
140
141 VA_START (Marker, FormatString);
142 Return = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
143 VA_END (Marker);
144 return Return;
145 }