1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * (C) Copyright IBM Corporation 2005, 2006 3*4882a593Smuzhiyun * All Rights Reserved. 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a 6*4882a593Smuzhiyun * copy of this software and associated documentation files (the "Software"), 7*4882a593Smuzhiyun * to deal in the Software without restriction, including without limitation 8*4882a593Smuzhiyun * the rights to use, copy, modify, merge, publish, distribute, sub license, 9*4882a593Smuzhiyun * and/or sell copies of the Software, and to permit persons to whom the 10*4882a593Smuzhiyun * Software is furnished to do so, subject to the following conditions: 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * The above copyright notice and this permission notice (including the next 13*4882a593Smuzhiyun * paragraph) shall be included in all copies or substantial portions of the 14*4882a593Smuzhiyun * Software. 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19*4882a593Smuzhiyun * IBM, 20*4882a593Smuzhiyun * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21*4882a593Smuzhiyun * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22*4882a593Smuzhiyun * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23*4882a593Smuzhiyun * SOFTWARE. 24*4882a593Smuzhiyun */ 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun /** 27*4882a593Smuzhiyun * \file indirect_table.h 28*4882a593Smuzhiyun * 29*4882a593Smuzhiyun * \author Ian Romanick <idr@us.ibm.com> 30*4882a593Smuzhiyun */ 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun #ifndef INDIRECT_TABLE_H 33*4882a593Smuzhiyun #define INDIRECT_TABLE_H 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun #include <inttypes.h> 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun /** 38*4882a593Smuzhiyun */ 39*4882a593Smuzhiyun struct __glXDispatchInfo { 40*4882a593Smuzhiyun /** 41*4882a593Smuzhiyun * Number of significant bits in the protocol opcode. Opcodes with values 42*4882a593Smuzhiyun * larger than ((1 << bits) - 1) are invalid. 43*4882a593Smuzhiyun */ 44*4882a593Smuzhiyun unsigned bits; 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun /** 47*4882a593Smuzhiyun */ 48*4882a593Smuzhiyun const int_fast16_t *dispatch_tree; 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun /** 51*4882a593Smuzhiyun * Array of protocol decode and dispatch functions index by the opcode 52*4882a593Smuzhiyun * search tree (i.e., \c dispatch_tree). The first element in each pair 53*4882a593Smuzhiyun * is the non-byte-swapped version, and the second element is the 54*4882a593Smuzhiyun * byte-swapped version. 55*4882a593Smuzhiyun */ 56*4882a593Smuzhiyun const void *(*dispatch_functions)[2]; 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /** 59*4882a593Smuzhiyun * Pointer to size validation data. This table is indexed with the same 60*4882a593Smuzhiyun * value as ::dispatch_functions. 61*4882a593Smuzhiyun * 62*4882a593Smuzhiyun * The first element in the pair is the size, in bytes, of the fixed-size 63*4882a593Smuzhiyun * portion of the protocol. 64*4882a593Smuzhiyun * 65*4882a593Smuzhiyun * For opcodes that have a variable-size portion, the second value is an 66*4882a593Smuzhiyun * index in \c size_func_table to calculate that size. If there is no 67*4882a593Smuzhiyun * variable-size portion, this index will be ~0. 68*4882a593Smuzhiyun * 69*4882a593Smuzhiyun * \note 70*4882a593Smuzhiyun * If size checking is not to be performed on this type of protocol 71*4882a593Smuzhiyun * data, this pointer will be \c NULL. 72*4882a593Smuzhiyun */ 73*4882a593Smuzhiyun const int_fast16_t(*size_table)[2]; 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /** 76*4882a593Smuzhiyun * Array of functions used to calculate the variable-size portion of 77*4882a593Smuzhiyun * protocol messages. Indexed by the second element of the entries 78*4882a593Smuzhiyun * in \c ::size_table. 79*4882a593Smuzhiyun * 80*4882a593Smuzhiyun * \note 81*4882a593Smuzhiyun * If size checking is not to be performed on this type of protocol 82*4882a593Smuzhiyun * data, this pointer will be \c NULL. 83*4882a593Smuzhiyun */ 84*4882a593Smuzhiyun const gl_proto_size_func *size_func_table; 85*4882a593Smuzhiyun }; 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun /** 88*4882a593Smuzhiyun * Sentinel value for an empty leaf in the \c dispatch_tree. 89*4882a593Smuzhiyun */ 90*4882a593Smuzhiyun #define EMPTY_LEAF INT_FAST16_MIN 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun /** 93*4882a593Smuzhiyun * Declare the index \c x as a leaf index. 94*4882a593Smuzhiyun */ 95*4882a593Smuzhiyun #define LEAF(x) -x 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun /** 98*4882a593Smuzhiyun * Determine if an index is a leaf index. 99*4882a593Smuzhiyun */ 100*4882a593Smuzhiyun #define IS_LEAF_INDEX(x) ((x) <= 0) 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun extern const struct __glXDispatchInfo Single_dispatch_info; 103*4882a593Smuzhiyun extern const struct __glXDispatchInfo Render_dispatch_info; 104*4882a593Smuzhiyun extern const struct __glXDispatchInfo VendorPriv_dispatch_info; 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun #endif /* INDIRECT_TABLE_H */ 107