Subject: Re: root device
To: Nathan J. Williams <nathanw@wasabisystems.com>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 02/10/2003 18:06:30
>> > > i think that having a program that could dump out the device tree
>> > > under netbsd would be *damn cool*!
>> > 
>> > Hey, look at what Darwin's ioreg outputs on my NetBSD/macppc machine:
>> > 
>> > +-o mainbus0@  <class unknownClass>
>> >   +-o cpu0@  <class unknownClass>
>> >
>> > [ ... ]
>> 
>> It'd be nice to have a _native_ NetBSD program to show this too.  I'm
>> sorta sure that's what Andrew meant :-)

yep.  that was what i meant.  kinda like pmap(1) that prints the
process's memory map.  i like that one, too, but perhaps i'm partial
to it because i wrote it.  :)

>Here's something I've had kicking around for a while. It's quite
>simple; embellish as necessary to get actual tree-like
>output. Locators only exist for devices configured explicitly; we
>don't store "found" locators anywhere besides the message buffer.
>
>% ./printdev
>
>mainbus0 
>cpu0 at mainbus0 
>pci0 at mainbus0 
>pchb0 at pci0 
>...

i once wrote a perl script (i don't even remember why) that takes
/var/run/dmesg.boot and prints this:

% ~/src/perl/devtree /var/run/dmesg.boot
cpu0 at mainbus0
pnpbios0 at mainbus0
  pckbc1 at pnpbios0 index 7 (PNP0303)
    pckbd0 at pckbc1 (kbd slot)
      wskbd0 at pckbd0
    pms0 at pckbc1 (aux slot)
      wsmouse0 at pms0 mux 0
  pckbc2 at pnpbios0 index 8 (PNP0F13)
  fdc1 at pnpbios0 index 11 (PNP0700)
  com0 at pnpbios0 index 14 (PNP0501)
pci0 at mainbus0 bus 0
  pchb0 at pci0 dev 0 function 0
    agp0 at pchb0
  ppb0 at pci0 dev 1 function 0
...

or this:

% ~/src/perl/devtree -v /var/run/dmesg.boot
cpu0 at mainbus0: (uniprocessor)
pnpbios0 at mainbus0: nodes 14, max len 262
  pckbc1 at pnpbios0 index 7 (PNP0303): kbd port
    pckbd0 at pckbc1 (kbd slot)
      wskbd0 at pckbd0: console keyboard
    pms0 at pckbc1 (aux slot)
      wsmouse0 at pms0 mux 0
  pckbc2 at pnpbios0 index 8 (PNP0F13): aux port
  fdc1 at pnpbios0 index 11 (PNP0700)
  com0 at pnpbios0 index 14 (PNP0501)
pci0 at mainbus0 bus 0: configuration mode 1
  pchb0 at pci0 dev 0 function 0
...

like i said, i don't remember why i wrote it now, nor what i would use
it for...

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."