]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the bug that debug output fails to print hex value to screen. Remove module inter...
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Apr 2009 06:52:02 +0000 (06:52 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Apr 2009 06:52:02 +0000 (06:52 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8057 6f19259b-4bc3-4df7-8a09-765794883524

DuetPkg/CpuDxe/Cpu.c

index 6d5e9dc3496d33e92960ef2537624fb1dcd8f5f8..42ffcd6c85e006835891ce36c6927414a0b41449 100644 (file)
@@ -543,88 +543,6 @@ DumpExceptionDataDebugOut (
 }\r
 #endif\r
 \r
-UINTN\r
-SPrint (\r
-  IN OUT    CHAR16  *Buffer,\r
-  IN CONST  CHAR16  *Format,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST   Marker;\r
-  UINTN     Index;\r
-  UINTN     Flags;\r
-  UINTN     Width;\r
-  UINT64    Value;\r
-\r
-  VA_START (Marker, Format);\r
-\r
-  //\r
-  // Process the format string. Stop if Buffer is over run.\r
-  //\r
-\r
-  for (Index = 0; *Format != 0; Format++) {\r
-    if (*Format != L'%') {\r
-      Buffer[Index++] = *Format;\r
-    } else {\r
-      \r
-      //\r
-      // Now it's time to parse what follows after %\r
-      // Support: % [ 0 width ] [ l ] x\r
-      // width - fill 0, to ensure the width of x will be "width"\r
-      // l        - UINT64 instead of UINT32\r
-      //\r
-      Width = 0;\r
-      Flags = 0;\r
-      Format ++;\r
-\r
-      if (*Format == L'0') {\r
-        Flags |= PREFIX_ZERO;\r
-        do {\r
-          Width += Width * 10 + (*Format - L'0');\r
-          Format ++;\r
-        } while (*Format >= L'1' && *Format <= L'9');\r
-      }\r
-\r
-      if (*Format == L'l') {\r
-        Flags |= LONG_TYPE;\r
-        Format ++;\r
-      }\r
-\r
-      \r
-      switch (*Format) {\r
-      case 'X':\r
-        Flags |= PREFIX_ZERO;\r
-        Width = sizeof (UINT64) * 2;\r
-        //\r
-        // break skiped on purpose\r
-        //\r
-      case 'x':\r
-        if ((Flags & LONG_TYPE) == LONG_TYPE) {\r
-          Value = VA_ARG (Marker, UINT64);\r
-        } else {\r
-          Value = VA_ARG (Marker, UINTN);\r
-        }\r
-\r
-        UnicodeValueToString (Buffer+Index, Flags, Value, Width);\r
-        \r
-        for ( ; Buffer[Index] != L'\0'; Index ++) {\r
-        }\r
-\r
-        break;\r
-\r
-      default:\r
-        //\r
-        // if the type is unknown print it to the screen\r
-        //\r
-        Buffer[Index++] = *Format;\r
-      }\r
-    } \r
-  }\r
-  Buffer[Index++] = '\0'; \r
-   \r
-  VA_END (Marker);\r
-  return Index;\r
-}\r
 \r
 VOID\r
 DumpExceptionDataVgaOut (\r
@@ -646,31 +564,35 @@ DumpExceptionDataVgaOut (
   VideoBuffer     = (CHAR16 *) (UINTN) 0xb8000;\r
 \r
 #ifdef EFI32\r
-  SPrint (\r
-    VideoBuffer, \r
-    L"!!!! IA32 Exception Type - %08x !!!!",\r
+  UnicodeSPrintAsciiFormat (\r
+    VideoBuffer,\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "!!!! IA32 Exception Type - %08x !!!!",\r
     InterruptType\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
-  SPrint (\r
-    VideoBuffer, \r
-    L"EIP - %08x, CS - %08x, EFLAGS - %08x",\r
+  UnicodeSPrintAsciiFormat (\r
+    VideoBuffer,\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "EIP - %08x, CS - %08x, EFLAGS - %08x",\r
     SystemContext.SystemContextIa32->Eip,\r
     SystemContext.SystemContextIa32->Cs,\r
     SystemContext.SystemContextIa32->Eflags\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
   if (ErrorCodeFlag & (1 << InterruptType)) {\r
-    SPrint (\r
+    UnicodeSPrintAsciiFormat (\r
       VideoBuffer,\r
-      L"ExceptionData - %08x",\r
+      COLUMN_MAX * sizeof (CHAR16),\r
+      "ExceptionData - %08x",\r
       SystemContext.SystemContextIa32->ExceptionData\r
     );\r
     VideoBuffer += COLUMN_MAX;\r
   }\r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"EAX - %08x, ECX - %08x, EDX - %08x, EBX - %08x",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "EAX - %08x, ECX - %08x, EDX - %08x, EBX - %08x",\r
     SystemContext.SystemContextIa32->Eax,\r
     SystemContext.SystemContextIa32->Ecx,\r
     SystemContext.SystemContextIa32->Edx,\r
@@ -678,9 +600,10 @@ DumpExceptionDataVgaOut (
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"ESP - %08x, EBP - %08x, ESI - %08x, EDI - %08x",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "ESP - %08x, EBP - %08x, ESI - %08x, EDI - %08x",\r
     SystemContext.SystemContextIa32->Esp,\r
     SystemContext.SystemContextIa32->Ebp,\r
     SystemContext.SystemContextIa32->Esi,\r
@@ -688,9 +611,10 @@ DumpExceptionDataVgaOut (
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"DS - %08x, ES - %08x, FS - %08x, GS - %08x, SS - %08x",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "DS - %08x, ES - %08x, FS - %08x, GS - %08x, SS - %08x",\r
     SystemContext.SystemContextIa32->Ds,\r
     SystemContext.SystemContextIa32->Es,\r
     SystemContext.SystemContextIa32->Fs,\r
@@ -699,9 +623,10 @@ DumpExceptionDataVgaOut (
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"GDTR - %08x %08x, IDTR - %08x %08x",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "GDTR - %08x %08x, IDTR - %08x %08x",\r
     SystemContext.SystemContextIa32->Gdtr[0],\r
     SystemContext.SystemContextIa32->Gdtr[1],\r
     SystemContext.SystemContextIa32->Idtr[0],\r
@@ -709,17 +634,19 @@ DumpExceptionDataVgaOut (
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"LDTR - %08x, TR - %08x",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "LDTR - %08x, TR - %08x",\r
     SystemContext.SystemContextIa32->Ldtr,\r
     SystemContext.SystemContextIa32->Tr\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"CR0 - %08x, CR2 - %08x, CR3 - %08x, CR4 - %08x",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "CR0 - %08x, CR2 - %08x, CR3 - %08x, CR4 - %08x",\r
     SystemContext.SystemContextIa32->Cr0,\r
     SystemContext.SystemContextIa32->Cr2,\r
     SystemContext.SystemContextIa32->Cr3,\r
@@ -727,9 +654,10 @@ DumpExceptionDataVgaOut (
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"DR0 - %08x, DR1 - %08x, DR2 - %08x, DR3 - %08x",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "DR0 - %08x, DR1 - %08x, DR2 - %08x, DR3 - %08x",\r
     SystemContext.SystemContextIa32->Dr0,\r
     SystemContext.SystemContextIa32->Dr1,\r
     SystemContext.SystemContextIa32->Dr2,\r
@@ -737,24 +665,27 @@ DumpExceptionDataVgaOut (
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"DR6 - %08x, DR7 - %08x",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "DR6 - %08x, DR7 - %08x",\r
     SystemContext.SystemContextIa32->Dr6,\r
     SystemContext.SystemContextIa32->Dr7\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 #else\r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"!!!! X64 Exception Type - %016lx !!!!",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "!!!! X64 Exception Type - %016lx !!!!",\r
     (UINT64)InterruptType\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"RIP - %016lx, CS - %016lx, RFLAGS - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "RIP - %016lx, CS - %016lx, RFLAGS - %016lx",\r
     SystemContext.SystemContextX64->Rip,\r
     SystemContext.SystemContextX64->Cs,\r
     SystemContext.SystemContextX64->Rflags\r
@@ -762,130 +693,145 @@ DumpExceptionDataVgaOut (
   VideoBuffer += COLUMN_MAX;\r
 \r
   if (ErrorCodeFlag & (1 << InterruptType)) {\r
-    SPrint (\r
+    UnicodeSPrintAsciiFormat (\r
       VideoBuffer,\r
-      L"ExceptionData - %016lx",\r
+      COLUMN_MAX * sizeof (CHAR16),\r
+      "ExceptionData - %016lx",\r
       SystemContext.SystemContextX64->ExceptionData\r
       );\r
     VideoBuffer += COLUMN_MAX;\r
   }\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"RAX - %016lx, RCX - %016lx, RDX - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "RAX - %016lx, RCX - %016lx, RDX - %016lx",\r
     SystemContext.SystemContextX64->Rax,\r
     SystemContext.SystemContextX64->Rcx,\r
     SystemContext.SystemContextX64->Rdx\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"RBX - %016lx, RSP - %016lx, RBP - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "RBX - %016lx, RSP - %016lx, RBP - %016lx",\r
     SystemContext.SystemContextX64->Rbx,\r
     SystemContext.SystemContextX64->Rsp,\r
     SystemContext.SystemContextX64->Rbp\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"RSI - %016lx, RDI - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "RSI - %016lx, RDI - %016lx",\r
     SystemContext.SystemContextX64->Rsi,\r
     SystemContext.SystemContextX64->Rdi\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"R8 - %016lx, R9 - %016lx, R10 - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "R8 - %016lx, R9 - %016lx, R10 - %016lx",\r
     SystemContext.SystemContextX64->R8,\r
     SystemContext.SystemContextX64->R9,\r
     SystemContext.SystemContextX64->R10\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"R11 - %016lx, R12 - %016lx, R13 - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "R11 - %016lx, R12 - %016lx, R13 - %016lx",\r
     SystemContext.SystemContextX64->R11,\r
     SystemContext.SystemContextX64->R12,\r
     SystemContext.SystemContextX64->R13\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"R14 - %016lx, R15 - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "R14 - %016lx, R15 - %016lx",\r
     SystemContext.SystemContextX64->R14,\r
     SystemContext.SystemContextX64->R15\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"DS - %016lx, ES - %016lx, FS - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "DS - %016lx, ES - %016lx, FS - %016lx",\r
     SystemContext.SystemContextX64->Ds,\r
     SystemContext.SystemContextX64->Es,\r
     SystemContext.SystemContextX64->Fs\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"GS - %016lx, SS - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "GS - %016lx, SS - %016lx",\r
     SystemContext.SystemContextX64->Gs,\r
     SystemContext.SystemContextX64->Ss\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"GDTR - %016lx %016lx, LDTR - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "GDTR - %016lx %016lx, LDTR - %016lx",\r
     SystemContext.SystemContextX64->Gdtr[0],\r
     SystemContext.SystemContextX64->Gdtr[1],\r
     SystemContext.SystemContextX64->Ldtr\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"IDTR - %016lx %016lx, TR - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "IDTR - %016lx %016lx, TR - %016lx",\r
     SystemContext.SystemContextX64->Idtr[0],\r
     SystemContext.SystemContextX64->Idtr[1],\r
     SystemContext.SystemContextX64->Tr\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"CR0 - %016lx, CR2 - %016lx, CR3 - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "CR0 - %016lx, CR2 - %016lx, CR3 - %016lx",\r
     SystemContext.SystemContextX64->Cr0,\r
     SystemContext.SystemContextX64->Cr2,\r
     SystemContext.SystemContextX64->Cr3\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"CR4 - %016lx, CR8 - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "CR4 - %016lx, CR8 - %016lx",\r
     SystemContext.SystemContextX64->Cr4,\r
     SystemContext.SystemContextX64->Cr8\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"DR0 - %016lx, DR1 - %016lx, DR2 - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "DR0 - %016lx, DR1 - %016lx, DR2 - %016lx",\r
     SystemContext.SystemContextX64->Dr0,\r
     SystemContext.SystemContextX64->Dr1,\r
     SystemContext.SystemContextX64->Dr2\r
     );\r
   VideoBuffer += COLUMN_MAX;\r
 \r
-  SPrint (\r
+  UnicodeSPrintAsciiFormat (\r
     VideoBuffer,\r
-    L"DR3 - %016lx, DR6 - %016lx, DR7 - %016lx",\r
+    COLUMN_MAX * sizeof (CHAR16),\r
+    "DR3 - %016lx, DR6 - %016lx, DR7 - %016lx",\r
     SystemContext.SystemContextX64->Dr3,\r
     SystemContext.SystemContextX64->Dr6,\r
     SystemContext.SystemContextX64->Dr7\r