MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Kernel Functions for Drivers                ddidevisneeded(9F)



NAME
     ddidevisneeded - inform the system that a  device's  com-
     ponent is required

SYNOPSIS
     #include 
     #include 



     int ddidevisneeded(devinfot *dip, int component, int level);


INTERFACE LEVEL
     Solaris DI specific (Solaris DI)

PARAMETERS
     dip          Pointer to the device's devinfo structure.


     component    Component of the driver which is needed.


     level        Power level at which the component is needed.


DESCRIPTION
     The ddidevisneeded() function is  obsolete  and  will  be
     removed  in  a future release. It is recommended that device
     drivers use pmraisepower(9F) and pmlowerpower(9F).


     The ddidevisneeded() function informs the system  that  a
     device component is needed at the specified power level. The
     level argument must be non-zero.


     This function sets a component to  the  required  level  and
     sets  all devices which depend on this to their normal power
     levels.


     The state of the device should be examined before each  phy-
     sical  access.  The  ddidevisneeded()  function should be
     called to set a component to the required power level if the
     operation  to be performed requires the component to be at a
     power level other than its current level.


     The ddidevisneeded() function might cause re-entry of the
     driver.  Deadlock may result if driver locks are held across
     the call to ddidevisneeded().



SunOS 5.11           Last change: 7 Dec 2003                    1






Kernel Functions for Drivers                ddidevisneeded(9F)



RETURN VALUES
     The ddidevisneeded() function returns:

     DISUCES    Power  successfully  set  to  the   requested
                    level.


     DIFAILURE    An error occurred.


EXAMPLES
     Example 1 disk driver code


     A hypothetical disk driver might include this code:


            static int
       xxdiskspundown(struct xxstate *xsp)
       {
                 return (xsp->powerlevel[DISKCOMPONENT] < POWERSPUNUP);
       }
       static int
       xxdiskstrategy(struct buf *bp)
       {

       ...

            mutexenter(&xxstatelock);
            /*
            * Since we have to drop the mutex, we have to do this in a loop
            * in case we get preempted and the device gets taken away from
            * us again
            */
            while (devicespundown(sp)) {
                 mutexexit(&xxstatelock);
                 if (ddidevisneeded(xsp->mydip,
                      XDISKCOMPONENT, XPOWERSPUNUP) != DISUCES) {
                           bioerror(bp,EIO);
                           biodone(bp);
                 return (0);
            }
                 mutexenter(&xxstatelock);
            }
            xsp->devicebusy];
            mutexexit(&xxstatelock);

       ...

       }





SunOS 5.11           Last change: 7 Dec 2003                    2






Kernel Functions for Drivers                ddidevisneeded(9F)



CONTEXT
     This function can be called from user or kernel context.

ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Interface Stability          Obsolete                    
    


SEE ALSO
     pm(7D),    pm-components(9P),    attach(9E),     detach(9E),
     power(9E), pmbusycomponent(9F), pmidlecomponent(9F)


     Writing Device Drivers

































SunOS 5.11           Last change: 7 Dec 2003                    3



OpenSolaris man pages main menu

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