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