Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing the device tree from user space

1,830 views
Skip to first unread message

Thomas Taranowski

unread,
Aug 9, 2010, 3:42:16 PM8/9/10
to
I'd like to build a userspace driver, and have it pull some hardware
details from the device tree, rather than hard coding. If I was
writing a kernel driver, I'd use the of_ routines (e.g.
of_get_property), etc., but i believe these are only accessible from
the kernel. Is there an API that reads the device tree from
userspace?

Thanks

Alan Curry

unread,
Aug 9, 2010, 4:52:38 PM8/9/10
to
In article <ff9e9a08-6723-43a3...@h17g2000pri.googlegroups.com>,

/proc/device-tree

--
Alan Curry

Thomas Taranowski

unread,
Aug 9, 2010, 5:16:08 PM8/9/10
to
On Aug 9, 1:52 pm, pac...@kosh.dhis.org (Alan Curry) wrote:
> In article <ff9e9a08-6723-43a3-85f7-e0b637821...@h17g2000pri.googlegroups.com>,

> Thomas Taranowski  <baringfo...@gmail.com> wrote:
>
> >I'd like to build a userspace driver, and have it pull some hardware
> >details from the device tree, rather than hard coding.  If I was
> >writing a kernel driver, I'd use the of_ routines (e.g.
> >of_get_property), etc., but i believe these are only accessible from
> >the kernel.  Is there an API that reads the device tree from
> >userspace?
>
> /proc/device-tree
>
> --
> Alan Curry

Thanks. I guess I was hoping there was an additional device tree
library I could use to extract out the device structure for me. /proc/
device-tree has what I want, but it looks like I have to parse the
directory and device files manually.

Felix Palmen

unread,
Aug 9, 2010, 5:30:14 PM8/9/10
to
* Thomas Taranowski <barin...@gmail.com>:

> Thanks. I guess I was hoping there was an additional device tree
> library I could use to extract out the device structure for me. /proc/
> device-tree has what I want, but it looks like I have to parse the
> directory and device files manually.

This may very well be a shot in the dark cause I'm not really familiar
with device handling in linux -- but -- what about hal and libhal? Maybe
you can find something interesting for your problem in the source?

Regards, Felix

--
Felix Palmen (Zirias) + [PGP] Felix Palmen <fe...@palmen-it.de>
web: http://palmen-it.de/ | http://palmen-it.de/pub.txt
my open source projects: | Fingerprint: ED9B 62D0 BE39 32F9 2488
http://palmen-it.de/?pg=pro + 5D0C 8177 9D80 5ECF F683

Alan Curry

unread,
Aug 10, 2010, 7:56:42 PM8/10/10
to
In article <1246796c-d36c-4934...@q40g2000prg.googlegroups.com>,

What hideous language could you be using where opening and reading regular
files is such a burden that you'd rather have to jump through the unknown
hoops of a specialist library you've never seen before?

--
Alan Curry

phil-new...@ipal.net

unread,
Aug 14, 2010, 1:26:29 PM8/14/10
to

Is that a conditional entry only present when the particular module is loaded?

=============================================================================
bessel/phil/c1 /home/phil 14> ls -Alv /{proc,sys}/*dev*
-r--r--r-- 1 root root 0 2010-08-14 13:25 /proc/devices

/sys/dev:
total 0
drwxr-xr-x 2 root root 0 2010-08-14 13:25 block
drwxr-xr-x 2 root root 0 2010-08-14 13:25 char

/sys/devices:
total 0
drwxr-xr-x 15 root root 0 2010-08-14 13:25 LNXSYSTM:00
drwxr-xr-x 29 root root 0 2010-08-14 13:24 pci0000:00
drwxr-xr-x 8 root root 0 2010-08-14 13:25 platform
drwxr-xr-x 17 root root 0 2010-08-14 13:25 pnp0
drwxr-xr-x 13 root root 0 2010-08-14 13:25 system
drwxr-xr-x 15 root root 0 2010-08-14 13:24 virtual
bessel/phil/c1 /home/phil 15>
=============================================================================

--
-----------------------------------------------------------------------------
| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------

Alan Curry

unread,
Aug 14, 2010, 5:54:19 PM8/14/10
to
In article <i46jk...@news2.newsguy.com>, <phil-new...@ipal.net> wrote:
>On Mon, 9 Aug 2010 20:52:38 +0000 (UTC) Alan Curry <pac...@kosh.dhis.org> wrote:
>|
>| /proc/device-tree
>
>Is that a conditional entry only present when the particular module is loaded?
>
>=============================================================================
>bessel/phil/c1 /home/phil 14> ls -Alv /{proc,sys}/*dev*
>-r--r--r-- 1 root root 0 2010-08-14 13:25 /proc/devices

It's present when you're on a machine that has a device tree. "Device
tree" is an OpenFirmware term.

Oh yeah, and CONFIG_PROC_DEVICETREE.

--
Alan Curry

0 new messages