]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/EfiLdr/Debug.c
13d9c74c465752babd32a3d88037703f2c52e682
[mirror_edk2.git] / DuetPkg / EfiLdr / Debug.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13 Debug.c
14
15 Abstract:
16
17 Revision History:
18
19 --*/
20 #include "EfiLdr.h"
21 #include "Debug.h"
22
23 UINT8 *mCursor;
24 UINT8 mHeaderIndex = 10;
25
26 VOID
27 PrintHeader (
28 CHAR8 Char
29 )
30 {
31 *(UINT8 *)(UINTN)(0x000b8000 + mHeaderIndex) = Char;
32 mHeaderIndex += 2;
33 }
34
35 VOID
36 ClearScreen (
37 VOID
38 )
39 {
40 UINT32 Index;
41
42 mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);
43 for (Index = 0; Index < 80 * 49; Index++) {
44 *mCursor = ' ';
45 mCursor += 2;
46 }
47 mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);
48 }
49
50 VOID
51 PrintValue64 (
52 UINT64 Value
53 )
54 {
55 PrintValue ((UINT32) RShiftU64 (Value, 32));
56 PrintValue ((UINT32) Value);
57 }
58
59 VOID
60 PrintValue (
61 UINT32 Value
62 )
63 {
64 UINT32 Index;
65 UINT8 Char;
66
67 for (Index = 0; Index < 8; Index++) {
68 Char = (UINT8)(((Value >> ((7 - Index) * 4)) & 0x0f) + '0');
69 if (Char > '9') {
70 Char = (UINT8) (Char - '0' - 10 + 'A');
71 }
72 *mCursor = Char;
73 mCursor += 2;
74 }
75 }
76
77 VOID
78 PrintString (
79 CHAR8 *String
80 )
81 {
82 UINT32 Index;
83
84 for (Index = 0; String[Index] != 0; Index++) {
85 if (String[Index] == '\n') {
86 mCursor = (UINT8 *)(UINTN)(0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));
87 } else {
88 *mCursor = String[Index];
89 mCursor += 2;
90 }
91 }
92 }
93