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