blob: 1cb7e39c80361e4b922e0ab200987d64d1aeb485 [file] [log] [blame]
klu218b84852008-03-19 05:11:21 +00001/** @file
klu2ca162102007-12-21 08:48:38 +00002
niruiyub68b78e2011-06-23 08:31:18 +00003Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
hhtianb1f700a2010-04-28 12:39:50 +00004This program and the accompanying materials
klu2ca162102007-12-21 08:48:38 +00005are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13 Debug.c
14
15Abstract:
16
17Revision History:
18
klu218b84852008-03-19 05:11:21 +000019**/
klu2ca162102007-12-21 08:48:38 +000020
21#include "DxeIpl.h"
niruiyub68b78e2011-06-23 08:31:18 +000022#include <Library/SerialPortLib.h>
qhuang840b499c2009-03-25 14:29:29 +000023#include "SerialStatusCode.h"
jljusten01b024f2010-10-16 18:51:32 +000024#include "Debug.h"
klu2ca162102007-12-21 08:48:38 +000025
26UINT8 *mCursor;
27UINT8 mHeaderIndex = 10;
28
29
30VOID
31PrintHeader (
32 CHAR8 Char
33 )
34{
35 *(UINT8 *)(UINTN)(0x000b8000 + mHeaderIndex) = Char;
36 mHeaderIndex += 2;
37}
38
39VOID
40ClearScreen (
41 VOID
42 )
43{
44 UINT32 Index;
45
46 mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);
47 for (Index = 0; Index < 80 * 49; Index++) {
48 *mCursor = ' ';
49 mCursor += 2;
50 }
51 mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);
52}
53
54VOID
klu2ca162102007-12-21 08:48:38 +000055PrintString (
niruiyub68b78e2011-06-23 08:31:18 +000056 IN CONST CHAR8 *FormatString,
57 ...
klu2ca162102007-12-21 08:48:38 +000058 )
59{
niruiyub68b78e2011-06-23 08:31:18 +000060 UINTN Index;
61 CHAR8 PrintBuffer[1000];
62 VA_LIST Marker;
klu2ca162102007-12-21 08:48:38 +000063
niruiyub68b78e2011-06-23 08:31:18 +000064 VA_START (Marker, FormatString);
65 AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);
66 VA_END (Marker);
67
68 for (Index = 0; PrintBuffer[Index] != 0; Index++) {
69 if (PrintBuffer[Index] == '\n') {
70 mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));
klu2ca162102007-12-21 08:48:38 +000071 } else {
niruiyub68b78e2011-06-23 08:31:18 +000072 *mCursor = (UINT8) PrintBuffer[Index];
klu2ca162102007-12-21 08:48:38 +000073 mCursor += 2;
74 }
75 }
niruiyub68b78e2011-06-23 08:31:18 +000076
klu2d26b17e2009-03-25 09:10:47 +000077 //
78 // All information also output to serial port.
79 //
niruiyufd99d1a2011-06-27 06:03:06 +000080 SerialPortWrite ((UINT8 *) PrintBuffer, Index);
klu2ca162102007-12-21 08:48:38 +000081}
82