From: H. Peter Anvin on
On 07/10/2010 11:07 AM, Pekka Enberg 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.

Yinghai is correct that this really needs to pick apart the command
line, especially since there is already support for command-line parsing
in the early boot code. I suggest we just reuse the earlyprintk=
option, especially since it's basically the same code and so should have
the same failure profile.

> +
> + while ((inb(early_serial_base + LSR)& XMTRDY) == 0&& --timeout)
> + ;
> +

cpu_relax(); here, probably.

-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Cyrill Gorcunov on
On Sat, Jul 10, 2010 at 10:40:20PM +0300, Pekka Enberg 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: Cyrill Gorcunov <gorcunov(a)gmail.com>
> Cc: Ingo Molnar <mingo(a)redhat.com>
> Cc: Yinghai Lu <yinghai(a)kernel.org>
> Signed-off-by: Pekka Enberg <penberg(a)cs.helsinki.fi>
> ---
> v1 -> v2:
>
> - Use 'earlyprintk' kernel parameter to determine whether to use
> early serial or not as suggested by Yinghai and hpa.
>
> arch/x86/boot/boot.h | 16 +++++++
> arch/x86/boot/main.c | 3 +
> arch/x86/boot/string.c | 41 ++++++++++++++++++
> arch/x86/boot/tty.c | 111 +++++++++++++++++++++++++++++++++++++++++++++---
> 4 files changed, 165 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
> index 98239d2..f05b5ac 100644
> --- a/arch/x86/boot/boot.h
> +++ b/arch/x86/boot/boot.h
> @@ -37,6 +37,8 @@
> extern struct setup_header hdr;
> extern struct boot_params boot_params;
>
> +#define cpu_relax() asm volatile("rep; nop" ::: "memory")
> +
> /* Basic port I/O */
> static inline void outb(u8 v, u16 port)
> {
> @@ -203,6 +205,17 @@ static inline int isdigit(int ch)
> return (ch >= '0') && (ch <= '9');
> }
>
> +static inline int isxdigit(int ch)
> +{
> + if (isdigit(ch))
> + return true;
> +
> + if ((ch >= 'a') && (ch <= 'f'))
> + return true;
> +
> + return (ch >= 'A') && (ch <= 'F');
> +}
> +

I suspect it's supposed to be static inline *bool*, right?

-- Cyrill
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Pekka Enberg on
H. Peter Anvin wrote:
>> +
>> + while ((inb(early_serial_base + LSR)& XMTRDY) == 0&& --timeout)
>> + ;
>> +
>
> cpu_relax(); here, probably.

Fixed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: H. Peter Anvin on
On 07/10/2010 02:17 PM, Pekka Enberg wrote:
> Hi!
>
> On Sat, Jul 10, 2010 at 11:49 PM, Yinghai Lu <yinghai(a)kernel.org> wrote:
>> can you analyze "console=uart8250,io,0x3f8,115200n8" instead?
>>
>> that is equal to "earlyprintk=ttyS0,115200 console=ttyS0,115200"
>>
>> so we only use one for all.
>>
>> also like to kill earlyprintk=ttyS0,115200 to favor earlycon
>
> hpa, what's your take on this?
>
> The 'console' variant seems overly complicated to me. We can add it
> but we also need to check for 'earlyprintk' as long as it's supported
> by the kernel.
>

earlyprintk= seems to be preferred over console= these days. Quite
frankly it's idiotic to have the user enter as many low-level details as
one has to do for the console= one.

Now, as for the I/O base, the I/O base for legacy serial ports are
available from a 4-element u16 array starting at absolute address 0x400.
I don't think Linux currently examines that array -- instead relying on
the hard-coded values 0x3f8, 0x2f8, 0x3e8, 0x2e8 -- but it might
something to consider for the future. However, we should match the
serial port subsystem there, of course.

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Cyrill Gorcunov on
On Sun, Jul 11, 2010 at 12:18:06AM +0300, Pekka Enberg wrote:
> On Sun, Jul 11, 2010 at 12:07 AM, Cyrill Gorcunov <gorcunov(a)gmail.com> wrote:
> >> @@ -203,6 +205,17 @@ static inline int isdigit(int ch)
> >> � � � return (ch >= '0') && (ch <= '9');
> >> �}
> >>
> >> +static inline int isxdigit(int ch)
> >> +{
> >> + � � if (isdigit(ch))
> >> + � � � � � � return true;
> >> +
> >> + � � if ((ch >= 'a') && (ch <= 'f'))
> >> + � � � � � � return true;
> >> +
> >> + � � return (ch >= 'A') && (ch <= 'F');
> >> +}
> >> +
> >
> > I suspect it's supposed to be static inline *bool*, right?
>
> Yes, but I followed 'isdigit' here for symmetry and it uses 'int'.
>
> Pekka
>

ok, I see

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