MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Kernel Functions for Drivers                         ddipeek(9F)



NAME
     ddipeek,  ddipeek8,  ddipeek16,  ddipeek32,  ddipeek64,
     ddipeekc,  ddipeeks,  ddipeekl,  ddipeekd - read a value
     from a location

SYNOPSIS
     #include 
     #include 



     int ddipeek8(devinfot *dip, int8t *addr, int8t *valuep);


     int ddipeek16(devinfot *dip, int16t *addr, int16t *valuep);


     int ddipeek32(devinfot *dip, int32t *addr, int32t *valuep);


     int ddipeek64(devinfot *dip, int64t *addr, int64t *valuep);


INTERFACE LEVEL
     Solaris  DI  specific  (Solaris  DI).   The   ddipeekc(),
     ddipeeks(),  ddipeekl(),  and  ddipeekd()  functions  are
     obsolete.  Use,  respectively,  ddipeek8(),   ddipeek16(),
     ddipeek32(), and ddipeek64(), instead.

PARAMETERS
     dip       A pointer to the device's devinfo structure.


     addr      Virtual address of the location to be examined.


     valuep    Pointer to a location to hold  the  result.  If  a
               null  pointer  is  specified,  then the value read
               from the location will simply be discarded.


DESCRIPTION
     These routines cautiously attempt to read  a  value  from  a
     specified  virtual  address,  and  return  the  value to the
     caller, using the parent nexus driver to assist in the  pro-
     cess where necessary.


     If the address is not valid, or the  value  cannot  be  read
     without an error occurring, an error code is returned.





SunOS 5.11          Last change: 16 Jan 2006                    1






Kernel Functions for Drivers                         ddipeek(9F)



     The routines are most useful when first trying to  establish
     the  presence  of  a  device  on  the  system  in a driver's
     probe(9E) or attach(9E) routines.

RETURN VALUES
     DISUCES    The value at the given  virtual  address  was
                    successfully read, and if valuep is non-null,
                    *valuep will have been updated.


     DIFAILURE    An error occurred while trying  to  read  the
                    location. *valuep is unchanged.


CONTEXT
     These functions can be called from user, interrupt, or  ker-
     nel context.

EXAMPLES
     Example 1 Checking to see that the status register of a dev-
     ice is mapped into the kernel address space:

       if (ddipeek8(dip, csr, (int8t *)0) != DISUCES) {
               cmnerr(CEWARN, "Status register not mapped");
               return (DIFAILURE);
       }


     Example 2 Reading and logging the device type of a  particu-
     lar device:

       int
       xxattach(devinfot *dip, ddiattachcmdt cmd)
       {
              ...
             /* map device registers */
              ...

             if (ddipeek32(dip, idaddr, &idvalue) != DISUCES) {
                     cmnerr(CEWARN, "%s%d: cannot read device identifier",
                       ddigetname(dip), ddigetinstance(dip));
                     goto failure;
             } else
                     cmnerr(CECONT, "!%s%d: device type 0x%x\n",
                       ddigetname(dip), ddigetinstance(dip), idvalue);
                  ...
                  ...

             ddireportdev(dip);
             return (DISUCES);

       failure:



SunOS 5.11          Last change: 16 Jan 2006                    2






Kernel Functions for Drivers                         ddipeek(9F)



             /* free any resources allocated */
             ...
             return (DIFAILURE);
       }


SEE ALSO
     attach(9E), probe(9E), ddipoke(9F)


     Writing Device Drivers

NOTES
     The functions described in this manual page previously  used
     symbolic  names  which specified their data access size; the
     function names have been  changed  so  they  now  specify  a
     fixed-width  data  size. See the following table for the new
     name equivalents:



     
     Previous Name                 New Name                    
     ddipeekc                     ddipeek8                   
     ddipeeks                     ddipeek16                  
     ddipeekl                     ddipeek32                  
     ddipeekd                     ddipeek64                  
    



























SunOS 5.11          Last change: 16 Jan 2006                    3



OpenSolaris man pages main menu

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