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