Browse Source

[console] Add support for the bochs/qemu debug port console

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
117fc61738
3 changed files with 90 additions and 0 deletions
  1. 86
    0
      src/arch/x86/core/debugcon.c
  2. 3
    0
      src/config/config.c
  3. 1
    0
      src/config/console.h

+ 86
- 0
src/arch/x86/core/debugcon.c View File

@@ -0,0 +1,86 @@
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
+
20
+FILE_LICENCE ( GPL2_OR_LATER );
21
+
22
+/** @file
23
+ *
24
+ * Debug port console
25
+ *
26
+ * The debug port is supported by bochs (via the "port_e9_hack"
27
+ * configuration file directive) and by qemu (via the "-debugcon"
28
+ * command-line option).
29
+ */
30
+
31
+#include <stdint.h>
32
+#include <ipxe/io.h>
33
+#include <ipxe/console.h>
34
+#include <ipxe/init.h>
35
+#include <config/console.h>
36
+
37
+/** Debug port */
38
+#define DEBUG_PORT 0xe9
39
+
40
+/** Debug port installation check magic value */
41
+#define DEBUG_PORT_CHECK 0xe9
42
+
43
+/* Set default console usage if applicable */
44
+#if ! ( defined ( CONSOLE_DEBUGCON ) && CONSOLE_EXPLICIT ( CONSOLE_DEBUGCON ) )
45
+#undef CONSOLE_DEBUGCON
46
+#define CONSOLE_DEBUGCON ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_TUI )
47
+#endif
48
+
49
+/**
50
+ * Print a character to debug port console
51
+ *
52
+ * @v character		Character to be printed
53
+ */
54
+static void debugcon_putchar ( int character ) {
55
+
56
+	/* Write character to debug port */
57
+	outb ( character, DEBUG_PORT );
58
+}
59
+
60
+/** Debug port console driver */
61
+struct console_driver debugcon_console __console_driver = {
62
+	.putchar = debugcon_putchar,
63
+	.usage = CONSOLE_DEBUGCON,
64
+};
65
+
66
+/**
67
+ * Initialise debug port console
68
+ *
69
+ */
70
+static void debugcon_init ( void ) {
71
+	uint8_t check;
72
+
73
+	/* Check if console is present */
74
+	check = inb ( DEBUG_PORT );
75
+	if ( check != DEBUG_PORT_CHECK ) {
76
+		DBG ( "Debug port not present; disabling console\n" );
77
+		debugcon_console.disabled = 1;
78
+	}
79
+}
80
+
81
+/**
82
+ * Debug port console initialisation function
83
+ */
84
+struct init_fn debugcon_init_fn __init_fn ( INIT_EARLY ) = {
85
+	.initialise = debugcon_init,
86
+};

+ 3
- 0
src/config/config.c View File

@@ -89,6 +89,9 @@ REQUIRE_OBJECT ( linux_console );
89 89
 #ifdef CONSOLE_VMWARE
90 90
 REQUIRE_OBJECT ( vmconsole );
91 91
 #endif
92
+#ifdef CONSOLE_DEBUGCON
93
+REQUIRE_OBJECT ( debugcon );
94
+#endif
92 95
 
93 96
 /*
94 97
  * Drag in all requested network protocols

+ 1
- 0
src/config/console.h View File

@@ -21,6 +21,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
21 21
 //#define	CONSOLE_SYSLOG		/* Syslog console */
22 22
 //#define	CONSOLE_SYSLOGS		/* Encrypted syslog console */
23 23
 //#define	CONSOLE_VMWARE		/* VMware logfile console */
24
+//#define	CONSOLE_DEBUGCON	/* Debug port console */
24 25
 
25 26
 #define	KEYBOARD_MAP	us
26 27
 

Loading…
Cancel
Save