1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 /*
  27  * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
  28  */
  29 
  30 #ifndef _SYS_DDI_TIMER_H
  31 #define _SYS_DDI_TIMER_H
  32 
  33 #include <sys/list.h>
  34 #include <sys/taskq_impl.h>
  35 #include <sys/cyclic.h>
  36 
  37 #ifdef  __cplusplus
  38 extern "C" {
  39 #endif
  40 
  41 #ifdef _KERNEL
  42 
  43 /*
  44  * Used by the new timeout functions
  45  */
  46 typedef struct __timeout *timeout_t;
  47 
  48 typedef enum ddi_periodic_flags {
  49         DPF_DISPATCHED = 0x01,
  50         DPF_EXECUTING = 0x02,
  51         DPF_CANCELLED = 0x04
  52 } ddi_periodic_flags_t;
  53 
  54 typedef struct ddi_periodic_impl {
  55         struct list_node dpr_link; /* protected by periodics_lock */
  56         struct list_node dpr_softint_link; /* only used when DPF_DISPATCHED */
  57         id_t dpr_id;
  58         hrtime_t dpr_interval;
  59 
  60         kmutex_t dpr_lock;
  61         kcondvar_t dpr_cv;
  62         ddi_periodic_flags_t dpr_flags;
  63         uint_t dpr_level; /* 0 <= dpr_level <= 10 */
  64         taskq_ent_t dpr_taskq_ent; /* only used for level of 0 */
  65         uint64_t dpr_fire_count;
  66 
  67         cyclic_id_t dpr_cyclic_id;
  68 
  69         void (*dpr_handler)(void *);
  70         void *dpr_arg;
  71 } ddi_periodic_impl_t;
  72 
  73 /*
  74  * Internal implementation functions for the DDI periodic interface.
  75  */
  76 void ddi_periodic_init(void);
  77 void ddi_periodic_softintr(int level);
  78 timeout_t i_timeout(void (*)(void *), void *, hrtime_t, int);
  79 void i_untimeout(timeout_t);
  80 
  81 #endif  /* _KERNEL */
  82 
  83 #ifdef  __cplusplus
  84 }
  85 #endif
  86 
  87 #endif  /* _SYS_DDI_TIMER_H */