2001-04-11 08:15:31

by antonpoon

[permalink] [raw]
Subject: How can I add a function to the kernel initialization

I have written a driver for a character set LCD module using parallel port. I want to display a message when the kernel is initialized.

I added the following to start_kernel() in init/main.c

#include <stdio.h>

{
int i;
char line = "Loading Kernel";
FILE *ptr;
ptr = fopen("/dev/lcd","w");

for (i=0;i<10;i++)
{
fprintf(ptr, "%s\n", line);
}
fclose(ptr);
}

Error was found, it looks like that it can not include stdio.h in the initialization.
How can I do that?

I wish to be personally CC'ed the answers/comments posted to the list in response to my posting. Thank you.

Best Regards,
Anton



---------------------------------------------
?w???ϥ?HongKong.com?l???t??
Thank you for using hongkong.com Email system


2001-04-11 11:23:14

by Bart Trojanowski

[permalink] [raw]
Subject: Re: How can I add a function to the kernel initialization


First it does not work because you do not have access to libc in the
kernel. Secondly your LCD driver is not available at the time of
start_kernel so there is no one to listen to the /dev/lcd.

The quickest hack would be to find your lcd driver and modify it to spit
out the Loading Kernel, after it initializes.

B.

On Wed, 11 Apr 2001, [email protected] wrote:

> I have written a driver for a character set LCD module using parallel port. I want to display a message when the kernel is initialized.
>
> I added the following to start_kernel() in init/main.c
>
> #include <stdio.h>
>
> {
> int i;
> char line = "Loading Kernel";
> FILE *ptr;
> ptr = fopen("/dev/lcd","w");
>
> for (i=0;i<10;i++)
> {
> fprintf(ptr, "%s\n", line);
> }
> fclose(ptr);
> }
>
> Error was found, it looks like that it can not include stdio.h in the initialization.
> How can I do that?
>
> I wish to be personally CC'ed the answers/comments posted to the list in response to my posting. Thank you.
>
> Best Regards,
> Anton
>
>
>
> ---------------------------------------------
> ?w???ϥ?HongKong.com?l???t??
> Thank you for using hongkong.com Email system
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

--
WebSig: http://www.jukie.net/~bart/sig/


2001-04-11 12:17:56

by Padraig Brady

[permalink] [raw]
Subject: Re: How can I add a function to the kernel initialization

These things usually sit off a serial port.
I.E. /dev/lcd is a link to /dev/ttyS0 or whatever.
Anyway the main point is you don't have access to libc.
So how can you access the serial port from the booting
kernel. Well to spit kernel messages out the serial
port you pass the console=ttyS1,19200 or equivalent
parameter to the kernel. So see what that is done
in the kernel code and copy.

Note http://www.kernelnewbies.org is probably more appropriate
for this sort of question.

Padraig.

Bart Trojanowski wrote:
>
> First it does not work because you do not have access to libc in the
> kernel. Secondly your LCD driver is not available at the time of
> start_kernel so there is no one to listen to the /dev/lcd.
>
> The quickest hack would be to find your lcd driver and modify it to spit
> out the Loading Kernel, after it initializes.
>
> B.
>
> On Wed, 11 Apr 2001, [email protected] wrote:
>
> > I have written a driver for a character set LCD module using parallel port. I want to display a message when the kernel is initialized.
> >
> > I added the following to start_kernel() in init/main.c
> >
> > #include <stdio.h>
> >
> > {
> > int i;
> > char line = "Loading Kernel";
> > FILE *ptr;
> > ptr = fopen("/dev/lcd","w");
> >
> > for (i=0;i<10;i++)
> > {
> > fprintf(ptr, "%s\n", line);
> > }
> > fclose(ptr);
> > }
> >
> > Error was found, it looks like that it can not include stdio.h in the initialization.
> > How can I do that?
> >
> > I wish to be personally CC'ed the answers/comments posted to the list in response to my posting. Thank you.
> >
> > Best Regards,
> > Anton

2001-04-15 14:20:26

by James Simmons

[permalink] [raw]
Subject: Re: How can I add a function to the kernel initialization


Is this a HD44780 LCD? Geert wrote a console driver sometime ago for this.
He had a driver for it. If he still doesn't I have a copy of the code.

MS: (n) 1. A debilitating and surprisingly widespread affliction that
renders the sufferer barely able to perform the simplest task. 2. A disease.

James Simmons [[email protected]] ____/|
fbdev/console/gfx developer \ o.O|
http://www.linux-fbdev.org =(_)=
http://linuxgfx.sourceforge.net U
http://linuxconsole.sourceforge.net