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