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