10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1278Shx147065 * Common Development and Distribution License (the "License"). 6*1278Shx147065 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1278Shx147065 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _CIS_H 270Sstevel@tonic-gate #define _CIS_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * This is the Card Services Card Information Structure (CIS) interpreter 330Sstevel@tonic-gate * header file. CIS information in this file is based on the 340Sstevel@tonic-gate * Release 2.01 PCMCIA standard. 350Sstevel@tonic-gate */ 360Sstevel@tonic-gate 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate 430Sstevel@tonic-gate #if defined(DEBUG) 440Sstevel@tonic-gate #define CIS_DEBUG 450Sstevel@tonic-gate #endif 460Sstevel@tonic-gate 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * The CIS interpreter has a single entry point with a bunch of function 500Sstevel@tonic-gate * id numbers. 510Sstevel@tonic-gate */ 520Sstevel@tonic-gate #define CISP_CIS_SETUP 0x01 /* setup CS address in CIS */ 530Sstevel@tonic-gate #define CISP_CIS_LIST_CREATE 0x02 /* create the CIS linked list */ 540Sstevel@tonic-gate #define CISP_CIS_LIST_DESTROY 0x03 /* destroy the CIS linked list */ 550Sstevel@tonic-gate #define CISP_CIS_GET_LTUPLE 0x04 /* get a tuple */ 560Sstevel@tonic-gate #define CISP_CIS_PARSE_TUPLE 0x05 /* parse a tuple */ 570Sstevel@tonic-gate #define CISP_CIS_CONV_DEVSPEED 0x06 /* convert devspeed to nS and back */ 580Sstevel@tonic-gate #define CISP_CIS_CONV_DEVSIZE 0x07 /* convert device size */ 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* 610Sstevel@tonic-gate * Make the calls to CardServices look like function calls. 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate #define CIS_CARD_SERVICES (*cis_card_services) 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * define the tuples that we recognize 670Sstevel@tonic-gate * 680Sstevel@tonic-gate * Layer 1 - Basic Compatability TUples 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate #define CISTPL_NULL 0x000 /* null tuple - ignore */ 710Sstevel@tonic-gate #define CISTPL_DEVICE 0x001 /* device information */ 720Sstevel@tonic-gate #define CISTPL_LONGLINK_CB 0x002 /* longlink to next tuple chain */ 730Sstevel@tonic-gate #define CISTPL_CONFIG_CB 0x004 /* configuration tuple */ 740Sstevel@tonic-gate #define CISTPL_CFTABLE_ENTRY_CB 0x005 /* configuration table entry */ 750Sstevel@tonic-gate #define CISTPL_LONGLINK_MFC 0x006 /* multi-function tuple */ 760Sstevel@tonic-gate #define CISTPL_BAR 0x007 /* Base Address Register definition */ 770Sstevel@tonic-gate #define CISTPL_CHECKSUM 0x010 /* checksum control */ 780Sstevel@tonic-gate #define CISTPL_LONGLINK_A 0x011 /* long-link to AM */ 790Sstevel@tonic-gate #define CISTPL_LONGLINK_C 0x012 /* long-link to CM */ 800Sstevel@tonic-gate #define CISTPL_LINKTARGET 0x013 /* link-target control */ 810Sstevel@tonic-gate #define CISTPL_NO_LINK 0x014 /* no-link control */ 820Sstevel@tonic-gate #define CISTPL_VERS_1 0x015 /* level 1 version information */ 830Sstevel@tonic-gate #define CISTPL_ALTSTR 0x016 /* alternate language string */ 840Sstevel@tonic-gate #define CISTPL_DEVICE_A 0x017 /* AM device information */ 850Sstevel@tonic-gate #define CISTPL_JEDEC_C 0x018 /* JEDEC programming info for CM */ 860Sstevel@tonic-gate #define CISTPL_JEDEC_A 0x019 /* JEDEC programming info for AM */ 870Sstevel@tonic-gate #define CISTPL_CONFIG 0x01a /* configuration */ 880Sstevel@tonic-gate #define CISTPL_CFTABLE_ENTRY 0x01b /* configuration-table-entry */ 890Sstevel@tonic-gate #define CISTPL_DEVICE_OC 0x01c /* other op conditions CM device info */ 900Sstevel@tonic-gate #define CISTPL_DEVICE_OA 0x01d /* other op conditions AM device info */ 910Sstevel@tonic-gate #define CISTPL_DEVICEGEO 0x01e /* Common Memory device geometry */ 920Sstevel@tonic-gate #define CISTPL_DEVICEGEO_A 0x01f /* Attribute Memory device geometry */ 930Sstevel@tonic-gate #define CISTPL_MANFID 0x020 /* manufacturer identification */ 940Sstevel@tonic-gate #define CISTPL_FUNCID 0x021 /* function identification */ 950Sstevel@tonic-gate #define CISTPL_FUNCE 0x022 /* function extension */ 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* 980Sstevel@tonic-gate * Layer 2 - Data Recording Format Tuples 990Sstevel@tonic-gate */ 1000Sstevel@tonic-gate #define CISTPL_SWIL 0x023 /* software interleave */ 1010Sstevel@tonic-gate #define CISTPL_VERS_2 0x040 /* level 2 version information */ 1020Sstevel@tonic-gate #define CISTPL_FORMAT 0x041 /* Common Memory recording format */ 1030Sstevel@tonic-gate #define CISTPL_GEOMETRY 0x042 /* geometry */ 1040Sstevel@tonic-gate #define CISTPL_BYTEORDER 0x043 /* byte order */ 1050Sstevel@tonic-gate #define CISTPL_DATE 0x044 /* card initialization date */ 1060Sstevel@tonic-gate #define CISTPL_BATTERY 0x045 /* battery replacement date */ 1070Sstevel@tonic-gate #define CISTPL_FORMAT_A 0x047 /* Attribute Memory recording format */ 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate /* 1100Sstevel@tonic-gate * Layer 3 - Data Organization Tuples 1110Sstevel@tonic-gate */ 1120Sstevel@tonic-gate #define CISTPL_ORG 0x046 /* organization */ 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* 1150Sstevel@tonic-gate * Layer 4 - System Specific Standard Tuples 1160Sstevel@tonic-gate */ 1170Sstevel@tonic-gate #define CISTPL_VEND_SPEC_80 0x080 /* vendor-specific 0x80 */ 1180Sstevel@tonic-gate #define CISTPL_VEND_SPEC_81 0x081 /* vendor-specific 0x81 */ 1190Sstevel@tonic-gate #define CISTPL_VEND_SPEC_82 0x082 /* vendor-specific 0x82 */ 1200Sstevel@tonic-gate #define CISTPL_VEND_SPEC_83 0x083 /* vendor-specific 0x83 */ 1210Sstevel@tonic-gate #define CISTPL_VEND_SPEC_84 0x084 /* vendor-specific 0x84 */ 1220Sstevel@tonic-gate #define CISTPL_VEND_SPEC_85 0x085 /* vendor-specific 0x85 */ 1230Sstevel@tonic-gate #define CISTPL_VEND_SPEC_86 0x086 /* vendor-specific 0x86 */ 1240Sstevel@tonic-gate #define CISTPL_VEND_SPEC_87 0x087 /* vendor-specific 0x87 */ 1250Sstevel@tonic-gate #define CISTPL_VEND_SPEC_88 0x088 /* vendor-specific 0x88 */ 1260Sstevel@tonic-gate #define CISTPL_VEND_SPEC_89 0x089 /* vendor-specific 0x89 */ 1270Sstevel@tonic-gate #define CISTPL_VEND_SPEC_8a 0x08a /* vendor-specific 0x8a */ 1280Sstevel@tonic-gate #define CISTPL_VEND_SPEC_8b 0x08b /* vendor-specific 0x8b */ 1290Sstevel@tonic-gate #define CISTPL_VEND_SPEC_8c 0x08c /* vendor-specific 0x8c */ 1300Sstevel@tonic-gate #define CISTPL_VEND_SPEC_8d 0x08d /* vendor-specific 0x8d */ 1310Sstevel@tonic-gate #define CISTPL_VEND_SPEC_8e 0x08e /* vendor-specific 0x8e */ 1320Sstevel@tonic-gate #define CISTPL_VEND_SPEC_8f 0x08f /* vendor-specific 0x8f */ 1330Sstevel@tonic-gate #define CISTPL_SPCL 0x090 /* special-purpose tuple */ 1340Sstevel@tonic-gate #define CISTPL_END 0x0ff /* end-of-list tuple */ 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* 1370Sstevel@tonic-gate * Macro to check if tuple is a vendor-specific tuple. 1380Sstevel@tonic-gate */ 1390Sstevel@tonic-gate #define CISTPL_VENDSPEC_START CISTPL_VEND_SPEC_80 1400Sstevel@tonic-gate #define CISTPL_VENDSPEC_END CISTPL_VEND_SPEC_8f 1410Sstevel@tonic-gate #define CISTPL_IS_VENDOR_SPECIFIC(td) (((td) >= CISTPL_VENDSPEC_START) && \ 1420Sstevel@tonic-gate ((td) <= CISTPL_VENDSPEC_END)) 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate /* 1450Sstevel@tonic-gate * The GetFirstTuple and GetNextTuple Card Services function calls use 1460Sstevel@tonic-gate * the DesiredTuple member of the tuple_t structure to determine 1470Sstevel@tonic-gate * while tuple type to return; since the CIS parser doesn't ever 1480Sstevel@tonic-gate * return CISTPL_END tuples, we can never ask for those tuples, 1490Sstevel@tonic-gate * so we overload this tuple code to mean that we want the 1500Sstevel@tonic-gate * first (or next) tuple in the chain. 1510Sstevel@tonic-gate * XXX - If we ever do return CISTPL_END tuples, we'll have to 1520Sstevel@tonic-gate * re-think this. 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate #define RETURN_FIRST_TUPLE 0x0ff /* return first/next tuple */ 1550Sstevel@tonic-gate #define RETURN_NEXT_TUPLE 0x0ff /* return first/next tuple */ 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate /* 1580Sstevel@tonic-gate * types for data in CIS and pointers into PC card's CIS space 1590Sstevel@tonic-gate * 1600Sstevel@tonic-gate * The "size" member is used by the NEXT_CIS_ADDR macro so that 1610Sstevel@tonic-gate * we don't run past the end of the mapped CIS address space. 1620Sstevel@tonic-gate */ 1630Sstevel@tonic-gate typedef uchar_t cisdata_t; 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate typedef struct cisptr_t { 1660Sstevel@tonic-gate acc_handle_t handle; /* access handle of CIS space */ 1670Sstevel@tonic-gate uint32_t size; /* size of mapped area */ 1680Sstevel@tonic-gate uint32_t offset; /* byte offset into CIS space */ 1690Sstevel@tonic-gate /* see flag definitions for cistpl_t structure */ 1700Sstevel@tonic-gate uint32_t flags; 1710Sstevel@tonic-gate } cisptr_t; 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate /* 1740Sstevel@tonic-gate * This is the maximum length that the data portion of a tuple can be. 1750Sstevel@tonic-gate * We have to use this since the brain-damaged 2.01 PCMCIA spec 1760Sstevel@tonic-gate * specifies that you can end a CIS chain by putting a CISTPL_END 1770Sstevel@tonic-gate * in the link field of the last VALID tuple. 1780Sstevel@tonic-gate */ 1790Sstevel@tonic-gate #define CIS_MAX_TUPLE_DATA_LEN 254 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate /* 1820Sstevel@tonic-gate * This is the maximum size of the string used to describe the name 1830Sstevel@tonic-gate * of the tuple. 1840Sstevel@tonic-gate */ 1850Sstevel@tonic-gate #define CIS_MAX_TUPLE_NAME_LEN 40 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * CIS_MAX_FUNCTIONS defines the maximum number of functions that can 1890Sstevel@tonic-gate * exist on a card. 1900Sstevel@tonic-gate */ 1910Sstevel@tonic-gate #define CIS_MAX_FUNCTIONS 8 /* max number of functions per card */ 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate /* 1940Sstevel@tonic-gate * Macros to manipulate addresses and data in various CIS spaces 1950Sstevel@tonic-gate * 1960Sstevel@tonic-gate * NEXT_CIS_ADDR(cisptr_t *) increments the offset to point to the 1970Sstevel@tonic-gate * next data element in the CIS, based on what space the CIS 1980Sstevel@tonic-gate * we are reading resides in. If the resulting address would 1990Sstevel@tonic-gate * be past the end of the mapped-in area, we return NULL, 2000Sstevel@tonic-gate * otherwise the adjusted offset value is returned. Note that 2010Sstevel@tonic-gate * this only works if the "size" member specifies the maximum 2020Sstevel@tonic-gate * mapped in window size and an "offset" member value of zero 2030Sstevel@tonic-gate * refers to the first byte of the window. 2040Sstevel@tonic-gate * 2050Sstevel@tonic-gate * GET_CIS_DATA(ptr) returns the data byte at the current CIS location. 2060Sstevel@tonic-gate * 2070Sstevel@tonic-gate * GET_CIS_ADDR(tp,ptr) returns the virtual address that was saved by a 2080Sstevel@tonic-gate * call to STORE_CIS_ADDR. 2090Sstevel@tonic-gate * 2100Sstevel@tonic-gate * BAD_CIS_ADDR is a flag that should be returned by callers of NEXT_CIS_ADDR 2110Sstevel@tonic-gate * if that macro returns NULL. Note that this flag shares the same bit 2120Sstevel@tonic-gate * field definitions as the tuple handler flags defined in cis_handlers.h 2130Sstevel@tonic-gate * so check that file if you make any changes to these flags. 2140Sstevel@tonic-gate * XXX - not the best distribution of flags, I'm afraid 2150Sstevel@tonic-gate */ 2160Sstevel@tonic-gate #define NEXT_CIS_ADDR(ptr) \ 2170Sstevel@tonic-gate (((ptr->flags&CISTPLF_AM_SPACE)?(ptr->offset += 2): \ 2180Sstevel@tonic-gate (ptr->offset++)), \ 2190Sstevel@tonic-gate ((ptr->offset > ptr->size)?(NULL):ptr->offset)) 2200Sstevel@tonic-gate #define GET_CIS_DATA(ptr) csx_Get8(ptr->handle, ptr->offset) 2210Sstevel@tonic-gate #define GET_CIS_ADDR(tp) ((cisdata_t *)(uintptr_t)(tp)->offset) 2220Sstevel@tonic-gate #define BAD_CIS_ADDR 0x080000000 /* read past end of mapped CIS error */ 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate /* 2250Sstevel@tonic-gate * CIS_MEM_ALLOC(len) is used to allocate memory for our local linked 2260Sstevel@tonic-gate * CIS list; we use a macro so that the same code can be used in 2270Sstevel@tonic-gate * the kernel as well as in user space 2280Sstevel@tonic-gate * 2290Sstevel@tonic-gate * CIS_MEM_FREE(ptr) - same comment as CIS_MEM_ALLOC 2300Sstevel@tonic-gate */ 2310Sstevel@tonic-gate #if !defined(_KERNEL) 2320Sstevel@tonic-gate #ifdef CISMALLOC_DEBUG 2330Sstevel@tonic-gate #define CIS_MEM_ALLOC(len) cis_malloc((uint32_t)len) 2340Sstevel@tonic-gate #define CIS_MEM_FREE(ptr) cis_free(ptr) 2350Sstevel@tonic-gate #else 2360Sstevel@tonic-gate #define CIS_MEM_ALLOC(len) malloc((uint32_t)len) 2370Sstevel@tonic-gate #define CIS_MEM_FREE(ptr) free(ptr) 2380Sstevel@tonic-gate #endif /* CISMALLOC_DEBUG */ 2390Sstevel@tonic-gate #else 2400Sstevel@tonic-gate #define CIS_MEM_ALLOC(len) cis_malloc((uint32_t)len) 2410Sstevel@tonic-gate #define CIS_MEM_FREE(ptr) cis_free(ptr) 2420Sstevel@tonic-gate #endif 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate typedef struct cis_u_malloc_tag_t { 2450Sstevel@tonic-gate caddr_t addr; 2460Sstevel@tonic-gate uint32_t len; 2470Sstevel@tonic-gate } cis_u_malloc_tag_t; 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate /* 2500Sstevel@tonic-gate * We keep the tuples in a locally-maintained linked list. This allows 2510Sstevel@tonic-gate * us to return the tuple information at any time to a client for 2520Sstevel@tonic-gate * those cards that make their CIS inaccessible once the card is 2530Sstevel@tonic-gate * configured. 2540Sstevel@tonic-gate */ 2550Sstevel@tonic-gate typedef struct cistpl_t { 2560Sstevel@tonic-gate cisdata_t type; /* type of tuple */ 2570Sstevel@tonic-gate cisdata_t len; /* length of tuple data */ 2580Sstevel@tonic-gate cisdata_t *data; /* data in tuple */ 2590Sstevel@tonic-gate union { 2600Sstevel@tonic-gate cisdata_t *byte; /* read pointer for GET_BYTE macros */ 2610Sstevel@tonic-gate uint16_t *sword; 2620Sstevel@tonic-gate } read; 2630Sstevel@tonic-gate uint32_t flags; /* misc flags */ 2640Sstevel@tonic-gate uint32_t offset; /* CIS address offset of start of tuple */ 2650Sstevel@tonic-gate struct cistpl_t *prev; /* back pointer */ 2660Sstevel@tonic-gate struct cistpl_t *next; /* forward pointer */ 2670Sstevel@tonic-gate } cistpl_t; 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate /* 2700Sstevel@tonic-gate * Flags that are used in the cistpl_t and cisptr_t linked lists 2710Sstevel@tonic-gate */ 2720Sstevel@tonic-gate #define CISTPLF_NOERROR 0x000000000 /* no error return from handler */ 2730Sstevel@tonic-gate #define CISTPLF_UNKNOWN 0x000000001 /* unknown tuple */ 2740Sstevel@tonic-gate #define CISTPLF_REGS 0x000000002 /* tuple contains registers */ 2750Sstevel@tonic-gate #define CISTPLF_COPYOK 0x000000004 /* OK to copy tuple data */ 2760Sstevel@tonic-gate #define CISTPLF_VALID 0x000000008 /* tuple is valid */ 2770Sstevel@tonic-gate #define CISTPLF_GLOBAL_CIS 0x000000010 /* tuple from global CIS */ 2780Sstevel@tonic-gate #define CISTPLF_MF_CIS 0x000000020 /* tuple from MF CIS chain */ 2790Sstevel@tonic-gate #define CISTPLF_FROM_AM 0x000000040 /* tuple read from AM space */ 2800Sstevel@tonic-gate #define CISTPLF_FROM_CM 0x000000080 /* tuple read from CM space */ 2810Sstevel@tonic-gate #define CISTPLF_IGNORE_TUPLE 0x000000100 /* ignore this tuple */ 2820Sstevel@tonic-gate #define CISTPLF_VENDOR_SPECIFIC 0x000000200 /* vnedor-specific tuple */ 2830Sstevel@tonic-gate #define CISTPLF_LINK_INVALID 0x001000000 /* tuple link is invalid */ 2840Sstevel@tonic-gate #define CISTPLF_PARAMS_INVALID 0x002000000 /* tuple body is invalid */ 2850Sstevel@tonic-gate #define CISTPLF_AM_SPACE 0x010000000 /* this tuple is in AM space */ 2860Sstevel@tonic-gate #define CISTPLF_CM_SPACE 0x020000000 /* this tuple is in CM space */ 2870Sstevel@tonic-gate #define CISTPLF_LM_SPACE 0x040000000 /* this tuple is in local memory */ 2880Sstevel@tonic-gate #define CISTPLF_MEM_ERR 0x080000000 /* GET_BYTE macros memory error */ 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate /* 2910Sstevel@tonic-gate * Some convienience macros 2920Sstevel@tonic-gate */ 2930Sstevel@tonic-gate #define CISTPLF_SPACE_MASK (CISTPLF_AM_SPACE | CISTPLF_CM_SPACE | \ 2940Sstevel@tonic-gate CISTPLF_LM_SPACE) 2950Sstevel@tonic-gate #define CISTPLF_FROM_MASK (CISTPLF_FROM_AM | CISTPLF_FROM_CM) 2960Sstevel@tonic-gate 2970Sstevel@tonic-gate /* 2980Sstevel@tonic-gate * Values used internally on calls to cis_get_ltuple. 2990Sstevel@tonic-gate * 3000Sstevel@tonic-gate * The GET_XXX_LTUPLEF and FIND_XXX_XXX values are mutually exclusive, 3010Sstevel@tonic-gate * i.e. cis_get_ltuple can only do one of these operations per call. 3020Sstevel@tonic-gate * 3030Sstevel@tonic-gate * The other flags are bit flags and they share the flags parameter. 3040Sstevel@tonic-gate * 3050Sstevel@tonic-gate * CIS_GET_LTUPLE_IGNORE - return tuples with CISTPLF_IGNORE_TUPLE 3060Sstevel@tonic-gate * set in cistpl_t->flags 3070Sstevel@tonic-gate */ 3080Sstevel@tonic-gate #define GET_FIRST_LTUPLEF 0x000000001 /* return first tuple in list */ 3090Sstevel@tonic-gate #define GET_LAST_LTUPLEF 0x000000002 /* return last tuple in list */ 3100Sstevel@tonic-gate #define FIND_LTUPLE_FWDF 0x000000003 /* find tuple, fwd search from tp */ 3110Sstevel@tonic-gate #define FIND_LTUPLE_BACKF 0x000000004 /* find tuple, backward from tp */ 3120Sstevel@tonic-gate #define FIND_NEXT_LTUPLEF 0x000000005 /* find tuple, fwd from tp+1 */ 3130Sstevel@tonic-gate #define FIND_PREV_LTUPLEF 0x000000006 /* find tuple, backward from tp-1 */ 3140Sstevel@tonic-gate #define GET_NEXT_LTUPLEF 0x000000007 /* return next tuple in list */ 3150Sstevel@tonic-gate #define GET_PREV_LTUPLEF 0x000000008 /* return prev tuple in list */ 3160Sstevel@tonic-gate #define CIS_GET_LTUPLE_OPMASK 0x00000ffff /* mask for operation values */ 3170Sstevel@tonic-gate #define CIS_GET_LTUPLE_IGNORE 0x000010000 /* return ignored tuples */ 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate /* 3200Sstevel@tonic-gate * macros for getting various data types out of a tuple 3210Sstevel@tonic-gate * Note that due to the modem tuple using a few big-endian values, 3220Sstevel@tonic-gate * we have to support both big and little endian macros 3230Sstevel@tonic-gate * 3240Sstevel@tonic-gate * Common Memory Specific macros - these will also work for tuples in 3250Sstevel@tonic-gate * local memory 3260Sstevel@tonic-gate */ 3270Sstevel@tonic-gate #define GET_CM_BYTE(tp) (((size_t)(tp)->len >= \ 3280Sstevel@tonic-gate ((uintptr_t)(tp)->read.byte - \ 3290Sstevel@tonic-gate (uintptr_t)(tp)->data)) ? \ 3300Sstevel@tonic-gate *(tp)->read.byte++ : ((tp)->flags |= CISTPLF_MEM_ERR)) 3310Sstevel@tonic-gate #define GET_CM_LEN(tp) ((size_t)(tp)->len - \ 3320Sstevel@tonic-gate ((uintptr_t)(tp)->read.byte - \ 3330Sstevel@tonic-gate (uintptr_t)(tp)->data)) 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate /* Attribute Memory Specific macros */ 3360Sstevel@tonic-gate #define GET_AM_BYTE(tp) (((size_t)(tp)->len >= \ 3370Sstevel@tonic-gate (((uintptr_t)(tp)->read.byte - \ 3380Sstevel@tonic-gate (uintptr_t)(tp)->data))>>1) ? \ 3390Sstevel@tonic-gate *(cisdata_t *)(tp)->read.sword++ : \ 3400Sstevel@tonic-gate ((tp)->flags |= CISTPLF_MEM_ERR)) 3410Sstevel@tonic-gate #define GET_AM_LEN(tp) ((size_t)(tp)->len - (((uintptr_t)(tp)->read.byte - \ 3420Sstevel@tonic-gate (uintptr_t)(tp)->data) >> 1)) 3430Sstevel@tonic-gate 3440Sstevel@tonic-gate /* generic macros */ 3450Sstevel@tonic-gate #define RESET_TP(tp) (tp)->read.byte = (tp)->data 3460Sstevel@tonic-gate #define LOOK_BYTE(tp) *(tp)->read.byte 3470Sstevel@tonic-gate #define GET_BYTE_ADDR(tp) (tp)->read.byte 3480Sstevel@tonic-gate 3490Sstevel@tonic-gate #define GET_BYTE(tp) (((tp)->flags & CISTPLF_AM_SPACE) ? \ 3500Sstevel@tonic-gate GET_AM_BYTE(tp) : GET_CM_BYTE(tp)) 351*1278Shx147065 #define GET_SHORT(tp) cis_get_short(tp) 352*1278Shx147065 #define GET_BE_SHORT(tp) cis_get_be_short(tp) 353*1278Shx147065 #define GET_INT24(tp) cis_get_int24(tp) 354*1278Shx147065 #define GET_LONG(tp) cis_get_long(tp) 3550Sstevel@tonic-gate #define GET_LEN(tp) (((tp)->flags & CISTPLF_AM_SPACE) ? \ 3560Sstevel@tonic-gate GET_AM_LEN(tp) : GET_CM_LEN(tp)) 3570Sstevel@tonic-gate 3580Sstevel@tonic-gate /* 3590Sstevel@tonic-gate * cistpl_ignore_list_t - this structure describes tuples in the global 3600Sstevel@tonic-gate * CIS list that we want to ignore if they 3610Sstevel@tonic-gate * also show up in a function-specific CIS. 3620Sstevel@tonic-gate */ 3630Sstevel@tonic-gate typedef struct cistpl_ignore_list_t { 3640Sstevel@tonic-gate cisdata_t type; 3650Sstevel@tonic-gate } cistpl_ignore_list_t; 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate #ifdef __cplusplus 3680Sstevel@tonic-gate } 3690Sstevel@tonic-gate #endif 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate #endif /* _CIS_H */ 372