Home | History | Annotate | Download | only in xuctblgen
      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 (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 /*
     22  * Copyright (c) 1996, 2001 by Sun Microsystems, Inc.
     23  * All rights reserved.
     24  */
     25 
     26 #ifndef	LOOKUP_TBL_H
     27 #define	LOOKUP_TBL_H
     28 
     29 #pragma	ident	"@(#)lookup_tbl.h	1.8 01/10/16 SMI"
     30 
     31 #include <stdio.h>
     32 #include <sys/types.h>
     33 #include <sys/isa_defs.h>
     34 
     35 
     36 /* structures */
     37 typedef struct _LookupTableEntry {
     38 	unsigned long	offset;
     39 	int	target_byte;
     40 	void	*cs_entry;
     41 	int	entry_unit;
     42 	void	*entry;
     43 } LookupTableEntry;
     44 
     45 typedef struct _LookupTable {
     46 	int	src_size;
     47 	int	dst_size;
     48 	boolean_t	cs_on;
     49 	int	tbl_ptr;
     50 	int	length;
     51 	int	alloc_len;
     52 	int	alloc_unit;
     53 	char	table_type;
     54 	LookupTableEntry	*tbl_list;
     55 	CARD8	*vector;
     56 } LookupTable;
     57 
     58 #ifdef	_BIG_ENDIAN
     59 typedef struct _lookup_size_type_t {
     60 	CARD32	size	:24;
     61 	CARD32	type	:8;
     62 } lookup_size_type_t;
     63 #else
     64 typedef struct _lookup_size_type_t {
     65 	CARD32	type	:8;
     66 	CARD32	size	:24;
     67 } lookup_size_type_t;
     68 #endif	/* _BIG_ENDIAN */
     69 
     70 /*
     71  * Since the "size" from the lookup_size_type_t is a 24-bit unsigned unit,
     72  * the maximum value that the "size" can have is pow(2, 24) - 1.
     73  */
     74 #define	LOOKUP_MAX_SIZE			(16777215)
     75 
     76 /*
     77  * The following values are to identify the table type, esp., at table_type
     78  * data field of LookupTable data structure at above.
     79  *
     80  * When U8_TABLE_TYPE_TRIE is specified, the data structure will be in
     81  * Trie data structure at "tbl_list" data field.
     82  * When U8_TABLE_TYPE_VECTOR is specified, the data structure will be in
     83  * a Vector data structure at "vector" data field. The "length" will
     84  * be the number of components in the vector and the "alloc_len" will
     85  * have allocated memory block size.
     86  */
     87 #define	U8_TABLE_TYPE_NOT_DEFINED	0
     88 #define	U8_TABLE_TYPE_TRIE		1
     89 #define	U8_TABLE_TYPE_VECTOR		2
     90 #define	U8_TABLE_TYPE_MAX_VALUE		U8_TABLE_TYPE_VECTOR
     91 
     92 
     93 /* public functions */
     94 LookupTable *LookupTable_create(int src_size, int dst_size, boolean_t cs_on,
     95 		char tbl_type);
     96 int LookupTable_add(LookupTable *lookup, unsigned long src, unsigned long dst,
     97 		int cs, int cs_length);
     98 int LookupTable_save(LookupTable *lookup, int fd);
     99 void LookupTable_destroy(LookupTable *lookup);
    100 
    101 
    102 #endif	/* LOOKUP_TBL_H */
    103