klu2 | 18b8485 | 2008-03-19 05:11:21 +0000 | [diff] [blame] | 1 | /** @file
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 2 |
|
niruiyu | b68b78e | 2011-06-23 08:31:18 +0000 | [diff] [blame] | 3 | Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
hhtian | b1f700a | 2010-04-28 12:39:50 +0000 | [diff] [blame] | 4 | This program and the accompanying materials
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 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 |
|
klu2 | 18b8485 | 2008-03-19 05:11:21 +0000 | [diff] [blame] | 19 | **/
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 20 |
|
| 21 | #include "DxeIpl.h"
|
niruiyu | b68b78e | 2011-06-23 08:31:18 +0000 | [diff] [blame] | 22 | #include <Library/SerialPortLib.h>
|
qhuang8 | 40b499c | 2009-03-25 14:29:29 +0000 | [diff] [blame] | 23 | #include "SerialStatusCode.h"
|
jljusten | 01b024f | 2010-10-16 18:51:32 +0000 | [diff] [blame] | 24 | #include "Debug.h"
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 25 |
|
| 26 | UINT8 *mCursor;
|
| 27 | UINT8 mHeaderIndex = 10;
|
| 28 |
|
| 29 |
|
| 30 | VOID
|
| 31 | PrintHeader (
|
| 32 | CHAR8 Char
|
| 33 | )
|
| 34 | {
|
| 35 | *(UINT8 *)(UINTN)(0x000b8000 + mHeaderIndex) = Char;
|
| 36 | mHeaderIndex += 2;
|
| 37 | }
|
| 38 |
|
| 39 | VOID
|
| 40 | ClearScreen (
|
| 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 |
|
| 54 | VOID
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 55 | PrintString (
|
niruiyu | b68b78e | 2011-06-23 08:31:18 +0000 | [diff] [blame] | 56 | IN CONST CHAR8 *FormatString,
|
| 57 | ...
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 58 | )
|
| 59 | {
|
niruiyu | b68b78e | 2011-06-23 08:31:18 +0000 | [diff] [blame] | 60 | UINTN Index;
|
| 61 | CHAR8 PrintBuffer[1000];
|
| 62 | VA_LIST Marker;
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 63 |
|
niruiyu | b68b78e | 2011-06-23 08:31:18 +0000 | [diff] [blame] | 64 | 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));
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 71 | } else {
|
niruiyu | b68b78e | 2011-06-23 08:31:18 +0000 | [diff] [blame] | 72 | *mCursor = (UINT8) PrintBuffer[Index];
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 73 | mCursor += 2;
|
| 74 | }
|
| 75 | }
|
niruiyu | b68b78e | 2011-06-23 08:31:18 +0000 | [diff] [blame] | 76 |
|
klu2 | d26b17e | 2009-03-25 09:10:47 +0000 | [diff] [blame] | 77 | //
|
| 78 | // All information also output to serial port.
|
| 79 | //
|
niruiyu | fd99d1a | 2011-06-27 06:03:06 +0000 | [diff] [blame] | 80 | SerialPortWrite ((UINT8 *) PrintBuffer, Index);
|
klu2 | ca16210 | 2007-12-21 08:48:38 +0000 | [diff] [blame] | 81 | }
|
| 82 |
|