xref: /freebsd/usr.sbin/dumpcis/cis.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1f7911ae5SWarner Losh /*
2f7911ae5SWarner Losh  *	PCMCIA card structures and defines.
3f7911ae5SWarner Losh  *	These defines relate to the user level
4f7911ae5SWarner Losh  *	structures and card information, not
5f7911ae5SWarner Losh  *	driver/process communication.
6f7911ae5SWarner Losh  *-------------------------------------------------------------------------
7f7911ae5SWarner Losh  */
8f7911ae5SWarner Losh /*-
9*1de7b4b8SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
10*1de7b4b8SPedro F. Giffuni  *
11f7911ae5SWarner Losh  * Copyright (c) 1995 Andrew McRae.  All rights reserved.
12f7911ae5SWarner Losh  *
13f7911ae5SWarner Losh  * Redistribution and use in source and binary forms, with or without
14f7911ae5SWarner Losh  * modification, are permitted provided that the following conditions
15f7911ae5SWarner Losh  * are met:
16f7911ae5SWarner Losh  * 1. Redistributions of source code must retain the above copyright
17f7911ae5SWarner Losh  *    notice, this list of conditions and the following disclaimer.
18f7911ae5SWarner Losh  * 2. Redistributions in binary form must reproduce the above copyright
19f7911ae5SWarner Losh  *    notice, this list of conditions and the following disclaimer in the
20f7911ae5SWarner Losh  *    documentation and/or other materials provided with the distribution.
21f7911ae5SWarner Losh  * 3. The name of the author may not be used to endorse or promote products
22f7911ae5SWarner Losh  *    derived from this software without specific prior written permission.
23f7911ae5SWarner Losh  *
24f7911ae5SWarner Losh  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25f7911ae5SWarner Losh  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26f7911ae5SWarner Losh  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27f7911ae5SWarner Losh  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28f7911ae5SWarner Losh  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29f7911ae5SWarner Losh  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30f7911ae5SWarner Losh  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31f7911ae5SWarner Losh  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32f7911ae5SWarner Losh  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33f7911ae5SWarner Losh  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34f7911ae5SWarner Losh  *
35f7911ae5SWarner Losh  */
36f7911ae5SWarner Losh 
37f7911ae5SWarner Losh /*
38f7911ae5SWarner Losh  *	Card Information Structure tuples definitions
39f7911ae5SWarner Losh  *	The structure of a tuple is basically:
40f7911ae5SWarner Losh  *
41f7911ae5SWarner Losh  *		Tuple_code
42f7911ae5SWarner Losh  *		Tuple_data_length
43f7911ae5SWarner Losh  *		Tuple_data ...
44f7911ae5SWarner Losh  *
45f7911ae5SWarner Losh  *	Tuples are contiguous in attribute memory, and
46f7911ae5SWarner Losh  *	are terminated with a 0xFF for the tuple code or
47f7911ae5SWarner Losh  *	the tuple length.
48f7911ae5SWarner Losh  */
49f7911ae5SWarner Losh #ifndef	_PCCARD_CIS_H
50f7911ae5SWarner Losh #define	_PCCARD_CIS_H
51f7911ae5SWarner Losh 
52f7911ae5SWarner Losh #define	CIS_NULL	0	/* Empty tuple */
53f7911ae5SWarner Losh #define	CIS_MEM_COMMON	0x01	/* Device descriptor, common memory */
54f7911ae5SWarner Losh #define	CIS_LONGLINK_CB	0x02	/* Long link to next chain for CardBus */
55f7911ae5SWarner Losh #define	CIS_INDIRECT	0x03	/* Indirect access */
56f7911ae5SWarner Losh #define	CIS_CONF_MAP_CB	0x04	/* Card Configuration map for CardBus */
57f7911ae5SWarner Losh #define	CIS_CONFIG_CB	0x05	/* Card Configuration entry for CardBus */
58f7911ae5SWarner Losh #define	CIS_LONGLINK_MFC	0x06	/* Long link to next chain for Multi function card */
59f7911ae5SWarner Losh #define	CIS_BAR		0x07	/* Base address register for CardBus */
60f7911ae5SWarner Losh #define	CIS_CHECKSUM	0x10	/* Checksum */
61f7911ae5SWarner Losh #define	CIS_LONGLINK_A	0x11	/* Link to Attribute memory */
62f7911ae5SWarner Losh #define	CIS_LONGLINK_C	0x12	/* Link to Common memory */
63f7911ae5SWarner Losh #define	CIS_LINKTARGET	0x13	/* Linked tuple must start with this. */
64f7911ae5SWarner Losh #define	CIS_NOLINK	0x14	/* Assume no common memory link tuple. */
65f7911ae5SWarner Losh #define	CIS_INFO_V1	0x15	/* Card info data, version 1 */
66f7911ae5SWarner Losh #define	CIS_ALTSTR	0x16	/* Alternate language string tuple. */
67f7911ae5SWarner Losh #define	CIS_MEM_ATTR	0x17	/* Device descriptor, Attribute memory */
68f7911ae5SWarner Losh #define	CIS_JEDEC_C	0x18	/* JEDEC descr for common memory */
69f7911ae5SWarner Losh #define	CIS_JEDEC_A	0x19	/* JEDEC descr for Attribute memory */
70f7911ae5SWarner Losh #define	CIS_CONF_MAP	0x1A	/* Card Configuration map */
71f7911ae5SWarner Losh #define	CIS_CONFIG	0x1B	/* Card Configuration entry */
72f7911ae5SWarner Losh #define	CIS_DEVICE_OC	0x1C	/* Other conditions info - common memory */
73f7911ae5SWarner Losh #define	CIS_DEVICE_OA	0x1D	/* Other conditions info - attribute memory */
74f7911ae5SWarner Losh #define	CIS_DEVICEGEO	0x1E	/* Geometry info for common memory */
75f7911ae5SWarner Losh #define	CIS_DEVICEGEO_A	0x1F	/* Geometry info for attribute memory */
76f7911ae5SWarner Losh #define	CIS_MANUF_ID	0x20	/* Card manufacturer's ID */
77f7911ae5SWarner Losh #define	CIS_FUNC_ID	0x21	/* Function of card */
78f7911ae5SWarner Losh #define	CIS_FUNC_EXT	0x22	/* Functional extension */
79f7911ae5SWarner Losh /*
80f7911ae5SWarner Losh  *	Data recording format tuples.
81f7911ae5SWarner Losh  */
82f7911ae5SWarner Losh #define	CIS_SW_INTERLV	0x23	/* Software interleave */
83f7911ae5SWarner Losh #define	CIS_VERS_2	0x40	/* Card info data, version 2 */
84f7911ae5SWarner Losh #define	CIS_FORMAT	0x41	/* Memory card format */
85f7911ae5SWarner Losh #define	CIS_GEOMETRY	0x42	/* Disk sector layout */
86f7911ae5SWarner Losh #define	CIS_BYTEORDER	0x43	/* Byte order of memory data */
87f7911ae5SWarner Losh #define	CIS_DATE	0x44	/* Format data/time */
88f7911ae5SWarner Losh #define	CIS_BATTERY	0x45	/* Battery replacement date */
89f7911ae5SWarner Losh #define	CIS_ORG		0x46	/* Organization of data on card */
90f7911ae5SWarner Losh #define	CIS_END		0xFF	/* Termination code */
91f7911ae5SWarner Losh 
92f7911ae5SWarner Losh /*
93f7911ae5SWarner Losh  *	Internal tuple definitions.
94f7911ae5SWarner Losh  *
95f7911ae5SWarner Losh  *	Device descriptor for memory (CIS_MEM_ATTR, CIS_MEM_COMMON)
96f7911ae5SWarner Losh  *
97f7911ae5SWarner Losh  *	Byte 1:
98f7911ae5SWarner Losh  *		0xF0 - Device type
99f7911ae5SWarner Losh  *		0x08 - Write protect switch
100f7911ae5SWarner Losh  *		0x07 - Speed index (7 = extended speed)
101f7911ae5SWarner Losh  *	Byte 2: Extended speed (bit 7 = another follows)
102f7911ae5SWarner Losh  *	Byte 3: (ignored if 0xFF)
103f7911ae5SWarner Losh  *		0xF8 - Addressable units (0's numbered)
104f7911ae5SWarner Losh  *		0x07 - Unit size
105f7911ae5SWarner Losh  *	The three byte sequence is repeated until byte 1 == 0xFF
106f7911ae5SWarner Losh  */
107f7911ae5SWarner Losh 
108f7911ae5SWarner Losh /*
109f7911ae5SWarner Losh  *	CIS_INFO_V1 - Version one card information.
110f7911ae5SWarner Losh  *
111f7911ae5SWarner Losh  *	Byte 1:   Major version number (should be 4)
112f7911ae5SWarner Losh  *	Byte 2:   Minor version number (should be 1)
113f7911ae5SWarner Losh  *	Byte 3-x: Null terminated Manufacturer name
114f7911ae5SWarner Losh  *	Byte x-x: Null terminated product name
115f7911ae5SWarner Losh  *	Byte x-x: Null terminated additional info 1
116f7911ae5SWarner Losh  *	Byte x-x: Null terminated additional info 2
117f7911ae5SWarner Losh  *	Byte x:   final byte must be 0xFF
118f7911ae5SWarner Losh  */
119f7911ae5SWarner Losh #define	CIS_MAJOR_VERSION	4
120f7911ae5SWarner Losh #define	CIS_MINOR_VERSION	1
121f7911ae5SWarner Losh 
122f7911ae5SWarner Losh /*
123f7911ae5SWarner Losh  *	CIS_CONF_MAP - Provides an address map for the card
124f7911ae5SWarner Losh  *			configuration register(s), and a max value
125f7911ae5SWarner Losh  *			identifying the last configuration tuple.
126f7911ae5SWarner Losh  *
127f7911ae5SWarner Losh  *	Byte 1:
128f7911ae5SWarner Losh  *		0x3C - Register mask size (0's numbered)
129f7911ae5SWarner Losh  *		0x03 - Register address size (0's numbered)
130f7911ae5SWarner Losh  *	Byte 2:
131f7911ae5SWarner Losh  *		0x3F - ID of last configuration.
132f7911ae5SWarner Losh  *	Byte 3-n: Card register address (size is determined by
133f7911ae5SWarner Losh  *			the value in byte 1).
134f7911ae5SWarner Losh  *	Byte x-x: Card register masks (size determined by the
135f7911ae5SWarner Losh  *			value in byte 1)
136f7911ae5SWarner Losh  */
137f7911ae5SWarner Losh 
138f7911ae5SWarner Losh /*
139f7911ae5SWarner Losh  *	CIS_CONFIG - Card configuration entry. Multiple tuples may
140f7911ae5SWarner Losh  *		exist of this type, each one describing a different
141f7911ae5SWarner Losh  *		memory/I-O map that can be used to address this card.
142f7911ae5SWarner Losh  *		The first one usually has extra config data about the
143f7911ae5SWarner Losh  *		card features. The final configuration tuple number
144f7911ae5SWarner Losh  *		is stored in the CIS_CONF_MAP tuple so that the complete
145f7911ae5SWarner Losh  *		list can be scanned.
146f7911ae5SWarner Losh  *
147f7911ae5SWarner Losh  *	Byte 1:
148f7911ae5SWarner Losh  *		0x3F - Configuration ID number.
149f7911ae5SWarner Losh  *		0x40 - Indicates this is the default configuration
150f7911ae5SWarner Losh  *		0x80 - Interface byte exists
151f7911ae5SWarner Losh  *	Byte 2: (exists only if bit 0x80 set in byte 1)
152f7911ae5SWarner Losh  *		0x0F - Interface type value
153f7911ae5SWarner Losh  *		0x10 - Battery voltage detect
154f7911ae5SWarner Losh  *		0x20 - Write protect active
155f7911ae5SWarner Losh  *		0x40 - RdyBsy active bit
156f7911ae5SWarner Losh  *		0x80 - Wait signal required
157f7911ae5SWarner Losh  *	Byte 3: (features byte)
158f7911ae5SWarner Losh  *		0x03 - Power sub-tuple(s) exists
159f7911ae5SWarner Losh  *		0x04 - Timing sub-tuple exists
160f7911ae5SWarner Losh  *		0x08 - I/O space sub-tuple exists
161f7911ae5SWarner Losh  *		0x10 - IRQ sub-tuple exists
162f7911ae5SWarner Losh  *		0x60 - Memory space sub-tuple(s) exists
163f7911ae5SWarner Losh  *		0x80 - Miscellaneous sub-tuple exists
164f7911ae5SWarner Losh  */
165f7911ae5SWarner Losh #define	CIS_FEAT_POWER(x)	((x) & 0x3)
166f7911ae5SWarner Losh #define	CIS_FEAT_TIMING		0x4
167f7911ae5SWarner Losh #define	CIS_FEAT_I_O		0x8
168f7911ae5SWarner Losh #define	CIS_FEAT_IRQ		0x10
169f7911ae5SWarner Losh #define	CIS_FEAT_MEMORY(x)	(((x) >> 5) & 0x3)
170f7911ae5SWarner Losh #define	CIS_FEAT_MISC		0x80
171f7911ae5SWarner Losh /*
172f7911ae5SWarner Losh  *	Depending on whether the "features" byte has the corresponding
173f7911ae5SWarner Losh  *	bit set, a number of sub-tuples follow. Some features have
174f7911ae5SWarner Losh  *	more than one sub-tuple, depending on the count within the
175f7911ae5SWarner Losh  *	features byte (e.g power feature bits allows up to 3 sub-tuples).
176f7911ae5SWarner Losh  *
177f7911ae5SWarner Losh  *	Power structure sub-tuple:
178f7911ae5SWarner Losh  *	Byte 1: parameter exists - Each bit (starting from 0x01) indicates
179f7911ae5SWarner Losh  *		that a parameter block exists - up to 8 parameter blocks
180f7911ae5SWarner Losh  *		are therefore allowed).
181f7911ae5SWarner Losh  *	Byte 2:
182f7911ae5SWarner Losh  *		0x7F - Parameter data
183f7911ae5SWarner Losh  *		0x80 - More bytes follow (0 = last byte)
184f7911ae5SWarner Losh  *
185f7911ae5SWarner Losh  *	Timing sub-tuple
186f7911ae5SWarner Losh  *	Byte 1:
187f7911ae5SWarner Losh  *		0x03 - Wait scale
188f7911ae5SWarner Losh  *		0x1C - Ready scale
189f7911ae5SWarner Losh  *		0xE0 - Reserved scale
190f7911ae5SWarner Losh  *	Byte 2: extended wait scale if wait scale != 3
191f7911ae5SWarner Losh  *	Byte 3: extended ready scale if ready scale != 7
192f7911ae5SWarner Losh  *	Byte 4: extended reserved scale if reserved scale != 7
193f7911ae5SWarner Losh  */
194f7911ae5SWarner Losh #define	CIS_WAIT_SCALE(x)	((x) & 0x3)
195f7911ae5SWarner Losh #define	CIS_READY_SCALE(x)	(((x)>>2) & 0x7)
196f7911ae5SWarner Losh #define	CIS_RESERVED_SCALE(x)	(((x)>>5) & 0x7)
197f7911ae5SWarner Losh /*
198f7911ae5SWarner Losh  *	I/O mapping sub-tuple:
199f7911ae5SWarner Losh  *	Byte 1:
200f7911ae5SWarner Losh  *		0x1F - I/O address lines
201f7911ae5SWarner Losh  *		0x20 - 8 bit I/O
202f7911ae5SWarner Losh  *		0x40 - 16 bit I/O
203f7911ae5SWarner Losh  *		0x80 - I/O range??
204f7911ae5SWarner Losh  *	Byte 2:
205f7911ae5SWarner Losh  *		0x0F - 0's numbered count of I/O block subtuples following.
206f7911ae5SWarner Losh  *		0x30 - Size of I/O address value within subtuple. Values
207f7911ae5SWarner Losh  *			can be 1 (8 bits), 2 (16 bits) or 3 (32 bits).
208f7911ae5SWarner Losh  *		0xC0 - Size of I/O port block size value within subtuple.
209f7911ae5SWarner Losh  *	I/O block sub-tuples, count from previous block:
210f7911ae5SWarner Losh  *		Byte 1-n: I/O start address
211f7911ae5SWarner Losh  *		Byte x-x: Size of I/O port block.
212f7911ae5SWarner Losh  */
213f7911ae5SWarner Losh #define	CIS_IO_ADDR(x)	((x) & 0x1F)
214f7911ae5SWarner Losh #define	CIS_IO_8BIT	0x20
215f7911ae5SWarner Losh #define	CIS_IO_16BIT	0x40
216f7911ae5SWarner Losh #define	CIS_IO_RANGE	0x80
217f7911ae5SWarner Losh #define	CIS_IO_BLKS(x)	((x) & 0xF)
218f7911ae5SWarner Losh #define	CIS_IO_ADSZ(x)	(((x)>>4) & 3)
219f7911ae5SWarner Losh #define	CIS_IO_BLKSZ(x)	(((x)>>6) & 3)
220f7911ae5SWarner Losh /*
221f7911ae5SWarner Losh  *	IRQ sub-tuple.
222f7911ae5SWarner Losh  *	Byte 1:
223f7911ae5SWarner Losh  *		0x0F - Irq number or mask bits
224f7911ae5SWarner Losh  *		0x10 - IRQ mask values exist
225f7911ae5SWarner Losh  *		0x20 - Level triggered interrupts
226f7911ae5SWarner Losh  *		0x40 - Pulse triggered requests
227f7911ae5SWarner Losh  *		0x80 - Interrupt sharing.
228f7911ae5SWarner Losh  *	Byte 2-3: Interrupt req mask (if 0x10 of byte 1 set).
229f7911ae5SWarner Losh  */
230f7911ae5SWarner Losh #define	CIS_IRQ_IRQN(x)		((x) & 0xF)
231f7911ae5SWarner Losh #define	CIS_IRQ_MASK		0x10
232f7911ae5SWarner Losh #define	CIS_IRQ_LEVEL		0x20
233f7911ae5SWarner Losh #define	CIS_IRQ_PULSE		0x40
234f7911ae5SWarner Losh #define	CIS_IRQ_SHARING		0x80
235f7911ae5SWarner Losh /*
236f7911ae5SWarner Losh  *	Memory block subtuple. Depending on the features bits, the
237f7911ae5SWarner Losh  *	following subtuples are used:
238f7911ae5SWarner Losh  *	mem features == 1
239f7911ae5SWarner Losh  *		Byte 1-2: upper 16 bits of 24 bit memory length.
240f7911ae5SWarner Losh  *	mem features == 2
241f7911ae5SWarner Losh  *		Byte 1-2: upper 16 bits of 24 bit memory length.
242f7911ae5SWarner Losh  *		Byte 3-4: upper 16 bits of 24 bit memory address.
243f7911ae5SWarner Losh  *	mem_features == 3
244f7911ae5SWarner Losh  *		Byte 1:
245f7911ae5SWarner Losh  *			0x07 - 0's numbered count of memory sub-tuples
246f7911ae5SWarner Losh  *			0x18 - Memory length size (1's numbered)
247f7911ae5SWarner Losh  *			0x60 - Memory address size (1's numbered)
248f7911ae5SWarner Losh  *			0x80 - Host address value exists
249f7911ae5SWarner Losh  *		Memory sub-tuples follow:
250f7911ae5SWarner Losh  *			Byte 1-n: Memory length value (<< 8)
251f7911ae5SWarner Losh  *			Byte n-n: Memory card address value (<< 8)
252f7911ae5SWarner Losh  *			Byte n-n: Memory host address value (<< 8)
253f7911ae5SWarner Losh  */
254f7911ae5SWarner Losh #define	CIS_FEAT_MEM_NONE	0	/* No memory config */
255f7911ae5SWarner Losh #define	CIS_FEAT_MEM_LEN	1	/* Just length */
256f7911ae5SWarner Losh #define	CIS_FEAT_MEM_ADDR	2	/* Card address & length */
257f7911ae5SWarner Losh #define	CIS_FEAT_MEM_WIN	3	/* Multiple windows */
258f7911ae5SWarner Losh 
259f7911ae5SWarner Losh #define	CIS_MEM_WINS(x)		(((x) & 0x7)+1)
260f7911ae5SWarner Losh #define	CIS_MEM_LENSZ(x)	(((x) >> 3) & 0x3)
261f7911ae5SWarner Losh #define	CIS_MEM_ADDRSZ(x)	(((x) >> 5) & 0x3)
262f7911ae5SWarner Losh #define	CIS_MEM_HOST		0x80
263f7911ae5SWarner Losh /*
264f7911ae5SWarner Losh  *	Misc sub-tuple.
265f7911ae5SWarner Losh  *	Byte 1:
266f7911ae5SWarner Losh  *	Byte 2:
267f7911ae5SWarner Losh  *		0x0c - DMA Request Signal
268f7911ae5SWarner Losh  *                      00 - not support DMA
269f7911ae5SWarner Losh  *                      01 - use SPKR# line
270f7911ae5SWarner Losh  *                      10 - use IOIS16# line
271f7911ae5SWarner Losh  *                      11 - use INPACK# line
272f7911ae5SWarner Losh  *		0x10 - DMA Width
273f7911ae5SWarner Losh  *                      0 - 8 bit DMA
274f7911ae5SWarner Losh  *                      1 - 16 bit DMA
275f7911ae5SWarner Losh  */
276f7911ae5SWarner Losh #define	CIS_MISC_DMA_WIDTH(x)	(((x) & 0x10) >> 4)
277f7911ae5SWarner Losh #define	CIS_MISC_DMA_REQ(x)	(((x) >> 2) & 0x3)
278f7911ae5SWarner Losh 
279f7911ae5SWarner Losh #endif	/* _PCCARD_CIS_H */
280