iPXE
debugcon.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 /** @file
27  *
28  * Debug port console
29  *
30  * The debug port is supported by bochs (via the "port_e9_hack"
31  * configuration file directive) and by qemu (via the "-debugcon"
32  * command-line option).
33  */
34 
35 #include <stdint.h>
36 #include <ipxe/io.h>
37 #include <ipxe/console.h>
38 #include <ipxe/init.h>
39 #include <config/console.h>
40 
41 /** Debug port */
42 #define DEBUG_PORT 0xe9
43 
44 /** Debug port installation check magic value */
45 #define DEBUG_PORT_CHECK 0xe9
46 
47 /* Set default console usage if applicable */
48 #if ! ( defined ( CONSOLE_DEBUGCON ) && CONSOLE_EXPLICIT ( CONSOLE_DEBUGCON ) )
49 #undef CONSOLE_DEBUGCON
50 #define CONSOLE_DEBUGCON ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_TUI )
51 #endif
52 
53 /**
54  * Print a character to debug port console
55  *
56  * @v character Character to be printed
57  */
58 static void debugcon_putchar ( int character ) {
59 
60  /* Write character to debug port */
61  outb ( character, DEBUG_PORT );
62 }
63 
64 /** Debug port console driver */
65 struct console_driver debugcon_console __console_driver = {
67  .usage = CONSOLE_DEBUGCON,
68 };
69 
70 /**
71  * Initialise debug port console
72  *
73  */
74 static void debugcon_init ( void ) {
75  uint8_t check;
76 
77  /* Check if console is present */
78  check = inb ( DEBUG_PORT );
79  if ( check != DEBUG_PORT_CHECK ) {
80  DBG ( "Debug port not present; disabling console\n" );
81  debugcon_console.disabled = CONSOLE_DISABLED;
82  }
83 }
84 
85 /**
86  * Debug port console initialisation function
87  */
88 struct init_fn debugcon_init_fn __init_fn ( INIT_EARLY ) = {
90 };
iPXE I/O API
static void debugcon_init(void)
Initialise debug port console.
Definition: debugcon.c:74
#define DEBUG_PORT_CHECK
Debug port installation check magic value.
Definition: debugcon.c:45
void(* initialise)(void)
Definition: init.h:15
struct console_driver debugcon_console __console_driver
Debug port console driver.
Definition: debugcon.c:65
#define INIT_EARLY
Early initialisation.
Definition: init.h:28
#define CONSOLE_DISABLED
Console is disabled for all uses.
Definition: console.h:111
An initialisation function.
Definition: init.h:14
void(* putchar)(int character)
Write a character to the console.
Definition: console.h:68
#define DEBUG_PORT
Debug port.
Definition: debugcon.c:42
struct init_fn debugcon_init_fn __init_fn(INIT_EARLY)
Debug port console initialisation function.
User interaction.
static void debugcon_putchar(int character)
Print a character to debug port console.
Definition: debugcon.c:58
unsigned char uint8_t
Definition: stdint.h:10
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
Console configuration.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define outb(data, io_addr)
Definition: io.h:309
A console driver.
Definition: console.h:55
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define CONSOLE_DEBUGCON
Definition: debugcon.c:50