• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*++
2 
3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 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 
27 VOID
PrintHeader(CHAR8 Char)28 PrintHeader (
29   CHAR8 Char
30   )
31 {
32   *(UINT8 *)(UINTN)(0x000b8000 + mHeaderIndex) = Char;
33   mHeaderIndex += 2;
34 }
35 
36 VOID
ClearScreen(VOID)37 ClearScreen (
38   VOID
39   )
40 {
41   UINT32 Index;
42 
43   mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);
44   for (Index = 0; Index < 80 * 49; Index++) {
45     *mCursor = ' ';
46     mCursor += 2;
47   }
48   mCursor = (UINT8 *)(UINTN)(0x000b8000 + 160);
49 }
50 
51 VOID
PrintString(IN CONST CHAR8 * FormatString,...)52 PrintString (
53   IN CONST CHAR8  *FormatString,
54   ...
55   )
56 {
57   UINTN           Index;
58   CHAR8           PrintBuffer[256];
59   VA_LIST         Marker;
60 
61   VA_START (Marker, FormatString);
62   AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);
63   VA_END (Marker);
64 
65   for (Index = 0; PrintBuffer[Index] != 0; Index++) {
66     if (PrintBuffer[Index] == '\n') {
67       mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));
68     } else {
69       *mCursor = (UINT8) PrintBuffer[Index];
70       mCursor += 2;
71     }
72   }
73 
74   //
75   // All information also output to serial port.
76   //
77   SerialPortWrite ((UINT8 *) PrintBuffer, Index);
78 }
79 
80