MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Driver Entry Points                                devmapmap(9E)



NAME
     devmapmap - device mapping create entry point

SYNOPSIS
     #include 
     #include 



     int prefixdevmapmap(devmapcookiet dhp, devt dev,
          uintt flags, offsett off, sizet len, void **pvtp);


INTERFACE LEVEL
     Solaris DI specific (Solaris DI).

ARGUMENTS
     dhp       An opaque mapping handle that the system  uses  to
               describe the mapping currently being created.


     dev       The device whose memory is to be mapped.


     flags     Flags indicating type of mapping. Possible  values
               are:

               MAPRIVATE     Changes are private.


               MAPSHARED      Changes should be shared.



     off       User offset within the logical  device  memory  at
               which the mapping begins.


     len       Length (in bytes) of the memory to be mapped.


     pvtp      A pointer to be filled in by device  drivers  with
               the driver private mapping data.


DESCRIPTION
     The devmapmap() entry point is  an  optional  routine  that
     allows  drivers to perform additional processing or to allo-
     cate private resources during the mapping setup  time.   For
     example,  in  order  for  device  drivers to support context
     switching, the drivers allocate  private  mapping  data  and
     associate  the  private  data with the mapping parameters in



SunOS 5.11           Last change: 7 Jan 1997                    1






Driver Entry Points                                devmapmap(9E)



     the devmapmap() entry point.


     The system calls devmapmap() after the user mapping to dev-
     ice  physical  memory  has  been  established. (For example,
     after the  devmap(9E) entry point is called.)


     devmapmap() receives a pointer to the driver  private  data
     for  this  mapping in pvtp. The system expects the driver to
     allocate its private data and set  *pvtp  to  the  allocated
     data.   The  driver must store off and len, which define the
     range of the mapping, in its private data.  Later, when  the
     system  calls  devmapunmap(9E), the driver will use the off
     and  len stored in pvtp to check if the entire  mapping,  or
     just  a part of it, is being unmapped. If only a part of the
     mapping is being unmapped, the driver must allocate   a  new
     private  data  for  the remaining mapping before freeing the
     old private data.  The driver will receive *pvtp  in  subse-
     quent event notification callbacks.


     If the driver support context switching,   it  should  store
     the  mapping handle  dhp in its private data *pvtp for later
     use in devmapunload(9F).


     For a driver that supports context  switching,  flags  indi-
     cates  whether  or  not the driver should allocate a private
     context  for the mapping.  For example, a driver  may  allo-
     cate a memory region to store the device context if flags is
     set to  MAPRIVATE.

RETURN VALUES
     devmapmap() returns the following values:

     0           Successful completion.


     Non-zero    An error occurred.


EXAMPLES
     Example 1  devmapmap()implementation


     The  following   shows   an   example   implementation   for
     devmapmap().


       static int
       xxdevmapmap(devmapcookiet dhp, devt dev, uintt flags, \



SunOS 5.11           Last change: 7 Jan 1997                    2






Driver Entry Points                                devmapmap(9E)



            offsett off,sizet len, void **pvtp)
       {
            struct xxresources  *pvt;
            struct xxcontext *thiscontext;
            struct xxsoftc *softc;
            softc = ddigetsoftstate(statep, getminor(dev));

            thiscontext = getcontext(softc, off, len);

            /* allocate resources for the mapping  - Device dependent */
            pvt = kmemzalloc(sizeof (struct xxresources), KMSLEP);

            pvt->off = off;
            pvt->len = len;
            pvt->dhp = dhp;
            pvt->ctx = thiscontext;
            *pvtp = pvt;
       }


SEE ALSO
     devmapunmap(9E), devmapunload(9F), devmapcallbackctl(9S)


     Writing Device Drivers






























SunOS 5.11           Last change: 7 Jan 1997                    3



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™