]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Print.c
e093260d1b5e26b3dbe1656fce9b194edbe948fc
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / PrintLite / Print.c
1 /*++
2
3 Copyright (c) 2004 - 2007, 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 Print.c
15
16 Abstract:
17
18 Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
19 simple implemenation of SPrint() and Print() to support debug.
20
21 You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
22 time. This makes the implementation very simple.
23
24 VSPrint, Print, SPrint format specification has the follwoing form
25
26 %[flags][width]type
27
28 flags:
29 '-' - Left justify
30 '+' - Prefix a sign
31 ' ' - Prefix a blank
32 ',' - Place commas in numberss
33 '0' - Prefix for width with zeros
34 'l' - UINT64
35 'L' - UINT64
36
37 width:
38 '*' - Get width from a UINTN argumnet from the argument list
39 Decimal number that represents width of print
40
41 type:
42 'X' - argument is a UINTN hex number, prefix '0'
43 'x' - argument is a hex number
44 'd' - argument is a decimal number
45 'a' - argument is an ascii string
46 'S','s' - argument is an Unicode string
47 'g' - argument is a pointer to an EFI_GUID
48 't' - argument is a pointer to an EFI_TIME structure
49 'c' - argument is an ascii character
50 'r' - argument is EFI_STATUS
51 '%' - Print a %
52
53 --*/
54
55 #include "Tiano.h"
56 #include "EfiDriverLib.h"
57 #include "TianoCommon.h"
58 #include "EfiCommonLib.h"
59 #include "PrintWidth.h"
60 #include "EfiPrintLib.h"
61 #include "Print.h"
62
63 UINTN
64 SPrint (
65 OUT CHAR_W *Buffer,
66 IN UINTN BufferSize,
67 IN CONST CHAR_W *Format,
68 ...
69 )
70 /*++
71
72 Routine Description:
73
74 SPrint function to process format and place the results in Buffer.
75
76 Arguments:
77
78 Buffer - Wide char buffer to print the results of the parsing of Format into.
79
80 BufferSize - Maximum number of characters to put into buffer. Zero means no
81 limit.
82
83 Format - Format string see file header for more details.
84
85 ... - Vararg list consumed by processing Format.
86
87 Returns:
88
89 Number of characters printed.
90
91 --*/
92 {
93 UINTN Return;
94 VA_LIST Marker;
95
96 VA_START (Marker, Format);
97 Return = VSPrint (Buffer, BufferSize, Format, Marker);
98 VA_END (Marker);
99
100 return Return;
101 }
102
103 UINTN
104 EFIAPI
105 VSPrint (
106 OUT CHAR_W *StartOfBuffer,
107 IN UINTN BufferSize,
108 IN CONST CHAR_W *FormatString,
109 IN VA_LIST Marker
110 )
111 /*++
112
113 Routine Description:
114
115 VSPrint function to process format and place the results in Buffer. Since a
116 VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
117 this is the main print working routine
118
119 Arguments:
120
121 StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
122
123 BufferSize - Maximum number of characters to put into buffer. Zero means
124 no limit.
125
126 FormatString - Unicode format string see file header for more details.
127
128 Marker - Vararg list consumed by processing Format.
129
130 Returns:
131
132 Number of characters printed.
133
134 --*/
135 {
136 EFI_STATUS Status;
137 EFI_PRINT_PROTOCOL *PrintProtocol;
138
139 Status = gBS->LocateProtocol (
140 &gEfiPrintProtocolGuid,
141 NULL,
142 (VOID*)&PrintProtocol
143 );
144 if (EFI_ERROR (Status)) {
145 return 0;
146 } else {
147 return PrintProtocol->VSPrint (
148 StartOfBuffer,
149 BufferSize,
150 FormatString,
151 Marker
152 );
153 }
154 }