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