xref: /illumos-gate/usr/src/uts/common/pcmcia/sys/cis.h (revision c48c3045)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55f9e250aShx  * Common Development and Distribution License (the "License").
65f9e250aShx  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
225f9e250aShx  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate #ifndef _CIS_H
277c478bd9Sstevel@tonic-gate #define	_CIS_H
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * This is the Card Services Card Information Structure (CIS) interpreter
317c478bd9Sstevel@tonic-gate  *	header file.  CIS information in this file is based on the
327c478bd9Sstevel@tonic-gate  *	Release 2.01 PCMCIA standard.
337c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate #if defined(DEBUG)
427c478bd9Sstevel@tonic-gate #define	CIS_DEBUG
437c478bd9Sstevel@tonic-gate #endif
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * The CIS interpreter has a single entry point with a bunch of function
487c478bd9Sstevel@tonic-gate  *	id numbers.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate #define	CISP_CIS_SETUP		0x01	/* setup CS address in CIS */
517c478bd9Sstevel@tonic-gate #define	CISP_CIS_LIST_CREATE	0x02	/* create the CIS linked list */
527c478bd9Sstevel@tonic-gate #define	CISP_CIS_LIST_DESTROY	0x03	/* destroy the CIS linked list */
537c478bd9Sstevel@tonic-gate #define	CISP_CIS_GET_LTUPLE	0x04	/* get a tuple */
547c478bd9Sstevel@tonic-gate #define	CISP_CIS_PARSE_TUPLE	0x05	/* parse a tuple */
557c478bd9Sstevel@tonic-gate #define	CISP_CIS_CONV_DEVSPEED	0x06	/* convert devspeed to nS and back */
567c478bd9Sstevel@tonic-gate #define	CISP_CIS_CONV_DEVSIZE	0x07	/* convert device size */
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate  * Make the  calls to CardServices look like function calls.
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate #define	CIS_CARD_SERVICES	(*cis_card_services)
637c478bd9Sstevel@tonic-gate /*
647c478bd9Sstevel@tonic-gate  * define the tuples that we recognize
657c478bd9Sstevel@tonic-gate  *
667c478bd9Sstevel@tonic-gate  * Layer 1 - Basic Compatability TUples
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate #define	CISTPL_NULL		0x000	/* null tuple - ignore */
697c478bd9Sstevel@tonic-gate #define	CISTPL_DEVICE		0x001	/* device information */
707c478bd9Sstevel@tonic-gate #define	CISTPL_LONGLINK_CB	0x002	/* longlink to next tuple chain */
717c478bd9Sstevel@tonic-gate #define	CISTPL_CONFIG_CB	0x004	/* configuration tuple */
727c478bd9Sstevel@tonic-gate #define	CISTPL_CFTABLE_ENTRY_CB	0x005	/* configuration table entry */
737c478bd9Sstevel@tonic-gate #define	CISTPL_LONGLINK_MFC	0x006	/* multi-function tuple */
747c478bd9Sstevel@tonic-gate #define	CISTPL_BAR		0x007	/* Base Address Register definition */
757c478bd9Sstevel@tonic-gate #define	CISTPL_CHECKSUM		0x010	/* checksum control */
767c478bd9Sstevel@tonic-gate #define	CISTPL_LONGLINK_A	0x011	/* long-link to AM */
777c478bd9Sstevel@tonic-gate #define	CISTPL_LONGLINK_C	0x012	/* long-link to CM */
787c478bd9Sstevel@tonic-gate #define	CISTPL_LINKTARGET	0x013	/* link-target control */
797c478bd9Sstevel@tonic-gate #define	CISTPL_NO_LINK		0x014	/* no-link control */
807c478bd9Sstevel@tonic-gate #define	CISTPL_VERS_1		0x015	/* level 1 version information */
817c478bd9Sstevel@tonic-gate #define	CISTPL_ALTSTR		0x016	/* alternate language string */
827c478bd9Sstevel@tonic-gate #define	CISTPL_DEVICE_A		0x017	/* AM device information */
837c478bd9Sstevel@tonic-gate #define	CISTPL_JEDEC_C		0x018	/* JEDEC programming info for CM */
847c478bd9Sstevel@tonic-gate #define	CISTPL_JEDEC_A		0x019	/* JEDEC programming info for AM */
857c478bd9Sstevel@tonic-gate #define	CISTPL_CONFIG		0x01a	/* configuration */
867c478bd9Sstevel@tonic-gate #define	CISTPL_CFTABLE_ENTRY	0x01b	/* configuration-table-entry */
877c478bd9Sstevel@tonic-gate #define	CISTPL_DEVICE_OC	0x01c	/* other op conditions CM device info */
887c478bd9Sstevel@tonic-gate #define	CISTPL_DEVICE_OA	0x01d	/* other op conditions AM device info */
897c478bd9Sstevel@tonic-gate #define	CISTPL_DEVICEGEO	0x01e	/* Common Memory device geometry */
907c478bd9Sstevel@tonic-gate #define	CISTPL_DEVICEGEO_A	0x01f	/* Attribute Memory device geometry */
91*c48c3045SToomas Soome #define	CISTPL_MANFID		0x020	/* manufacturer identification */
927c478bd9Sstevel@tonic-gate #define	CISTPL_FUNCID		0x021	/* function identification */
937c478bd9Sstevel@tonic-gate #define	CISTPL_FUNCE		0x022	/* function extension */
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * Layer 2 - Data Recording Format Tuples
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate #define	CISTPL_SWIL		0x023	/* software interleave */
997c478bd9Sstevel@tonic-gate #define	CISTPL_VERS_2		0x040	/* level 2 version information */
1007c478bd9Sstevel@tonic-gate #define	CISTPL_FORMAT		0x041	/* Common Memory recording format */
1017c478bd9Sstevel@tonic-gate #define	CISTPL_GEOMETRY		0x042	/* geometry */
1027c478bd9Sstevel@tonic-gate #define	CISTPL_BYTEORDER	0x043	/* byte order */
1037c478bd9Sstevel@tonic-gate #define	CISTPL_DATE		0x044	/* card initialization date */
1047c478bd9Sstevel@tonic-gate #define	CISTPL_BATTERY		0x045	/* battery replacement date */
1057c478bd9Sstevel@tonic-gate #define	CISTPL_FORMAT_A		0x047	/* Attribute Memory recording format */
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate  * Layer 3 - Data Organization Tuples
1097c478bd9Sstevel@tonic-gate  */
1107c478bd9Sstevel@tonic-gate #define	CISTPL_ORG		0x046	/* organization */
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate  * Layer 4 - System Specific Standard Tuples
1147c478bd9Sstevel@tonic-gate  */
1157c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_80	0x080	/* vendor-specific 0x80 */
1167c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_81	0x081	/* vendor-specific 0x81 */
1177c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_82	0x082	/* vendor-specific 0x82 */
1187c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_83	0x083	/* vendor-specific 0x83 */
1197c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_84	0x084	/* vendor-specific 0x84 */
1207c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_85	0x085	/* vendor-specific 0x85 */
1217c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_86	0x086	/* vendor-specific 0x86 */
1227c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_87	0x087	/* vendor-specific 0x87 */
1237c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_88	0x088	/* vendor-specific 0x88 */
1247c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_89	0x089	/* vendor-specific 0x89 */
1257c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_8a	0x08a	/* vendor-specific 0x8a */
1267c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_8b	0x08b	/* vendor-specific 0x8b */
1277c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_8c	0x08c	/* vendor-specific 0x8c */
1287c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_8d	0x08d	/* vendor-specific 0x8d */
1297c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_8e	0x08e	/* vendor-specific 0x8e */
1307c478bd9Sstevel@tonic-gate #define	CISTPL_VEND_SPEC_8f	0x08f	/* vendor-specific 0x8f */
1317c478bd9Sstevel@tonic-gate #define	CISTPL_SPCL		0x090	/* special-purpose tuple */
1327c478bd9Sstevel@tonic-gate #define	CISTPL_END		0x0ff	/* end-of-list tuple */
1347c478bd9Sstevel@tonic-gate /*
1357c478bd9Sstevel@tonic-gate  * Macro to check if tuple is a vendor-specific tuple.
1367c478bd9Sstevel@tonic-gate  */
1377c478bd9Sstevel@tonic-gate #define	CISTPL_VENDSPEC_START	CISTPL_VEND_SPEC_80
1387c478bd9Sstevel@tonic-gate #define	CISTPL_VENDSPEC_END	CISTPL_VEND_SPEC_8f
1397c478bd9Sstevel@tonic-gate #define	CISTPL_IS_VENDOR_SPECIFIC(td)	(((td) >= CISTPL_VENDSPEC_START) &&   \
1407c478bd9Sstevel@tonic-gate 						((td) <= CISTPL_VENDSPEC_END))
1427c478bd9Sstevel@tonic-gate /*
1437c478bd9Sstevel@tonic-gate  * The GetFirstTuple and GetNextTuple Card Services function calls use
1447c478bd9Sstevel@tonic-gate  *	the DesiredTuple member of the tuple_t structure to determine
1457c478bd9Sstevel@tonic-gate  *	while tuple type to return; since the CIS parser doesn't ever
1467c478bd9Sstevel@tonic-gate  *	return CISTPL_END tuples, we can never ask for those tuples,
1477c478bd9Sstevel@tonic-gate  *	so we overload this tuple code to mean that we want the
1487c478bd9Sstevel@tonic-gate  *	first (or next) tuple in the chain.
1497c478bd9Sstevel@tonic-gate  * XXX - If we ever do return CISTPL_END tuples, we'll have to
1507c478bd9Sstevel@tonic-gate  *	re-think this.
1517c478bd9Sstevel@tonic-gate  */
1527c478bd9Sstevel@tonic-gate #define	RETURN_FIRST_TUPLE	0x0ff	/* return first/next tuple */
1537c478bd9Sstevel@tonic-gate #define	RETURN_NEXT_TUPLE	0x0ff	/* return first/next tuple */
1557c478bd9Sstevel@tonic-gate /*
1567c478bd9Sstevel@tonic-gate  * types for data in CIS and pointers into PC card's CIS space
1577c478bd9Sstevel@tonic-gate  *
1587c478bd9Sstevel@tonic-gate  * The "size" member is used by the NEXT_CIS_ADDR macro so that
1597c478bd9Sstevel@tonic-gate  *	we don't run past the end of the mapped CIS address space.
1607c478bd9Sstevel@tonic-gate  */
1617c478bd9Sstevel@tonic-gate typedef uchar_t cisdata_t;
1637c478bd9Sstevel@tonic-gate typedef struct cisptr_t {
1647c478bd9Sstevel@tonic-gate     acc_handle_t	handle;	/* access handle of CIS space */
1657c478bd9Sstevel@tonic-gate     uint32_t		size;	/* size of mapped area */
1667c478bd9Sstevel@tonic-gate     uint32_t		offset;	/* byte offset into CIS space */
1677c478bd9Sstevel@tonic-gate 	/* see flag definitions for cistpl_t structure */
1687c478bd9Sstevel@tonic-gate     uint32_t		flags;
1697c478bd9Sstevel@tonic-gate } cisptr_t;
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * This is the maximum length that the data portion of a tuple can be.
1737c478bd9Sstevel@tonic-gate  *	We have to use this since the brain-damaged 2.01 PCMCIA spec
1747c478bd9Sstevel@tonic-gate  *	specifies that you can end a CIS chain by putting a CISTPL_END
1757c478bd9Sstevel@tonic-gate  *	in the link field of the last VALID tuple.
1767c478bd9Sstevel@tonic-gate  */
1777c478bd9Sstevel@tonic-gate #define	CIS_MAX_TUPLE_DATA_LEN	254
1797c478bd9Sstevel@tonic-gate /*
1807c478bd9Sstevel@tonic-gate  * This is the maximum size of the string used to describe the name
1817c478bd9Sstevel@tonic-gate  *	of the tuple.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate #define	CIS_MAX_TUPLE_NAME_LEN	40
1857c478bd9Sstevel@tonic-gate /*
1867c478bd9Sstevel@tonic-gate  * CIS_MAX_FUNCTIONS defines the maximum number of functions that can
1877c478bd9Sstevel@tonic-gate  *	exist on a card.
1887c478bd9Sstevel@tonic-gate  */
1897c478bd9Sstevel@tonic-gate #define	CIS_MAX_FUNCTIONS	8	/* max number of functions per card */
1917c478bd9Sstevel@tonic-gate /*
1927c478bd9Sstevel@tonic-gate  * Macros to manipulate addresses and data in various CIS spaces
1937c478bd9Sstevel@tonic-gate  *
1947c478bd9Sstevel@tonic-gate  * NEXT_CIS_ADDR(cisptr_t *) increments the offset to point to the
1957c478bd9Sstevel@tonic-gate  *	next data element in the CIS, based on what space the CIS
1967c478bd9Sstevel@tonic-gate  *	we are reading resides in.  If the resulting address would
1977c478bd9Sstevel@tonic-gate  *	be past the end of the mapped-in area, we return NULL,
1987c478bd9Sstevel@tonic-gate  *	otherwise the adjusted offset value is returned. Note that
1997c478bd9Sstevel@tonic-gate  *	this only works if the "size" member specifies the maximum
2007c478bd9Sstevel@tonic-gate  *	mapped in window size and an "offset" member value of zero
2017c478bd9Sstevel@tonic-gate  *	refers to the first byte of the window.
2027c478bd9Sstevel@tonic-gate  *
2037c478bd9Sstevel@tonic-gate  * GET_CIS_DATA(ptr) returns the data byte at the current CIS location.
2047c478bd9Sstevel@tonic-gate  *
2057c478bd9Sstevel@tonic-gate  * GET_CIS_ADDR(tp,ptr) returns the virtual address that was saved by a
2067c478bd9Sstevel@tonic-gate  *	call to STORE_CIS_ADDR.
2077c478bd9Sstevel@tonic-gate  *
2087c478bd9Sstevel@tonic-gate  * BAD_CIS_ADDR is a flag that should be returned by callers of NEXT_CIS_ADDR
2097c478bd9Sstevel@tonic-gate  *	if that macro returns NULL.  Note that this flag shares the same bit
2107c478bd9Sstevel@tonic-gate  *	field definitions as the tuple handler flags defined in cis_handlers.h
2117c478bd9Sstevel@tonic-gate  *	so check that file if you make any changes to these flags.
2127c478bd9Sstevel@tonic-gate  * XXX - not the best distribution of flags, I'm afraid
2137c478bd9Sstevel@tonic-gate  */
2147c478bd9Sstevel@tonic-gate #define	NEXT_CIS_ADDR(ptr)	\
2157c478bd9Sstevel@tonic-gate 			(((ptr->flags&CISTPLF_AM_SPACE)?(ptr->offset += 2): \
2167c478bd9Sstevel@tonic-gate 				(ptr->offset++)),	\
217*c48c3045SToomas Soome 				((ptr->offset > ptr->size)?(0):ptr->offset))
2187c478bd9Sstevel@tonic-gate #define	GET_CIS_DATA(ptr)	csx_Get8(ptr->handle, ptr->offset)
2197c478bd9Sstevel@tonic-gate #define	GET_CIS_ADDR(tp)	((cisdata_t *)(uintptr_t)(tp)->offset)
2207c478bd9Sstevel@tonic-gate #define	BAD_CIS_ADDR	0x080000000 /* read past end of mapped CIS error */
2227c478bd9Sstevel@tonic-gate /*
2237c478bd9Sstevel@tonic-gate  * CIS_MEM_ALLOC(len) is used to allocate memory for our local linked
2247c478bd9Sstevel@tonic-gate  *	CIS list; we use a macro so that the same code can be used in
2257c478bd9Sstevel@tonic-gate  *	the kernel as well as in user space
2267c478bd9Sstevel@tonic-gate  *
2277c478bd9Sstevel@tonic-gate  * CIS_MEM_FREE(ptr) - same comment as CIS_MEM_ALLOC
2287c478bd9Sstevel@tonic-gate  */
2297c478bd9Sstevel@tonic-gate #if !defined(_KERNEL)
2307c478bd9Sstevel@tonic-gate #ifdef	CISMALLOC_DEBUG
2317c478bd9Sstevel@tonic-gate #define	CIS_MEM_ALLOC(len)		cis_malloc((uint32_t)len)
2327c478bd9Sstevel@tonic-gate #define	CIS_MEM_FREE(ptr)		cis_free(ptr)
2337c478bd9Sstevel@tonic-gate #else
2347c478bd9Sstevel@tonic-gate #define	CIS_MEM_ALLOC(len)		malloc((uint32_t)len)
2357c478bd9Sstevel@tonic-gate #define	CIS_MEM_FREE(ptr)		free(ptr)
2367c478bd9Sstevel@tonic-gate #endif	/* CISMALLOC_DEBUG */
2377c478bd9Sstevel@tonic-gate #else
2387c478bd9Sstevel@tonic-gate #define	CIS_MEM_ALLOC(len)		cis_malloc((uint32_t)len)
2397c478bd9Sstevel@tonic-gate #define	CIS_MEM_FREE(ptr)		cis_free(ptr)
2407c478bd9Sstevel@tonic-gate #endif
2427c478bd9Sstevel@tonic-gate typedef struct cis_u_malloc_tag_t {
2437c478bd9Sstevel@tonic-gate 	caddr_t		addr;
2447c478bd9Sstevel@tonic-gate 	uint32_t	len;
2457c478bd9Sstevel@tonic-gate } cis_u_malloc_tag_t;
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * We keep the tuples in a locally-maintained linked list.  This allows
2497c478bd9Sstevel@tonic-gate  *	us to return the tuple information at any time to a client for
2507c478bd9Sstevel@tonic-gate  *	those cards that make their CIS inaccessible once the card is
2517c478bd9Sstevel@tonic-gate  *	configured.
2527c478bd9Sstevel@tonic-gate  */
2537c478bd9Sstevel@tonic-gate typedef struct cistpl_t {
2547c478bd9Sstevel@tonic-gate 	cisdata_t	type;	/* type of tuple */
2557c478bd9Sstevel@tonic-gate 	cisdata_t	len;	/* length of tuple data */
2567c478bd9Sstevel@tonic-gate 	cisdata_t	*data;	/* data in tuple */
2577c478bd9Sstevel@tonic-gate 	union {
2587c478bd9Sstevel@tonic-gate 		cisdata_t	*byte;	/* read pointer for GET_BYTE macros */
2597c478bd9Sstevel@tonic-gate 		uint16_t	*sword;
2607c478bd9Sstevel@tonic-gate 	}		read;
2617c478bd9Sstevel@tonic-gate 	uint32_t	flags;	/* misc flags */
2627c478bd9Sstevel@tonic-gate 	uint32_t	offset;	/* CIS address offset of start of tuple */
2637c478bd9Sstevel@tonic-gate 	struct cistpl_t	*prev;	/* back pointer */
2647c478bd9Sstevel@tonic-gate 	struct cistpl_t	*next;	/* forward pointer */
2657c478bd9Sstevel@tonic-gate } cistpl_t;
2677c478bd9Sstevel@tonic-gate /*
2687c478bd9Sstevel@tonic-gate  * Flags that are used in the cistpl_t and cisptr_t linked lists
2697c478bd9Sstevel@tonic-gate  */
2707c478bd9Sstevel@tonic-gate #define	CISTPLF_NOERROR		0x000000000 /* no error return from handler */
2717c478bd9Sstevel@tonic-gate #define	CISTPLF_UNKNOWN		0x000000001 /* unknown tuple */
2727c478bd9Sstevel@tonic-gate #define	CISTPLF_REGS		0x000000002 /* tuple contains registers */
2737c478bd9Sstevel@tonic-gate #define	CISTPLF_COPYOK		0x000000004 /* OK to copy tuple data */
2747c478bd9Sstevel@tonic-gate #define	CISTPLF_VALID		0x000000008 /* tuple is valid */
2757c478bd9Sstevel@tonic-gate #define	CISTPLF_GLOBAL_CIS	0x000000010 /* tuple from global CIS */
2767c478bd9Sstevel@tonic-gate #define	CISTPLF_MF_CIS		0x000000020 /* tuple from MF CIS chain */
2777c478bd9Sstevel@tonic-gate #define	CISTPLF_FROM_AM		0x000000040 /* tuple read from AM space */
2787c478bd9Sstevel@tonic-gate #define	CISTPLF_FROM_CM		0x000000080 /* tuple read from CM space */
2797c478bd9Sstevel@tonic-gate #define	CISTPLF_IGNORE_TUPLE	0x000000100 /* ignore this tuple */
2807c478bd9Sstevel@tonic-gate #define	CISTPLF_VENDOR_SPECIFIC	0x000000200 /* vnedor-specific tuple */
2817c478bd9Sstevel@tonic-gate #define	CISTPLF_LINK_INVALID	0x001000000 /* tuple link is invalid */
2827c478bd9Sstevel@tonic-gate #define	CISTPLF_PARAMS_INVALID	0x002000000 /* tuple body is invalid */
2837c478bd9Sstevel@tonic-gate #define	CISTPLF_AM_SPACE	0x010000000 /* this tuple is in AM space */
2847c478bd9Sstevel@tonic-gate #define	CISTPLF_CM_SPACE	0x020000000 /* this tuple is in CM space */
2857c478bd9Sstevel@tonic-gate #define	CISTPLF_LM_SPACE	0x040000000 /* this tuple is in local memory */
2867c478bd9Sstevel@tonic-gate #define	CISTPLF_MEM_ERR		0x080000000 /* GET_BYTE macros memory error */
2887c478bd9Sstevel@tonic-gate /*
2897c478bd9Sstevel@tonic-gate  * Some convienience macros
2907c478bd9Sstevel@tonic-gate  */
2917c478bd9Sstevel@tonic-gate #define	CISTPLF_SPACE_MASK	(CISTPLF_AM_SPACE | CISTPLF_CM_SPACE |	\
2927c478bd9Sstevel@tonic-gate 							CISTPLF_LM_SPACE)
2937c478bd9Sstevel@tonic-gate #define	CISTPLF_FROM_MASK	(CISTPLF_FROM_AM | CISTPLF_FROM_CM)
2957c478bd9Sstevel@tonic-gate /*
2967c478bd9Sstevel@tonic-gate  * Values used internally on calls to cis_get_ltuple.
2977c478bd9Sstevel@tonic-gate  *
2987c478bd9Sstevel@tonic-gate  * The GET_XXX_LTUPLEF and FIND_XXX_XXX values are mutually exclusive,
2997c478bd9Sstevel@tonic-gate  *	i.e. cis_get_ltuple can only do one of these operations per call.
3007c478bd9Sstevel@tonic-gate  *
3017c478bd9Sstevel@tonic-gate  * The other flags are bit flags and they share the flags parameter.
3027c478bd9Sstevel@tonic-gate  *
3037c478bd9Sstevel@tonic-gate  *    CIS_GET_LTUPLE_IGNORE - return tuples with CISTPLF_IGNORE_TUPLE
3047c478bd9Sstevel@tonic-gate  *				set in cistpl_t->flags
3057c478bd9Sstevel@tonic-gate  */
3067c478bd9Sstevel@tonic-gate #define	GET_FIRST_LTUPLEF	0x000000001 /* return first tuple in list */
3077c478bd9Sstevel@tonic-gate #define	GET_LAST_LTUPLEF	0x000000002 /* return last tuple in list */
3087c478bd9Sstevel@tonic-gate #define	FIND_LTUPLE_FWDF	0x000000003 /* find tuple, fwd search from tp */
3097c478bd9Sstevel@tonic-gate #define	FIND_LTUPLE_BACKF	0x000000004 /* find tuple, backward from tp */
3107c478bd9Sstevel@tonic-gate #define	FIND_NEXT_LTUPLEF	0x000000005 /* find tuple, fwd from tp+1 */
3117c478bd9Sstevel@tonic-gate #define	FIND_PREV_LTUPLEF	0x000000006 /* find tuple, backward from tp-1 */
3127c478bd9Sstevel@tonic-gate #define	GET_NEXT_LTUPLEF	0x000000007 /* return next tuple in list */
3137c478bd9Sstevel@tonic-gate #define	GET_PREV_LTUPLEF	0x000000008 /* return prev tuple in list */
3147c478bd9Sstevel@tonic-gate #define	CIS_GET_LTUPLE_OPMASK	0x00000ffff /* mask for operation values */
3157c478bd9Sstevel@tonic-gate #define	CIS_GET_LTUPLE_IGNORE	0x000010000 /* return ignored tuples */
3177c478bd9Sstevel@tonic-gate /*
3187c478bd9Sstevel@tonic-gate  * macros for getting various data types out of a tuple
3197c478bd9Sstevel@tonic-gate  * Note that due to the modem tuple using a few big-endian values,
3207c478bd9Sstevel@tonic-gate  * we have to support both big and little endian macros
3217c478bd9Sstevel@tonic-gate  *
3227c478bd9Sstevel@tonic-gate  * Common Memory Specific macros - these will also work for tuples in
3237c478bd9Sstevel@tonic-gate  *	local memory
3247c478bd9Sstevel@tonic-gate  */
3257c478bd9Sstevel@tonic-gate #define	GET_CM_BYTE(tp)	(((size_t)(tp)->len >= \
3267c478bd9Sstevel@tonic-gate 				((uintptr_t)(tp)->read.byte - \
3277c478bd9Sstevel@tonic-gate 					(uintptr_t)(tp)->data)) ? \
3287c478bd9Sstevel@tonic-gate 			 *(tp)->read.byte++ : ((tp)->flags |= CISTPLF_MEM_ERR))
3297c478bd9Sstevel@tonic-gate #define	GET_CM_LEN(tp)	((size_t)(tp)->len - \
3307c478bd9Sstevel@tonic-gate 				((uintptr_t)(tp)->read.byte - \
3317c478bd9Sstevel@tonic-gate 				(uintptr_t)(tp)->data))
3337c478bd9Sstevel@tonic-gate /* Attribute Memory Specific macros */
3347c478bd9Sstevel@tonic-gate #define	GET_AM_BYTE(tp)	(((size_t)(tp)->len >= \
3357c478bd9Sstevel@tonic-gate 				(((uintptr_t)(tp)->read.byte - \
3367c478bd9Sstevel@tonic-gate 					(uintptr_t)(tp)->data))>>1) ? \
3377c478bd9Sstevel@tonic-gate 			 *(cisdata_t *)(tp)->read.sword++ : \
3387c478bd9Sstevel@tonic-gate 				((tp)->flags |= CISTPLF_MEM_ERR))
3397c478bd9Sstevel@tonic-gate #define	GET_AM_LEN(tp)	((size_t)(tp)->len - (((uintptr_t)(tp)->read.byte - \
3407c478bd9Sstevel@tonic-gate 				(uintptr_t)(tp)->data) >> 1))
3427c478bd9Sstevel@tonic-gate /* generic macros */
3437c478bd9Sstevel@tonic-gate #define	RESET_TP(tp)	(tp)->read.byte = (tp)->data
3447c478bd9Sstevel@tonic-gate #define	LOOK_BYTE(tp)	*(tp)->read.byte
3457c478bd9Sstevel@tonic-gate #define	GET_BYTE_ADDR(tp) (tp)->read.byte
3477c478bd9Sstevel@tonic-gate #define	GET_BYTE(tp)	(((tp)->flags & CISTPLF_AM_SPACE) ? \
3487c478bd9Sstevel@tonic-gate 				GET_AM_BYTE(tp) : GET_CM_BYTE(tp))
3495f9e250aShx #define	GET_SHORT(tp)		cis_get_short(tp)
3505f9e250aShx #define	GET_BE_SHORT(tp)	cis_get_be_short(tp)
3515f9e250aShx #define	GET_INT24(tp)		cis_get_int24(tp)
3525f9e250aShx #define	GET_LONG(tp)		cis_get_long(tp)
3537c478bd9Sstevel@tonic-gate #define	GET_LEN(tp)	(((tp)->flags & CISTPLF_AM_SPACE) ? \
3547c478bd9Sstevel@tonic-gate 				GET_AM_LEN(tp) : GET_CM_LEN(tp))
3567c478bd9Sstevel@tonic-gate /*
3577c478bd9Sstevel@tonic-gate  * cistpl_ignore_list_t - this structure describes tuples in the global
3587c478bd9Sstevel@tonic-gate  *				CIS list that we want to ignore if they
3597c478bd9Sstevel@tonic-gate  *				also show up in a function-specific CIS.
3607c478bd9Sstevel@tonic-gate  */
3617c478bd9Sstevel@tonic-gate typedef struct cistpl_ignore_list_t {
3627c478bd9Sstevel@tonic-gate 	cisdata_t	type;
3637c478bd9Sstevel@tonic-gate } cistpl_ignore_list_t;
3657c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3667c478bd9Sstevel@tonic-gate }
3677c478bd9Sstevel@tonic-gate #endif
3697c478bd9Sstevel@tonic-gate #endif	/* _CIS_H */