xref: /titanic_50/usr/src/uts/common/pcmcia/sys/cs.h (revision 2eeaed14a5e2ed9bd811643ad5bffc3510ca0310)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _CS_H
28 #define	_CS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * PCMCIA Card Services header file
38  */
39 
40 /*
41  * XXX - This define really should be in a global header file
42  *	somewhere; we do this stunt here since a lot of
43  *	people include this header file but not necessarily
44  *	the header file in which this is defined.
45  */
46 #ifndef	_VERSION
47 #define	_VERSION(major, minor)	((major)<<16|(minor))
48 #endif
49 
50 /*
51  * Define this version of CS - this should correspond to the PCMCIA
52  *	version number specified in the PCMCIA standard.
53  */
54 #define	CS_VERSION	_VERSION(5, 2)
55 
56 /*
57  * CS_INTERNAL_REVISION_LEVEL is our internal revision level value returned
58  *	via GetCardServicesInfo in get_cardservices_info_t->Revision
59  */
60 #define	CS_INTERNAL_REVISION_LEVEL	_VERSION(2, 0)
61 
62 #define	CS_GET_CARDSERVICES_INFO_VENDOR_STRING	"Solaris UNIX Card Services\n" \
63 		"Copyright (c) 1996 by Sun Microsystems, Inc.\n"	\
64 		"All rights reserved\n"					\
65 		"%W% %E% SMI\n"	\
66 		"Based on the PC Card Standard, February 1995\n"
67 
68 /*
69  * typedef for function pointers to quiet lint and cc -v
70  */
71 typedef	int32_t (csfunction_t)(int32_t, ...);	/* for lint - cc -v quieting */
72 
73 /*
74  * CS_SUN_VENDOR_DESCRIPTION - can be returned by clients handling
75  *				the CS_EVENT_CLIENT_INFO event in the
76  *				client_info_t->VendorName member.
77  */
78 #define	CS_SUN_VENDOR_DESCRIPTION	"Sun Microsystems, Inc. (c) 1996"
79 
80 /*
81  * Return codes from Card Services - these correspond to the PCMCIA
82  *	standard and also include some implementation-specific return
83  *	codes.
84  */
85 #define	CS_SUCCESS		0x00	/* Request succeeded */
86 #define	CS_BAD_ADAPTER		0x01	/* Specified adapter is invalid */
87 #define	CS_BAD_ATTRIBUTE	0x02	/* Bad attribute value */
88 #define	CS_BAD_BASE		0x03	/* System base address invalid */
89 #define	CS_BAD_EDC		0x04	/* EDC generator is invalid */
90 	/* RESERVED - 0x05 */
91 #define	CS_BAD_IRQ		0x06	/* Invalid IRQ */
92 #define	CS_BAD_OFFSET		0x07	/* Card offset invalid */
93 #define	CS_BAD_PAGE		0x08	/* Card page invalid */
94 #define	CS_READ_FAILURE		0x09	/* Unable to complete read request */
95 #define	CS_BAD_SIZE		0x0a	/* Size is invalid */
96 #define	CS_BAD_SOCKET		0x0b	/* Specified socket is invalid */
97 	/* RESERVED - 0x0c */
98 #define	CS_BAD_TYPE		0x0d	/* Window/interface type invalid */
99 #define	CS_BAD_VCC		0x0e	/* Vcc value/index invalid */
100 #define	CS_BAD_VPP		0x0f	/* Vpp value/index invalid */
101 #define	CS_BAD_WINDOW		0x11	/* Specified window is invalid */
102 #define	CS_WRITE_FAILURE	0x12	/* Unable to complete write request */
103 	/* RESERVED - 0x13 */
104 #define	CS_NO_CARD		0x14	/* No PC card in socket */
105 #define	CS_UNSUPPORTED_FUNCTION	0x15	/* Unsupported function */
106 #define	CS_UNSUPPORTED_MODE	0x16	/* Unsupported processor mode */
107 #define	CS_BAD_SPEED		0x17	/* Specified speed is unavailable */
108 #define	CS_BUSY			0x18	/* CS is busy - try again later */
109 #define	CS_GENERAL_FAILURE	0x19	/* Undefined error */
110 #define	CS_WRITE_PROTECTED	0x1a	/* Media is write protected */
111 #define	CS_BAD_ARG_LENGTH	0x1b	/* Arg length invalid */
112 #define	CS_BAD_ARGS		0x1c	/* Arg values invalid */
113 #define	CS_CONFIGURATION_LOCKED	0x1d	/* This configuration is locked */
114 #define	CS_IN_USE		0x1e	/* Requested resource in use */
115 #define	CS_NO_MORE_ITEMS	0x1f	/* No more of requested item */
116 #define	CS_OUT_OF_RESOURCE	0x20	/* Internal CS resources exhausted */
117 #define	CS_BAD_HANDLE		0x21	/* client or window handle invalid */
118 
119 /*
120  * The following are Solaris-specific extended return codes
121  */
122 #define	CS_NO_CIS		0x80	/* No CIS on card */
123 #define	CS_BAD_CIS		0x81	/* Bad CIS on card */
124 #define	CS_UNKNOWN_TUPLE	0x82	/* unknown tuple */
125 #define	CS_BAD_VERSION		0x83	/* bad CS version */
126 #define	CS_UNSUPPORTED_EVENT	0x84	/* Unsupported event in client */
127 #define	CS_CSI_ERROR		0x85	/* error in csi driver protocol */
128 #define	CS_CSI_NOT_INIT		0x86	/* csi library/driver not initialized */
129 #define	CS_NO_TUPLE_PARSER	0x87	/* no tuple parser for this tuple */
130 #define	CS_CARD_NOT_READY	0x88	/* card not ready */
131 #define	CS_ERRORLIST_END	0x8000	/* end of error list */
132 
133 /*
134  * Card Services event codes - these do NOT correspond to the PCMCIA
135  *	standard event codes for CS since these events are encoded as
136  *	bit flags, while the PCMCIA standard event codes are encoded
137  *	as numerical values.  In practice, this shouldn't be a problem
138  *	since no one should be looking at the absolute value of the
139  *	event codes; these defines should be used.
140  *
141  * The numerical value of an event code determines in what order a client
142  *	will receive the event if other events are also pending for that
143  *	client. XXX - need to make event_t a 64-bit field.
144  *
145  * Card Services receives these events from Socket Services or by reading
146  *	the card's Pin Replacement Register.  In either case, the client
147  *	always gets the same type of notification.
148  */
149 #define	CS_EVENT_REGISTRATION_COMPLETE	0x00000001 /* 0x82 */
150 #define	CS_EVENT_PM_RESUME		0x00000002 /* 0x05 */
151 #define	CS_EVENT_CARD_INSERTION		0x00000004 /* 0x0c */
152 #define	CS_EVENT_CARD_READY		0x00000008 /* 0x01 */
153 #define	CS_EVENT_BATTERY_LOW		0x00000010 /* 0x02 is also BVD2 */
154 #define	CS_EVENT_BATTERY_DEAD		0x00000020 /* 0x40 is also BVD1 */
155 #define	CS_EVENT_CARD_LOCK		0x00000040 /* 0x03 */
156 #define	CS_EVENT_PM_SUSPEND		0x00000080 /* 0x04 */
157 #define	CS_EVENT_CARD_RESET		0x00000100 /* 0x11 */
158 #define	CS_EVENT_CARD_UNLOCK		0x00000200 /* 0x06 */
159 #define	CS_EVENT_EJECTION_COMPLETE	0x00000400 /* 0x07 */
160 #define	CS_EVENT_EJECTION_REQUEST	0x00000800 /* 0x08 */
161 #define	CS_EVENT_ERASE_COMPLETE		0x00001000 /* 0x81 */
162 #define	CS_EVENT_EXCLUSIVE_COMPLETE	0x00002000 /* 0x0d */
163 #define	CS_EVENT_EXCLUSIVE_REQUEST	0x00004000 /* 0x0e */
164 #define	CS_EVENT_INSERTION_COMPLETE	0x00008000 /* 0x09 */
165 #define	CS_EVENT_INSERTION_REQUEST	0x00010000 /* 0x0a */
166 #define	CS_EVENT_RESET_COMPLETE		0x00020000 /* 0x80 */
167 #define	CS_EVENT_RESET_PHYSICAL		0x00040000 /* 0x0f */
168 #define	CS_EVENT_RESET_REQUEST		0x00080000 /* 0x10 */
169 #define	CS_EVENT_MTD_REQUEST		0x00100000 /* 0x12 */
170 #define	CS_EVENT_CLIENT_INFO		0x00200000 /* 0x14 */
171 #define	CS_EVENT_TIMER_EXPIRED		0x00400000 /* 0x15 */
172 #define	CS_EVENT_WRITE_PROTECT		0x01000000 /* 0x17 */
173 
174 /*
175  * The CS_EVENT_SS_UPDATED event is generated when Socket Services
176  *	has completed parsing the CIS and has done any necessary
177  *	work to get the client driver loaded and attached.
178  */
179 #define	CS_EVENT_SS_UPDATED		0x00800000 /* 0x16 */
180 
181 /*
182  * The CS_EVENT_STATUS_CHANGE event is generated by a Socket Services
183  *	PCE_CARD_STATUS_CHANGE event; this event gets converted to
184  *	the appropriate Card Services events when Card Services
185  *	reads the PRR.
186  */
187 #define	CS_EVENT_STATUS_CHANGE		0x02000000 /* ?? */
188 
189 /*
190  * The CS_EVENT_CARD_REMOVAL is the last "real" CS event and must
191  *	have the highest value of all "real" CS events so that this
192  *	event is handed to the client after all other queued events
193  *	have been processed.
194  * If the client has set the CS_EVENT_CARD_REMOVAL_LOWP flag in
195  *	either of their event masks, then they will also receive
196  *	a CS_EVENT_CARD_REMOVAL at low (cs_event_thread) priority;
197  *	in this low priority removal event, the client can call
198  *	many CS functions that they can't call when they recieve
199  *	the high priority removal event.
200  */
201 #define	CS_EVENT_CARD_REMOVAL		0x10000000 /* 0x0b */
202 #define	CS_EVENT_CARD_REMOVAL_LOWP	0x20000000 /* ?? */
203 /*
204  * The following are not events but they share the event flags field
205  *	and are used internally by CS.  These bit patterns will never
206  *	be seen by clients.
207  * CS_EVENT_ALL_CLIENTS can only be set by the super-client and by
208  *	the CSI clients; setting this bit causes the driver to
209  *	receive any events specified in their event masks whenever
210  *	any such events occur on the socket.
211  * CS_EVENT_READY_TIMEOUT is a CS-private flag and should never be
212  *	set by clients.
213  */
214 #define	CS_EVENT_ALL_CLIENTS		0x40000000 /* ?? */
215 #define	CS_EVENT_READY_TIMEOUT		0x80000000 /* ?? */
216 
217 /*
218  * CS_EVENT_CLIENT_EVENTS_MASK is a msk of events that only the framework
219  *	is allowed to manipulate.
220  */
221 #define	CS_EVENT_CLIENT_EVENTS_MASK	~(CS_EVENT_SS_UPDATED |		\
222 						CS_EVENT_ALL_CLIENTS |	\
223 						CS_EVENT_CARD_REMOVAL_LOWP)
224 
225 /*
226  * client_info_t structure used by clients for a CS_EVENT_CLIENT_INFO
227  *	event and for the GetClientInfo function.
228  */
229 #define	CS_CLIENT_INFO_MAX_NAME_LEN	80
230 typedef struct client_info_t {
231 	uint32_t	Attributes;
232 	uint32_t	Revision;	/* BCD value of client revision */
233 	uint32_t	CSLevel;	/* BCD value of CS release */
234 	uint32_t	RevDate;	/* revision date */
235 	char		ClientName[CS_CLIENT_INFO_MAX_NAME_LEN];
236 	char		VendorName[CS_CLIENT_INFO_MAX_NAME_LEN];
237 	char		DriverName[MODMAXNAMELEN];
238 } client_info_t;
239 
240 /*
241  * Flags for client_info_t->Attributes
242  *
243  * The low order byte bit values are used to return the data passed
244  *	in to RegisterClient in the client_reg_t->Attributes member.
245  */
246 #define	CS_CLIENT_INFO_SOCKET_SERVICES	INFO_SOCKET_SERVICES
247 #define	CS_CLIENT_INFO_IO_CLIENT	INFO_IO_CLIENT
248 #define	CS_CLIENT_INFO_MTD_CLIENT	INFO_MTD_CLIENT
249 #define	CS_CLIENT_INFO_MEM_CLIENT	INFO_MEM_CLIENT
250 #define	CS_CLIENT_INFO_CSI_CLIENT	INFO_CSI_CLIENT
251 #define	CS_CLIENT_INFO_CARD_SHARE	INFO_CARD_SHARE
252 #define	CS_CLIENT_INFO_CARD_EXCL	INFO_CARD_EXCL
253 #define	CS_CLIENT_INFO_CLIENT_MASK	0x000000ff
254 /*
255  * Control and status flags.
256  */
257 #define	CS_CLIENT_INFO_VALID		0x00010000	/* client info valid */
258 #define	CS_CLIENT_INFO_CLIENT_ACTIVE	0x00020000	/* client is for card */
259 #define	CS_CLIENT_INFO_FLAGS_MASK	0xffff0000
260 /*
261  * Client Info subservice flags and types.
262  */
263 #define	CS_CLIENT_INFO_SUBSVC_CS	0x00000000	/* CS client data */
264 #define	CS_CLIENT_INFO_SUBSVC_MASK	0x0000ff00	/* sub-service mask */
265 #define	GET_CLIENT_INFO_SUBSVC(s)	(((s) & CS_CLIENT_INFO_SUBSVC_MASK)>>8)
266 #define	SET_CLIENT_INFO_SUBSVC(s)	(((s)<<8) & CS_CLIENT_INFO_SUBSVC_MASK)
267 
268 /*
269  * CS_CLIENT_INFO_MAKE_DATE - Macro to make constructing the
270  *	client_info_t->RevDate member easier. Parameters are:
271  *
272  *	day - from 1 to 31
273  *	month - from 1 to 12
274  *	year - year relative to 1980
275  *			00 - 1980
276  *			06 - 1986
277  *			12 = 1992
278  *			16 - 1996, etc...
279  */
280 #define	CS_CLIENT_INFO_MAKE_DATE(d, m, y)	(((d) & 0x01f) |	\
281 						(((m) & 0x0f) << 5) |	\
282 						(((y) & 0x7f) << 9))
283 #define	CS_CLIENT_INFO_GET_DAY(d)		((d) & 0x1f)
284 #define	CS_CLIENT_INFO_GET_MONTH(m)		(((m) >> 5) & 0x0f)
285 #define	CS_CLIENT_INFO_GET_YEAR(y)		((((y) >> 9) & 0x7f) + 1980)
286 #define	CS_CLIENT_INFO_GET_YEAR_OFFSET(y)	(((y) >> 9) & 0x7f)
287 
288 /*
289  * get_firstnext_client_t_t structure used for GetFirstClient and GetNextClient
290  */
291 typedef struct get_firstnext_client_t {
292 	uint32_t	Socket;
293 	uint32_t	Attributes;
294 	client_handle_t	client_handle;		/* returned client handle */
295 	uint32_t	num_clients;
296 } get_firstnext_client_t;
297 
298 /*
299  * Flags for get_firstnext_client_t->Attributes
300  */
301 #define	CS_GET_FIRSTNEXT_CLIENT_ALL_CLIENTS	0x00000001
302 #define	CS_GET_FIRSTNEXT_CLIENT_SOCKET_ONLY	0x00000002
303 
304 /*
305  * The client event callback argument structure - this is passed in to
306  *	the client event handler.  Most of these arguments are identical
307  *	to the PCMCIA-specified arguments.
308  */
309 typedef struct event_callback_args_t {
310 	client_handle_t	client_handle;
311 	void		*info;
312 	void		*mtdrequest;
313 	void		*buffer;
314 	void		*misc;
315 	void		*client_data;
316 	client_info_t	client_info;
317 } event_callback_args_t;
318 
319 /*
320  * Event priority flag passed to the client's event handler; the client
321  *	uses this priority to determine which mutex to use.
322  */
323 #define	CS_EVENT_PRI_LOW	0x0001
324 #define	CS_EVENT_PRI_HIGH	0x0002
325 #define	CS_EVENT_PRI_NONE	0x0004
326 
327 /*
328  * Event-specific event_callback_args_t->info values
329  *
330  * CS_EVENT_WRITE_PROTECT
331  *	CS_EVENT_WRITE_PROTECT_WPOFF - card is not write protected
332  *	CS_EVENT_WRITE_PROTECT_WPON - card is write protected
333  */
334 #define	CS_EVENT_WRITE_PROTECT_WPOFF	0x0000
335 #define	CS_EVENT_WRITE_PROTECT_WPON	0xffff
336 
337 /*
338  * Endinanness and data ordering Attribute bits common to both R2 and
339  *	CardBus windows and common to RequestIO, RequestWindow and
340  *	DupHandle.
341  */
342 #define	WIN_ACC_ENDIAN_MASK	0x00300000	/* endian mask */
343 #define	WIN_ACC_NEVER_SWAP	0x00000000	/* i/o access: no swap */
344 #define	WIN_ACC_BIG_ENDIAN	0x00100000	/* big endian */
345 #define	WIN_ACC_LITTLE_ENDIAN	0x00200000	/* little endian */
346 
347 #define	WIN_ACC_ORDER_MASK	0x00700000	/* order mask */
348 #define	WIN_ACC_STRICT_ORDER	0x00000000	/* strict order */
349 #define	WIN_ACC_UNORDERED_OK	0x00100000	/* may be re-ordered */
350 #define	WIN_ACC_MERGING_OK	0x00200000	/* may merge i/o */
351 #define	WIN_ACC_LOADCACHING_OK	0x00300000	/* may cache reads */
352 #define	WIN_ACC_STORECACHING_OK	0x00400000	/* may cache all i/o */
353 
354 /*
355  * io_req_t structure used for RequestIO and ReleaseIO
356  */
357 typedef struct io_req_t {
358 	uint32_t	Socket;
359 	baseaddru_t	BasePort1;
360 	uint32_t	NumPorts1;	/* 1st IO range no. contiguous ports */
361 	uint32_t	Attributes1;	/* 1st IO range attributes */
362 	baseaddru_t	BasePort2;
363 	uint32_t	NumPorts2;	/* 2nd IO range no. contiguous ports */
364 	uint32_t	Attributes2;	/* 2nd IO range attributes */
365 	uint32_t	IOAddrLines;	/* number of IO address lines decoded */
366 } io_req_t;
367 
368 /*
369  * Flags for RequestIO and ReleaseIO
370  */
371 #define	IO_DATA_WIDTH_MASK	0x00000001	/* data path width mask */
372 #define	IO_DATA_WIDTH_8		0x00000000	/* 8 bit data path */
373 #define	IO_DATA_WIDTH_16	0x00000001	/* 16 bit data path */
374 
375 /*
376  * The following flags are included for compatability with other versions of
377  *	Card Services, but they are not implemented in this version.  They
378  *	are assigned values as placeholders only.  If any of these flags
379  *	are set on a call to RequestIO, CS_BAD_ATTRIBUTE is returned.
380  */
381 #define	IO_SHARED		0x00010000	/* for compatability only */
382 #define	IO_FIRST_SHARED		0x00020000	/* for compatability only */
383 #define	IO_FORCE_ALIAS_ACCESS	0x00040000	/* for compatability only */
384 
385 /*
386  * The following flags are private to Card Services and should never be set
387  *	by a client.  Doing so will cause the system to take a supervisor
388  *	trap at level twenty-nine.
389  */
390 #define	IO_DEALLOCATE_WINDOW	0x10000000	/* CS private */
391 #define	IO_DISABLE_WINDOW	0x20000000	/* CS private */
392 
393 /*
394  * win_req_t structure used for RequestWindow
395  *
396  * Note that the ReqOffset member is not defined in the current PCMCIA
397  *	spec but is included here to aid clients in determining the
398  *	optimum offset to give to MapMemPage.
399  */
400 typedef struct win_req_t {
401 	uint32_t	Socket;
402 	uint32_t	Attributes;	/* window flags */
403 	union {
404 	    uint32_t		base;	/* requested window base address */
405 	    acc_handle_t	handle;	/* access handle for base of window */
406 	} Base;
407 	uint32_t	Size;		/* window size requested/granted */
408 	union {
409 	    uint32_t		AccessSpeed;	/* window access speed */
410 	    uint32_t		IOAddrLines;	/* for I/O windows only */
411 	} win_params;
412 	uint32_t	ReqOffset;	/* required window offest */
413 } win_req_t;
414 
415 /*
416  * modify_win_t structure used for ModifyWindow
417  */
418 typedef struct modify_win_t {
419 	uint32_t	Attributes;	/* window flags */
420 	uint32_t	AccessSpeed;	/* window access speed */
421 } modify_win_t;
422 
423 /*
424  * Flags for RequestWindow and ModifyWindow
425  */
426 #define	WIN_MEMORY_TYPE_MASK	0x00000021	/* window type mask */
427 #define	WIN_MEMORY_TYPE_CM	0x00000000	/* window points to CM */
428 #define	WIN_MEMORY_TYPE_AM	0x00000001	/* window points to AM */
429 #define	WIN_MEMORY_TYPE_IO	0x00000020	/* window points to IO */
430 
431 #define	WIN_DATA_WIDTH_MASK	0x00000042	/* data path width mask */
432 #define	WIN_DATA_WIDTH_8	0x00000000	/* 8-bit data path */
433 #define	WIN_DATA_WIDTH_16	0x00000002	/* 16-bit data path */
434 #define	WIN_DATA_WIDTH_32	0x00000040	/* 32-bit data path */
435 
436 #define	WIN_ENABLE		0x00000004	/* enable/disable window */
437 #define	WIN_OFFSET_SIZE		0x00000008	/* card offsets window sized */
438 #define	WIN_ACCESS_SPEED_VALID	0x00000010	/* speed valid (ModifyWindow) */
439 
440 #define	WIN_PREFETCH_CACHE_MASK	0x00000300	/* prefetch/cache mask */
441 #define	WIN_PREFETCH		0x00000100	/* prefetchable not cacheable */
442 #define	WIN_PREFETCH_CACHE	0x00000200	/* prefetchable and cacheable */
443 
444 #define	WIN_BAR_MASK		0x00007000	/* Base Address Register mask */
445 #define	WIN_BAR_1		0x00001000	/* Base Address Register 1 */
446 #define	WIN_BAR_2		0x00002000	/* Base Address Register 2 */
447 #define	WIN_BAR_3		0x00003000	/* Base Address Register 3 */
448 #define	WIN_BAR_4		0x00004000	/* Base Address Register 4 */
449 #define	WIN_BAR_5		0x00005000	/* Base Address Register 5 */
450 #define	WIN_BAR_6		0x00006000	/* Base Address Register 6 */
451 #define	WIN_BAR_7		0x00007000	/* Base Address Register 7 */
452 
453 /*
454  * The following flag is used internally by Card Services and should never
455  *	be set by the caller.
456  */
457 #define	WIN_DATA_WIDTH_VALID	0x00008000	/* CS internal */
458 
459 /*
460  * The following flags are included for compatability with other versions of
461  *	Card Services, but they are not implemented in this version.  They
462  *	are assigned values as placeholders only.  If any of these flags
463  *	are set on a call to RequestWindow, CS_BAD_ATTRIBUTE is returned.
464  */
465 #define	WIN_PAGED		0x00010000	/* for compatability only */
466 #define	WIN_SHARED		0x00020000	/* for compatability only */
467 #define	WIN_FIRST_SHARED	0x00040000	/* for compatability only */
468 #define	WIN_BINDING_SPECIFIC	0x00080000	/* for compatability only */
469 
470 /*
471  * The following flag is actually part of the AccessSpeed member
472  */
473 #define	WIN_USE_WAIT		0x80	/* use window that supports WAIT */
474 
475 /*
476  * client_reg_t structure for RegisterClient
477  */
478 typedef struct client_reg_t {
479 	uint32_t		Attributes;
480 	uint32_t		EventMask;
481 	event_callback_args_t	event_callback_args;
482 	uint32_t		Version;	/* CS version to expect */
483 	csfunction_t		*event_handler;
484 	/* DDI support */
485 	ddi_iblock_cookie_t	*iblk_cookie;	/* event iblk cookie */
486 	ddi_idevice_cookie_t	*idev_cookie;	/* event idev cookie */
487 	dev_info_t		*dip;		/* client's dip */
488 	char			driver_name[MODMAXNAMELEN];
489 	/* CS private */
490 	void			*priv;		/* CS private data */
491 } client_reg_t;
492 
493 /*
494  * Flags for RegisterClient - some of these flags are also used internally
495  *	by CS to sequence the order of event callbacks and to allow Socket
496  *	Services to register as a "super" client.
497  *
498  * The client_reg_t->Attributes structure member uses these flags.
499  *
500  * The client_info_t->Attributes, client_types_t->type and client_t->flags
501  *	tructure members use these flags as well.
502  *
503  * Client types - mutually exclusive.
504  */
505 #define	INFO_SOCKET_SERVICES	0x00000001
506 #define	INFO_IO_CLIENT		0x00000002
507 #define	INFO_MTD_CLIENT		0x00000004
508 #define	INFO_MEM_CLIENT		0x00000008
509 #define	INFO_CSI_CLIENT		0x00000010
510 #define	INFO_CLIENT_TYPE_MASK	(INFO_SOCKET_SERVICES |		\
511 					INFO_IO_CLIENT |	\
512 					INFO_MTD_CLIENT	|	\
513 					INFO_MEM_CLIENT |	\
514 					INFO_CSI_CLIENT)
515 #define	MAX_CLIENT_TYPES	3	/* doesn't include SS or CSI clients */
516 
517 /*
518  * The following two are for backwards-compatability with the PCMCIA spec.
519  *	We will give the client CARD_INSERTION and REGISTRATION_COMPLETE
520  *	if either of these two bits are set.  Normally, all IO and MEM
521  *	clients should set both of these bits.
522  */
523 #define	INFO_CARD_SHARE		0x00000020
524 #define	INFO_CARD_EXCL		0x00000040
525 #define	INFO_CARD_FLAGS_MASK	(INFO_CARD_SHARE | INFO_CARD_EXCL)
526 
527 /*
528  * tuple_t struct used for GetFirstTuple, GetNextTuple, GetTupleData
529  *	and ParseTuple
530  *
531  * Note that the values for DesiredTuple are defined in the cis.h header
532  *	file.
533  */
534 typedef struct tuple_t {
535 	uint32_t	Socket;		/* socket number to get tuple from */
536 	uint32_t	Attributes;	/* tuple return attributes */
537 	cisdata_t	DesiredTuple;	/* tuple to search for or flags */
538 	cisdata_t	TupleOffset;	/* offset in tuple data body */
539 	uint32_t	Flags;		/* CS private */
540 	cistpl_t	*LinkOffset;	/* CS private */
541 	cistpl_t	*CISOffset;	/* CS private */
542 	cisdata_t	TupleDataMax;	/* max size of tuple data area */
543 	cisdata_t	TupleDataLen;	/* actual size of tuple data area */
544 					/* tuple body data buffer */
545 	cisdata_t	TupleData[CIS_MAX_TUPLE_DATA_LEN];
546 	cisdata_t	TupleCode;	/* tuple type code */
547 	cisdata_t	TupleLink;	/* tuple data body size */
548 } tuple_t;
549 
550 /*
551  * Attribute flags definitions for CS tuple functions.
552  *
553  */
554 #define	TUPLE_RETURN_LINK		0x00000002 /* return link tuples */
555 #define	TUPLE_RETURN_IGNORED_TUPLES	0x00010000 /* return ignored tuples */
556 #define	TUPLE_RETURN_NAME		0x00020000 /* return tuple name */
557 
558 /*
559  * cisinfo_t structure used for ValidateCIS
560  */
561 typedef struct cisinfo_t {
562 	uint32_t	Socket;		/* socket number to validate CIS on */
563 	uint32_t	Chains;		/* number of tuple chains in CIS */
564 	uint32_t	Tuples;		/* total number of tuples in CIS */
565 } cisinfo_t;
566 
567 /*
568  * map_mem_page_t structure used for MapMemPage
569  */
570 typedef struct map_mem_page_t {
571 	uint32_t	CardOffset;	/* card offset */
572 	uint32_t	Page;		/* page number */
573 } map_mem_page_t;
574 
575 /*
576  * sockevent_t structure used for GetEventMask and SetEventMask
577  */
578 typedef struct sockevent_t {
579 	uint32_t	Attributes;	/* attribute flags for call */
580 	uint32_t	EventMask;	/* event mask to set or return */
581 	uint32_t	Socket;		/* socket number if necessary */
582 } sockevent_t;
583 
584 /*
585  * request_socket_mask_t structure used for RequestSocketMask
586  */
587 typedef struct request_socket_mask_t {
588 	uint32_t	Socket;		/* socket number if necessary */
589 	uint32_t	EventMask;	/* event mask to set or return */
590 } request_socket_mask_t;
591 
592 /*
593  * release_socket_mask_t structure used for ReleaseSocketMask
594  */
595 typedef struct release_socket_mask_t {
596 	uint32_t	Socket;
597 } release_socket_mask_t;
598 
599 /*
600  * Flags for GetEventMask and SetEventMask
601  */
602 #define	CONF_EVENT_MASK_GLOBAL	0x00000000	/* global event mask */
603 #define	CONF_EVENT_MASK_CLIENT	0x00000001	/* client event mask */
604 #define	CONF_EVENT_MASK_VALID	0x00000001	/* client event mask */
605 
606 /*
607  * convert_speed_t structure used for ConvertSpeed
608  */
609 typedef struct convert_speed_t {
610 	uint32_t	Attributes;
611 	uint32_t	nS;
612 	uint32_t	devspeed;
613 } convert_speed_t;
614 
615 /*
616  * Flags for ConvertSpeed
617  */
618 #define	CONVERT_NS_TO_DEVSPEED	0x00000001
619 #define	CONVERT_DEVSPEED_TO_NS	0x00000002
620 
621 /*
622  * convert_size_t structure used for ConvertSize
623  */
624 typedef struct convert_size_t {
625 	uint32_t	Attributes;
626 	uint32_t	bytes;
627 	uint32_t	devsize;
628 } convert_size_t;
629 
630 /*
631  * Flags for ConvertSize
632  */
633 #define	CONVERT_BYTES_TO_DEVSIZE	0x00000001
634 #define	CONVERT_DEVSIZE_TO_BYTES	0x00000002
635 
636 #define	MAX_CS_EVENT_BUFSIZE		64	/* single event */
637 #define	MAX_MULTI_EVENT_BUFSIZE		512	/* all events */
638 
639 #define	CS_EVENT_MAX_BUFSIZE	MAX_MULTI_EVENT_BUFSIZE
640 #define	CS_ERROR_MAX_BUFSIZE	MAX_CS_EVENT_BUFSIZE
641 
642 /*
643  * event2text_t structure used for Event2Text
644  */
645 typedef struct event2text_t {
646 	event_t		event;		/* events */
647 					/* buffer to return text strings */
648 	char		text[CS_EVENT_MAX_BUFSIZE];
649 } event2text_t;
650 
651 /*
652  * error2text_t structure used for Error2Text
653  */
654 typedef struct error2text_t {
655 	uint32_t	item;
656 	char		text[CS_ERROR_MAX_BUFSIZE];
657 } error2text_t;
658 
659 /*
660  * get_status_t structure used for GetStatus
661  *
662  * The values in the status members are the same as the CS_EVENT_XXX values.
663  */
664 typedef struct get_status_t {
665 	uint32_t	Socket;
666 	uint32_t	CardState;	/* "live" card status for this client */
667 	uint32_t	SocketState;	/* latched socket values */
668 	uint32_t	raw_CardState;	/* raw live card status */
669 } get_status_t;
670 
671 /*
672  * GetStatus returns card state using the same bit definitions
673  *	as the CS_EVENT_XXX bits. Some of the CS_EVENT_XXX bits
674  *	are not meaningful for GetStatus and are reused here for
675  *	status definitions.
676  *
677  * get_status_t->CardState and get_status_t->raw_CardState bits
678  */
679 #define	CS_STATUS_WRITE_PROTECTED	CS_EVENT_WRITE_PROTECT
680 #define	CS_STATUS_CARD_LOCKED		CS_EVENT_CARD_LOCK
681 #define	CS_STATUS_EJECTION_REQUEST	CS_EVENT_EJECTION_REQUEST
682 #define	CS_STATUS_INSERTION_REQUEST	CS_EVENT_INSERTION_REQUEST
683 #define	CS_STATUS_BATTERY_DEAD		CS_EVENT_BATTERY_DEAD
684 #define	CS_STATUS_BATTERY_LOW		CS_EVENT_BATTERY_LOW
685 #define	CS_STATUS_CARD_READY		CS_EVENT_CARD_READY
686 #define	CS_STATUS_CARD_INSERTED		CS_EVENT_CARD_INSERTION
687 #define	CS_STATUS_RES_EVT1		0x00100000
688 #define	CS_STATUS_RES_EVT2		0x00200000
689 #define	CS_STATUS_RES_EVT3		0x00400000
690 #define	CS_STATUS_VCC_50		0x10000000
691 #define	CS_STATUS_VCC_33		0x20000000
692 #define	CS_STATUS_VCC_XX		0x40000000
693 #define	CS_STATUS_REQ_ATTN		0x80000000
694 /*
695  * get_status_t->SocketState bits
696  */
697 #define	CS_SOCK_STATUS_WRITE_PROTECT_CHANGE	CS_EVENT_WRITE_PROTECT
698 #define	CS_SOCK_STATUS_CARD_LOCK_CHNAGE		CS_EVENT_CARD_LOCK
699 #define	CS_SOCK_STATUS_EJECTION_PENDING		CS_EVENT_EJECTION_REQUEST
700 #define	CS_SOCK_STATUS_INSERTION_PENDING	CS_EVENT_INSERTION_REQUEST
701 #define	CS_SOCK_STATUS_BATTERY_DEAD_CHNAGE	CS_EVENT_BATTERY_DEAD
702 #define	CS_SOCK_STATUS_BATTERY_LOW_CHNAGE	CS_EVENT_BATTERY_LOW
703 #define	CS_SOCK_STATUS_CARD_READY_CHANGE	CS_EVENT_CARD_READY
704 #define	CS_SOCK_STATUS_CARD_DETECT_CHNAGE	CS_EVENT_CARD_INSERTION
705 
706 /*
707  * map_log_socket_t structure used for MapLogSocket
708  */
709 typedef struct map_log_socket_t {
710 	uint32_t	LogSocket;	/* logical socket */
711 	uint32_t	PhyAdapter;	/* physical adapter */
712 	uint32_t	PhySocket;	/* physical socket */
713 } map_log_socket_t;
714 
715 /*
716  * get_physical_adapter_info_t structure used for GetPhysicalAdapterInfo
717  */
718 typedef struct get_physical_adapter_info_t {
719 	uint32_t	LogSocket;	/* logical socket */
720 	uint32_t	PhySocket;	/* physical socket */
721 	uint32_t	flags;		/* adapter flags */
722 	char		name[MODMAXNAMELEN]; /* adapter module name */
723 	uint32_t	major;		/* adapter major number */
724 	uint32_t	minor;		/* adapter minor number */
725 	uint32_t	instance;	/* instance number of this adapter */
726 	uint32_t	number;		/* canonical adapter number */
727 	uint32_t	num_sockets;	/* # sockets on this adapter */
728 	uint32_t	first_socket;	/* first socket # on this adapter */
729 } get_physical_adapter_info_t;
730 
731 /*
732  * irq_req_t structure used for RequestIRQ and ReleaseIRQ
733  */
734 typedef struct irq_req_t {
735 	uint32_t		Socket;
736 	uint32_t		Attributes;	/* IRQ attribute flags */
737 	csfunction_t		*irq_handler;
738 	void			*irq_handler_arg;
739 	ddi_iblock_cookie_t	*iblk_cookie;	/* IRQ iblk cookie */
740 	ddi_idevice_cookie_t	*idev_cookie;	/* IRQ idev cookie */
741 } irq_req_t;
742 
743 /*
744  * Flags for RequestIRQ and ReleaseIRQ
745  */
746 #define	IRQ_TYPE_EXCLUSIVE		0x00000002
747 /*
748  * The following flags are included for compatability with other versions of
749  *	Card Services, but they are not implemented in this version.  They
750  *	are assigned values as placeholders only.  If any of these flags
751  *	are set on a call to RequestIRQ, CS_BAD_ATTRIBUTE is returned.
752  */
753 #define	IRQ_FORCED_PULSE		0x00010000
754 #define	IRQ_TYPE_TIME			0x00020000
755 #define	IRQ_TYPE_DYNAMIC_SHARING	0x00040000
756 #define	IRQ_FIRST_SHARED		0x00080000
757 #define	IRQ_PULSE_ALLOCATED		0x00100000
758 
759 /*
760  * release_config_t structure used for ReleaseConfiguration
761  */
762 typedef struct release_config_t {
763 	uint32_t	Socket;
764 } release_config_t;
765 
766 /*
767  * config_req_t structure used for RequestConfiguration
768  */
769 typedef struct config_req_t {
770 	uint32_t	Socket;
771 	uint32_t	Attributes;	/* configuration attributes */
772 	uint32_t	Vcc;		/* Vcc value */
773 	uint32_t	Vpp1;		/* Vpp1 value */
774 	uint32_t	Vpp2;		/* Vpp2 value */
775 	uint32_t	IntType;	/* socket interface type - mem or IO */
776 	uint32_t	ConfigBase;	/* offset from start of AM space */
777 	uint32_t	Status;		/* value to write to STATUS register */
778 	uint32_t	Pin;		/* value to write to PRR */
779 	uint32_t	Copy;		/* value to write to COPY register */
780 	uint32_t	ConfigIndex;	/* value to write to COR */
781 	uint32_t	Present;	/* which config registers present */
782 	uint32_t	ExtendedStatus;	/* value to write to EXSTAT register */
783 } config_req_t;
784 
785 /*
786  * Flags for RequestConfiguration - note that the CONF_ENABLE_IRQ_STEERING
787  *	flag shares the same bit field as the Attributes flags for
788  *	ModifyConfiguration.
789  */
790 #define	CONF_ENABLE_IRQ_STEERING	0x00010000
791 /*
792  * The following flags are used for the IntType member to specify which
793  *	type of socket interface the client wants.
794  */
795 #define	SOCKET_INTERFACE_MEMORY		0x00000001
796 #define	SOCKET_INTERFACE_MEMORY_AND_IO	0x00000002
797 /*
798  * The following flags are used for the Present member to specify which
799  *	configuration registers are present.  They may also be used by
800  *	clients for their internal state.
801  */
802 #define	CONFIG_OPTION_REG_PRESENT	0x00000001 /* COR present */
803 #define	CONFIG_STATUS_REG_PRESENT	0x00000002 /* STAT reg present */
804 #define	CONFIG_PINREPL_REG_PRESENT	0x00000004 /* PRR present */
805 #define	CONFIG_COPY_REG_PRESENT		0x00000008 /* COPY reg present */
806 #define	CONFIG_EXSTAT_REG_PRESENT	0x00000010 /* EXSTAT reg present */
807 #define	CONFIG_IOBASE0_REG_PRESENT	0x00000020 /* IOBASE0 reg present */
808 #define	CONFIG_IOBASE1_REG_PRESENT	0x00000040 /* IOBASE1 reg present */
809 #define	CONFIG_IOBASE2_REG_PRESENT	0x00000080 /* IOBASE2 reg present */
810 #define	CONFIG_IOBASE3_REG_PRESENT	0x00000100 /* IOBASE3 reg present */
811 #define	CONFIG_IOLIMIT_REG_PRESENT	0x00000200 /* IOLIMIT reg present */
812 
813 /*
814  * CONFIG_IOBASE_REG_MASK - mask of IO Base Port register present bits
815  * CONFIG_IOBASE_REG_SHIFT - shifts IO Base Port register present bits
816  */
817 #define	CONFIG_IOBASE_REG_MASK		0x000001e0 /* IOBASEn present mask */
818 #define	CONFIG_IOBASE_REG_SHIFT		5
819 
820 /*
821  * Bit definitions for configuration registers.
822  *
823  * Pin Replacement Register (PRR) bits - these are used for calls to
824  *	RequestConfiguration, AccessConfigurationRegister and
825  *	GetConfigurationInfo, as well as internally by clients
826  *	and Card Services.
827  * To inform Card Services that a particular bit in the PRR is valid on
828  *	a call to RequestConfiguration, both the XXX_STATUS and the
829  *	XXX_EVENT bits must be set.
830  */
831 #define	PRR_WP_STATUS		0x01	/* R-WP state W-write WP Cbit */
832 #define	PRR_READY_STATUS	0x02	/* R-READY state W-write READY Cbit */
833 #define	PRR_BVD2_STATUS		0x04	/* R-BVD2 state W-write BVD2 Cbit */
834 #define	PRR_BVD1_STATUS		0x08	/* R-BVD1 state W-write BVD1 Cbit */
835 #define	PRR_WP_EVENT		0x10	/* WP changed */
836 #define	PRR_READY_EVENT		0x20	/* READY changed */
837 #define	PRR_BVD2_EVENT		0x40	/* BVD2 changed */
838 #define	PRR_BVD1_EVENT		0x80	/* BVD1 changed */
839 /*
840  * Configuration Option Register (COR) bits
841  */
842 #define	COR_ENABLE_FUNCTION	0x01	/* enable function */
843 #define	COR_ENABLE_BASE_LIMIT	0x02	/* enable base and limit registers */
844 #define	COR_ENABLE_IREQ_ROUTING	0x04	/* enable IREQ routing */
845 #define	COR_STATUS_CHANGE_MODE	0x08	/* status change mode */
846 #define	COR_LEVEL_IRQ		0x40	/* set to enable level interrupts */
847 #define	COR_SOFT_RESET		0x80	/* soft reset bit */
848 /*
849  * Card Configuration Status Register (CCSR)
850  */
851 #define	CCSR_INTR_ACK		0x01	/* interrupt acknowledge */
852 #define	CCSR_INTR		0x02	/* interrupt pending */
853 #define	CCSR_POWER_DOWN		0x04	/* power down card */
854 #define	CCSR_AUDIO		0x08	/* enable Audio signal */
855 #define	CCSR_IO_IS_8		0x20	/* only 8-bit IO data path */
856 #define	CCSR_SIG_CHG		0x40	/* enable status changes */
857 #define	CCSR_CHANGED		0x80	/* one of the PRR bits has changed */
858 /*
859  * Macros to manipulate the Socket and Copy Register (SCR) values
860  */
861 #define	SCR_GET_SOCKET(r)		((r)&0x0f)
862 #define	SCR_GET_COPY(r)			(((r)>>4)&7)
863 #define	SCR_SET_SOCKET(s)		((s)&0x0f)
864 #define	SCR_SET_COPY(c)			(((c)&7)<<4)
865 #define	SCR_SET_SOCKET_COPY(s, c)	(((s)&0x0f) | (((c)&7)<<4))
866 
867 /*
868  * modify_config_t structure used for ModifyConfiguration
869  */
870 typedef struct modify_config_t {
871 	uint32_t	Socket;
872 	uint32_t	Attributes;	/* attributes to modify */
873 	uint32_t	Vpp1;		/* Vpp1 value */
874 	uint32_t	Vpp2;		/* Vpp2 value */
875 } modify_config_t;
876 
877 /*
878  * Flags for ModifyConfiguration - note that the CONF_ENABLE_IRQ_STEERING
879  *	flag used with RequestConfiguration shares this bit field.
880  */
881 #define	CONF_VPP1_CHANGE_VALID		0x00000002	/* Vpp1 is valid */
882 #define	CONF_VPP2_CHANGE_VALID		0x00000004	/* Vpp2 is valid */
883 #define	CONF_IRQ_CHANGE_VALID		0x00000008	/* IRQ is valid */
884 
885 /*
886  * access_config_reg_t structure used for AccessConfigurationRegister
887  */
888 typedef struct access_config_reg_t {
889 	uint32_t	Socket;
890 	uint32_t	Action;		/* register access operation */
891 	uint32_t	Offset;		/* config register offset */
892 	uint32_t	Value;		/* value read or written */
893 } access_config_reg_t;
894 /*
895  * Flags for AccessConfigurationRegister
896  */
897 #define	CONFIG_REG_READ		0x00000001	/* read config register */
898 #define	CONFIG_REG_WRITE	0x00000002	/* write config register */
899 /*
900  * The following offsets are used to specify the configuration register
901  *	offset to AccessConfigurationRegister
902  */
903 #define	CONFIG_OPTION_REG_OFFSET	0x00	/* COR offset */
904 #define	CONFIG_STATUS_REG_OFFSET	0x02	/* STAT reg offset */
905 #define	CONFIG_PINREPL_REG_OFFSET	0x04	/* PRR offset */
906 #define	CONFIG_COPY_REG_OFFSET		0x06	/* COPY reg offset */
907 #define	CONFIG_EXSTAT_REG_OFFSET	0x08	/* EXSTAT reg offset */
908 #define	CONFIG_IOBASE0_REG_OFFSET	0x0a	/* IOBASE0 reg offset */
909 #define	CONFIG_IOBASE1_REG_OFFSET	0x0c	/* IOBASE1 reg offset */
910 #define	CONFIG_IOBASE2_REG_OFFSET	0x0e	/* IOBASE2 reg offset */
911 #define	CONFIG_IOBASE3_REG_OFFSET	0x10	/* IOBASE3 reg offset */
912 #define	CONFIG_IOLIMIT_REG_OFFSET	0x12	/* IOLIMIT reg offset */
913 
914 /*
915  * reset_function_t structure used for ResetFunction
916  */
917 typedef struct reset_function_t {
918 	uint32_t	Socket;
919 	uint32_t	Attributes;
920 } reset_function_t;
921 
922 /*
923  * get_cardservices_info_t structure used for GetCardServicesInfo
924  */
925 #define	CS_GET_CARDSERVICES_INFO_MAX_VS_LEN	512
926 typedef struct get_cardservices_info_t {
927 	char		Signature[2];	/* CS signature bytes */
928 	uint32_t	NumSockets;	/* number of sockets */
929 	uint32_t	Revision;	/* BCD value of CS revision */
930 	uint32_t	CSLevel;	/* BCD value of CS release */
931 	uint32_t	FuncsPerSocket;	/* max number of functions per socket */
932 	char		VendorString[CS_GET_CARDSERVICES_INFO_MAX_VS_LEN];
933 } get_cardservices_info_t;
934 
935 /*
936  * get_configuration_info_t structure used by GetConfigurationInfo
937  */
938 typedef struct get_configuration_info_t {
939 	uint32_t	Socket;		/* Socket/function to get info for */
940 	uint32_t	Attributes;	/* configuration attributes */
941 	uint32_t	Vcc;		/* Vcc value */
942 	uint32_t	Vpp1;		/* Vpp1 value */
943 	uint32_t	Vpp2;		/* Vpp2 value */
944 	uint32_t	IntType;	/* memory only or memory and IO ifc */
945 	uint32_t	ConfigBase;	/* offset from start of AM space */
946 	uint32_t	Status;		/* value written to STATUS register */
947 	uint32_t	Pin;		/* value written to PRR */
948 	uint32_t	Copy;		/* value to written COPY register */
949 	uint32_t	Option;		/* which written to COR */
950 	uint32_t	Present;	/* which config registers present */
951 	uint32_t	FirstDevType;	/* from CISTPL_DEVICE */
952 	uint32_t	FuncCode;	/* from CISTPL_FUNCID */
953 	uint32_t	SysInitMask;	/* from CISTPL_FUNCID */
954 	uint32_t	ManufCode;	/* from CISTPL_MANFID */
955 	uint32_t	ManufInfo;	/* from CISTPL_MANFID */
956 	uint32_t	CardValues;	/* which config registers written */
957 	uint32_t	AssignedIRQ;	/* IRQ assigned to card */
958 	uint32_t	IRQ_Attributes;	/* IRQ attributes */
959 	uint32_t	BasePort1;	/* address of 1st IO range */
960 	uint32_t	NumPorts1;	/* 1st IO range no. contiguous ports */
961 	uint32_t	Attributes1;	/* 1st IO range attributes */
962 	uint32_t	BasePort2;	/* address of 2nd IO range */
963 	uint32_t	NumPorts2;	/* 2nd IO range no. contiguous ports */
964 	uint32_t	Attributes2;	/* 2nd IO range attributes */
965 	uint32_t	IOAddrLines;	/* number of IO address lines decoded */
966 	uint32_t	ExStat;		/* value written to EXSTAT register */
967 	uint32_t	DMA_Attributes;	/* signals used for DMA */
968 	uint32_t	DMA_Assign_Chan;	/* assigned DMA channel */
969 	uint32_t	NumIOWindows;	/* number of IO windows in use */
970 	uint32_t	NumMemWindows;	/* number of memory windows in use */
971 } get_configuration_info_t;
972 
973 /*
974  * devnode_desc_t structure used in make_device_node_t and remove_device_node_t
975  *	for MakeDeviceNode and RemoveDeviceNode
976  */
977 typedef struct devnode_desc_t {
978 	char	*name;		/* device node path and name */
979 	int32_t	spec_type;	/* dev special type (block or char) */
980 	int32_t	minor_num;	/* device node minor number */
981 	char	*node_type;	/* device node type */
982 } devnode_desc_t;
983 
984 /*
985  * make_device_node_t structure used for MakeDeviceNode
986  */
987 typedef struct make_device_node_t {
988 	uint32_t	Action;		/* device operation */
989 	uint32_t	NumDevNodes;	/* number of nodes to create */
990 	devnode_desc_t	*devnode_desc;	/* description of device nodes */
991 } make_device_node_t;
992 /*
993  * Action values for MakeDeviceNode
994  */
995 #define	CREATE_DEVICE_NODE		0x01	/* create device node */
996 
997 /*
998  * remove_device_node_t structure used for RemoveDeviceNode
999  */
1000 typedef struct remove_device_node_t {
1001 	uint32_t	Action;		/* device operation */
1002 	uint32_t	NumDevNodes;	/* number of nodes to remove */
1003 	devnode_desc_t	*devnode_desc;	/* description of device nodes */
1004 } remove_device_node_t;
1005 /*
1006  * Action values for RemoveDeviceNode
1007  *
1008  * Note: The "Action" member for make_device_node_t and remove_device_node_t
1009  *		share the same set of values.
1010  */
1011 #define	REMOVE_DEVICE_NODE		0x02	/* remove device node */
1012 #define	REMOVE_ALL_DEVICE_NODES		0x03	/* remove all device nodes */
1013 
1014 /*
1015  * cs_ddi_info_t for CS_DDI_Info
1016  */
1017 typedef struct cs_ddi_info_t {
1018 	uint32_t	Socket;		/* socket number */
1019 	char		*driver_name;	/* unique driver name */
1020 	dev_info_t	*dip;		/* dip */
1021 	int32_t		instance;	/* instance */
1022 } cs_ddi_info_t;
1023 
1024 /*
1025  * cs_sys_ctl_t for CS_Sys_Ctl
1026  */
1027 typedef struct cs_sys_ctl_t {
1028 	uint32_t	Socket;
1029 	uint32_t	Action;
1030 	uint32_t	Flags;
1031 	uint32_t	Events;
1032 	client_handle_t	client_handle;
1033 } cs_sys_ctl_t;
1034 /*
1035  * cs_sys_ctl_t->Action defines
1036  *
1037  * CS_SYS_CTL_SEND_EVENT - send events in cs_sys_ctl_t->Events to clients
1038  */
1039 #define	CS_SYS_CTL_SEND_EVENT	0x0001	/* simulate events */
1040 /*
1041  * cs_sys_ctl_t->Flags defines
1042  *
1043  * CS_SYS_CTL_WAIT_SYNC - wait for operation to complete, otherwise
1044  *	return immediately
1045  * CS_SYS_CTL_EVENT_SOCKET - send events to all clients on specified
1046  *	socket
1047  * CS_SYS_CTL_EVENT_CLIENT - send events to client specified by
1048  *	cs_sys_ctl_t->client_handle
1049  */
1050 #define	CS_SYS_CTL_WAIT_SYNC	0x00000001	/* synchornize with thread */
1051 #define	CS_SYS_CTL_EVENT_SOCKET	0x00000002	/* to all clients on socket */
1052 #define	CS_SYS_CTL_EVENT_CLIENT	0x00000004	/* to client specified */
1053 
1054 /*
1055  * Autoincrement control flags for RepPut8, RepPut16, RepPut32, RepPut32,
1056  *	RepGet8, RepGet16, RepGet32, RepGet64
1057  */
1058 #define	CS_DEV_AUTOINCR		DDI_DEV_AUTOINCR
1059 #define	CS_DEV_NO_AUTOINCR	DDI_DEV_NO_AUTOINCR
1060 
1061 /*
1062  * Card Services function prototypes
1063  */
1064 int32_t csx_RegisterClient(client_handle_t *, client_reg_t *);
1065 int32_t csx_DeregisterClient(client_handle_t);
1066 int32_t csx_GetStatus(client_handle_t, get_status_t *);
1067 int32_t csx_SetEventMask(client_handle_t, sockevent_t *);
1068 int32_t csx_GetEventMask(client_handle_t, sockevent_t *);
1069 int32_t csx_RequestIO(client_handle_t, io_req_t *);
1070 int32_t csx_ReleaseIO(client_handle_t, io_req_t *);
1071 int32_t csx_RequestIRQ(client_handle_t, irq_req_t *);
1072 int32_t csx_ReleaseIRQ(client_handle_t, irq_req_t *);
1073 int32_t csx_RequestWindow(client_handle_t, window_handle_t *, win_req_t *);
1074 int32_t csx_ReleaseWindow(window_handle_t);
1075 int32_t csx_ModifyWindow(window_handle_t, modify_win_t *);
1076 int32_t csx_MapMemPage(window_handle_t, map_mem_page_t *);
1077 int32_t csx_RequestSocketMask(client_handle_t, request_socket_mask_t *);
1078 int32_t csx_ReleaseSocketMask(client_handle_t, release_socket_mask_t *);
1079 int32_t csx_RequestConfiguration(client_handle_t, config_req_t *);
1080 int32_t csx_ModifyConfiguration(client_handle_t, modify_config_t *);
1081 int32_t csx_ReleaseConfiguration(client_handle_t, release_config_t *);
1082 int32_t csx_AccessConfigurationRegister(client_handle_t, access_config_reg_t *);
1083 int32_t csx_GetFirstTuple(client_handle_t, tuple_t *);
1084 int32_t csx_GetNextTuple(client_handle_t, tuple_t *);
1085 int32_t csx_GetTupleData(client_handle_t, tuple_t *);
1086 int32_t csx_MapLogSocket(client_handle_t, map_log_socket_t *);
1087 int32_t csx_ValidateCIS(client_handle_t, cisinfo_t *);
1088 int32_t csx_MakeDeviceNode(client_handle_t, make_device_node_t *);
1089 int32_t csx_RemoveDeviceNode(client_handle_t, remove_device_node_t *);
1090 int32_t csx_ConvertSpeed(convert_speed_t *);
1091 int32_t csx_ConvertSize(convert_size_t *);
1092 int32_t csx_Event2Text(event2text_t *);
1093 int32_t csx_Error2Text(error2text_t *);
1094 int32_t csx_CS_DDI_Info(cs_ddi_info_t *);
1095 int32_t csx_CS_Sys_Ctl(cs_sys_ctl_t *);
1096 int32_t csx_ResetFunction(client_handle_t, reset_function_t *);
1097 int32_t csx_GetFirstClient(get_firstnext_client_t *);
1098 int32_t csx_GetNextClient(get_firstnext_client_t *);
1099 int32_t csx_GetClientInfo(client_handle_t, client_info_t *);
1100 int32_t csx_GetCardServicesInfo(client_handle_t, get_cardservices_info_t *);
1101 int32_t csx_GetConfigurationInfo(client_handle_t *, get_configuration_info_t *);
1102 int32_t csx_GetPhysicalAdapterInfo(client_handle_t,
1103 					get_physical_adapter_info_t *);
1104 
1105 /*
1106  * CIS tuple parsing functions
1107  */
1108 int32_t csx_Parse_CISTPL_CONFIG(client_handle_t, tuple_t *, cistpl_config_t *);
1109 int32_t csx_Parse_CISTPL_DEVICE(client_handle_t, tuple_t *, cistpl_device_t *);
1110 int32_t csx_Parse_CISTPL_DEVICE_A(client_handle_t, tuple_t *,
1111 					cistpl_device_t *);
1112 int32_t csx_Parse_CISTPL_DEVICE_OA(client_handle_t, tuple_t *,
1113 					cistpl_device_t *);
1114 int32_t csx_Parse_CISTPL_DEVICE_OC(client_handle_t, tuple_t *,
1115 					cistpl_device_t *);
1116 int32_t csx_Parse_CISTPL_VERS_1(client_handle_t, tuple_t *, cistpl_vers_1_t *);
1117 int32_t csx_Parse_CISTPL_VERS_2(client_handle_t, tuple_t *, cistpl_vers_2_t *);
1118 int32_t csx_Parse_CISTPL_JEDEC_A(client_handle_t, tuple_t *, cistpl_jedec_t *);
1119 int32_t csx_Parse_CISTPL_JEDEC_C(client_handle_t, tuple_t *, cistpl_jedec_t *);
1120 int32_t csx_Parse_CISTPL_FORMAT(client_handle_t, tuple_t *, cistpl_format_t *);
1121 int32_t csx_Parse_CISTPL_FORMAT_A(client_handle_t, tuple_t *,
1122 					cistpl_format_t *);
1123 int32_t csx_Parse_CISTPL_GEOMETRY(client_handle_t, tuple_t *,
1124 					cistpl_geometry_t *);
1125 int32_t csx_Parse_CISTPL_BYTEORDER(client_handle_t, tuple_t *,
1126 					cistpl_byteorder_t *);
1127 int32_t csx_Parse_CISTPL_DATE(client_handle_t, tuple_t *, cistpl_date_t *);
1128 int32_t csx_Parse_CISTPL_BATTERY(client_handle_t, tuple_t *,
1129 					cistpl_battery_t *);
1130 int32_t csx_Parse_CISTPL_ORG(client_handle_t, tuple_t *, cistpl_org_t *);
1131 int32_t csx_Parse_CISTPL_MANFID(client_handle_t, tuple_t *, cistpl_manfid_t *);
1132 int32_t csx_Parse_CISTPL_FUNCID(client_handle_t, tuple_t *, cistpl_funcid_t *);
1133 int32_t csx_Parse_CISTPL_FUNCE(client_handle_t, tuple_t *, cistpl_funce_t *,
1134 					uint32_t);
1135 int32_t csx_Parse_CISTPL_CFTABLE_ENTRY(client_handle_t, tuple_t *,
1136 					cistpl_cftable_entry_t *);
1137 int32_t csx_Parse_CISTPL_LINKTARGET(client_handle_t, tuple_t *,
1138 					cistpl_linktarget_t *);
1139 int32_t csx_Parse_CISTPL_LONGLINK_A(client_handle_t, tuple_t *,
1140 					cistpl_longlink_ac_t *);
1141 int32_t csx_Parse_CISTPL_LONGLINK_C(client_handle_t, tuple_t *,
1142 					cistpl_longlink_ac_t *);
1143 int32_t csx_Parse_CISTPL_LONGLINK_MFC(client_handle_t, tuple_t *,
1144 					cistpl_longlink_mfc_t *);
1145 int32_t csx_Parse_CISTPL_SPCL(client_handle_t, tuple_t *,
1146 					cistpl_spcl_t *);
1147 int32_t csx_Parse_CISTPL_SWIL(client_handle_t, tuple_t *,
1148 					cistpl_swil_t *);
1149 int32_t csx_Parse_CISTPL_BAR(client_handle_t, tuple_t *,
1150 					cistpl_bar_t *);
1151 int32_t csx_Parse_CISTPL_DEVICEGEO(client_handle_t, tuple_t *,
1152 					cistpl_devicegeo_t *);
1153 int32_t csx_Parse_CISTPL_DEVICEGEO_A(client_handle_t, tuple_t *,
1154 					cistpl_devicegeo_t *);
1155 int32_t csx_Parse_CISTPL_LONGLINK_CB(client_handle_t, tuple_t *,
1156 					cistpl_longlink_cb_t *);
1157 int32_t csx_ParseTuple(client_handle_t, tuple_t *, cisparse_t *, uint32_t);
1158 
1159 /*
1160  * Data access functions
1161  */
1162 void csx_Put8(acc_handle_t, uint32_t, uint8_t);
1163 void csx_Put16(acc_handle_t, uint32_t, uint16_t);
1164 void csx_Put32(acc_handle_t, uint32_t, uint32_t);
1165 void csx_Put64(acc_handle_t, uint32_t, uint64_t);
1166 uint8_t csx_Get8(acc_handle_t, uint32_t);
1167 uint16_t csx_Get16(acc_handle_t, uint32_t);
1168 uint32_t csx_Get32(acc_handle_t, uint32_t);
1169 uint64_t csx_Get64(acc_handle_t, uint32_t);
1170 void csx_RepPut8(acc_handle_t, uint8_t *, uint32_t, uint32_t, uint32_t);
1171 void csx_RepPut16(acc_handle_t, uint16_t *, uint32_t, uint32_t, uint32_t);
1172 void csx_RepPut32(acc_handle_t, uint32_t *, uint32_t, uint32_t, uint32_t);
1173 void csx_RepPut64(acc_handle_t, uint64_t *, uint32_t, uint32_t, uint32_t);
1174 void csx_RepGet8(acc_handle_t, uint8_t *, uint32_t, uint32_t, uint32_t);
1175 void csx_RepGet16(acc_handle_t, uint16_t *, uint32_t, uint32_t, uint32_t);
1176 void csx_RepGet32(acc_handle_t, uint32_t *, uint32_t, uint32_t, uint32_t);
1177 void csx_RepGet64(acc_handle_t, uint64_t *, uint32_t, uint32_t, uint32_t);
1178 
1179 /*
1180  * Data access handle manipulation functions
1181  */
1182 int32_t csx_GetMappedAddr(acc_handle_t, void **);
1183 int32_t csx_GetPhysAddr(acc_handle_t, void **);
1184 int32_t csx_DupHandle(acc_handle_t, acc_handle_t *, uint32_t);
1185 int32_t csx_FreeHandle(acc_handle_t *);
1186 int32_t csx_GetHandleOffset(acc_handle_t, uint32_t *);
1187 int32_t csx_SetHandleOffset(acc_handle_t, uint32_t);
1188 
1189 /*
1190  * XXX - PCMCIA Shady Meadows Retirement Community
1191  *
1192  * The defines in this section should be retired once the PS drivers
1193  *	get updated.
1194  *
1195  * XXX This is an old version of WIN_DATA_WIDTH_MASK and should be
1196  *	retired soon. RETIRE
1197  */
1198 #define	WIN_DATA_WIDTH		0x00000002	/* 16-bit data path */
1199 /*
1200  * XXX The following are old versions of the IO_DATA_WIDTH_XXX names and
1201  *	should be retured soon. RETIRE
1202  */
1203 #define	IO_DATA_PATH_WIDTH	0x00000001	/* 16 bit data path */
1204 #define	IO_DATA_PATH_WIDTH_8	0x00000000	/* 8 bit data path */
1205 #define	IO_DATA_PATH_WIDTH_16	0x00000001	/* 16 bit data path */
1206 /*
1207  * XXX - REMOVAL_ALL_DEVICE_NODES typo, remove soon. RETIRE
1208  */
1209 #define	REMOVAL_ALL_DEVICE_NODES	0x03	/* remove all device nodes */
1210 
1211 /*
1212  * The old name of the csx_RequestSocketMask structure was
1213  *	sockmask_t for some bizzare reason. This typedef
1214  *	keeps that old name around until we can fix
1215  *	the drivers.
1216  */
1217 typedef struct request_socket_mask_t sockmask_t;	/* RETIRE */
1218 
1219 /* XXX - RETIRE and change to a typedef XXX */
1220 struct devnode_desc {
1221     char	*name;		/* device node path and name */
1222     int32_t	spec_type;	/* dev special type (block or char) */
1223     int32_t	minor_num;	/* device node minor number */
1224     char	*node_type;	/* device node type */
1225 };
1226 
1227 #ifdef	__cplusplus
1228 }
1229 #endif
1230 
1231 #endif	/* _CS_H */
1232