LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 03-08-2013, 03:28 PM   #1
djdjdjole
LQ Newbie
 
Registered: Oct 2012
Posts: 15

Rep: Reputation: Disabled
Driver - theoretical questions


Page http://www.armadeus.com/wiki/index.p...river#Examples refers to few statements that are
strange to me. For example it states that GPIO driver is usable through its /proc interface:

1.use /proc/drivers/gpio/portXmode to ...
2.use /proc/drivers/gpio/portXdir to ...
3.then use /proc/drivers/gpio/portX to ...
...

There is example on using it with shell script as well as from C language. And also (link on the same page)
there is example on using GPIO driver via /dev/gpio/.. nodes.
What I want to ask is why exactly "proc" branches, named like above, and not more or less of them ?
Probably driver somehow dictates it - no matter, I would appreciate some usefull links.
Also why two interfaces - via "proc" and via "dev" and when should I use one or the other ? Could it be
something other then "proc" file system ?

Thanks
 
Old 03-10-2013, 12:24 AM   #2
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: /root
Distribution: Slackware & BSD
Posts: 1,220

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
What I want to ask is why exactly "proc" branches, named like above, and not more or less of them ?Probably driver somehow dictates it - no matter, I would appreciate some usefull links.
/proc is a temporary folder containing an internal file system that enumerates processes and all devices related to the process. Thus a device caught into the process is listed how the system sees it, not how the factory describes it.

The best link to learn about /proc is from your terminal, type

Code:
~~$ man proc

Quote:
Also why two interfaces - via "proc" and via "dev" and when should I use one or the other ?
To query about device descriptors use /dev.
To query a process and its appurtenances use /proc.

Quote:
Could it be something other then "proc" file system ?
Yes there are two one more you need to know: /sys and /var

These are basic concepts flowing out of Unix Philosophy. So it is suggested to read the basics about Unix/Linux system. Here is a nice book.

Hope that helps.

Last edited by malekmustaq; 03-10-2013 at 12:26 AM.
 
2 members found this post helpful.
Old 03-10-2013, 06:28 AM   #3
djdjdjole
LQ Newbie
 
Registered: Oct 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Thanks malekmustaq, some of points you emphasized, I red about (maybe not enough). Yet, I still don't know where those names (portXmode, portXdir, ... - X is A,B,C,... ports) came from. For example why not prtXmd or prtXd ...?
Then also, why not only /dev/gpio node, but /dev/gpio/PD31, /dev/gpio/PF14 ... (ie why subnodes and why exactly those names). And userland apps use both - proc and dev (link I quoted).
Probably coming from driver (which I am not familiar with). Unfortunatelly I supose I should also read some driver books.
Maybe I am wrong - but at first glance, didn't notice "/sys" file info in book you mentioned. Sorry if I was wrong, but neither manual pages have related info (although it is less priority to me at the moment).

Thanks

And sorry, I never paid attention to "Yes", you mentioned in your post
 
Old 03-15-2013, 11:03 AM   #4
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: /root
Distribution: Slackware & BSD
Posts: 1,220

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Yet, I still don't know where those names (portXmode, portXdir, ... - X is A,B,C,... ports) came from. For example why not prtXmd or prtXd ...?
Then also, why not only /dev/gpio node, but /dev/gpio/PD31, /dev/gpio/PF14 ... (ie why subnodes and why exactly those names). And userland apps use both - proc and dev (link I quoted).
The system has to use the one it sees most fitting to the device it discovers; it merely chooses from among thousands of driver codes ported into the kernel branches. The varying node 'semantic' are given by these codes and is written into the root directory /dev or /proc including distinct information about the hardware such as serial numbers.

Quote:

Probably coming from driver (which I am not familiar with). Unfortunatelly I supose I should also read some driver books.
Your inquisitive attitude is admirable, you are free to read more about it of course. But I think there are more important challenges which need priority, unless maybe if you are on to driver coding.

Good luck.

Last edited by malekmustaq; 03-15-2013 at 11:04 AM.
 
1 members found this post helpful.
Old 03-15-2013, 07:34 PM   #5
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,455

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
Actually, /proc is not "a temporary folder." It is an imaginary one. The entire "file" and "directory" structure that you see there has no actual, physical existence. When you "list a directory," "read a file," or "write to a file" (if authorized), you are actually communicating with a kernel API. Drivers can create these and often do. When you access their "files" and "directories," you are conversing with the driver directly.
 
1 members found this post helpful.
Old 03-15-2013, 07:47 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 2,329

Rep: Reputation: 593Reputation: 593Reputation: 593Reputation: 593Reputation: 593Reputation: 593
Quote:
Originally Posted by djdjdjole View Post
Thanks malekmustaq, some of points you emphasized, I red about (maybe not enough). Yet, I still don't know where those names (portXmode, portXdir, ... - X is A,B,C,... ports) came from. For example why not prtXmd or prtXd ...?
Then also, why not only /dev/gpio node, but /dev/gpio/PD31, /dev/gpio/PF14 ... (ie why subnodes and why exactly those names). And userland apps use both - proc and dev (link I quoted).
Probably coming from driver (which I am not familiar with). Unfortunatelly I supose I should also read some driver books.
Maybe I am wrong - but at first glance, didn't notice "/sys" file info in book you mentioned. Sorry if I was wrong, but neither manual pages have related info (although it is less priority to me at the moment).

Thanks

And sorry, I never paid attention to "Yes", you mentioned in your post
There are oddnesses all over.

/proc was originally a virtual filesystem - presenting the process table as a filesystem. It turned out to be so useful that people working on the system added other things - like the partition table, cpu information, ... And it got out of hand.

A long time ago, IRIX put the device table in a /sys virtual filesystem, and gradually went to putting most of the devices identified into a /dev as symbolic links to to the /sys tables.

This got people thinking about other tables, and how to manage them - thus the /sys and/or the /proc/sys and the ability to tune the kernel parameters...

This in turn made it easier to do things that formerly required an ioctl definition... So creating such things became even more regulated - and flexible. Now, device drivers register things they want to allow to be tuned into one or the other virtual filesystems.

The names USED for these parameters are selected by device driver author. In some cases, they try to follow some conventions.

The difference between the /dev and the /proc entries is what they are used for. The /dev entries are used by applications to pass data from user space to the driver to the device. Then entries in the /proc filesystem are used to control how the driver works (things like buffer sizes, sampling rates, ...)- not the data passing through the driver.

You can get a fair amount of information from the "man proc" page - though it may be a bit out of date with respect to a specific kernel, it should give you an idea of what it is.

You can google for "procfs" "sysfs" and "devfs", which should find you documentation on each of these virtual filesystems. Internally, they all work the same way, but have different areas of the kernel to work with.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some theoretical questions (LAN). stf92 General 11 02-15-2013 10:04 PM
Theoretical Future?? nathanhillinbl Linux - Security 5 05-04-2007 02:43 AM
Theoretical considerations about switching between OS's holrin Linux - Laptop and Netbook 2 10-06-2006 07:49 PM
Theoretical test enviroment Richie55 Linux - General 1 02-02-2006 08:15 AM
Theoretical Question jgr220 Linux - Security 3 03-29-2003 06:40 AM


All times are GMT -5. The time now is 04:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration