Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ makedevice(D3DK) — Motorola System V 88k Release 4 Version 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

makedevice(D3DK)  —  

.IX \f4makedevice\fP(D3DK)

NAME

makedevice − make device number from major and minor numbers

SYNOPSIS

#include <sys/types.h>
#include <sys/ddi.h>
dev_t makedevice(major_t majnum, minor_t minnum);

ARGUMENTS

majnumMajor number. 

minnumMinor number. 

DESCRIPTION

The makedevice function creates a device number from a major and minor device number.  makedevice should be used to create device numbers so that the driver will port easily to releases that treat device numbers differently. 

RETURN VALUE

The device number, containing both the major number and the minor number, is returned.  No validation of the major or minor numbers is performed. 

LEVEL

Base or Interrupt. 

NOTES

Does not sleep. 

Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function. 

SEE ALSO

getemajor(D3DK), geteminor(D3DK), getmajor(D3DK), getminor(D3DK)

EXAMPLE

In the following example, makedevice is used to create the device number selected during a clone open.  If the CLONEOPEN flag is set (line 11), we lock the list of minor devices (line 12) and search through the list, looking for a minor device that is available (lines 13-14).  If we find an unused minor, we break off the search, mark the minor as being in use (line 20), unlock the list, create a new device number, and store it in the memory location pointed to by devp (line 22).  If no unused minor was found, we unlock the list and return the error ENXIO. 

1  xxxopen(q, devp, oflag, sflag, crp)
2queue_t ∗q;
3dev_t ∗dev;
4int oflag;
5int sflag;
6cred_t ∗crp;
7  {
8minor_t minnum;
9pl_t pl;
10extern lock_t ∗xxxminlock;
 11if (sflag == CLONEOPEN) {
12pl = LOCK(xxxminlock, plstr);
13for (minnum = 0; minnum < XXXMAXMIN; minnum++)
14if (!INUSE(minnum))
15break;
16if (minnum >= XXXMAXMIN) {
17UNLOCK(xxxminlock, pl);
18return(ENXIO);
19} else {
20SETINUSE(minnum);
21UNLOCK(xxxminlock, pl);
22∗devp = makedevice(getemajor(∗devp), minnum);
23}
24}
...

.IX \f4makedevice\fP(D3DK), example
.IX \f4getemajor\fP(D3DK), example

DDI/DKI

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026