Re: [RFC/PATCH] x86: Early-boot serial I/O support

From: Yinghai Lu
Date: Sat Jul 10 2010 - 14:38:19 EST


On Sat, Jul 10, 2010 at 11:07 AM, Pekka Enberg <penberg@xxxxxxxxxxxxxx> wrote:
> This patch adds serial I/O support to very early boot printf(). It's useful for
> debugging boot code when running Linux under KVM, for example. The actual code
> was lifted from early printk.
>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Cyrill Gorcunov <gorcunov@xxxxxxxxx>
> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
> ---
>  arch/x86/boot/boot.h |    1 +
>  arch/x86/boot/main.c |    3 ++
>  arch/x86/boot/tty.c  |   65 +++++++++++++++++++++++++++++++++++++++++++++----
>  3 files changed, 63 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
> index 98239d2..5b37014 100644
> --- a/arch/x86/boot/boot.h
> +++ b/arch/x86/boot/boot.h
> @@ -333,6 +333,7 @@ size_t strnlen(const char *s, size_t maxlen);
>  unsigned int atou(const char *s);
>
>  /* tty.c */
> +void serial_init(void);
>  void puts(const char *);
>  void putchar(int);
>  int getchar(void);
> diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
> index 140172b..1437efe 100644
> --- a/arch/x86/boot/main.c
> +++ b/arch/x86/boot/main.c
> @@ -127,6 +127,9 @@ static void init_heap(void)
>
>  void main(void)
>  {
> +       /* Initialize serial console */
> +       serial_init();
> +
>        /* First, copy the boot header into the "zeropage" */
>        copy_boot_params();
>
> diff --git a/arch/x86/boot/tty.c b/arch/x86/boot/tty.c
> index 01ec69c..2f0def5 100644
> --- a/arch/x86/boot/tty.c
> +++ b/arch/x86/boot/tty.c
> @@ -10,8 +10,7 @@
>  * ----------------------------------------------------------------------- */
>
>  /*
> - * Very simple screen I/O
> - * XXX: Probably should add very simple serial I/O?
> + * Very simple screen and serial I/O
>  */
>
>  #include "boot.h"
> @@ -20,13 +19,58 @@
>  * These functions are in .inittext so they can be used to signal
>  * error during initialization.
>  */
> +static int early_serial_base = 0x3f8;  /* ttyS0 */

it seems you should analyze the command line to get io port and baud rate.

earlycon=
console=uart8250...
console=ttyS0 etc.

cmdline_find_option could be used with this.

Thanks

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/