|
@@ -12,10 +12,10 @@
|
12
|
12
|
*/
|
13
|
13
|
|
14
|
14
|
#include "stddef.h"
|
15
|
|
-#include "console.h"
|
16
|
15
|
#include <gpxe/init.h>
|
17
|
16
|
#include "io.h"
|
18
|
17
|
#include <unistd.h>
|
|
18
|
+#include <gpxe/serial.h>
|
19
|
19
|
#include "config/serial.h"
|
20
|
20
|
|
21
|
21
|
/* Set default values if none specified */
|
|
@@ -91,13 +91,11 @@
|
91
|
91
|
#define uart_writeb(val,addr) outb((val),(addr))
|
92
|
92
|
#endif
|
93
|
93
|
|
94
|
|
-struct console_driver serial_console __console_driver;
|
95
|
|
-
|
96
|
94
|
/*
|
97
|
95
|
* void serial_putc(int ch);
|
98
|
96
|
* Write character `ch' to port UART_BASE.
|
99
|
97
|
*/
|
100
|
|
-static void serial_putc ( int ch ) {
|
|
98
|
+void serial_putc ( int ch ) {
|
101
|
99
|
int i;
|
102
|
100
|
int status;
|
103
|
101
|
i = 1000; /* timeout */
|
|
@@ -116,7 +114,7 @@ static void serial_putc ( int ch ) {
|
116
|
114
|
* int serial_getc(void);
|
117
|
115
|
* Read a character from port UART_BASE.
|
118
|
116
|
*/
|
119
|
|
-static int serial_getc ( void ) {
|
|
117
|
+int serial_getc ( void ) {
|
120
|
118
|
int status;
|
121
|
119
|
int ch;
|
122
|
120
|
do {
|
|
@@ -135,7 +133,7 @@ static int serial_getc ( void ) {
|
135
|
133
|
* If there is a character in the input buffer of port UART_BASE,
|
136
|
134
|
* return nonzero; otherwise return 0.
|
137
|
135
|
*/
|
138
|
|
-static int serial_ischar ( void ) {
|
|
136
|
+int serial_ischar ( void ) {
|
139
|
137
|
int status;
|
140
|
138
|
status = uart_readb(UART_BASE + UART_LSR); /* line status reg; */
|
141
|
139
|
return status & 1; /* rx char available */
|
|
@@ -217,7 +215,6 @@ static void serial_init ( void ) {
|
217
|
215
|
/* line status reg */
|
218
|
216
|
status = uart_readb(UART_BASE + UART_LSR);
|
219
|
217
|
} while(status & UART_LSR_DR);
|
220
|
|
- serial_console.disabled = 0;
|
221
|
218
|
out:
|
222
|
219
|
return;
|
223
|
220
|
}
|
|
@@ -229,10 +226,6 @@ static void serial_init ( void ) {
|
229
|
226
|
*/
|
230
|
227
|
static void serial_fini ( void ) {
|
231
|
228
|
int i, status;
|
232
|
|
- if (serial_console.disabled) {
|
233
|
|
- /* no serial interface */
|
234
|
|
- return;
|
235
|
|
- }
|
236
|
229
|
/* Flush the output buffer to avoid dropping characters,
|
237
|
230
|
* if we are reinitializing the serial port.
|
238
|
231
|
*/
|
|
@@ -243,26 +236,17 @@ static void serial_fini ( void ) {
|
243
|
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
|
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
|
+};
|