summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Hajnoczi2008-06-04 22:00:46 +0200
committerMichael Brown2008-06-05 01:45:43 +0200
commit831db76ff7275ae33cfb95ba9b7cfed337464ebd (patch)
treeecdceb0019fecf807c44e2015b46c090bf09fbaf
parent[util] config-local.h to avoid accidental commits (diff)
downloadipxe-831db76ff7275ae33cfb95ba9b7cfed337464ebd.tar.gz
ipxe-831db76ff7275ae33cfb95ba9b7cfed337464ebd.tar.xz
ipxe-831db76ff7275ae33cfb95ba9b7cfed337464ebd.zip
[Serial] Split serial console from serial driver
-rw-r--r--src/core/config.c2
-rw-r--r--src/core/serial.c42
-rw-r--r--src/core/serial_console.c31
-rw-r--r--src/include/gpxe/init.h5
-rw-r--r--src/include/gpxe/serial.h14
5 files changed, 62 insertions, 32 deletions
diff --git a/src/core/config.c b/src/core/config.c
index 402cba90..efb82809 100644
--- a/src/core/config.c
+++ b/src/core/config.c
@@ -54,7 +54,7 @@
REQUIRE_OBJECT ( bios_console );
#endif
#ifdef CONSOLE_SERIAL
-REQUIRE_OBJECT ( serial );
+REQUIRE_OBJECT ( serial_console );
#endif
#ifdef CONSOLE_DIRECT_VGA
REQUIRE_OBJECT ( video_subr );
diff --git a/src/core/serial.c b/src/core/serial.c
index a5b3f913..54c22954 100644
--- a/src/core/serial.c
+++ b/src/core/serial.c
@@ -12,10 +12,10 @@
*/
#include "stddef.h"
-#include "console.h"
#include <gpxe/init.h>
#include "io.h"
#include <unistd.h>
+#include <gpxe/serial.h>
#include "config/serial.h"
/* Set default values if none specified */
@@ -91,13 +91,11 @@
#define uart_writeb(val,addr) outb((val),(addr))
#endif
-struct console_driver serial_console __console_driver;
-
/*
* void serial_putc(int ch);
* Write character `ch' to port UART_BASE.
*/
-static void serial_putc ( int ch ) {
+void serial_putc ( int ch ) {
int i;
int status;
i = 1000; /* timeout */
@@ -116,7 +114,7 @@ static void serial_putc ( int ch ) {
* int serial_getc(void);
* Read a character from port UART_BASE.
*/
-static int serial_getc ( void ) {
+int serial_getc ( void ) {
int status;
int ch;
do {
@@ -135,7 +133,7 @@ static int serial_getc ( void ) {
* If there is a character in the input buffer of port UART_BASE,
* return nonzero; otherwise return 0.
*/
-static int serial_ischar ( void ) {
+int serial_ischar ( void ) {
int status;
status = uart_readb(UART_BASE + UART_LSR); /* line status reg; */
return status & 1; /* rx char available */
@@ -217,7 +215,6 @@ static void serial_init ( void ) {
/* line status reg */
status = uart_readb(UART_BASE + UART_LSR);
} while(status & UART_LSR_DR);
- serial_console.disabled = 0;
out:
return;
}
@@ -229,10 +226,6 @@ static void serial_init ( void ) {
*/
static void serial_fini ( void ) {
int i, status;
- if (serial_console.disabled) {
- /* no serial interface */
- return;
- }
/* Flush the output buffer to avoid dropping characters,
* if we are reinitializing the serial port.
*/
@@ -243,26 +236,17 @@ static void serial_fini ( void ) {
/* Don't mark it as disabled; it's still usable */
}
-struct console_driver serial_console __console_driver = {
- .putchar = serial_putc,
- .getchar = serial_getc,
- .iskey = serial_ischar,
- .disabled = 1,
-};
-
-/** Serial console startup function */
-struct startup_fn serial_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
- .startup = serial_init,
- .shutdown = serial_fini,
-};
-
/**
- * Serial console initialisation function
+ * Serial driver initialisation function
*
- * Initialise console early on so that it is available to capture
- * early debug messages. It is safe to call serial_init() multiple
- * times.
+ * Initialise serial port early on so that it is available to capture
+ * early debug messages.
*/
-struct init_fn serial_init_fn __init_fn ( INIT_CONSOLE ) = {
+struct init_fn serial_init_fn __init_fn ( INIT_SERIAL ) = {
.initialise = serial_init,
};
+
+/** Serial driver startup function */
+struct startup_fn serial_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
+ .shutdown = serial_fini,
+};
diff --git a/src/core/serial_console.c b/src/core/serial_console.c
new file mode 100644
index 00000000..0300482a
--- /dev/null
+++ b/src/core/serial_console.c
@@ -0,0 +1,31 @@
+#include <gpxe/init.h>
+#include <gpxe/serial.h>
+#include "console.h"
+
+/** @file
+ *
+ * Serial console
+ *
+ */
+
+struct console_driver serial_console __console_driver;
+
+static void serial_console_init ( void ) {
+ /* Serial driver initialization should already be done,
+ * time to enable the serial console. */
+ serial_console.disabled = 0;
+}
+
+struct console_driver serial_console __console_driver = {
+ .putchar = serial_putc,
+ .getchar = serial_getc,
+ .iskey = serial_ischar,
+ .disabled = 1,
+};
+
+/**
+ * Serial console initialisation function
+ */
+struct init_fn serial_console_init_fn __init_fn ( INIT_CONSOLE ) = {
+ .initialise = serial_console_init,
+};
diff --git a/src/include/gpxe/init.h b/src/include/gpxe/init.h
index d83aa5e5..c468213e 100644
--- a/src/include/gpxe/init.h
+++ b/src/include/gpxe/init.h
@@ -22,8 +22,9 @@ struct init_fn {
*/
#define INIT_EARLY 01 /**< Early initialisation */
-#define INIT_CONSOLE 02 /**< Console initialisation */
-#define INIT_NORMAL 03 /**< Normal initialisation */
+#define INIT_SERIAL 02 /**< Serial driver initialisation */
+#define INIT_CONSOLE 03 /**< Console initialisation */
+#define INIT_NORMAL 04 /**< Normal initialisation */
/** @} */
diff --git a/src/include/gpxe/serial.h b/src/include/gpxe/serial.h
new file mode 100644
index 00000000..2825b936
--- /dev/null
+++ b/src/include/gpxe/serial.h
@@ -0,0 +1,14 @@
+#ifndef _GPXE_SERIAL_H
+#define _GPXE_SERIAL_H
+
+/** @file
+ *
+ * Serial driver functions
+ *
+ */
+
+extern void serial_putc ( int ch );
+extern int serial_getc ( void );
+extern int serial_ischar ( void );
+
+#endif /* _GPXE_SERIAL_H */