mirror of https://github.com/ipxe/ipxe.git
[serial] Use new UART abstraction in serial console driver
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/38/head
parent
5e622dc085
commit
2a696ab963
|
@ -41,8 +41,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#include <ipxe/image.h>
|
#include <ipxe/image.h>
|
||||||
#include <ipxe/version.h>
|
#include <ipxe/version.h>
|
||||||
#include <usr/imgmgmt.h>
|
#include <usr/imgmgmt.h>
|
||||||
#include "config/console.h"
|
|
||||||
#include "config/serial.h"
|
|
||||||
|
|
||||||
/** The "SYSLINUX" version string */
|
/** The "SYSLINUX" version string */
|
||||||
static char __bss16_array ( syslinux_version, [32] );
|
static char __bss16_array ( syslinux_version, [32] );
|
||||||
|
@ -261,8 +259,10 @@ static __asmcall void int21 ( struct i386_all_regs *ix86 ) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x04: /* Write Character to Serial Port */
|
case 0x04: /* Write Character to Serial Port */
|
||||||
serial_putc ( ix86->regs.dl );
|
if ( serial_console.base ) {
|
||||||
ix86->flags &= ~CF;
|
uart_transmit ( &serial_console, ix86->regs.dl );
|
||||||
|
ix86->flags &= ~CF;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x09: /* Write DOS String to Console */
|
case 0x09: /* Write DOS String to Console */
|
||||||
|
@ -455,15 +455,12 @@ static __asmcall void int22 ( struct i386_all_regs *ix86 ) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x000B: /* Get Serial Console Configuration */
|
case 0x000B: /* Get Serial Console Configuration */
|
||||||
#if defined(CONSOLE_SERIAL) && !defined(COMPRESERVE)
|
if ( serial_console.base ) {
|
||||||
ix86->regs.dx = COMCONSOLE;
|
ix86->regs.dx = ( ( intptr_t ) serial_console.base );
|
||||||
ix86->regs.cx = 115200 / COMSPEED;
|
ix86->regs.cx = serial_console.divisor;
|
||||||
ix86->regs.bx = 0;
|
ix86->regs.bx = 0;
|
||||||
#else
|
ix86->flags &= ~CF;
|
||||||
ix86->regs.dx = 0;
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ix86->flags &= ~CF;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x000E: /* Get configuration file name */
|
case 0x000E: /* Get configuration file name */
|
||||||
|
|
|
@ -55,7 +55,7 @@ PROVIDE_REQUIRING_SYMBOL();
|
||||||
REQUIRE_OBJECT ( bios_console );
|
REQUIRE_OBJECT ( bios_console );
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONSOLE_SERIAL
|
#ifdef CONSOLE_SERIAL
|
||||||
REQUIRE_OBJECT ( serial_console );
|
REQUIRE_OBJECT ( serial );
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONSOLE_DIRECT_VGA
|
#ifdef CONSOLE_DIRECT_VGA
|
||||||
REQUIRE_OBJECT ( video_subr );
|
REQUIRE_OBJECT ( video_subr );
|
||||||
|
|
|
@ -13,11 +13,6 @@
|
||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER );
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
#define COM1 0x3f8
|
|
||||||
#define COM2 0x2f8
|
|
||||||
#define COM3 0x3e8
|
|
||||||
#define COM4 0x2e8
|
|
||||||
|
|
||||||
#define COMCONSOLE COM1 /* I/O port address */
|
#define COMCONSOLE COM1 /* I/O port address */
|
||||||
|
|
||||||
/* Keep settings from a previous user of the serial port (e.g. lilo or
|
/* Keep settings from a previous user of the serial port (e.g. lilo or
|
||||||
|
|
|
@ -1,259 +1,184 @@
|
||||||
/*
|
/*
|
||||||
* The serial port interface routines implement a simple polled i/o
|
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
||||||
* interface to a standard serial port. Due to the space restrictions
|
|
||||||
* for the boot blocks, no BIOS support is used (since BIOS requires
|
|
||||||
* expensive real/protected mode switches), instead the rudimentary
|
|
||||||
* BIOS support is duplicated here.
|
|
||||||
*
|
*
|
||||||
* The base address and speed for the i/o port are passed from the
|
* This program is free software; you can redistribute it and/or
|
||||||
* Makefile in the COMCONSOLE and CONSPEED preprocessor macros. The
|
* modify it under the terms of the GNU General Public License as
|
||||||
* line control parameters are currently hard-coded to 8 bits, no
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
* parity, 1 stop bit (8N1). This can be changed in init_serial().
|
* License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* You can also choose to distribute this program under the terms of
|
||||||
|
* the Unmodified Binary Distribution Licence (as given in the file
|
||||||
|
* COPYING.UBDL), provided that you have satisfied its requirements.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER );
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#include "stddef.h"
|
/** @file
|
||||||
|
*
|
||||||
|
* Serial console
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include <ipxe/init.h>
|
#include <ipxe/init.h>
|
||||||
#include <ipxe/io.h>
|
#include <ipxe/uart.h>
|
||||||
#include <unistd.h>
|
#include <ipxe/console.h>
|
||||||
#include <ipxe/serial.h>
|
#include <ipxe/serial.h>
|
||||||
#include "config/serial.h"
|
#include <config/console.h>
|
||||||
|
#include <config/serial.h>
|
||||||
|
|
||||||
/* Set default values if none specified */
|
/* Set default console usage if applicable */
|
||||||
|
#if ! ( defined ( CONSOLE_SERIAL ) && CONSOLE_EXPLICIT ( CONSOLE_SERIAL ) )
|
||||||
#ifndef COMCONSOLE
|
#undef CONSOLE_SERIAL
|
||||||
#define COMCONSOLE 0x3f8
|
#define CONSOLE_SERIAL ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COMSPEED
|
/* UART port number */
|
||||||
#define COMSPEED 9600
|
#ifdef COMCONSOLE
|
||||||
#endif
|
#define CONSOLE_PORT COMCONSOLE
|
||||||
|
|
||||||
#ifndef COMDATA
|
|
||||||
#define COMDATA 8
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef COMPARITY
|
|
||||||
#define COMPARITY 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef COMSTOP
|
|
||||||
#define COMSTOP 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef UART_BASE
|
|
||||||
#define UART_BASE ( COMCONSOLE )
|
|
||||||
|
|
||||||
#undef UART_BAUD
|
|
||||||
#define UART_BAUD ( COMSPEED )
|
|
||||||
|
|
||||||
#if ((115200%UART_BAUD) != 0)
|
|
||||||
#error Bad ttys0 baud rate
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define COMBRD (115200/UART_BAUD)
|
|
||||||
|
|
||||||
/* Line Control Settings */
|
|
||||||
#define UART_LCS ( ( ( (COMDATA) - 5 ) << 0 ) | \
|
|
||||||
( ( (COMPARITY) ) << 3 ) | \
|
|
||||||
( ( (COMSTOP) - 1 ) << 2 ) )
|
|
||||||
|
|
||||||
/* Data */
|
|
||||||
#define UART_RBR 0x00
|
|
||||||
#define UART_TBR 0x00
|
|
||||||
|
|
||||||
/* Control */
|
|
||||||
#define UART_IER 0x01
|
|
||||||
#define UART_IIR 0x02
|
|
||||||
#define UART_FCR 0x02
|
|
||||||
#define UART_LCR 0x03
|
|
||||||
#define UART_MCR 0x04
|
|
||||||
#define UART_DLL 0x00
|
|
||||||
#define UART_DLM 0x01
|
|
||||||
|
|
||||||
/* Status */
|
|
||||||
#define UART_LSR 0x05
|
|
||||||
#define UART_LSR_TEMPT 0x40 /* Transmitter empty */
|
|
||||||
#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
|
|
||||||
#define UART_LSR_BI 0x10 /* Break interrupt indicator */
|
|
||||||
#define UART_LSR_FE 0x08 /* Frame error indicator */
|
|
||||||
#define UART_LSR_PE 0x04 /* Parity error indicator */
|
|
||||||
#define UART_LSR_OE 0x02 /* Overrun error indicator */
|
|
||||||
#define UART_LSR_DR 0x01 /* Receiver data ready */
|
|
||||||
|
|
||||||
#define UART_MSR 0x06
|
|
||||||
#define UART_SCR 0x07
|
|
||||||
|
|
||||||
#if defined(UART_MEM)
|
|
||||||
#define uart_readb(addr) readb((addr))
|
|
||||||
#define uart_writeb(val,addr) writeb((val),(addr))
|
|
||||||
#else
|
#else
|
||||||
#define uart_readb(addr) inb((addr))
|
#define CONSOLE_PORT 0
|
||||||
#define uart_writeb(val,addr) outb((val),(addr))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Boolean for the state of serial driver initialization */
|
/* UART baud rate */
|
||||||
int serial_initialized = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* void serial_putc(int ch);
|
|
||||||
* Write character `ch' to port UART_BASE.
|
|
||||||
*/
|
|
||||||
void serial_putc ( int ch ) {
|
|
||||||
int i;
|
|
||||||
int status;
|
|
||||||
i = 1000; /* timeout */
|
|
||||||
while(--i > 0) {
|
|
||||||
status = uart_readb(UART_BASE + UART_LSR);
|
|
||||||
if (status & UART_LSR_THRE) {
|
|
||||||
/* TX buffer emtpy */
|
|
||||||
uart_writeb(ch, UART_BASE + UART_TBR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
mdelay(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* int serial_getc(void);
|
|
||||||
* Read a character from port UART_BASE.
|
|
||||||
*/
|
|
||||||
int serial_getc ( void ) {
|
|
||||||
int status;
|
|
||||||
int ch;
|
|
||||||
do {
|
|
||||||
status = uart_readb(UART_BASE + UART_LSR);
|
|
||||||
} while((status & 1) == 0);
|
|
||||||
ch = uart_readb(UART_BASE + UART_RBR); /* fetch (first) character */
|
|
||||||
ch &= 0x7f; /* remove any parity bits we get */
|
|
||||||
if (ch == 0x7f) { /* Make DEL... look like BS */
|
|
||||||
ch = 0x08;
|
|
||||||
}
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* int serial_ischar(void);
|
|
||||||
* If there is a character in the input buffer of port UART_BASE,
|
|
||||||
* return nonzero; otherwise return 0.
|
|
||||||
*/
|
|
||||||
int serial_ischar ( void ) {
|
|
||||||
int status;
|
|
||||||
status = uart_readb(UART_BASE + UART_LSR); /* line status reg; */
|
|
||||||
return status & 1; /* rx char available */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* int serial_init(void);
|
|
||||||
* Initialize port UART_BASE to speed COMSPEED, line settings 8N1.
|
|
||||||
*/
|
|
||||||
static void serial_init ( void ) {
|
|
||||||
int status;
|
|
||||||
int divisor, lcs;
|
|
||||||
|
|
||||||
DBG ( "Serial port %#x initialising\n", UART_BASE );
|
|
||||||
|
|
||||||
divisor = COMBRD;
|
|
||||||
lcs = UART_LCS;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef COMPRESERVE
|
#ifdef COMPRESERVE
|
||||||
lcs = uart_readb(UART_BASE + UART_LCR) & 0x7f;
|
#define CONSOLE_BAUD 0
|
||||||
uart_writeb(0x80 | lcs, UART_BASE + UART_LCR);
|
#else
|
||||||
divisor = (uart_readb(UART_BASE + UART_DLM) << 8) | uart_readb(UART_BASE + UART_DLL);
|
#define CONSOLE_BAUD COMSPEED
|
||||||
uart_writeb(lcs, UART_BASE + UART_LCR);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set Baud Rate Divisor to COMSPEED, and test to see if the
|
/* UART line control register value */
|
||||||
* serial port appears to be present.
|
#ifdef COMPRESERVE
|
||||||
*/
|
#define CONSOLE_LCR 0
|
||||||
uart_writeb(0x80 | lcs, UART_BASE + UART_LCR);
|
#else
|
||||||
uart_writeb(0xaa, UART_BASE + UART_DLL);
|
#define CONSOLE_LCR UART_LCR_WPS ( COMDATA, COMPARITY, COMSTOP )
|
||||||
if (uart_readb(UART_BASE + UART_DLL) != 0xaa) {
|
#endif
|
||||||
DBG ( "Serial port %#x UART_DLL failed\n", UART_BASE );
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
uart_writeb(0x55, UART_BASE + UART_DLL);
|
|
||||||
if (uart_readb(UART_BASE + UART_DLL) != 0x55) {
|
|
||||||
DBG ( "Serial port %#x UART_DLL failed\n", UART_BASE );
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
uart_writeb(divisor & 0xff, UART_BASE + UART_DLL);
|
|
||||||
if (uart_readb(UART_BASE + UART_DLL) != (divisor & 0xff)) {
|
|
||||||
DBG ( "Serial port %#x UART_DLL failed\n", UART_BASE );
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
uart_writeb(0xaa, UART_BASE + UART_DLM);
|
|
||||||
if (uart_readb(UART_BASE + UART_DLM) != 0xaa) {
|
|
||||||
DBG ( "Serial port %#x UART_DLM failed\n", UART_BASE );
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
uart_writeb(0x55, UART_BASE + UART_DLM);
|
|
||||||
if (uart_readb(UART_BASE + UART_DLM) != 0x55) {
|
|
||||||
DBG ( "Serial port %#x UART_DLM failed\n", UART_BASE );
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
uart_writeb((divisor >> 8) & 0xff, UART_BASE + UART_DLM);
|
|
||||||
if (uart_readb(UART_BASE + UART_DLM) != ((divisor >> 8) & 0xff)) {
|
|
||||||
DBG ( "Serial port %#x UART_DLM failed\n", UART_BASE );
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
uart_writeb(lcs, UART_BASE + UART_LCR);
|
|
||||||
|
|
||||||
/* disable interrupts */
|
/** Serial console UART */
|
||||||
uart_writeb(0x0, UART_BASE + UART_IER);
|
struct uart serial_console;
|
||||||
|
|
||||||
/* enable fifos */
|
/**
|
||||||
uart_writeb(0x01, UART_BASE + UART_FCR);
|
* Print a character to serial console
|
||||||
|
*
|
||||||
/* Set clear to send, so flow control works... */
|
* @v character Character to be printed
|
||||||
uart_writeb((1<<1), UART_BASE + UART_MCR);
|
|
||||||
|
|
||||||
/* Flush the input buffer. */
|
|
||||||
do {
|
|
||||||
/* rx buffer reg
|
|
||||||
* throw away (unconditionally the first time)
|
|
||||||
*/
|
|
||||||
(void) uart_readb(UART_BASE + UART_RBR);
|
|
||||||
/* line status reg */
|
|
||||||
status = uart_readb(UART_BASE + UART_LSR);
|
|
||||||
} while(status & UART_LSR_DR);
|
|
||||||
|
|
||||||
/* Note that serial support has been initialized */
|
|
||||||
serial_initialized = 1;
|
|
||||||
out:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* void serial_fini(void);
|
|
||||||
* Cleanup our use of the serial port, in particular flush the
|
|
||||||
* output buffer so we don't accidentially lose characters.
|
|
||||||
*/
|
*/
|
||||||
static void serial_fini ( int flags __unused ) {
|
static void serial_putchar ( int character ) {
|
||||||
int i, status;
|
|
||||||
/* Flush the output buffer to avoid dropping characters,
|
/* Do nothing if we have no UART */
|
||||||
* if we are reinitializing the serial port.
|
if ( ! serial_console.base )
|
||||||
*/
|
return;
|
||||||
i = 10000; /* timeout */
|
|
||||||
do {
|
/* Transmit character */
|
||||||
status = uart_readb(UART_BASE + UART_LSR);
|
uart_transmit ( &serial_console, character );
|
||||||
} while((--i > 0) && !(status & UART_LSR_TEMPT));
|
|
||||||
/* Don't mark it as disabled; it's still usable */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serial driver initialisation function
|
* Get character from serial console
|
||||||
*
|
*
|
||||||
* Initialise serial port early on so that it is available to capture
|
* @ret character Character read from console
|
||||||
* early debug messages.
|
|
||||||
*/
|
*/
|
||||||
struct init_fn serial_init_fn __init_fn ( INIT_SERIAL ) = {
|
static int serial_getchar ( void ) {
|
||||||
|
uint8_t data;
|
||||||
|
|
||||||
|
/* Do nothing if we have no UART */
|
||||||
|
if ( ! serial_console.base )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Wait for data to be ready */
|
||||||
|
while ( ! uart_data_ready ( &serial_console ) ) {}
|
||||||
|
|
||||||
|
/* Receive data */
|
||||||
|
data = uart_receive ( &serial_console );
|
||||||
|
|
||||||
|
/* Strip any high bit and convert DEL to backspace */
|
||||||
|
data &= 0x7f;
|
||||||
|
if ( data == 0x7f )
|
||||||
|
data = 0x08;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for character ready to read from serial console
|
||||||
|
*
|
||||||
|
* @ret True Character available to read
|
||||||
|
* @ret False No character available to read
|
||||||
|
*/
|
||||||
|
static int serial_iskey ( void ) {
|
||||||
|
|
||||||
|
/* Do nothing if we have no UART */
|
||||||
|
if ( ! serial_console.base )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Check UART */
|
||||||
|
return uart_data_ready ( &serial_console );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Serial console */
|
||||||
|
struct console_driver serial_console_driver __console_driver = {
|
||||||
|
.putchar = serial_putchar,
|
||||||
|
.getchar = serial_getchar,
|
||||||
|
.iskey = serial_iskey,
|
||||||
|
.usage = CONSOLE_SERIAL,
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Initialise serial console */
|
||||||
|
static void serial_init ( void ) {
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
/* Do nothing if we have no default port */
|
||||||
|
if ( ! CONSOLE_PORT )
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Select UART */
|
||||||
|
if ( ( rc = uart_select ( &serial_console, CONSOLE_PORT ) ) != 0 ) {
|
||||||
|
DBG ( "Could not select UART %d: %s\n",
|
||||||
|
CONSOLE_PORT, strerror ( rc ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialise UART */
|
||||||
|
if ( ( rc = uart_init ( &serial_console, CONSOLE_BAUD,
|
||||||
|
CONSOLE_LCR ) ) != 0 ) {
|
||||||
|
DBG ( "Could not initialise UART %d baud %d LCR %#02x: %s\n",
|
||||||
|
CONSOLE_PORT, CONSOLE_BAUD, CONSOLE_LCR, strerror ( rc ));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shut down serial console
|
||||||
|
*
|
||||||
|
* @v flags Shutdown flags
|
||||||
|
*/
|
||||||
|
static void serial_shutdown ( int flags __unused ) {
|
||||||
|
|
||||||
|
/* Do nothing if we have no UART */
|
||||||
|
if ( ! serial_console.base )
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Flush any pending output */
|
||||||
|
uart_flush ( &serial_console );
|
||||||
|
|
||||||
|
/* Leave console enabled; it's still usable */
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Serial console initialisation function */
|
||||||
|
struct init_fn serial_console_init_fn __init_fn ( INIT_CONSOLE ) = {
|
||||||
.initialise = serial_init,
|
.initialise = serial_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Serial driver startup function */
|
/** Serial console startup function */
|
||||||
struct startup_fn serial_startup_fn __startup_fn ( STARTUP_EARLY ) = {
|
struct startup_fn serial_startup_fn __startup_fn ( STARTUP_EARLY ) = {
|
||||||
.shutdown = serial_fini,
|
.shutdown = serial_shutdown,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
#include <ipxe/init.h>
|
|
||||||
#include <ipxe/serial.h>
|
|
||||||
#include <ipxe/console.h>
|
|
||||||
#include <config/console.h>
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
*
|
|
||||||
* Serial console
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Set default console usage if applicable */
|
|
||||||
#if ! ( defined ( CONSOLE_SERIAL ) && CONSOLE_EXPLICIT ( CONSOLE_SERIAL ) )
|
|
||||||
#undef CONSOLE_SERIAL
|
|
||||||
#define CONSOLE_SERIAL ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct console_driver serial_console __console_driver;
|
|
||||||
|
|
||||||
static void serial_console_init ( void ) {
|
|
||||||
/*
|
|
||||||
* Check if serial driver initialization is done.
|
|
||||||
* If so, it's time to enable the serial console.
|
|
||||||
*/
|
|
||||||
if ( serial_initialized )
|
|
||||||
serial_console.disabled = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct console_driver serial_console __console_driver = {
|
|
||||||
.putchar = serial_putc,
|
|
||||||
.getchar = serial_getc,
|
|
||||||
.iskey = serial_ischar,
|
|
||||||
.disabled = CONSOLE_DISABLED,
|
|
||||||
.usage = CONSOLE_SERIAL,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serial console initialisation function
|
|
||||||
*/
|
|
||||||
struct init_fn serial_console_init_fn __init_fn ( INIT_CONSOLE ) = {
|
|
||||||
.initialise = serial_console_init,
|
|
||||||
};
|
|
|
@ -26,10 +26,9 @@ struct init_fn {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define INIT_EARLY 01 /**< Early initialisation */
|
#define INIT_EARLY 01 /**< Early initialisation */
|
||||||
#define INIT_SERIAL 02 /**< Serial driver initialisation */
|
#define INIT_CONSOLE 02 /**< Console initialisation */
|
||||||
#define INIT_CONSOLE 03 /**< Console initialisation */
|
#define INIT_NORMAL 03 /**< Normal initialisation */
|
||||||
#define INIT_NORMAL 04 /**< Normal initialisation */
|
#define INIT_LATE 04 /**< Late initialisation */
|
||||||
#define INIT_LATE 05 /**< Late initialisation */
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,14 @@
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Serial driver functions
|
* Serial console
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
extern void serial_putc ( int ch );
|
#include <ipxe/uart.h>
|
||||||
extern int serial_getc ( void );
|
|
||||||
extern int serial_ischar ( void );
|
extern struct uart serial_console;
|
||||||
extern int serial_initialized;
|
|
||||||
|
|
||||||
#endif /* _IPXE_SERIAL_H */
|
#endif /* _IPXE_SERIAL_H */
|
||||||
|
|
Loading…
Reference in New Issue