Subject: RE: devnos and dv_unit.
To: 'Ben Harris' , Aaditya Rai <>
From: Aaditya Rai <>
List: tech-kern
Date: 10/16/2001 08:24:49
Much clearer now, Thanks!


-----Original Message-----
From: Ben Harris []
Sent: Monday, October 15, 2001 4:05 PM
Subject: Re: devnos and dv_unit.

In article
<> you
>I have a newbie question. How can one read the device tree..? Moreover,
>say that the autoconf code detects 2 cards for my driver, and passes me the
>unit numbers for these cards (say, 0 and 1) in dv_unit. Lets also assume
>that my driver interprets a devno from userland as "top 2 bits are the card
>How will someone in the userland make devnos for my cards (given that they
>cant find the respective unit numbers, unless I provide an ioctl)...?

I'm not quite sure what you mean, so I'll give you a general overview of how
the unit number gets passed around:

At attach time, driver gets unit number from autoconfig machinary, and
displays it for the user as part of the device name (e.g. foo1).

User creates a device node (or several) in /dev using MAKEDEV, which
knows which major number your device uses, and how to encode the unit number
into the minor number (e.g. ./MAKEDEV foo1, creating /dev/foo1 with major
number 42 and minor number 1).

User either provides the name of your device to a program directly (fooctl
-f foo1 ingest), or puts it in a config file (/etc/foo.conf) or whatever.

That program opens /dev/foo1, which causes the kernel to look up your device
in cdevsw (or bdevsw if it's a buffered device), and call its open routine,
passing it the major and minor number, from which it can work out the unit

Is that clear?

Ben Harris
Portmaster, NetBSD/arm26