MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Kernel Functions for Drivers                 ddilogsysevent(9F)



NAME
     ddilogsysevent - log system event for drivers

SYNOPSIS
     #include 
     #include 



     int ddilogsysevent(devinfot *dip, char *vendor,
          char *class, char *subclass, nvlistt *attrlist,
          syseventidt *eidp, int sleepflag);


INTERFACE LEVEL
     Solaris DI specific (Solaris DI).

PARAMETERS
     dip           A  pointer  to  the  devinfo  node  for  this
                   driver.


     vendor        A pointer to a  string  defining  the  vendor.
                   Third-party drivers should use their company's
                   stock symbol (or similarly  enduring  identif-
                   ier).    Sun-supplied   drivers   should   use
                   DIVENDORSUNW.


     class         A pointer  to  a  string  defining  the  event
                   class.


     subclass      A pointer to a string defining the event  sub-
                   class.


     attrlist     A pointer to an nvlistt,  listing  the  name-
                   value  attributes associated with the event or
                   NUL if there are no such attributes for  this
                   event.


     eidp          The address of a  syseventidt  structure  in
                   which  the  event's sequence number and times-
                   tamp are returned if the event is successfully
                   queued. May be NUL if this information is not
                   of interest. See below for the  definition  of
                   syseventidt.






SunOS 5.11          Last change: 16 Jan 2006                    1






Kernel Functions for Drivers                 ddilogsysevent(9F)



     sleepflag    Indicates how a caller  wants  to  handle  the
                   possibility  of resources not being available.
                   If sleepflag is DINOSLEP, the caller  does
                   not  care if the allocation fails or the queue
                   is full and can  handle  a  failure  appropri-
                   ately.  If sleepflag is DISLEP, the caller
                   wishes to have the allocation and queuing rou-
                   tines wait for resources to become available.


DESCRIPTION
     The ddilogsysevent() function causes a  system  event,  of
     the  specified class and subclass, to be generated on behalf
     of the driver and queued  for  delivery  to  syseventd,  the
     user-land sysevent daemon.


     The publisher string for the event is constructed using  the
     vendor name and driver name, with the format:

       ":kern:"




     The two fields of eidp, eidseq and eidts,  are  sufficient
     to uniquely identify an event.

STRUCTURE MEMBERS
     The structure members of syseventidt are:

            uint64t   eidseq;        /* sysevent sequence number */
            hrtimet   eidts;         /* sysevent timestamp */


RETURN VALUES
     The ddilogsysevent() function returns:

     DISUCES       The event has  been  queued  for  delivery
                       successfully.


     DIENOMEM        There is not enough memory  to  queue  the
                       system event at this time. DIENOMEM can-
                       not  be  returned   when   sleepflag   is
                       DISLEP.


     DIEBUSY         The system event queue  is  full  at  this
                       time.  DIEBUSY  cannot  be returned when
                       sleepflag is DISLEP.




SunOS 5.11          Last change: 16 Jan 2006                    2






Kernel Functions for Drivers                 ddilogsysevent(9F)



     DIETRANSPORT    The syseventd daemon is not responding and
                       events  cannot  be  queued or delivered at
                       this time. DIETRANSPORT can be  returned
                       even when sleepflag is DISLEP.


     DIECONTEXT      sleepflag is DISLEP and the driver  is
                       running in interrupt context.



     ddilogsysevent supports the following data types:
       DATATYPEBYTE
       DATATYPEINT16
       DATATYPEUINT16
       DATATYPEINT32
       DATATYPEUINT32
       DATATYPEINT64
       DATATYPEUINT64
       DATATYPESTRING
       DATATYPEBYTEARAY
       DATATYPEINT16ARAY
       DATATYPEUINT16ARAY
       DATATYPEINT32ARAY
       DATATYPEUINT32ARAY
       DATATYPEINT64ARAY
       DATATYPEUINT64ARAY

CONTEXT
     The ddilogsysevent() function can  be  called  from  user,
     interrupt,  or  kernel  context,  except  when sleepflag is
     DISLEP, in which case it cannot be called from  interrupt
     context.

EXAMPLES
     Example 1 Logging System Event with No Attributes

           if (ddilogsysevent(dip, DIVENDORSUNW, "class", "subclass",
               NUL, NUL, DISLEP) != DISUCES) {
               cmnerr(CEWARN, "error logging system event\n");
           }


     Example 2 Logging System Event with  Two  Name/Value  Attri-
     butes, an Integer and a String

       nvlistt    *attrlist;
       syseventidt   eid;

       if (nvlistalloc(&attrlist, NVUNIQUENAMETYPE, KMSLEP) == 0)
       {
           err = nvlistadduint32(attrlist, intname, intvalue);



SunOS 5.11          Last change: 16 Jan 2006                    3






Kernel Functions for Drivers                 ddilogsysevent(9F)



           if (err == 0)
               err = nvlistaddstring(attrlist, strname, strvalue);
           if (err == 0)
               err = ddilogsysevent(dip, DIVENDORSUNW,
                 "class", "subclass", attrlist, &eid, DISLEP);
           if (err != DISUCES)
               cmnerr(CEWARN, "error logging system event\n");
           nvlistfree(attrlist);
           }


     Example 3 Use Timeout to  Handle  nvlist  and  System  Event
     Resource Allocation Failures


     Since no blocking calls are made, this example would be use-
     able  from a driver needing to generate an event from inter-
     rupt context.


       static int
           xxsetimeouthandler(xxstatet *xx)
           {
               xx->xxtimeoutid = (xxgenerateevent(xx) ?
                   timeout(xxsetimeouthandler, xx, 4) : 0);
           }

           static int
           xxgenerateevent(xxstatet *xx)
           {
               int err;

               err = nvlistalloc(&xx->xxevattrlist, NVUNIQUENAMETYPE, 0);
               if (err != 0)
                   return (1);
               err = nvlistadduint32(&xx->xxevattrlist,
                   xx->xxevname, xx->xxevvalue);
               if (err != 0) {
                   nvlistfree(xx->xxevattrlist);
                   return(1);
               }

               err = ddilogsysevent(xx->xxdip, DIVENDORSUNW,
                   xx->xxevclass, xx->xxevsbclass,
                   xx->xxevattrlist, NUL, DINOSLEP);
               nvlistfree(xx->xxevattrlist);
               if (err == DISUCES  err == DIETRANSPORT) {
                   if (err == DIETRANSPORT)
                       cmnerr(CEWARN, "cannot log system event\n");
                   return (0);
               }
               return (1);



SunOS 5.11          Last change: 16 Jan 2006                    4






Kernel Functions for Drivers                 ddilogsysevent(9F)



           }


SEE ALSO
     syseventd(1M),    attributes(5),     nvlistaddboolean(9F),
     nvlistalloc(9F)


     Writing Device Drivers














































SunOS 5.11          Last change: 16 Jan 2006                    5



OpenSolaris man pages main menu

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