]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSupportUI.c
MdeModulePkg/EbcDxe: Add comments for functions
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcDebugger / EdbSupportUI.c
CommitLineData
e8a5ac7c 1/** @file\r
748edcd5 2\r
e8a5ac7c
DB
3Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials\r
748edcd5
PB
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
748edcd5 12\r
e8a5ac7c 13**/\r
748edcd5
PB
14\r
15#include "Edb.h"\r
16\r
d138a2e9
DB
17/**\r
18 Set the current coordinates of the cursor position.\r
19\r
20 @param ConOut Point to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.\r
21 @param Column The position to set the cursor to.\r
22 @param Row The position to set the cursor to.\r
23 @param LineLength Length of a line.\r
24 @param TotalRow Total row of a screen.\r
25 @param Str Point to the string.\r
26 @param StrPos The position of the string.\r
27 @param Len The length of the string.\r
28\r
29**/\r
748edcd5
PB
30VOID\r
31EFIAPI\r
32SetCursorPosition (\r
33 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,\r
34 IN UINTN Column,\r
35 IN INTN Row,\r
36 IN UINTN LineLength,\r
37 IN UINTN TotalRow,\r
38 IN CHAR16 *Str,\r
39 IN UINTN StrPos,\r
40 IN UINTN Len\r
41 );\r
42\r
e8a5ac7c
DB
43/**\r
44\r
45 Function waits for a given event to fire, or for an optional timeout to expire.\r
46\r
47 @param Event - The event to wait for\r
48 @param Timeout - An optional timeout value in 100 ns units.\r
49\r
50 @retval EFI_SUCCESS - Event fired before Timeout expired.\r
51 @retval EFI_TIME_OUT - Timout expired before Event fired..\r
52\r
53**/\r
748edcd5
PB
54EFI_STATUS\r
55EFIAPI\r
56WaitForSingleEvent (\r
57 IN EFI_EVENT Event,\r
58 IN UINT64 Timeout OPTIONAL\r
59 )\r
748edcd5
PB
60{\r
61 EFI_STATUS Status;\r
62 UINTN Index;\r
63 EFI_EVENT TimerEvent;\r
64 EFI_EVENT WaitList[2];\r
65\r
532daaed 66 if (Timeout != 0) {\r
748edcd5
PB
67 //\r
68 // Create a timer event\r
69 //\r
70 Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);\r
71 if (!EFI_ERROR (Status)) {\r
72 //\r
73 // Set the timer event\r
74 //\r
75 gBS->SetTimer (\r
76 TimerEvent,\r
77 TimerRelative,\r
78 Timeout\r
79 );\r
80\r
81 //\r
82 // Wait for the original event or the timer\r
83 //\r
84 WaitList[0] = Event;\r
85 WaitList[1] = TimerEvent;\r
86 Status = gBS->WaitForEvent (2, WaitList, &Index);\r
87 gBS->CloseEvent (TimerEvent);\r
88\r
89 //\r
90 // If the timer expired, change the return to timed out\r
91 //\r
92 if (!EFI_ERROR (Status) && Index == 1) {\r
93 Status = EFI_TIMEOUT;\r
94 }\r
95 }\r
96 } else {\r
97 //\r
98 // No timeout... just wait on the event\r
99 //\r
100 Status = gBS->WaitForEvent (1, &Event, &Index);\r
101 ASSERT (!EFI_ERROR (Status));\r
102 ASSERT (Index == 0);\r
103 }\r
104\r
105 return Status;\r
106}\r
107\r
e8a5ac7c
DB
108/**\r
109\r
110 Move the cursor position one character backward.\r
111\r
112 @param LineLength Length of a line. Get it by calling QueryMode\r
113 @param Column Current column of the cursor position\r
114 @param Row Current row of the cursor position\r
115\r
116**/\r
748edcd5
PB
117VOID\r
118EFIAPI\r
119ConMoveCursorBackward (\r
120 IN UINTN LineLength,\r
121 IN OUT UINTN *Column,\r
122 IN OUT UINTN *Row\r
123 )\r
748edcd5
PB
124{\r
125 ASSERT (Column != NULL);\r
126 ASSERT (Row != NULL);\r
127 //\r
128 // If current column is 0, move to the last column of the previous line,\r
129 // otherwise, just decrement column.\r
130 //\r
131 if (*Column == 0) {\r
132 (*Column) = LineLength - 1;\r
133 //\r
134 // if (*Row > 0) {\r
135 //\r
136 (*Row)--;\r
137 //\r
138 // }\r
139 //\r
140 } else {\r
141 (*Column)--;\r
142 }\r
143}\r
144\r
e8a5ac7c
DB
145/**\r
146\r
147 Move the cursor position one character backward.\r
148\r
149 @param LineLength Length of a line. Get it by calling QueryMode\r
150 @param TotalRow Total row of a screen, get by calling QueryMode\r
151 @param Column Current column of the cursor position\r
152 @param Row Current row of the cursor position\r
153\r
154**/\r
748edcd5
PB
155VOID\r
156EFIAPI\r
157ConMoveCursorForward (\r
158 IN UINTN LineLength,\r
159 IN UINTN TotalRow,\r
160 IN OUT UINTN *Column,\r
161 IN OUT UINTN *Row\r
162 )\r
748edcd5
PB
163{\r
164 ASSERT (Column != NULL);\r
165 ASSERT (Row != NULL);\r
166 //\r
167 // If current column is at line end, move to the first column of the nest\r
168 // line, otherwise, just increment column.\r
169 //\r
170 (*Column)++;\r
171 if (*Column >= LineLength) {\r
172 (*Column) = 0;\r
173 if ((*Row) < TotalRow - 1) {\r
174 (*Row)++;\r
175 }\r
176 }\r
177}\r
178\r
179CHAR16 mBackupSpace[EFI_DEBUG_INPUS_BUFFER_SIZE];\r
180CHAR16 mInputBufferHistory[EFI_DEBUG_INPUS_BUFFER_SIZE];\r
181\r
d138a2e9
DB
182/**\r
183\r
184 Get user input.\r
185\r
186 @param Prompt The prompt string.\r
187 @param InStr Point to the input string.\r
188 @param StrLength The max length of string user can input.\r
189\r
190**/\r
748edcd5
PB
191VOID\r
192EFIAPI\r
193Input (\r
194 IN CHAR16 *Prompt OPTIONAL,\r
195 OUT CHAR16 *InStr,\r
196 IN UINTN StrLength\r
197 )\r
198{\r
199 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;\r
200 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;\r
201 BOOLEAN Done;\r
202 UINTN Column;\r
203 UINTN Row;\r
204 UINTN StartColumn;\r
205 UINTN Update;\r
206 UINTN Delete;\r
207 UINTN Len;\r
208 UINTN StrPos;\r
209 UINTN Index;\r
210 UINTN LineLength;\r
211 UINTN TotalRow;\r
212 UINTN SkipLength;\r
213 UINTN OutputLength;\r
214 UINTN TailRow;\r
215 UINTN TailColumn;\r
216 EFI_INPUT_KEY Key;\r
217 BOOLEAN InsertMode;\r
218 BOOLEAN NeedAdjust;\r
219 UINTN SubIndex;\r
220 CHAR16 *CommandStr;\r
221\r
222 ConOut = gST->ConOut;\r
223 ConIn = gST->ConIn;\r
224\r
225 ASSERT (ConOut != NULL);\r
226 ASSERT (ConIn != NULL);\r
227 ASSERT (InStr != NULL);\r
228\r
532daaed 229 if (Prompt != NULL) {\r
748edcd5
PB
230 ConOut->OutputString (ConOut, Prompt);\r
231 }\r
232 //\r
233 // Read a line from the console\r
234 //\r
235 Len = 0;\r
236 StrPos = 0;\r
237 OutputLength = 0;\r
238 Update = 0;\r
239 Delete = 0;\r
240 InsertMode = TRUE;\r
241 NeedAdjust = FALSE;\r
242\r
243 //\r
244 // If buffer is not large enough to hold a CHAR16, do nothing.\r
245 //\r
246 if (StrLength < 1) {\r
247 return ;\r
248 }\r
249 //\r
250 // Get the screen setting and the current cursor location\r
251 //\r
252 StartColumn = ConOut->Mode->CursorColumn;\r
253 Column = StartColumn;\r
254 Row = ConOut->Mode->CursorRow;\r
255 ConOut->QueryMode (ConOut, ConOut->Mode->Mode, &LineLength, &TotalRow);\r
256 if (LineLength == 0) {\r
257 return ;\r
258 }\r
259\r
260 SetMem (InStr, StrLength * sizeof (CHAR16), 0);\r
261 Done = FALSE;\r
262 do {\r
263 //\r
264 // Read a key\r
265 //\r
266 WaitForSingleEvent (ConIn->WaitForKey, 0);\r
267 ConIn->ReadKeyStroke (ConIn, &Key);\r
268\r
269 switch (Key.UnicodeChar) {\r
270 case CHAR_CARRIAGE_RETURN:\r
271 //\r
272 // All done, print a newline at the end of the string\r
273 //\r
274 TailRow = Row + (Len - StrPos + Column) / LineLength;\r
275 TailColumn = (Len - StrPos + Column) % LineLength;\r
276 Done = TRUE;\r
277 break;\r
278\r
279 case CHAR_BACKSPACE:\r
532daaed 280 if (StrPos != 0) {\r
748edcd5
PB
281 //\r
282 // If not move back beyond string beginning, move all characters behind\r
283 // the current position one character forward\r
284 //\r
285 StrPos -= 1;\r
286 Update = StrPos;\r
287 Delete = 1;\r
288 CopyMem (InStr + StrPos, InStr + StrPos + 1, sizeof (CHAR16) * (Len - StrPos));\r
289\r
290 //\r
291 // Adjust the current column and row\r
292 //\r
293 ConMoveCursorBackward (LineLength, &Column, &Row);\r
294\r
295 NeedAdjust = TRUE;\r
296 }\r
297 break;\r
298\r
299 default:\r
300 if (Key.UnicodeChar >= ' ') {\r
301 //\r
302 // If we are at the buffer's end, drop the key\r
303 //\r
304 if (Len == StrLength - 1 && (InsertMode || StrPos == Len)) {\r
305 break;\r
306 }\r
307 //\r
308 // If in insert mode, move all characters behind the current position\r
309 // one character backward to make space for this character. Then store\r
310 // the character.\r
311 //\r
312 if (InsertMode) {\r
313 for (Index = Len; Index > StrPos; Index -= 1) {\r
314 InStr[Index] = InStr[Index - 1];\r
315 }\r
316 }\r
317\r
318 InStr[StrPos] = Key.UnicodeChar;\r
319 Update = StrPos;\r
320\r
321 StrPos += 1;\r
322 OutputLength = 1;\r
323 }\r
324 break;\r
325\r
326 case 0:\r
327 switch (Key.ScanCode) {\r
328 case SCAN_DELETE:\r
329 //\r
330 // Move characters behind current position one character forward\r
331 //\r
532daaed 332 if (Len != 0) {\r
748edcd5
PB
333 Update = StrPos;\r
334 Delete = 1;\r
335 CopyMem (InStr + StrPos, InStr + StrPos + 1, sizeof (CHAR16) * (Len - StrPos));\r
336\r
337 NeedAdjust = TRUE;\r
338 }\r
339 break;\r
340\r
341 case SCAN_LEFT:\r
342 //\r
343 // Adjust current cursor position\r
344 //\r
532daaed 345 if (StrPos != 0) {\r
748edcd5
PB
346 StrPos -= 1;\r
347 ConMoveCursorBackward (LineLength, &Column, &Row);\r
348 }\r
349 break;\r
350\r
351 case SCAN_RIGHT:\r
352 //\r
353 // Adjust current cursor position\r
354 //\r
355 if (StrPos < Len) {\r
356 StrPos += 1;\r
357 ConMoveCursorForward (LineLength, TotalRow, &Column, &Row);\r
358 }\r
359 break;\r
360\r
361 case SCAN_HOME:\r
362 //\r
363 // Move current cursor position to the beginning of the command line\r
364 //\r
365 Row -= (StrPos + StartColumn) / LineLength;\r
366 Column = StartColumn;\r
367 StrPos = 0;\r
368 break;\r
369\r
370 case SCAN_END:\r
371 //\r
372 // Move current cursor position to the end of the command line\r
373 //\r
374 TailRow = Row + (Len - StrPos + Column) / LineLength;\r
375 TailColumn = (Len - StrPos + Column) % LineLength;\r
376 Row = TailRow;\r
377 Column = TailColumn;\r
378 StrPos = Len;\r
379 break;\r
380\r
381 case SCAN_ESC:\r
382 //\r
383 // Prepare to clear the current command line\r
384 //\r
385 InStr[0] = 0;\r
386 Update = 0;\r
387 Delete = Len;\r
388 Row -= (StrPos + StartColumn) / LineLength;\r
389 Column = StartColumn;\r
390 OutputLength = 0;\r
391\r
392 NeedAdjust = TRUE;\r
393 break;\r
394\r
395 case SCAN_INSERT:\r
396 //\r
397 // Toggle the SEnvInsertMode flag\r
398 //\r
399 InsertMode = (BOOLEAN)!InsertMode;\r
400 break;\r
401\r
402 case SCAN_UP:\r
403 case SCAN_DOWN:\r
404 //\r
405 // show history\r
406 //\r
407 CopyMem (InStr, mInputBufferHistory, StrLength * sizeof(CHAR16));\r
408 StrPos = StrLen (mInputBufferHistory);\r
409 Update = 0;\r
410 Delete = 0;\r
411 OutputLength = 0;\r
412\r
413 TailRow = Row + (StrPos + StartColumn) / LineLength;\r
414 TailColumn = (StrPos + StartColumn) % LineLength;\r
415 Row = TailRow;\r
416 Column = TailColumn;\r
417 NeedAdjust = FALSE;\r
418\r
419 ConOut->SetCursorPosition (ConOut, StartColumn, Row);\r
420 for (SubIndex = 0; SubIndex < EFI_DEBUG_INPUS_BUFFER_SIZE - (StartColumn - EFI_DEBUG_PROMPT_COLUMN); SubIndex++) {\r
421 mBackupSpace[SubIndex] = L' ';\r
422 }\r
423 EDBPrint (mBackupSpace);\r
424 SetMem (mBackupSpace, (EFI_DEBUG_INPUS_BUFFER_SIZE - (StartColumn - EFI_DEBUG_PROMPT_COLUMN)) * sizeof(CHAR16), 0);\r
425\r
426 ConOut->SetCursorPosition (ConOut, StartColumn, Row);\r
427 Len = StrPos;\r
428\r
429 break;\r
430\r
431 case SCAN_F1:\r
432 case SCAN_F2:\r
433 case SCAN_F3:\r
434 case SCAN_F4:\r
435 case SCAN_F5:\r
436 case SCAN_F6:\r
437 case SCAN_F7:\r
438 case SCAN_F8:\r
439 case SCAN_F9:\r
440 case SCAN_F10:\r
441 case SCAN_F11:\r
442 case SCAN_F12:\r
443 CommandStr = GetCommandNameByKey (Key);\r
444 if (CommandStr != NULL) {\r
445 StrnCpyS (InStr, StrLength, CommandStr, StrLength - 1);\r
446 return ;\r
447 }\r
448 break;\r
449 }\r
450 }\r
451\r
452 if (Done) {\r
453 break;\r
454 }\r
455 //\r
456 // If we need to update the output do so now\r
457 //\r
458 if (Update != -1) {\r
459 if (NeedAdjust) {\r
460 ConOut->SetCursorPosition (ConOut, Column, Row);\r
461 for (SubIndex = 0; SubIndex < EFI_DEBUG_INPUS_BUFFER_SIZE - (Column - EFI_DEBUG_PROMPT_COLUMN); SubIndex++) {\r
462 mBackupSpace[SubIndex] = L' ';\r
463 }\r
464 EDBPrint (mBackupSpace);\r
465 SetMem (mBackupSpace, (EFI_DEBUG_INPUS_BUFFER_SIZE - (Column - EFI_DEBUG_PROMPT_COLUMN)) * sizeof(CHAR16), 0);\r
466 ConOut->SetCursorPosition (ConOut, Column, Row);\r
467 NeedAdjust = FALSE;\r
468 }\r
469 EDBPrint (InStr + Update);\r
470 Len = StrLen (InStr);\r
471\r
532daaed 472 if (Delete != 0) {\r
748edcd5
PB
473 SetMem (InStr + Len, Delete * sizeof (CHAR16), 0x00);\r
474 }\r
475\r
476 if (StrPos > Len) {\r
477 StrPos = Len;\r
478 }\r
479\r
480 Update = (UINTN) -1;\r
481\r
482 //\r
483 // After using print to reflect newly updates, if we're not using\r
484 // BACKSPACE and DELETE, we need to move the cursor position forward,\r
485 // so adjust row and column here.\r
486 //\r
487 if (Key.UnicodeChar != CHAR_BACKSPACE && !(Key.UnicodeChar == 0 && Key.ScanCode == SCAN_DELETE)) {\r
488 //\r
489 // Calulate row and column of the tail of current string\r
490 //\r
491 TailRow = Row + (Len - StrPos + Column + OutputLength) / LineLength;\r
492 TailColumn = (Len - StrPos + Column + OutputLength) % LineLength;\r
493\r
494 //\r
495 // If the tail of string reaches screen end, screen rolls up, so if\r
496 // Row does not equal TailRow, Row should be decremented\r
497 //\r
498 // (if we are recalling commands using UPPER and DOWN key, and if the\r
499 // old command is too long to fit the screen, TailColumn must be 79.\r
500 //\r
501 if (TailColumn == 0 && TailRow >= TotalRow && (UINTN) Row != TailRow) {\r
502 Row--;\r
503 }\r
504 //\r
505 // Calculate the cursor position after current operation. If cursor\r
506 // reaches line end, update both row and column, otherwise, only\r
507 // column will be changed.\r
508 //\r
509 if (Column + OutputLength >= LineLength) {\r
510 SkipLength = OutputLength - (LineLength - Column);\r
511\r
512 Row += SkipLength / LineLength + 1;\r
513 if ((UINTN) Row > TotalRow - 1) {\r
514 Row = TotalRow - 1;\r
515 }\r
516\r
517 Column = SkipLength % LineLength;\r
518 } else {\r
519 Column += OutputLength;\r
520 }\r
521 }\r
522\r
523 Delete = 0;\r
524 }\r
525 //\r
526 // Set the cursor position for this key\r
527 //\r
528 SetCursorPosition (ConOut, Column, Row, LineLength, TotalRow, InStr, StrPos, Len);\r
529 } while (!Done);\r
530\r
531 CopyMem (mInputBufferHistory, InStr, StrLength * sizeof(CHAR16));\r
532\r
533 //\r
534 // Return the data to the caller\r
535 //\r
536 return ;\r
537}\r
538\r
d138a2e9
DB
539/**\r
540 Set the current coordinates of the cursor position.\r
541\r
542 @param ConOut Point to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.\r
543 @param Column The position to set the cursor to.\r
544 @param Row The position to set the cursor to.\r
545 @param LineLength Length of a line.\r
546 @param TotalRow Total row of a screen.\r
547 @param Str Point to the string.\r
548 @param StrPos The position of the string.\r
549 @param Len The length of the string.\r
550\r
551**/\r
748edcd5
PB
552VOID\r
553EFIAPI\r
554SetCursorPosition (\r
555 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut,\r
556 IN UINTN Column,\r
557 IN INTN Row,\r
558 IN UINTN LineLength,\r
559 IN UINTN TotalRow,\r
560 IN CHAR16 *Str,\r
561 IN UINTN StrPos,\r
562 IN UINTN Len\r
563 )\r
564{\r
565 CHAR16 Backup;\r
566\r
567 ASSERT (ConOut != NULL);\r
568 ASSERT (Str != NULL);\r
569\r
570 Backup = 0;\r
571 if (Row >= 0) {\r
572 ConOut->SetCursorPosition (ConOut, Column, Row);\r
573 return ;\r
574 }\r
575\r
576 if (Len - StrPos > Column * Row) {\r
577 Backup = *(Str + StrPos + Column * Row);\r
578 *(Str + StrPos + Column * Row) = 0;\r
579 }\r
580\r
581 EDBPrint (L"%s", Str + StrPos);\r
582 if (Len - StrPos > Column * Row) {\r
583 *(Str + StrPos + Column * Row) = Backup;\r
584 }\r
585\r
586 ConOut->SetCursorPosition (ConOut, 0, 0);\r
587}\r
588\r
d138a2e9
DB
589/**\r
590\r
591 SetPageBreak.\r
592\r
593**/\r
748edcd5
PB
594BOOLEAN\r
595EFIAPI\r
596SetPageBreak (\r
597 VOID\r
598 )\r
599{\r
600 EFI_INPUT_KEY Key;\r
601 CHAR16 Str[3];\r
602 BOOLEAN OmitPrint;\r
603\r
604 //\r
605 // Check\r
606 //\r
607 if (!mDebuggerPrivate.EnablePageBreak) {\r
608 return FALSE;\r
609 }\r
610\r
611 gST->ConOut->OutputString (gST->ConOut, L"Press ENTER to continue, 'q' to exit:");\r
612\r
613 OmitPrint = FALSE;\r
614 //\r
615 // Wait for user input\r
616 //\r
617 Str[0] = ' ';\r
618 Str[1] = 0;\r
619 Str[2] = 0;\r
620 for (;;) {\r
621 WaitForSingleEvent (gST->ConIn->WaitForKey, 0);\r
622 gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
623\r
624 //\r
625 // handle control keys\r
626 //\r
627 if (Key.UnicodeChar == CHAR_NULL) {\r
628 if (Key.ScanCode == SCAN_ESC) {\r
629 gST->ConOut->OutputString (gST->ConOut, L"\r\n");\r
630 OmitPrint = TRUE;\r
631 break;\r
632 }\r
633\r
634 continue;\r
635 }\r
636\r
637 if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
638 gST->ConOut->OutputString (gST->ConOut, L"\r\n");\r
639 break;\r
640 }\r
641 //\r
642 // Echo input\r
643 //\r
644 Str[1] = Key.UnicodeChar;\r
645 if (Str[1] == CHAR_BACKSPACE) {\r
646 continue;\r
647 }\r
648\r
649 gST->ConOut->OutputString (gST->ConOut, Str);\r
650\r
651 if ((Str[1] == L'q') || (Str[1] == L'Q')) {\r
652 OmitPrint = TRUE;\r
653 } else {\r
654 OmitPrint = FALSE;\r
655 }\r
656\r
657 Str[0] = CHAR_BACKSPACE;\r
658 }\r
659\r
660 return OmitPrint;\r
661}\r
662\r
d138a2e9
DB
663/**\r
664 Print a Unicode string to the output device.\r
665\r
666 @param Format A Null-terminated Unicode format string.\r
667 @param ... The variable argument list that contains pointers to Null-\r
668 terminated Unicode strings to be printed\r
669\r
670**/\r
748edcd5
PB
671UINTN\r
672EFIAPI\r
673EDBPrint (\r
674 IN CONST CHAR16 *Format,\r
675 ...\r
676 )\r
677{\r
678 UINTN Return;\r
679 VA_LIST Marker;\r
680 CHAR16 Buffer[EFI_DEBUG_MAX_PRINT_BUFFER];\r
681\r
682 VA_START (Marker, Format);\r
683 Return = UnicodeVSPrint (Buffer, sizeof (Buffer), Format, Marker);\r
684 VA_END (Marker);\r
685\r
686 if (gST->ConOut != NULL) {\r
687 //\r
688 // To be extra safe make sure ConOut has been initialized\r
689 //\r
690 gST->ConOut->OutputString (gST->ConOut, Buffer);\r
691 }\r
692\r
693 return Return;\r
694}\r
695\r
d138a2e9
DB
696/**\r
697 Print a Unicode string to the output buffer.\r
698\r
699 @param Buffer A pointer to the output buffer for the produced Null-terminated\r
700 Unicode string.\r
701 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
702 @param Format A Null-terminated Unicode format string.\r
703 @param ... The variable argument list that contains pointers to Null-\r
704 terminated Unicode strings to be printed\r
705\r
706**/\r
748edcd5
PB
707UINTN\r
708EFIAPI\r
709EDBSPrint (\r
710 OUT CHAR16 *Buffer,\r
711 IN INTN BufferSize,\r
712 IN CONST CHAR16 *Format,\r
713 ...\r
714 )\r
715{\r
716 UINTN Return;\r
717 VA_LIST Marker;\r
718\r
719 ASSERT (BufferSize > 0);\r
720\r
721 VA_START (Marker, Format);\r
722 Return = UnicodeVSPrint (Buffer, (UINTN)BufferSize, Format, Marker);\r
723 VA_END (Marker);\r
724\r
725 return Return;\r
726}\r
727\r
d138a2e9
DB
728/**\r
729 Print a Unicode string to the output buffer with specified offset..\r
730\r
731 @param Buffer A pointer to the output buffer for the produced Null-terminated\r
732 Unicode string.\r
733 @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.\r
734 @param Offset The offset of the buffer.\r
735 @param Format A Null-terminated Unicode format string.\r
736 @param ... The variable argument list that contains pointers to Null-\r
737 terminated Unicode strings to be printed\r
738\r
739**/\r
748edcd5
PB
740UINTN\r
741EFIAPI\r
742EDBSPrintWithOffset (\r
743 OUT CHAR16 *Buffer,\r
744 IN INTN BufferSize,\r
745 IN UINTN Offset,\r
746 IN CONST CHAR16 *Format,\r
747 ...\r
748 )\r
749{\r
750 UINTN Return;\r
751 VA_LIST Marker;\r
752\r
753 ASSERT (BufferSize - (Offset * sizeof(CHAR16)) > 0);\r
754\r
755 VA_START (Marker, Format);\r
756 Return = UnicodeVSPrint (Buffer + Offset, (UINTN)(BufferSize - (Offset * sizeof(CHAR16))), Format, Marker);\r
757 VA_END (Marker);\r
758\r
759 return Return;\r
760}\r