Quellcode durchsuchen

[Serial] Split serial console from serial driver

tags/v0.9.4
Stefan Hajnoczi vor 16 Jahren
Ursprung
Commit
831db76ff7
5 geänderte Dateien mit 62 neuen und 32 gelöschten Zeilen
  1. 1
    1
      src/core/config.c
  2. 13
    29
      src/core/serial.c
  3. 31
    0
      src/core/serial_console.c
  4. 3
    2
      src/include/gpxe/init.h
  5. 14
    0
      src/include/gpxe/serial.h

+ 1
- 1
src/core/config.c Datei anzeigen

54
 REQUIRE_OBJECT ( bios_console );
54
 REQUIRE_OBJECT ( bios_console );
55
 #endif
55
 #endif
56
 #ifdef CONSOLE_SERIAL
56
 #ifdef CONSOLE_SERIAL
57
-REQUIRE_OBJECT ( serial );
57
+REQUIRE_OBJECT ( serial_console );
58
 #endif
58
 #endif
59
 #ifdef CONSOLE_DIRECT_VGA
59
 #ifdef CONSOLE_DIRECT_VGA
60
 REQUIRE_OBJECT ( video_subr );
60
 REQUIRE_OBJECT ( video_subr );

+ 13
- 29
src/core/serial.c Datei anzeigen

12
  */
12
  */
13
 
13
 
14
 #include "stddef.h"
14
 #include "stddef.h"
15
-#include "console.h"
16
 #include <gpxe/init.h>
15
 #include <gpxe/init.h>
17
 #include "io.h"
16
 #include "io.h"
18
 #include <unistd.h>
17
 #include <unistd.h>
18
+#include <gpxe/serial.h>
19
 #include "config/serial.h"
19
 #include "config/serial.h"
20
 
20
 
21
 /* Set default values if none specified */
21
 /* Set default values if none specified */
91
 #define uart_writeb(val,addr) outb((val),(addr))
91
 #define uart_writeb(val,addr) outb((val),(addr))
92
 #endif
92
 #endif
93
 
93
 
94
-struct console_driver serial_console __console_driver;
95
-
96
 /*
94
 /*
97
  * void serial_putc(int ch);
95
  * void serial_putc(int ch);
98
  *	Write character `ch' to port UART_BASE.
96
  *	Write character `ch' to port UART_BASE.
99
  */
97
  */
100
-static void serial_putc ( int ch ) {
98
+void serial_putc ( int ch ) {
101
 	int i;
99
 	int i;
102
 	int status;
100
 	int status;
103
 	i = 1000; /* timeout */
101
 	i = 1000; /* timeout */
116
  * int serial_getc(void);
114
  * int serial_getc(void);
117
  *	Read a character from port UART_BASE.
115
  *	Read a character from port UART_BASE.
118
  */
116
  */
119
-static int serial_getc ( void ) {
117
+int serial_getc ( void ) {
120
 	int status;
118
 	int status;
121
 	int ch;
119
 	int ch;
122
 	do {
120
 	do {
135
  *       If there is a character in the input buffer of port UART_BASE,
133
  *       If there is a character in the input buffer of port UART_BASE,
136
  *       return nonzero; otherwise return 0.
134
  *       return nonzero; otherwise return 0.
137
  */
135
  */
138
-static int serial_ischar ( void ) {
136
+int serial_ischar ( void ) {
139
 	int status;
137
 	int status;
140
 	status = uart_readb(UART_BASE + UART_LSR);	/* line status reg; */
138
 	status = uart_readb(UART_BASE + UART_LSR);	/* line status reg; */
141
 	return status & 1;		/* rx char available */
139
 	return status & 1;		/* rx char available */
217
 		/* line status reg */
215
 		/* line status reg */
218
 		status = uart_readb(UART_BASE + UART_LSR);
216
 		status = uart_readb(UART_BASE + UART_LSR);
219
 	} while(status & UART_LSR_DR);
217
 	} while(status & UART_LSR_DR);
220
-	serial_console.disabled = 0;
221
  out:
218
  out:
222
 	return;
219
 	return;
223
 }
220
 }
229
  */
226
  */
230
 static void serial_fini ( void ) {
227
 static void serial_fini ( void ) {
231
 	int i, status;
228
 	int i, status;
232
-	if (serial_console.disabled) {
233
-		/* no serial interface */
234
-		return;
235
-	}
236
 	/* Flush the output buffer to avoid dropping characters,
229
 	/* Flush the output buffer to avoid dropping characters,
237
 	 * if we are reinitializing the serial port.
230
 	 * if we are reinitializing the serial port.
238
 	 */
231
 	 */
243
 	/* Don't mark it as disabled; it's still usable */
236
 	/* Don't mark it as disabled; it's still usable */
244
 }
237
 }
245
 
238
 
246
-struct console_driver serial_console __console_driver = {
247
-	.putchar = serial_putc,
248
-	.getchar = serial_getc,
249
-	.iskey = serial_ischar,
250
-	.disabled = 1,
251
-};
252
-
253
-/** Serial console startup function */
254
-struct startup_fn serial_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
255
-	.startup = serial_init,
256
-	.shutdown = serial_fini,
257
-};
258
-
259
 /**
239
 /**
260
- * Serial console initialisation function
240
+ * Serial driver initialisation function
261
  *
241
  *
262
- * Initialise console early on so that it is available to capture
263
- * early debug messages.  It is safe to call serial_init() multiple
264
- * times.
242
+ * Initialise serial port early on so that it is available to capture
243
+ * early debug messages.
265
  */
244
  */
266
-struct init_fn serial_init_fn __init_fn ( INIT_CONSOLE ) = {
245
+struct init_fn serial_init_fn __init_fn ( INIT_SERIAL ) = {
267
 	.initialise = serial_init,
246
 	.initialise = serial_init,
268
 };
247
 };
248
+
249
+/** Serial driver startup function */
250
+struct startup_fn serial_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
251
+	.shutdown = serial_fini,
252
+};

+ 31
- 0
src/core/serial_console.c Datei anzeigen

1
+#include <gpxe/init.h>
2
+#include <gpxe/serial.h>
3
+#include "console.h"
4
+
5
+/** @file
6
+ *
7
+ * Serial console
8
+ *
9
+ */
10
+
11
+struct console_driver serial_console __console_driver;
12
+
13
+static void serial_console_init ( void ) {
14
+	/* Serial driver initialization should already be done,
15
+	 * time to enable the serial console. */
16
+	serial_console.disabled = 0;
17
+}
18
+
19
+struct console_driver serial_console __console_driver = {
20
+	.putchar = serial_putc,
21
+	.getchar = serial_getc,
22
+	.iskey = serial_ischar,
23
+	.disabled = 1,
24
+};
25
+
26
+/**
27
+ * Serial console initialisation function
28
+ */
29
+struct init_fn serial_console_init_fn __init_fn ( INIT_CONSOLE ) = {
30
+	.initialise = serial_console_init,
31
+};

+ 3
- 2
src/include/gpxe/init.h Datei anzeigen

22
  */
22
  */
23
 
23
 
24
 #define INIT_EARLY	01	/**< Early initialisation */
24
 #define INIT_EARLY	01	/**< Early initialisation */
25
-#define	INIT_CONSOLE	02	/**< Console initialisation */
26
-#define INIT_NORMAL	03	/**< Normal initialisation */
25
+#define INIT_SERIAL	02	/**< Serial driver initialisation */
26
+#define	INIT_CONSOLE	03	/**< Console initialisation */
27
+#define INIT_NORMAL	04	/**< Normal initialisation */
27
 
28
 
28
 /** @} */
29
 /** @} */
29
 
30
 

+ 14
- 0
src/include/gpxe/serial.h Datei anzeigen

1
+#ifndef _GPXE_SERIAL_H
2
+#define _GPXE_SERIAL_H
3
+
4
+/** @file
5
+ *
6
+ * Serial driver functions
7
+ *
8
+ */
9
+
10
+extern void serial_putc ( int ch );
11
+extern int serial_getc ( void );
12
+extern int serial_ischar ( void );
13
+
14
+#endif /* _GPXE_SERIAL_H */

Laden…
Abbrechen
Speichern