How logs will come to UART serial console?

Dave Hylands dhylands at gmail.com
Tue May 17 12:09:28 EDT 2011


Hi sandeep,

On Tue, May 17, 2011 at 12:52 AM, sandeep kumar
<coolsandyforyou at gmail.com> wrote:
>
> Hi ,
> Here is my question.
> when we put 'printk's in kernel code the logs will go to the log_buffer.(i observed that from implementation)
> But when UART is enabled(in the bootloader), the same printk logs are going to the serial console.
> As per my study printk doesnot implementing anything that writes to the UART console.
>
> Now here are my questions,
> how this is being achieved? Where this is implemented?(which file)

When you register your UART driver there is typically an option to
register a console driver at the same time.

For example, let's take a look at the 8250 serial driver. We'll look
at the file drivers/serial/8250.c

Search for the function serial8250_console_init, which has a call to
register_console.

That's the starting point that sets up the console driver. You can
have other drivers call register_console and get your console messages
sent out whatever bizarre device you may have connected to your
system.

You can also have multiple consoles registered at the same time.

> Where wil be the parsing of the cmdline string sent from the bootloader is done?

The function console_setup is called when the console= parameter is
passed on the kernel command line.
<http://lxr.linux.no/linux+v2.6.38/kernel/printk.c#L904>

The __setup just after the end of the function is what causes it to
call that function when the console= parameter is passed.

--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com



More information about the Kernelnewbies mailing list