Skip to content

Commit c5e7467

Browse files
diandersDaniel Thompson
authored andcommitted
serial: 8250_early: Support kgdboc_earlycon
Implement the read() function in the early console driver. With recent kgdb patches this allows you to use kgdb to debug fairly early into the system boot. We only bother implementing this if polling is enabled since kgdb can't be enabled without that. Signed-off-by: Douglas Anderson <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Link: https://lore.kernel.org/r/20200507130644.v4.11.I8f668556c244776523320a95b09373a86eda11b7@changeid Signed-off-by: Daniel Thompson <[email protected]>
1 parent 205b5bd commit c5e7467

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drivers/tty/serial/8250/8250_early.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ static void early_serial8250_write(struct console *console,
109109
uart_console_write(port, s, count, serial_putc);
110110
}
111111

112+
#ifdef CONFIG_CONSOLE_POLL
113+
static int early_serial8250_read(struct console *console,
114+
char *s, unsigned int count)
115+
{
116+
struct earlycon_device *device = console->data;
117+
struct uart_port *port = &device->port;
118+
unsigned int status;
119+
int num_read = 0;
120+
121+
while (num_read < count) {
122+
status = serial8250_early_in(port, UART_LSR);
123+
if (!(status & UART_LSR_DR))
124+
break;
125+
s[num_read++] = serial8250_early_in(port, UART_RX);
126+
}
127+
128+
return num_read;
129+
}
130+
#else
131+
#define early_serial8250_read NULL
132+
#endif
133+
112134
static void __init init_port(struct earlycon_device *device)
113135
{
114136
struct uart_port *port = &device->port;
@@ -149,6 +171,7 @@ int __init early_serial8250_setup(struct earlycon_device *device,
149171
init_port(device);
150172

151173
device->con->write = early_serial8250_write;
174+
device->con->read = early_serial8250_read;
152175
return 0;
153176
}
154177
EARLYCON_DECLARE(uart8250, early_serial8250_setup);

0 commit comments

Comments
 (0)