Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Apr 1998 01:10:55 -0700 (PDT)
From:      Julian Elischer <julian@whistle.com>
To:        Ulf Zimmermann <ulf@Alameda.net>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Tips needed about dynamic device registering
Message-ID:  <Pine.BSF.3.95.980426004827.8626A-100000@current1.whistle.com>
In-Reply-To: <199804260705.AAA27466@Gatekeeper.Alameda.net>

next in thread | previous in thread | raw e-mail | index | archive | help


On Sun, 26 Apr 1998, Ulf Zimmermann wrote:

> Basic this:
> 
> Device myx<number>.ctl or so, gives a control interface, which allows
> talking with the controller, so that for example a rebuild of a RAID
> drive can be initiated or a new system drive can be added.
> 
> Then x sd type devices, where maybe the minor number is based on the
> controller unit (1 to 4 controllers) and the number of the system drive.
> Something like this:
> 
> Major myx Minor   0 = 1. Controller,  1. system drive
> Major myx Minor   1 = 1. Controller,  2. system drive
> ...
> Major myx Minor  31 = 1. Controller, 32. system drive
> Major myx Minor  32 = 2. Controller,  1. system drive
> ...
> Major myx Minor 127 = 4. Controller, 32. system drive
> 
> This would provide garantied number, based on the controller
> and system drive number and someone would have space to online 
> add disk capacity.

The minor number is a 24 bit value.
it is perculiar in that in a dev_t it is 24 bits made up of
16 bits and 8 bits which are NOT CONTIGUOUS.
however you may divide them up any way you feel.
If you use the diskslice stuff that bruce wrote, (as in the present
sd.c and wd.c) you will need to stick with the layout
in disklabel.h (shown below). 
TYPE is basically unused I think. you could use the lower 5 UNIT
bits for your 'system drive #' and the upper UNIT bits for the controller.
OR you could use the TYPE bits.. present practice is to use the 
top TYPE bit to indicate a control (.ctl) device.
These bits are made in the filesysteme by MAKEDEV
and defined by a combination of these macro's and your code.

that's all there is to it..

DEVFS makes this whole question GO AWAY.
it handles it all for you.

/*
     3                     2                   1                   0
     1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
    _________________________________________________________________
    | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    -----------------------------------------------------------------
    |     TYPE    |UNIT_2 | SLICE   |   MAJOR?      | UNIT    |PART |
    ----------------------------------------------------------------- */
#define dkmakeminor(unit, slice, part) \
                        (((slice) << 16) | (((unit) & 0x1e0) << 16) |\
                        (((unit) & 0x1f) << 3) | (part))

#define dkmodpart(dev, part)  (((dev) & ~(dev_t)7) | (part)) 

#define dkmodslice(dev, slice)  (((dev) & ~(dev_t)0x1f0000) | ((slice) <<
16))

#define dkpart(dev)  (minor(dev) & 7)  

#define dkslice(dev)  ((minor(dev)  >> 16) & 0x1f)

#define dktype(dev)  ((minor(dev) >> 25) & 0x7f) 

#define dkunit(dev)  ((((dev) >> 16) & 0x1e0) | (((dev) >> 3) & 0x1f))



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.980426004827.8626A-100000>