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