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 #pragma ident "%Z%%M% %I% %E% SMI" /* SunOS 1.6 */ 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* 45 * Vuid input queue structure. 46 */ 47 typedef struct vuid_queue { 48 struct vuid_q_node *top; /* input queue head (first in line) */ 49 struct vuid_q_node *bottom; /* input queue head (last in line) */ 50 struct vuid_q_node *free; /* input queue free list */ 51 int num; /* number of items currently on queue */ 52 int size; /* number of items allowed on queue */ 53 } Vuid_queue; 54 #define VUID_QUEUE_NULL ((Vuid_queue *)0) 55 #define vq_used(vq) ((vq)->num) 56 #define vq_avail(vq) ((vq)->size - (vq)->num) 57 #define vq_size(vq) ((vq)->size) 58 #define vq_is_empty(vq) ((vq)->top == VUID_Q_NODE_NULL) 59 #define vq_is_full(vq) ((vq)->num == (vq)->size) 60 61 /* 62 * Vuid input queue node structure. 63 */ 64 typedef struct vuid_q_node { 65 struct vuid_q_node *next; /* Next item in queue */ 66 struct vuid_q_node *prev; /* Previous item in queue */ 67 Firm_event firm_event; /* Firm event */ 68 } Vuid_q_node; 69 #define VUID_Q_NODE_NULL ((Vuid_q_node *)0) 70 71 /* 72 * Vuid input queue status codes. 73 */ 74 typedef enum vuid_q_code { 75 VUID_Q_OK = 0, /* OK */ 76 VUID_Q_OVERFLOW = 1, /* overflow */ 77 VUID_Q_EMPTY = 2 /* empty */ 78 } Vuid_q_code; 79 80 extern void vq_initialize(); /* (Vuid_queue *vq, caddr_t data, uint_t bytes) */ 81 /* Client allocates bytes worth of storage */ 82 /* and pass in a data. Client destroys the q */ 83 /* simply by releasing data. */ 84 extern Vuid_q_code vq_put(); /* (Vuid_queue *vq, Firm_event *firm_event) */ 85 /* Place firm_event on queue, position is */ 86 /* dependent on the firm event's time. Can */ 87 /* return VUID_Q_OVERFLOW if no more room. */ 88 extern Vuid_q_code vq_get(); /* (Vuid_queue *vq, Firm_event *firm_event) */ 89 /* Place event on top of queue in firm_event. */ 90 /* Can return VUID_Q_EMPTY if no more events */ 91 extern Vuid_q_code vq_peek(); /* Like vq_get but doesn't remove from queue */ 92 extern Vuid_q_code vq_putback(); /* (Vuid_queue *vq, Firm_event *firm_event) */ 93 /* Push firm_event on top of queue. Can */ 94 /* return VUID_Q_OVERFLOW if no more room. */ 95 96 extern int vq_compress(); /* (Vuid_queue *vq, factor) Try to */ 97 /* collapse the queue to a size of 1/factor */ 98 /* by squeezing like valuator events together */ 99 /* Returns number collapsed */ 100 extern int vq_is_valuator(); /* (Vuid_q_node *vqn) if value is not 0 or 1 */ 101 /* || pair_type is FE_PAIR_DELTA or */ 102 /* FE_PAIR_ABSOLUTE */ 103 extern void vq_delete_node(); /* (Vuid_queue *vq, Vuid_q_node *vqn) */ 104 /* Deletes vqn from vq */ 105 106 #ifdef __cplusplus 107 } 108 #endif 109 110 #endif /* _SYS_VUID_QUEUE_H */ 111