kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* How logs will come to UART serial console?
@ 2011-05-17  7:52 sandeep kumar
  2011-05-17 15:09 ` Haojian Zhuang
  2011-05-17 16:09 ` Dave Hylands
  0 siblings, 2 replies; 4+ messages in thread
From: sandeep kumar @ 2011-05-17  7:52 UTC (permalink / raw)
  To: kernelnewbies

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)

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


Thanking you,
sandeep kumar.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110517/35ee4dfd/attachment.html 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* How logs will come to UART serial console?
  2011-05-17  7:52 How logs will come to UART serial console? sandeep kumar
@ 2011-05-17 15:09 ` Haojian Zhuang
  2011-05-17 16:09 ` Dave Hylands
  1 sibling, 0 replies; 4+ messages in thread
From: Haojian Zhuang @ 2011-05-17 15:09 UTC (permalink / raw)
  To: kernelnewbies

On Tue, May 17, 2011 at 3:52 PM, sandeep kumar
<coolsandyforyou@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)
>
console_unlock() in kernel/printk.c

> Where wil be the parsing of the cmdline string sent from the bootloader is
> done?
>
>
> Thanking you,
> sandeep kumar.
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* How logs will come to UART serial console?
  2011-05-17  7:52 How logs will come to UART serial console? sandeep kumar
  2011-05-17 15:09 ` Haojian Zhuang
@ 2011-05-17 16:09 ` Dave Hylands
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Hylands @ 2011-05-17 16:09 UTC (permalink / raw)
  To: kernelnewbies

Hi sandeep,

On Tue, May 17, 2011 at 12:52 AM, sandeep kumar
<coolsandyforyou@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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* How logs will come to UART serial console?
@ 2011-05-18 18:49 Haphazard H
  0 siblings, 0 replies; 4+ messages in thread
From: Haphazard H @ 2011-05-18 18:49 UTC (permalink / raw)
  To: kernelnewbies

> Hi sandeep,
>
> On Tue, May 17, 2011 at 12:52 AM, sandeep kumar
> <coolsandyforyou@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

Think the file has changed, its now in drivers/tty/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.

If so, you can see the output in all the registered ports.

> > 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>

In the console_setup function, the struct console's address in stored in a char pointer.
If you want to know how the parsing is done,

if (str[0] >= '0' && str[0] <= '9') {
??????????????? strcpy(buf, "ttyS");
??????????????? strncpy(buf + 4, str, sizeof(buf) - 5);
???????? } else {
???????????????? strncpy(buf, str, sizeof(buf) - 1);
???????? }
???????? buf[sizeof(buf) - 1] = 0;
???????? if ((options = strchr(str, ',')) != NULL)
???????????????? *(options++) = 0;

I they check the str[0], the first element in the received char array, it corresponds to 
char name[16] // from linux/console.h
the name parameter in the static struct console serial8250_console is "ttyS".
Basically what the first line does is that, the console device's name 
should not start with numbers. If not actual name is copied.

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

/harper

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-18 18:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-17  7:52 How logs will come to UART serial console? sandeep kumar
2011-05-17 15:09 ` Haojian Zhuang
2011-05-17 16:09 ` Dave Hylands
  -- strict thread matches above, loose matches on Subject: below --
2011-05-18 18:49 Haphazard H

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).