summaryrefslogtreecommitdiff
path: root/EmbeddedPkg
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-03 09:11:55 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-03 09:11:55 +0000
commit56226bf769a9eb7712b5627b316ec3898efdd4b4 (patch)
tree46faf4331b644a33450691c1e2c7fd55c06363d4 /EmbeddedPkg
parente8e95df41d44e4c49adcc1503e1e53e2dcab5733 (diff)
downloadedk2-platforms-56226bf769a9eb7712b5627b316ec3898efdd4b4.tar.xz
EmbeddedPkg/SimpleTextInOutSerial: Update the cursor position
It is a UEFI requirement to update the cursor position infomation for each string displayed using calls to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL->OutputString(). git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11728 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmbeddedPkg')
-rw-r--r--EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c62
1 files changed, 60 insertions, 2 deletions
diff --git a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
index 583721b39e..85bb08d682 100644
--- a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
+++ b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
@@ -517,14 +517,72 @@ OutputString (
IN CHAR16 *String
)
{
- UINTN Size = StrLen(String) + 1;
- CHAR8 *OutputString = AllocatePool(Size);
+ UINTN Size;
+ CHAR8* OutputString;
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
+ UINTN MaxColumn;
+ UINTN MaxRow;
+ Size = StrLen(String) + 1;
+ OutputString = AllocatePool(Size);
+
//If there is any non-ascii characters in String buffer then replace it with '?'
//Eventually, UnicodeStrToAsciiStr API should be fixed.
SafeUnicodeStrToAsciiStr(String, OutputString);
SerialPortWrite ((UINT8 *)OutputString, Size - 1);
+ //
+ // Parse each character of the string to output
+ // to update the cursor position information
+ //
+ Mode = This->Mode;
+
+ Status = This->QueryMode (
+ This,
+ Mode->Mode,
+ &MaxColumn,
+ &MaxRow
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (; *String != CHAR_NULL; String++) {
+
+ switch (*String) {
+ case CHAR_BACKSPACE:
+ if (Mode->CursorColumn > 0) {
+ Mode->CursorColumn--;
+ }
+ break;
+
+ case CHAR_LINEFEED:
+ if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
+ Mode->CursorRow++;
+ }
+ break;
+
+ case CHAR_CARRIAGE_RETURN:
+ Mode->CursorColumn = 0;
+ break;
+
+ default:
+ if (Mode->CursorColumn >= (INT32) (MaxColumn - 1)) {
+ // Move the cursor as if we print CHAR_CARRIAGE_RETURN & CHAR_LINE_FEED
+ // CHAR_LINEFEED
+ if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
+ Mode->CursorRow++;
+ }
+ // CHAR_CARIAGE_RETURN
+ Mode->CursorColumn = 0;
+ } else {
+ Mode->CursorColumn++;
+ }
+ break;
+ }
+ }
+
FreePool(OutputString);
return EFI_SUCCESS;