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