]>
Commit | Line | Data |
---|---|---|
9071550e | 1 | /*++\r |
2 | \r | |
b4f9bc4d | 3 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r |
b1f700a8 | 4 | This program and the accompanying materials \r |
9071550e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | Debug.c\r | |
14 | \r | |
15 | Abstract:\r | |
16 | \r | |
17 | Revision History:\r | |
18 | \r | |
19 | --*/\r | |
20 | #include "EfiLdr.h"\r | |
21 | #include "Debug.h"\r | |
6fc74eaa | 22 | #include <Library/SerialPortLib.h>\r |
9071550e | 23 | \r |
24 | UINT8 *mCursor;\r | |
25 | UINT8 mHeaderIndex = 10;\r | |
26 | \r | |
27 | VOID\r | |
28 | PrintHeader (\r | |
29 | CHAR8 Char\r | |
30 | )\r | |
31 | {\r | |
32 | *(UINT8 *)(UINTN)(0x000b8000 + mHeaderIndex) = Char;\r | |
33 | mHeaderIndex += 2;\r | |
34 | }\r | |
35 | \r | |
36 | VOID\r | |
37 | ClearScreen (\r | |
38 | VOID\r | |
39 | )\r | |
40 | {\r | |
41 | UINT32 Index;\r | |
42 | \r | |
43 | mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);\r | |
44 | for (Index = 0; Index < 80 * 49; Index++) {\r | |
45 | *mCursor = ' ';\r | |
46 | mCursor += 2;\r | |
47 | }\r | |
48 | mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);\r | |
49 | }\r | |
50 | \r | |
6fc74eaa | 51 | \r |
52 | VOID \r | |
53 | PrintU32Base10 (\r | |
54 | UINT32 Value\r | |
9071550e | 55 | )\r |
56 | {\r | |
6fc74eaa | 57 | UINT32 Index;\r |
58 | CHAR8 Char;\r | |
59 | CHAR8 String[11];\r | |
60 | UINTN StringPos;\r | |
61 | UINT32 B10Div;\r | |
62 | \r | |
63 | B10Div = 1000000000;\r | |
64 | for (Index = 0, StringPos = 0; Index < 10; Index++) {\r | |
b4f9bc4d | 65 | Char = (UINT8) (((Value / B10Div) % 10) + '0');\r |
6fc74eaa | 66 | if ((StringPos > 0) || (Char != '0')) {\r |
67 | String[StringPos] = Char;\r | |
68 | StringPos++;\r | |
69 | }\r | |
70 | B10Div = B10Div / 10;\r | |
71 | }\r | |
72 | \r | |
73 | if (StringPos == 0) {\r | |
74 | String[0] = '0';\r | |
75 | StringPos++;\r | |
76 | }\r | |
77 | \r | |
78 | String[StringPos] = '\0';\r | |
79 | \r | |
80 | PrintString (String);\r | |
9071550e | 81 | }\r |
82 | \r | |
6fc74eaa | 83 | \r |
9071550e | 84 | VOID\r |
85 | PrintValue (\r | |
86 | UINT32 Value\r | |
87 | )\r | |
88 | {\r | |
89 | UINT32 Index;\r | |
6fc74eaa | 90 | CHAR8 Char;\r |
91 | CHAR8 String[9];\r | |
9071550e | 92 | \r |
93 | for (Index = 0; Index < 8; Index++) {\r | |
e188a609 | 94 | Char = (UINT8)(((Value >> ((7 - Index) * 4)) & 0x0f) + '0');\r |
9071550e | 95 | if (Char > '9') {\r |
e188a609 | 96 | Char = (UINT8) (Char - '0' - 10 + 'A');\r |
9071550e | 97 | }\r |
6fc74eaa | 98 | String[Index] = Char;\r |
9071550e | 99 | }\r |
6fc74eaa | 100 | \r |
101 | String[sizeof (String) - 1] = '\0';\r | |
102 | \r | |
103 | PrintString (String);\r | |
104 | }\r | |
105 | \r | |
106 | VOID\r | |
107 | PrintValue64 (\r | |
108 | UINT64 Value\r | |
109 | )\r | |
110 | {\r | |
111 | PrintValue ((UINT32) RShiftU64 (Value, 32));\r | |
112 | PrintValue ((UINT32) Value);\r | |
9071550e | 113 | }\r |
114 | \r | |
115 | VOID\r | |
116 | PrintString (\r | |
e188a609 | 117 | CHAR8 *String\r |
9071550e | 118 | )\r |
119 | {\r | |
120 | UINT32 Index;\r | |
121 | \r | |
122 | for (Index = 0; String[Index] != 0; Index++) {\r | |
123 | if (String[Index] == '\n') {\r | |
124 | mCursor = (UINT8 *)(UINTN)(0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));\r | |
125 | } else {\r | |
126 | *mCursor = String[Index];\r | |
127 | mCursor += 2;\r | |
128 | }\r | |
129 | }\r | |
6fc74eaa | 130 | \r |
131 | //\r | |
132 | // All information also output to serial port.\r | |
133 | //\r | |
134 | SerialPortWrite ((UINT8*) String, Index);\r | |
9071550e | 135 | }\r |
136 | \r |