1/*
2 * cistpl.h 1.34 2000/06/19 23:18:12
3 *
4 * The contents of this file are subject to the Mozilla Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License
7 * at http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific language governing rights and
12 * limitations under the License.
13 *
14 * The initial developer of the original code is David A. Hinds
15 * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
16 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
17 *
18 * Alternatively, the contents of this file may be used under the
19 * terms of the GNU General Public License version 2 (the "GPL"), in which
20 * case the provisions of the GPL are applicable instead of the
21 * above.  If you wish to allow the use of your version of this file
22 * only under the terms of the GPL and not to allow others to use
23 * your version of this file under the MPL, indicate your decision by
24 * deleting the provisions above and replace them with the notice and
25 * other provisions required by the GPL.  If you do not delete the
26 * provisions above, a recipient may use your version of this file
27 * under either the MPL or the GPL.
28 */
29
30#ifndef _LINUX_CISTPL_H
31#define _LINUX_CISTPL_H
32
33#define CISTPL_NULL		0x00
34#define CISTPL_DEVICE		0x01
35#define CISTPL_LONGLINK_CB	0x02
36#define CISTPL_INDIRECT		0x03
37#define CISTPL_CONFIG_CB	0x04
38#define CISTPL_CFTABLE_ENTRY_CB	0x05
39#define CISTPL_LONGLINK_MFC	0x06
40#define CISTPL_BAR		0x07
41#define CISTPL_PWR_MGMNT	0x08
42#define CISTPL_EXTDEVICE	0x09
43#define CISTPL_CHECKSUM		0x10
44#define CISTPL_LONGLINK_A	0x11
45#define CISTPL_LONGLINK_C	0x12
46#define CISTPL_LINKTARGET	0x13
47#define CISTPL_NO_LINK		0x14
48#define CISTPL_VERS_1		0x15
49#define CISTPL_ALTSTR		0x16
50#define CISTPL_DEVICE_A		0x17
51#define CISTPL_JEDEC_C		0x18
52#define CISTPL_JEDEC_A		0x19
53#define CISTPL_CONFIG		0x1a
54#define CISTPL_CFTABLE_ENTRY	0x1b
55#define CISTPL_DEVICE_OC	0x1c
56#define CISTPL_DEVICE_OA	0x1d
57#define CISTPL_DEVICE_GEO	0x1e
58#define CISTPL_DEVICE_GEO_A	0x1f
59#define CISTPL_MANFID		0x20
60#define CISTPL_FUNCID		0x21
61#define CISTPL_FUNCE		0x22
62#define CISTPL_SWIL		0x23
63#define CISTPL_END		0xff
64/* Layer 2 tuples */
65#define CISTPL_VERS_2		0x40
66#define CISTPL_FORMAT		0x41
67#define CISTPL_GEOMETRY		0x42
68#define CISTPL_BYTEORDER	0x43
69#define CISTPL_DATE		0x44
70#define CISTPL_BATTERY		0x45
71#define CISTPL_FORMAT_A		0x47
72/* Layer 3 tuples */
73#define CISTPL_ORG		0x46
74#define CISTPL_SPCL		0x90
75
76typedef struct cistpl_longlink_t {
77    u_int	addr;
78} cistpl_longlink_t;
79
80typedef struct cistpl_checksum_t {
81    u_short	addr;
82    u_short	len;
83    u_char	sum;
84} cistpl_checksum_t;
85
86#define CISTPL_MAX_FUNCTIONS	8
87#define CISTPL_MFC_ATTR		0x00
88#define CISTPL_MFC_COMMON	0x01
89
90typedef struct cistpl_longlink_mfc_t {
91    u_char	nfn;
92    struct {
93	u_char	space;
94	u_int	addr;
95    } fn[CISTPL_MAX_FUNCTIONS];
96} cistpl_longlink_mfc_t;
97
98#define CISTPL_MAX_ALTSTR_STRINGS	4
99
100typedef struct cistpl_altstr_t {
101    u_char	ns;
102    u_char	ofs[CISTPL_MAX_ALTSTR_STRINGS];
103    char	str[254];
104} cistpl_altstr_t;
105
106#define CISTPL_DTYPE_NULL	0x00
107#define CISTPL_DTYPE_ROM	0x01
108#define CISTPL_DTYPE_OTPROM	0x02
109#define CISTPL_DTYPE_EPROM	0x03
110#define CISTPL_DTYPE_EEPROM	0x04
111#define CISTPL_DTYPE_FLASH	0x05
112#define CISTPL_DTYPE_SRAM	0x06
113#define CISTPL_DTYPE_DRAM	0x07
114#define CISTPL_DTYPE_FUNCSPEC	0x0d
115#define CISTPL_DTYPE_EXTEND	0x0e
116
117#define CISTPL_MAX_DEVICES	4
118
119typedef struct cistpl_device_t {
120    u_char	ndev;
121    struct {
122	u_char 	type;
123	u_char	wp;
124	u_int	speed;
125	u_int	size;
126    } dev[CISTPL_MAX_DEVICES];
127} cistpl_device_t;
128
129#define CISTPL_DEVICE_MWAIT	0x01
130#define CISTPL_DEVICE_3VCC	0x02
131
132typedef struct cistpl_device_o_t {
133    u_char		flags;
134    cistpl_device_t	device;
135} cistpl_device_o_t;
136
137#define CISTPL_VERS_1_MAX_PROD_STRINGS	4
138
139typedef struct cistpl_vers_1_t {
140    u_char	major;
141    u_char	minor;
142    u_char	ns;
143    u_char	ofs[CISTPL_VERS_1_MAX_PROD_STRINGS];
144    char	str[254];
145} cistpl_vers_1_t;
146
147typedef struct cistpl_jedec_t {
148    u_char	nid;
149    struct {
150	u_char	mfr;
151	u_char	info;
152    } id[CISTPL_MAX_DEVICES];
153} cistpl_jedec_t;
154
155typedef struct cistpl_manfid_t {
156    u_short	manf;
157    u_short	card;
158} cistpl_manfid_t;
159
160#define CISTPL_FUNCID_MULTI	0x00
161#define CISTPL_FUNCID_MEMORY	0x01
162#define CISTPL_FUNCID_SERIAL	0x02
163#define CISTPL_FUNCID_PARALLEL	0x03
164#define CISTPL_FUNCID_FIXED	0x04
165#define CISTPL_FUNCID_VIDEO	0x05
166#define CISTPL_FUNCID_NETWORK	0x06
167#define CISTPL_FUNCID_AIMS	0x07
168#define CISTPL_FUNCID_SCSI	0x08
169
170#define CISTPL_SYSINIT_POST	0x01
171#define CISTPL_SYSINIT_ROM	0x02
172
173typedef struct cistpl_funcid_t {
174    u_char	func;
175    u_char	sysinit;
176} cistpl_funcid_t;
177
178typedef struct cistpl_funce_t {
179    u_char	type;
180    u_char	data[0];
181} cistpl_funce_t;
182
183/*======================================================================
184
185    Modem Function Extension Tuples
186
187======================================================================*/
188
189#define CISTPL_FUNCE_SERIAL_IF		0x00
190#define CISTPL_FUNCE_SERIAL_CAP		0x01
191#define CISTPL_FUNCE_SERIAL_SERV_DATA	0x02
192#define CISTPL_FUNCE_SERIAL_SERV_FAX	0x03
193#define CISTPL_FUNCE_SERIAL_SERV_VOICE	0x04
194#define CISTPL_FUNCE_SERIAL_CAP_DATA	0x05
195#define CISTPL_FUNCE_SERIAL_CAP_FAX	0x06
196#define CISTPL_FUNCE_SERIAL_CAP_VOICE	0x07
197#define CISTPL_FUNCE_SERIAL_IF_DATA	0x08
198#define CISTPL_FUNCE_SERIAL_IF_FAX	0x09
199#define CISTPL_FUNCE_SERIAL_IF_VOICE	0x0a
200
201/* UART identification */
202#define CISTPL_SERIAL_UART_8250		0x00
203#define CISTPL_SERIAL_UART_16450	0x01
204#define CISTPL_SERIAL_UART_16550	0x02
205#define CISTPL_SERIAL_UART_8251		0x03
206#define CISTPL_SERIAL_UART_8530		0x04
207#define CISTPL_SERIAL_UART_85230	0x05
208
209/* UART capabilities */
210#define CISTPL_SERIAL_UART_SPACE	0x01
211#define CISTPL_SERIAL_UART_MARK		0x02
212#define CISTPL_SERIAL_UART_ODD		0x04
213#define CISTPL_SERIAL_UART_EVEN		0x08
214#define CISTPL_SERIAL_UART_5BIT		0x01
215#define CISTPL_SERIAL_UART_6BIT		0x02
216#define CISTPL_SERIAL_UART_7BIT		0x04
217#define CISTPL_SERIAL_UART_8BIT		0x08
218#define CISTPL_SERIAL_UART_1STOP	0x10
219#define CISTPL_SERIAL_UART_MSTOP	0x20
220#define CISTPL_SERIAL_UART_2STOP	0x40
221
222typedef struct cistpl_serial_t {
223    u_char	uart_type;
224    u_char	uart_cap_0;
225    u_char	uart_cap_1;
226} cistpl_serial_t;
227
228typedef struct cistpl_modem_cap_t {
229    u_char	flow;
230    u_char	cmd_buf;
231    u_char	rcv_buf_0, rcv_buf_1, rcv_buf_2;
232    u_char	xmit_buf_0, xmit_buf_1, xmit_buf_2;
233} cistpl_modem_cap_t;
234
235#define CISTPL_SERIAL_MOD_103		0x01
236#define CISTPL_SERIAL_MOD_V21		0x02
237#define CISTPL_SERIAL_MOD_V23		0x04
238#define CISTPL_SERIAL_MOD_V22		0x08
239#define CISTPL_SERIAL_MOD_212A		0x10
240#define CISTPL_SERIAL_MOD_V22BIS	0x20
241#define CISTPL_SERIAL_MOD_V26		0x40
242#define CISTPL_SERIAL_MOD_V26BIS	0x80
243#define CISTPL_SERIAL_MOD_V27BIS	0x01
244#define CISTPL_SERIAL_MOD_V29		0x02
245#define CISTPL_SERIAL_MOD_V32		0x04
246#define CISTPL_SERIAL_MOD_V32BIS	0x08
247#define CISTPL_SERIAL_MOD_V34		0x10
248
249#define CISTPL_SERIAL_ERR_MNP2_4	0x01
250#define CISTPL_SERIAL_ERR_V42_LAPM	0x02
251
252#define CISTPL_SERIAL_CMPR_V42BIS	0x01
253#define CISTPL_SERIAL_CMPR_MNP5		0x02
254
255#define CISTPL_SERIAL_CMD_AT1		0x01
256#define CISTPL_SERIAL_CMD_AT2		0x02
257#define CISTPL_SERIAL_CMD_AT3		0x04
258#define CISTPL_SERIAL_CMD_MNP_AT	0x08
259#define CISTPL_SERIAL_CMD_V25BIS	0x10
260#define CISTPL_SERIAL_CMD_V25A		0x20
261#define CISTPL_SERIAL_CMD_DMCL		0x40
262
263typedef struct cistpl_data_serv_t {
264    u_char	max_data_0;
265    u_char	max_data_1;
266    u_char	modulation_0;
267    u_char	modulation_1;
268    u_char	error_control;
269    u_char	compression;
270    u_char	cmd_protocol;
271    u_char	escape;
272    u_char	encrypt;
273    u_char	misc_features;
274    u_char	ccitt_code[0];
275} cistpl_data_serv_t;
276
277typedef struct cistpl_fax_serv_t {
278    u_char	max_data_0;
279    u_char	max_data_1;
280    u_char	modulation;
281    u_char	encrypt;
282    u_char	features_0;
283    u_char	features_1;
284    u_char	ccitt_code[0];
285} cistpl_fax_serv_t;
286
287typedef struct cistpl_voice_serv_t {
288    u_char	max_data_0;
289    u_char	max_data_1;
290} cistpl_voice_serv_t;
291
292/*======================================================================
293
294    LAN Function Extension Tuples
295
296======================================================================*/
297
298#define CISTPL_FUNCE_LAN_TECH		0x01
299#define CISTPL_FUNCE_LAN_SPEED		0x02
300#define CISTPL_FUNCE_LAN_MEDIA		0x03
301#define CISTPL_FUNCE_LAN_NODE_ID	0x04
302#define CISTPL_FUNCE_LAN_CONNECTOR	0x05
303
304/* LAN technologies */
305#define CISTPL_LAN_TECH_ARCNET		0x01
306#define CISTPL_LAN_TECH_ETHERNET	0x02
307#define CISTPL_LAN_TECH_TOKENRING	0x03
308#define CISTPL_LAN_TECH_LOCALTALK	0x04
309#define CISTPL_LAN_TECH_FDDI		0x05
310#define CISTPL_LAN_TECH_ATM		0x06
311#define CISTPL_LAN_TECH_WIRELESS	0x07
312
313typedef struct cistpl_lan_tech_t {
314    u_char	tech;
315} cistpl_lan_tech_t;
316
317typedef struct cistpl_lan_speed_t {
318    u_int	speed;
319} cistpl_lan_speed_t;
320
321/* LAN media definitions */
322#define CISTPL_LAN_MEDIA_UTP		0x01
323#define CISTPL_LAN_MEDIA_STP		0x02
324#define CISTPL_LAN_MEDIA_THIN_COAX	0x03
325#define CISTPL_LAN_MEDIA_THICK_COAX	0x04
326#define CISTPL_LAN_MEDIA_FIBER		0x05
327#define CISTPL_LAN_MEDIA_900MHZ		0x06
328#define CISTPL_LAN_MEDIA_2GHZ		0x07
329#define CISTPL_LAN_MEDIA_5GHZ		0x08
330#define CISTPL_LAN_MEDIA_DIFF_IR	0x09
331#define CISTPL_LAN_MEDIA_PTP_IR		0x0a
332
333typedef struct cistpl_lan_media_t {
334    u_char	media;
335} cistpl_lan_media_t;
336
337typedef struct cistpl_lan_node_id_t {
338    u_char	nb;
339    u_char	id[16];
340} cistpl_lan_node_id_t;
341
342typedef struct cistpl_lan_connector_t {
343    u_char	code;
344} cistpl_lan_connector_t;
345
346/*======================================================================
347
348    IDE Function Extension Tuples
349
350======================================================================*/
351
352#define CISTPL_IDE_INTERFACE		0x01
353
354typedef struct cistpl_ide_interface_t {
355    u_char	interface;
356} cistpl_ide_interface_t;
357
358/* First feature byte */
359#define CISTPL_IDE_SILICON		0x04
360#define CISTPL_IDE_UNIQUE		0x08
361#define CISTPL_IDE_DUAL			0x10
362
363/* Second feature byte */
364#define CISTPL_IDE_HAS_SLEEP		0x01
365#define CISTPL_IDE_HAS_STANDBY		0x02
366#define CISTPL_IDE_HAS_IDLE		0x04
367#define CISTPL_IDE_LOW_POWER		0x08
368#define CISTPL_IDE_REG_INHIBIT		0x10
369#define CISTPL_IDE_HAS_INDEX		0x20
370#define CISTPL_IDE_IOIS16		0x40
371
372typedef struct cistpl_ide_feature_t {
373    u_char	feature1;
374    u_char	feature2;
375} cistpl_ide_feature_t;
376
377#define CISTPL_FUNCE_IDE_IFACE		0x01
378#define CISTPL_FUNCE_IDE_MASTER		0x02
379#define CISTPL_FUNCE_IDE_SLAVE		0x03
380
381/*======================================================================
382
383    Configuration Table Entries
384
385======================================================================*/
386
387#define CISTPL_BAR_SPACE	0x07
388#define CISTPL_BAR_SPACE_IO	0x10
389#define CISTPL_BAR_PREFETCH	0x20
390#define CISTPL_BAR_CACHEABLE	0x40
391#define CISTPL_BAR_1MEG_MAP	0x80
392
393typedef struct cistpl_bar_t {
394    u_char	attr;
395    u_int	size;
396} cistpl_bar_t;
397
398typedef struct cistpl_config_t {
399    u_char	last_idx;
400    u_int	base;
401    u_int	rmask[4];
402    u_char	subtuples;
403} cistpl_config_t;
404
405/* These are bits in the 'present' field, and indices in 'param' */
406#define CISTPL_POWER_VNOM	0
407#define CISTPL_POWER_VMIN	1
408#define CISTPL_POWER_VMAX	2
409#define CISTPL_POWER_ISTATIC	3
410#define CISTPL_POWER_IAVG	4
411#define CISTPL_POWER_IPEAK	5
412#define CISTPL_POWER_IDOWN	6
413
414#define CISTPL_POWER_HIGHZ_OK	0x01
415#define CISTPL_POWER_HIGHZ_REQ	0x02
416
417typedef struct cistpl_power_t {
418    u_char	present;
419    u_char	flags;
420    u_int	param[7];
421} cistpl_power_t;
422
423typedef struct cistpl_timing_t {
424    u_int	wait, waitscale;
425    u_int	ready, rdyscale;
426    u_int	reserved, rsvscale;
427} cistpl_timing_t;
428
429#define CISTPL_IO_LINES_MASK	0x1f
430#define CISTPL_IO_8BIT		0x20
431#define CISTPL_IO_16BIT		0x40
432#define CISTPL_IO_RANGE		0x80
433
434#define CISTPL_IO_MAX_WIN	16
435
436typedef struct cistpl_io_t {
437    u_char	flags;
438    u_char	nwin;
439    struct {
440	u_int	base;
441	u_int	len;
442    } win[CISTPL_IO_MAX_WIN];
443} cistpl_io_t;
444
445typedef struct cistpl_irq_t {
446    u_int	IRQInfo1;
447    u_int	IRQInfo2;
448} cistpl_irq_t;
449
450#define CISTPL_MEM_MAX_WIN	8
451
452typedef struct cistpl_mem_t {
453    u_char	flags;
454    u_char	nwin;
455    struct {
456	u_int	len;
457	u_int	card_addr;
458	u_int	host_addr;
459    } win[CISTPL_MEM_MAX_WIN];
460} cistpl_mem_t;
461
462#define CISTPL_CFTABLE_DEFAULT		0x0001
463#define CISTPL_CFTABLE_BVDS		0x0002
464#define CISTPL_CFTABLE_WP		0x0004
465#define CISTPL_CFTABLE_RDYBSY		0x0008
466#define CISTPL_CFTABLE_MWAIT		0x0010
467#define CISTPL_CFTABLE_AUDIO		0x0800
468#define CISTPL_CFTABLE_READONLY		0x1000
469#define CISTPL_CFTABLE_PWRDOWN		0x2000
470
471typedef struct cistpl_cftable_entry_t {
472    u_char		index;
473    u_short		flags;
474    u_char		interface;
475    cistpl_power_t	vcc, vpp1, vpp2;
476    cistpl_timing_t	timing;
477    cistpl_io_t		io;
478    cistpl_irq_t	irq;
479    cistpl_mem_t	mem;
480    u_char		subtuples;
481} cistpl_cftable_entry_t;
482
483#define CISTPL_CFTABLE_MASTER		0x000100
484#define CISTPL_CFTABLE_INVALIDATE	0x000200
485#define CISTPL_CFTABLE_VGA_PALETTE	0x000400
486#define CISTPL_CFTABLE_PARITY		0x000800
487#define CISTPL_CFTABLE_WAIT		0x001000
488#define CISTPL_CFTABLE_SERR		0x002000
489#define CISTPL_CFTABLE_FAST_BACK	0x004000
490#define CISTPL_CFTABLE_BINARY_AUDIO	0x010000
491#define CISTPL_CFTABLE_PWM_AUDIO	0x020000
492
493typedef struct cistpl_cftable_entry_cb_t {
494    u_char		index;
495    u_int		flags;
496    cistpl_power_t	vcc, vpp1, vpp2;
497    u_char		io;
498    cistpl_irq_t	irq;
499    u_char		mem;
500    u_char		subtuples;
501} cistpl_cftable_entry_cb_t;
502
503typedef struct cistpl_device_geo_t {
504    u_char		ngeo;
505    struct {
506	u_char		buswidth;
507	u_int		erase_block;
508	u_int		read_block;
509	u_int		write_block;
510	u_int		partition;
511	u_int		interleave;
512    } geo[CISTPL_MAX_DEVICES];
513} cistpl_device_geo_t;
514
515typedef struct cistpl_vers_2_t {
516    u_char	vers;
517    u_char	comply;
518    u_short	dindex;
519    u_char	vspec8, vspec9;
520    u_char	nhdr;
521    u_char	vendor, info;
522    char	str[244];
523} cistpl_vers_2_t;
524
525typedef struct cistpl_org_t {
526    u_char	data_org;
527    char	desc[30];
528} cistpl_org_t;
529
530#define CISTPL_ORG_FS		0x00
531#define CISTPL_ORG_APPSPEC	0x01
532#define CISTPL_ORG_XIP		0x02
533
534typedef struct cistpl_format_t {
535    u_char	type;
536    u_char	edc;
537    u_int	offset;
538    u_int	length;
539} cistpl_format_t;
540
541#define CISTPL_FORMAT_DISK	0x00
542#define CISTPL_FORMAT_MEM	0x01
543
544#define CISTPL_EDC_NONE		0x00
545#define CISTPL_EDC_CKSUM	0x01
546#define CISTPL_EDC_CRC		0x02
547#define CISTPL_EDC_PCC		0x03
548
549typedef union cisparse_t {
550    cistpl_device_t		device;
551    cistpl_checksum_t		checksum;
552    cistpl_longlink_t		longlink;
553    cistpl_longlink_mfc_t	longlink_mfc;
554    cistpl_vers_1_t		version_1;
555    cistpl_altstr_t		altstr;
556    cistpl_jedec_t		jedec;
557    cistpl_manfid_t		manfid;
558    cistpl_funcid_t		funcid;
559    cistpl_funce_t		funce;
560    cistpl_bar_t		bar;
561    cistpl_config_t		config;
562    cistpl_cftable_entry_t	cftable_entry;
563    cistpl_cftable_entry_cb_t	cftable_entry_cb;
564    cistpl_device_geo_t		device_geo;
565    cistpl_vers_2_t		vers_2;
566    cistpl_org_t		org;
567    cistpl_format_t		format;
568} cisparse_t;
569
570typedef struct tuple_t {
571    u_int	Attributes;
572    cisdata_t 	DesiredTuple;
573    u_int	Flags;		/* internal use */
574    u_int	LinkOffset;	/* internal use */
575    u_int	CISOffset;	/* internal use */
576    cisdata_t	TupleCode;
577    cisdata_t	TupleLink;
578    cisdata_t	TupleOffset;
579    cisdata_t	TupleDataMax;
580    cisdata_t	TupleDataLen;
581    cisdata_t	*TupleData;
582} tuple_t;
583
584/* Special cisdata_t value */
585#define RETURN_FIRST_TUPLE	0xff
586
587/* Attributes for tuple calls */
588#define TUPLE_RETURN_LINK	0x01
589#define TUPLE_RETURN_COMMON	0x02
590
591/* For ValidateCIS */
592typedef struct cisinfo_t {
593    u_int	Chains;
594} cisinfo_t;
595
596#define CISTPL_MAX_CIS_SIZE	0x200
597
598/* For ReplaceCIS */
599typedef struct cisdump_t {
600    u_int	Length;
601    cisdata_t	Data[CISTPL_MAX_CIS_SIZE];
602} cisdump_t;
603
604int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple);
605int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple);
606int pcmcia_get_tuple_data(client_handle_t handle, tuple_t *tuple);
607int pcmcia_parse_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse);
608
609int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info);
610int pcmcia_replace_cis(client_handle_t handle, cisdump_t *cis);
611
612#endif /* LINUX_CISTPL_H */
613