Re: Device node - How does kernel know about it

2007-12-30 Thread Brad Boyer
On Thu, Dec 27, 2007 at 07:27:17PM -0800, Siva Prasad wrote:
 What is the kernel routine that is first called when there is, for
 example a read() function call from user program? 
 I would like to start debugging from there and see if any thing at all
 happens when there is a call. Appreciate your help with this question.

I don't generally recommend starting debugging at that level, but I'll
try to give you some pointers. Every system call coming into the kernel
from a user space program initially runs a little piece of assembly
language code that looks up a handler (by number) in the system call
table and sets up the proper environment to call the appropriate function
that implements that call (which is written in C). Normally, those
functions are named with a prefix of sys_ and the name of the system
call. For example, the implementation of read(2) is called sys_read. You
should be able to find it in fs/read_write.c. Other system call
implementations are scattered around to be with code related to that
call. Most of the file related ones can be found someplace under the
fs directory.

Brad Boyer
[EMAIL PROTECTED]

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Device node - How does kernel know about it

2007-12-27 Thread Nicholas Mc Guire
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 * Ramdisk is also executing fine, just that prints are not coming out of
 serial. I can see the execution of various user programs with a printk
 in sys_execve() routine. Ramdisk has all the required files like
 /dev/console, /dev/ttyS0, etc.
 * Looking further into tty driver, I noticed that call to tty_write() or
 do_tty_write() is not happening at all. So, somewhere the interface
 between kernel and user program is lost.
 * Just to check it out, I tried to write a small kernel module and a
 test program.
  - Attached memtest.c module (not really testing memory there. :-))
  - Attached testmemtest.c user program, that just open's it and reads
 the information
  - Created a device node using mknod /dev/memtest c 168 0
  - When I do insmod memtest.ko inside the ramdisk bootup scripts, I
 could see all the printk's on the console
  - When I execute testmemtest next in the same script, it does not
 display the printk inside of memtest.c module. This only indicates that
 read call did not really go to the kernel side.
  - Just to check my program's validity, I checked on a similar machine
 and all the code works fine.
  - uname -r also matches with what I built. So, chances of exiting
 from open call because of mismatch is remote. Since userland cannot
 print, I have no idea what exactly is happening there.

The kernel will simply look at the major:minor numbers - so maybe you
simply have a wrong major/minor for /dev/ttyS0 ? in that case you will
see nothing but other than that most things will go on working.

hofrat
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFHdLY2nU7rXZKfY2oRApFpAKCKfGanKHGuFFJmUFy3aQtjmWNjEACfU7uK
hrfpn2RMn5l23ZqCOXV5rd8=
=GfsF
-END PGP SIGNATURE-
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: Device node - How does kernel know about it

2007-12-27 Thread Siva Prasad
Thank you Jon and Nicholas.

I already have console=ttyS0 in the kernel command line. That is not
helping me.

I looked at the major/minor numbers with a good working system and it
looks correct for the nodes created in ramdisk.

What is the kernel routine that is first called when there is, for
example a read() function call from user program? 
I would like to start debugging from there and see if any thing at all
happens when there is a call. Appreciate your help with this question.

Thanks
Siva


-Original Message-
From: Nicholas Mc Guire [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 28, 2007 12:39 AM
To: Siva Prasad
Cc: linuxppc-dev@ozlabs.org; [EMAIL PROTECTED]
Subject: Re: Device node - How does kernel know about it

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 * Ramdisk is also executing fine, just that prints are not coming out
of
 serial. I can see the execution of various user programs with a printk
 in sys_execve() routine. Ramdisk has all the required files like
 /dev/console, /dev/ttyS0, etc.
 * Looking further into tty driver, I noticed that call to tty_write()
or
 do_tty_write() is not happening at all. So, somewhere the interface
 between kernel and user program is lost.
 * Just to check it out, I tried to write a small kernel module and a
 test program.
  - Attached memtest.c module (not really testing memory there. :-))
  - Attached testmemtest.c user program, that just open's it and reads
 the information
  - Created a device node using mknod /dev/memtest c 168 0
  - When I do insmod memtest.ko inside the ramdisk bootup scripts, I
 could see all the printk's on the console
  - When I execute testmemtest next in the same script, it does not
 display the printk inside of memtest.c module. This only indicates
that
 read call did not really go to the kernel side.
  - Just to check my program's validity, I checked on a similar machine
 and all the code works fine.
  - uname -r also matches with what I built. So, chances of exiting
 from open call because of mismatch is remote. Since userland cannot
 print, I have no idea what exactly is happening there.

The kernel will simply look at the major:minor numbers - so maybe you
simply have a wrong major/minor for /dev/ttyS0 ? in that case you will
see nothing but other than that most things will go on working.

hofrat
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFHdLY2nU7rXZKfY2oRApFpAKCKfGanKHGuFFJmUFy3aQtjmWNjEACfU7uK
hrfpn2RMn5l23ZqCOXV5rd8=
=GfsF
-END PGP SIGNATURE-
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Device node - How does kernel know about it

2007-12-27 Thread Jon Smirl
On 12/27/07, Siva Prasad [EMAIL PROTECTED] wrote:
 Thank you Jon and Nicholas.

 I already have console=ttyS0 in the kernel command line. That is not
 helping me.

Do you have
CONFIG_EARLY_PRINTK=y
in .config?



 I looked at the major/minor numbers with a good working system and it
 looks correct for the nodes created in ramdisk.

 What is the kernel routine that is first called when there is, for
 example a read() function call from user program?
 I would like to start debugging from there and see if any thing at all
 happens when there is a call. Appreciate your help with this question.

 Thanks
 Siva


 -Original Message-
 From: Nicholas Mc Guire [mailto:[EMAIL PROTECTED]
 Sent: Friday, December 28, 2007 12:39 AM
 To: Siva Prasad
 Cc: linuxppc-dev@ozlabs.org; [EMAIL PROTECTED]
 Subject: Re: Device node - How does kernel know about it

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

  * Ramdisk is also executing fine, just that prints are not coming out
 of
  serial. I can see the execution of various user programs with a printk
  in sys_execve() routine. Ramdisk has all the required files like
  /dev/console, /dev/ttyS0, etc.
  * Looking further into tty driver, I noticed that call to tty_write()
 or
  do_tty_write() is not happening at all. So, somewhere the interface
  between kernel and user program is lost.
  * Just to check it out, I tried to write a small kernel module and a
  test program.
   - Attached memtest.c module (not really testing memory there. :-))
   - Attached testmemtest.c user program, that just open's it and reads
  the information
   - Created a device node using mknod /dev/memtest c 168 0
   - When I do insmod memtest.ko inside the ramdisk bootup scripts, I
  could see all the printk's on the console
   - When I execute testmemtest next in the same script, it does not
  display the printk inside of memtest.c module. This only indicates
 that
  read call did not really go to the kernel side.
   - Just to check my program's validity, I checked on a similar machine
  and all the code works fine.
   - uname -r also matches with what I built. So, chances of exiting
  from open call because of mismatch is remote. Since userland cannot
  print, I have no idea what exactly is happening there.
 
 The kernel will simply look at the major:minor numbers - so maybe you
 simply have a wrong major/minor for /dev/ttyS0 ? in that case you will
 see nothing but other than that most things will go on working.

 hofrat
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.2.4 (GNU/Linux)

 iD8DBQFHdLY2nU7rXZKfY2oRApFpAKCKfGanKHGuFFJmUFy3aQtjmWNjEACfU7uK
 hrfpn2RMn5l23ZqCOXV5rd8=
 =GfsF
 -END PGP SIGNATURE-



-- 
Jon Smirl
[EMAIL PROTECTED]
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: Device node - How does kernel know about it

2007-12-27 Thread Siva Prasad
Jon,

Yes!... I have CONFIG_EARLY_PRINTK=y, and I could see early prints
during booting the kernel. Afterwards, printk's also work as expected.
Only printf's from user space has problem.

- Siva


-Original Message-
From: Jon Smirl [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 27, 2007 8:16 PM
To: Siva Prasad
Cc: Nicholas Mc Guire; linuxppc-dev@ozlabs.org;
[EMAIL PROTECTED]
Subject: Re: Device node - How does kernel know about it

On 12/27/07, Siva Prasad [EMAIL PROTECTED] wrote:
 Thank you Jon and Nicholas.

 I already have console=ttyS0 in the kernel command line. That is not
 helping me.

Do you have
CONFIG_EARLY_PRINTK=y
in .config?



 I looked at the major/minor numbers with a good working system and it
 looks correct for the nodes created in ramdisk.

 What is the kernel routine that is first called when there is, for
 example a read() function call from user program?
 I would like to start debugging from there and see if any thing at all
 happens when there is a call. Appreciate your help with this question.

 Thanks
 Siva


 -Original Message-
 From: Nicholas Mc Guire [mailto:[EMAIL PROTECTED]
 Sent: Friday, December 28, 2007 12:39 AM
 To: Siva Prasad
 Cc: linuxppc-dev@ozlabs.org; [EMAIL PROTECTED]
 Subject: Re: Device node - How does kernel know about it

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

  * Ramdisk is also executing fine, just that prints are not coming
out
 of
  serial. I can see the execution of various user programs with a
printk
  in sys_execve() routine. Ramdisk has all the required files like
  /dev/console, /dev/ttyS0, etc.
  * Looking further into tty driver, I noticed that call to
tty_write()
 or
  do_tty_write() is not happening at all. So, somewhere the interface
  between kernel and user program is lost.
  * Just to check it out, I tried to write a small kernel module and a
  test program.
   - Attached memtest.c module (not really testing memory there. :-))
   - Attached testmemtest.c user program, that just open's it and
reads
  the information
   - Created a device node using mknod /dev/memtest c 168 0
   - When I do insmod memtest.ko inside the ramdisk bootup scripts,
I
  could see all the printk's on the console
   - When I execute testmemtest next in the same script, it does not
  display the printk inside of memtest.c module. This only indicates
 that
  read call did not really go to the kernel side.
   - Just to check my program's validity, I checked on a similar
machine
  and all the code works fine.
   - uname -r also matches with what I built. So, chances of exiting
  from open call because of mismatch is remote. Since userland cannot
  print, I have no idea what exactly is happening there.
 
 The kernel will simply look at the major:minor numbers - so maybe you
 simply have a wrong major/minor for /dev/ttyS0 ? in that case you will
 see nothing but other than that most things will go on working.

 hofrat
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.2.4 (GNU/Linux)

 iD8DBQFHdLY2nU7rXZKfY2oRApFpAKCKfGanKHGuFFJmUFy3aQtjmWNjEACfU7uK
 hrfpn2RMn5l23ZqCOXV5rd8=
 =GfsF
 -END PGP SIGNATURE-



-- 
Jon Smirl
[EMAIL PROTECTED]
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Device node - How does kernel know about it

2007-12-26 Thread Siva Prasad
Hi,

I am really interested in finding out how kernel knows about device
nodes and how the whole thing work. This is as part of my debugging
effort on 8641D based PowerPC board.

* It all started with the problem of not printing any thing that comes
from ramdisk (echo and printf statements), while kernel printk's work
perfectly fine.
* Ramdisk is also executing fine, just that prints are not coming out of
serial. I can see the execution of various user programs with a printk
in sys_execve() routine. Ramdisk has all the required files like
/dev/console, /dev/ttyS0, etc.
* Looking further into tty driver, I noticed that call to tty_write() or
do_tty_write() is not happening at all. So, somewhere the interface
between kernel and user program is lost.
* Just to check it out, I tried to write a small kernel module and a
test program.
  - Attached memtest.c module (not really testing memory there. :-))
  - Attached testmemtest.c user program, that just open's it and reads
the information
  - Created a device node using mknod /dev/memtest c 168 0
  - When I do insmod memtest.ko inside the ramdisk bootup scripts, I
could see all the printk's on the console
  - When I execute testmemtest next in the same script, it does not
display the printk inside of memtest.c module. This only indicates that
read call did not really go to the kernel side.
  - Just to check my program's validity, I checked on a similar machine
and all the code works fine. 
  - uname -r also matches with what I built. So, chances of exiting
from open call because of mismatch is remote. Since userland cannot
print, I have no idea what exactly is happening there.

Now going back to the original question...
How does a kernel know about device nodes and how to link with it.
Basically I believe interface between user programs and kernel is lost
at device nodes.

Appreciate any help in continuing my debugging efforts.

Thanks
Siva



memtest.c
Description: memtest.c


testmemtest.c
Description: testmemtest.c
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: Device node - How does kernel know about it

2007-12-26 Thread Jon Smirl
On 12/26/07, Siva Prasad [EMAIL PROTECTED] wrote:
 Hi,

 I am really interested in finding out how kernel knows about device
 nodes and how the whole thing work. This is as part of my debugging
 effort on 8641D based PowerPC board.

 * It all started with the problem of not printing any thing that comes
 from ramdisk (echo and printf statements), while kernel printk's work
 perfectly fine.
 * Ramdisk is also executing fine, just that prints are not coming out of
 serial. I can see the execution of various user programs with a printk
 in sys_execve() routine. Ramdisk has all the required files like
 /dev/console, /dev/ttyS0, etc.

Does adding console=ttyS0,baud to the kernel boot command line fix it?

-- 
Jon Smirl
[EMAIL PROTECTED]
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev