leon, apbuart: Inherit HW parameters on sysconsole

The cons layer decides which of the registered console device is granted as
system console. When a device specific console driver performs its first_open,
it inherits UART parameters from boot loader only if it is the system console.
This commit is contained in:
Martin Aberg
2017-03-10 15:32:38 +01:00
committed by Daniel Hellstrom
parent 6e2e129966
commit f164a29470
3 changed files with 15 additions and 7 deletions

View File

@@ -20,12 +20,14 @@
struct console_dev;
#define CONSOLE_FLAG_SYSCON 0x01
#define CONSOLE_FLAG_SYSCON 0x01
#define CONSOLE_FLAG_SYSCON_GRANT 0x02
struct console_dev {
rtems_termios_device_context base;
/* Set to CONSOLE_FLAG_SYSCON if this UART should be system console and/or
* debug console.
/* Set CONSOLE_FLAG_SYSCON to request this device to be system console
* and/or debug console. CONSOLE_FLAG_SYSCON_GRANT will be set on the
* device which was selected as system console.
*/
int flags;
char *fsname; /* File system prefix */

View File

@@ -440,10 +440,12 @@ static bool first_open(
uart->tty = tty;
/* Preserve values set by bootloader */
get_attributes(base, term);
term->c_oflag |= ONLCR;
set_attributes(base, term);
/* Inherit UART hardware parameters from bootloader on system console */
if (uart->condev.flags & CONSOLE_FLAG_SYSCON_GRANT) {
get_attributes(base, term);
term->c_oflag |= ONLCR;
set_attributes(base, term);
}
/* Enable TX/RX */
uart->regs->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;

View File

@@ -89,6 +89,10 @@ void console_dev_register(struct console_dev *dev)
/* Not enough console structures */
return;
}
dev->flags &= ~CONSOLE_FLAG_SYSCON_GRANT;
if (con->flags & FLAG_SYSCON) {
dev->flags |= CONSOLE_FLAG_SYSCON_GRANT;
}
/* Assign Console */
con->dev = dev;