[okl4-developer] serial driver l4_kdb
Lukas HANEL
lukas.hanel at st.com
Mon May 26 23:15:56 EST 2008
Hi Josh,
thanks a lot for your comprehensive answer!
So in fact I had already written my own iguana level serial driver for
my device and was searching ways to test its functionality.
After your response I used the posix example and could see that output
works!
The aforementioned problem with the kernel emptying the fifo disapeared
after a complete rebuild.
Lukas Hänel
Josh Matthews wrote:
> Hi Lukas,
>
> On Sat, May 24, 2008 at 1:32 AM, Lukas HANEL <lukas.hanel at st.com
> <mailto:lukas.hanel at st.com>> wrote:
>
> Geoffrey Lee wrote:
> > Output via kdb can go out in one of the following two ways:
> >
> > (1) your printf() or whatever libc print function gets routed to
> > libs/c/sys-*/ which ends up calling the kdb character print
> > functions, or you implement your own such as print function
> > and end up calling the kdb character print functions directly
> >
>
> In this case, how/where is the kernel/userland boundary crossed?
>
>
> This depends on the implementation that the write_fn() and read_fn()
> function pointers point to for the stdio fd's. This setup is done in
> libs/c/src/sys-{X}/sys_stdio.c (where {X} is the build environment for
> your application). For Iguana, the read/write function pointers for
> stdout are statically initialised to point to a read_init and
> write_init function, which then points them on the first read/write to
> a read/write function which uses L4_KDB_PrintChar and L4_KDB_ReadChar.
> The L4_KDB functions (architecture-specific, defined in
> arch/{arch}/libs/l4/include/kdebug.h) trap into the kernel to perform
> the read/write - it is here that the user/kernel boundary is crossed.
>
>
> > (2) you use vserial for your i/o. In this instance you don't
> > really care what the backend is. If you choose to use l4kdb_uart,
> > it will do a cheesy emulation of a serial device, enough to
> > read and write, anyway.
> >
>
> Using vserial for my i/o means I do not use printf?
> In fact I am now testing the functionality of my serial driver and
> have
> not yet found a way to send data via the vserial interface. How
> would I
> do this?
>
>
> No, you still use printf(). printf() eventually gets routed through to
> fputc() (passing stdout as the output stream), which calls the
> write_fn function pointer on stdout - as mentioned, that function
> pointer gets set up in libs/c/src/sys-{X}/sys_stdio.c, and you can
> point it to whatever you want. In this case, you would point it to a
> write function that would use the vserial interface to output the
> character. In fact, this has already been done - check out
> libs/c/src/sys-posix/sys_stdio.c. There are two functions -
> serial_read and serial_write - which would be good to look at as a
> starting point to understanding how this is done. When you build an
> example in the POSIX environment (using example_env=posix), all output
> is over vserial (unless vserial is not available, in which case it
> falls back to KDB). Let us know if you have any questions about that.
>
>
> Also, I am facing a problem with the kernel console. Iguana and the
> Kernel use the same serial device, like in gumstix. When I send a
> char,
> I get an interrupt delivered to my driver, but the data register
> of the
> device is already empty. If, in the kernel's console.cc/get_c()
> function
> I disable the reading of this register, it works. I programmed the
> kernel timer for a 10ms tick.
> Do you have an idea what I could do? E.g. is it possible to have
> kernel
> and iguana use the same serial device?
>
>
> The problem you are seeing is a result of both the kernel and iguana
> using KDB for IO - I'd definitely recommend switching over to using a
> "real" serial device for applications.
>
> Best regards,
> Josh Matthews
>
More information about the Developer
mailing list