FreeBSD/Linux Kernel Cross Reference
sys/pccard/cardinfo.h
1 /*
2 * Include file for PCMCIA user process interface
3 *
4 *-------------------------------------------------------------------------
5 *
6 * Copyright (c) 1995 Andrew McRae. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /* $FreeBSD: releng/5.1/sys/pccard/cardinfo.h 113946 2003-04-23 23:39:21Z imp $ */
32
33 #ifndef _PCCARD_CARDINFO_H_
34 #define _PCCARD_CARDINFO_H_
35
36 #ifndef _KERNEL
37 #include <sys/types.h>
38 #endif
39 #include <sys/ioccom.h>
40
41 #define PIOCGSTATE _IOR('P', 1, struct slotstate) /* Get slot state */
42 #define PIOCGMEM _IOWR('P', 2, struct mem_desc) /* Get memory map */
43 #define PIOCSMEM _IOW('P', 3, struct mem_desc) /* Set memory map */
44 #define PIOCGIO _IOWR('P', 4, struct io_desc) /* Get I/O map */
45 #define PIOCSIO _IOW('P', 5, struct io_desc) /* Set I/O map */
46 #define PIOCSDRV _IOWR('P', 6, struct dev_desc) /* Set driver */
47 #define PIOCRWFLAG _IOW('P', 7, int) /* Set flags for drv use */
48 #define PIOCRWMEM _IOWR('P', 8, unsigned long) /* Set mem for drv use */
49 #define PIOCSPOW _IOW('P', 9, struct power) /* Set power structure */
50 #define PIOCSVIR _IOW('P', 10, int) /* Virtual insert/remove */
51 #define PIOCSBEEP _IOW('P', 11, int) /* Select Beep */
52 #define PIOCSRESOURCE _IOWR('P', 12, struct pccard_resource) /* get resource info */
53 /*
54 * Debug codes.
55 */
56 #define PIOCGREG _IOWR('P',100, struct pcic_reg) /* get reg */
57 #define PIOCSREG _IOW('P', 101, struct pcic_reg) /* Set reg */
58
59 /*
60 * Slot states for PIOCGSTATE
61 *
62 * Here's a state diagram of all the possible states:
63 *
64 * power x 1
65 * -------------------
66 * / \
67 * / v
68 * resume +----------+ power x 0 +----------+
69 * ------->| inactive |<--------------| filled |
70 * / +----------+ +----------+
71 * / / \ ^ |
72 * nil <--------- \ insert or | | suspend or
73 * suspend \ power x 1 | | eject
74 * \ | v
75 * \ +----------+
76 * ----------->| empty |
77 * eject +----------+
78 *
79 * Note, the above diagram is for the state. On suspend, the laststate
80 * gets set to suspend to tell pccardd what happened. Also the nil state
81 * means that when the no state change has happened. Note: if you eject
82 * while suspended in the inactive state, you will return to the
83 * empty state if you do not insert a new card and to the inactive state
84 * if you do insert a new card.
85 *
86 * Some might argue that inactive should be sticky forever and
87 * eject/insert shouldn't take it out of that state. They might be
88 * right. On the other hand, some would argue that eject resets all
89 * state. They might be right. They both can't be right. The above
90 * represents a reasonable compromise between the two.
91 *
92 * Some bridges allow one to query to see if the card was changed while
93 * we were suspended. Others do not. We make no use of this functionality
94 * at this time.
95 */
96 enum cardstate { noslot, empty, suspend, filled, inactive };
97
98 /*
99 * Descriptor structure for memory map.
100 */
101 struct mem_desc {
102 int window; /* Memory map window number (0-4) */
103 int flags; /* Flags - see below */
104 caddr_t start; /* System memory start */
105 int size; /* Size of memory area */
106 unsigned long card; /* Card memory address */
107 };
108
109 #define MDF_16BITS 0x01 /* Memory is 16 bits wide */
110 #define MDF_ZEROWS 0x02 /* Set no wait states for memory */
111 #define MDF_WS0 0x04 /* Wait state flags */
112 #define MDF_WS1 0x08
113 #define MDF_ATTR 0x10 /* Memory is attribute memory */
114 #define MDF_WP 0x20 /* Write protect memory */
115 #define MDF_ACTIVE 0x40 /* Context active (read-only) */
116
117 /*
118 * Descriptor structure for I/O map
119 */
120 struct io_desc {
121 int window; /* I/O map number (0-1) */
122 int flags; /* Flags - see below */
123 int start; /* I/O port start */
124 int size; /* Number of port addresses */
125 };
126
127 #define IODF_WS 0x01 /* Set wait states for 16 bit I/O access */
128 #define IODF_16BIT 0x02 /* I/O access are 16 bit */
129 #define IODF_CS16 0x04 /* Allow card selection of 16 bit access */
130 #define IODF_ZEROWS 0x08 /* No wait states for 8 bit I/O */
131 #define IODF_ACTIVE 0x10 /* Context active (read-only) */
132
133 /*
134 * Device descriptor for allocation of driver.
135 */
136 #define DEV_MISC_LEN 36
137 #define DEV_MAX_CIS_LEN 40
138 struct dev_desc {
139 char name[16]; /* Driver name */
140 int unit; /* Driver unit number */
141 unsigned long mem; /* Memory address of driver */
142 int memsize; /* Memory size (if used) */
143 int iobase; /* base of I/O ports */
144 int iosize; /* Length of I/O ports */
145 int irqmask; /* Interrupt number(s) to allocate */
146 int flags; /* Device flags */
147 uint8_t misc[DEV_MISC_LEN]; /* For any random info */
148 uint8_t manufstr[DEV_MAX_CIS_LEN];
149 uint8_t versstr[DEV_MAX_CIS_LEN];
150 uint8_t cis3str[DEV_MAX_CIS_LEN];
151 uint8_t cis4str[DEV_MAX_CIS_LEN];
152 uint32_t manufacturer; /* Manufacturer ID */
153 uint32_t product; /* Product ID */
154 uint32_t prodext; /* Product ID (extended) */
155 };
156 #if __FreeBSD_version < 5000000 /* 4.x compatibility only. */
157 #define PIOCSDRVOLD _IOWR('P', 6, struct dev_desc_old) /* Set driver */
158 struct dev_desc_old {
159 char name[16]; /* Driver name */
160 int unit; /* Driver unit number */
161 unsigned long mem; /* Memory address of driver */
162 int memsize; /* Memory size (if used) */
163 int iobase; /* base of I/O ports */
164 int iosize; /* Length of I/O ports */
165 int irqmask; /* Interrupt number(s) to allocate */
166 int flags; /* Device flags */
167 uint8_t misc[DEV_MISC_LEN]; /* For any random info */
168 uint8_t manufstr[DEV_MAX_CIS_LEN];
169 uint8_t versstr[DEV_MAX_CIS_LEN];
170 uint32_t manufacturer; /* Manufacturer ID */
171 uint32_t product; /* Product ID */
172 uint32_t prodext; /* Product ID (extended) */
173 };
174 #endif
175 #define DEV_DESC_HAS_SIZE 1
176
177 struct pcic_reg {
178 unsigned char reg;
179 unsigned char value;
180 };
181
182 /*
183 * Slot information. Used to read current status of slot.
184 */
185 struct slotstate {
186 enum cardstate state; /* Current state of slot */
187 enum cardstate laststate; /* Previous state of slot */
188 int maxmem; /* Max allowed memory windows */
189 int maxio; /* Max allowed I/O windows */
190 int irqs; /* Bitmap of IRQs allowed */
191 int flags; /* Capability flags */
192 };
193
194 /*
195 * The power values are in volts * 10, e.g. 5V is 50, 3.3V is 33.
196 */
197 struct power {
198 int vcc;
199 int vpp;
200 };
201
202 /*
203 * The PC-Card resource IOC_GET_RESOURCE_RANGE
204 */
205 struct pccard_resource {
206 int type;
207 u_long size;
208 u_long min;
209 u_long max;
210 u_long resource_addr;
211 };
212
213
214 /*
215 * Other system limits
216 */
217 #define MAXSLOT 16
218 #define NUM_MEM_WINDOWS 10
219 #define NUM_IO_WINDOWS 6
220 #define CARD_DEVICE "/dev/card%d" /* String for snprintf */
221 #define PCCARD_MEMSIZE (4*1024)
222
223 #endif /* !_PCCARD_CARDINFO_H_ */
Cache object: df15fb23356a32309a40fd3d4bf97562
|