xref: /onnv-gate/usr/src/uts/common/sys/vuid_queue.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright (c) 1985,1997-1998 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate  * All rights reserved.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*
28*0Sstevel@tonic-gate  * This file describes a virtual user input device (vuid) event queue
29*0Sstevel@tonic-gate  * maintainence package (see ../sundev/vuid_event.h for a description
30*0Sstevel@tonic-gate  * of what vuid is).  This header file defines the interface that a
31*0Sstevel@tonic-gate  * client of this package sees.	 This package is used to maintain queues
32*0Sstevel@tonic-gate  * of firm events awaiting deliver to some consumer.
33*0Sstevel@tonic-gate  */
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #ifndef _SYS_VUID_QUEUE_H
36*0Sstevel@tonic-gate #define	_SYS_VUID_QUEUE_H
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SunOS 1.6 */
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #ifdef	__cplusplus
41*0Sstevel@tonic-gate extern "C" {
42*0Sstevel@tonic-gate #endif
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate /*
45*0Sstevel@tonic-gate  * Vuid input queue structure.
46*0Sstevel@tonic-gate  */
47*0Sstevel@tonic-gate typedef struct	vuid_queue {
48*0Sstevel@tonic-gate 	struct	vuid_q_node *top;	/* input queue head (first in line) */
49*0Sstevel@tonic-gate 	struct	vuid_q_node *bottom;	/* input queue head (last in line) */
50*0Sstevel@tonic-gate 	struct	vuid_q_node *free;	/* input queue free list */
51*0Sstevel@tonic-gate 	int	num;			/* number of items currently on queue */
52*0Sstevel@tonic-gate 	int	size;			/* number of items allowed on queue */
53*0Sstevel@tonic-gate } Vuid_queue;
54*0Sstevel@tonic-gate #define	VUID_QUEUE_NULL ((Vuid_queue *)0)
55*0Sstevel@tonic-gate #define	vq_used(vq) ((vq)->num)
56*0Sstevel@tonic-gate #define	vq_avail(vq) ((vq)->size - (vq)->num)
57*0Sstevel@tonic-gate #define	vq_size(vq) ((vq)->size)
58*0Sstevel@tonic-gate #define	vq_is_empty(vq) ((vq)->top == VUID_Q_NODE_NULL)
59*0Sstevel@tonic-gate #define	vq_is_full(vq) ((vq)->num == (vq)->size)
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate /*
62*0Sstevel@tonic-gate  * Vuid input queue node structure.
63*0Sstevel@tonic-gate  */
64*0Sstevel@tonic-gate typedef struct	vuid_q_node {
65*0Sstevel@tonic-gate 	struct	vuid_q_node *next;	/* Next item in queue */
66*0Sstevel@tonic-gate 	struct	vuid_q_node *prev;	/* Previous item in queue */
67*0Sstevel@tonic-gate 	Firm_event firm_event;		/* Firm event */
68*0Sstevel@tonic-gate } Vuid_q_node;
69*0Sstevel@tonic-gate #define	VUID_Q_NODE_NULL	((Vuid_q_node *)0)
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate /*
72*0Sstevel@tonic-gate  * Vuid input queue status codes.
73*0Sstevel@tonic-gate  */
74*0Sstevel@tonic-gate typedef enum	vuid_q_code {
75*0Sstevel@tonic-gate 	VUID_Q_OK = 0,		/* OK */
76*0Sstevel@tonic-gate 	VUID_Q_OVERFLOW = 1,	/* overflow */
77*0Sstevel@tonic-gate 	VUID_Q_EMPTY = 2	/* empty */
78*0Sstevel@tonic-gate } Vuid_q_code;
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate extern	void vq_initialize(); /* (Vuid_queue *vq, caddr_t data, uint_t bytes) */
81*0Sstevel@tonic-gate 				/* Client allocates bytes worth of storage */
82*0Sstevel@tonic-gate 				/* and pass in a data. Client destroys the q */
83*0Sstevel@tonic-gate 				/* simply by releasing data. */
84*0Sstevel@tonic-gate extern	Vuid_q_code vq_put();	/* (Vuid_queue *vq, Firm_event *firm_event) */
85*0Sstevel@tonic-gate 				/* Place firm_event on queue, position is */
86*0Sstevel@tonic-gate 				/* dependent on the firm event's time.	Can */
87*0Sstevel@tonic-gate 				/* return VUID_Q_OVERFLOW if no more room. */
88*0Sstevel@tonic-gate extern	Vuid_q_code vq_get();	/* (Vuid_queue *vq, Firm_event *firm_event) */
89*0Sstevel@tonic-gate 				/* Place event on top of queue in firm_event. */
90*0Sstevel@tonic-gate 				/* Can return VUID_Q_EMPTY if no more events */
91*0Sstevel@tonic-gate extern	Vuid_q_code vq_peek();	/* Like vq_get but doesn't remove from queue */
92*0Sstevel@tonic-gate extern	Vuid_q_code vq_putback(); /* (Vuid_queue *vq, Firm_event *firm_event) */
93*0Sstevel@tonic-gate 				/* Push firm_event on top of queue.  Can */
94*0Sstevel@tonic-gate 				/* return VUID_Q_OVERFLOW if no more room. */
95*0Sstevel@tonic-gate 
96*0Sstevel@tonic-gate extern	int vq_compress();	/* (Vuid_queue *vq, factor)  Try to */
97*0Sstevel@tonic-gate 				/* collapse the queue to a size of 1/factor */
98*0Sstevel@tonic-gate 				/* by squeezing like valuator events together */
99*0Sstevel@tonic-gate 				/* Returns number collapsed */
100*0Sstevel@tonic-gate extern	int vq_is_valuator();	/* (Vuid_q_node *vqn) if value is not 0 or 1 */
101*0Sstevel@tonic-gate 				/* || pair_type is FE_PAIR_DELTA or */
102*0Sstevel@tonic-gate 				/* FE_PAIR_ABSOLUTE */
103*0Sstevel@tonic-gate extern	void vq_delete_node();	/* (Vuid_queue *vq, Vuid_q_node *vqn) */
104*0Sstevel@tonic-gate 				/* Deletes vqn from vq */
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate #ifdef	__cplusplus
107*0Sstevel@tonic-gate }
108*0Sstevel@tonic-gate #endif
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate #endif	/* _SYS_VUID_QUEUE_H */
111