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