2 * cs_internal.h 1.54 2000/10/26 20:10:55
4 * The contents of this file are subject to the Mozilla Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License
7 * at http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific language governing rights and
12 * limitations under the License.
14 * The initial developer of the original code is David A. Hinds
15 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
16 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
19 #ifndef _LINUX_CS_INTERNAL_H
20 #define _LINUX_CS_INTERNAL_H
22 #include <linux/config.h>
24 typedef struct erase_busy_t
{
25 eraseq_entry_t
*erase
;
26 client_handle_t client
;
27 struct timer_list timeout
;
28 struct erase_busy_t
*prev
, *next
;
31 #define ERASEQ_MAGIC 0xFA67
32 typedef struct eraseq_t
{
34 client_handle_t handle
;
36 eraseq_entry_t
*entry
;
39 #define CLIENT_MAGIC 0x51E6
40 typedef struct client_t
{
47 event_t EventMask
, PendingEvents
;
48 int (*event_handler
)(event_t event
, int priority
,
49 event_callback_args_t
*);
50 event_callback_args_t event_callback_args
;
51 struct client_t
*next
;
53 wait_queue_head_t mtd_req
;
54 erase_busy_t erase_busy
;
57 /* Flags in client state */
58 #define CLIENT_CONFIG_LOCKED 0x0001
59 #define CLIENT_IRQ_REQ 0x0002
60 #define CLIENT_IO_REQ 0x0004
61 #define CLIENT_UNBOUND 0x0008
62 #define CLIENT_STALE 0x0010
63 #define CLIENT_WIN_REQ(i) (0x20<<(i))
64 #define CLIENT_CARDBUS 0x8000
66 typedef struct io_window_t
{
68 ioaddr_t BasePort
, NumPorts
;
69 ioaddr_t InUse
, Config
;
72 #define WINDOW_MAGIC 0xB35C
73 typedef struct window_t
{
76 client_handle_t handle
;
77 struct socket_info_t
*sock
;
83 #define REGION_MAGIC 0xE3C9
84 typedef struct region_t
{
93 #define REGION_STALE 0x01
95 /* Each card function gets one of these guys */
96 typedef struct config_t
{
99 u_int Vcc
, Vpp1
, Vpp2
;
102 u_char Status
, Pin
, Copy
, Option
, ExtStatus
;
111 /* Maximum number of IO windows per socket */
114 /* Maximum number of memory windows per socket */
117 /* The size of the CIS cache */
118 #define MAX_CIS_TABLE 64
119 #define MAX_CIS_DATA 512
121 typedef struct socket_info_t
{
123 struct pccard_operations
* ss_entry
;
125 socket_state_t socket
;
130 client_handle_t clients
;
132 client_handle_t reset_handle
;
133 pccard_mem_map cis_mem
;
136 #ifdef CONFIG_CARDBUS
137 struct resource
* cb_cis_res
;
139 struct cb_config_t
*cb_config
;
145 io_window_t io
[MAX_IO_WIN
];
146 window_t win
[MAX_WIN
];
147 region_t
*c_region
, *a_region
;
148 erase_busy_t erase_busy
;
154 } cis_table
[MAX_CIS_TABLE
];
155 char cis_cache
[MAX_CIS_DATA
];
158 #ifdef CONFIG_PROC_FS
159 struct proc_dir_entry
*proc
;
164 /* Flags in config state */
165 #define CONFIG_LOCKED 0x01
166 #define CONFIG_IRQ_REQ 0x02
167 #define CONFIG_IO_REQ 0x04
169 /* Flags in socket state */
170 #define SOCKET_PRESENT 0x0008
171 #define SOCKET_SETUP_PENDING 0x0010
172 #define SOCKET_SHUTDOWN_PENDING 0x0020
173 #define SOCKET_RESET_PENDING 0x0040
174 #define SOCKET_SUSPEND 0x0080
175 #define SOCKET_WIN_REQ(i) (0x0100<<(i))
176 #define SOCKET_IO_REQ(i) (0x1000<<(i))
177 #define SOCKET_REGION_INFO 0x4000
178 #define SOCKET_CARDBUS 0x8000
180 #define CHECK_HANDLE(h) \
181 (((h) == NULL) || ((h)->client_magic != CLIENT_MAGIC))
183 #define CHECK_SOCKET(s) \
184 (((s) >= sockets) || (socket_table[s]->ss_entry == NULL))
186 #define SOCKET(h) (socket_table[(h)->Socket])
187 #define CONFIG(h) (&SOCKET(h)->config[(h)->Function])
189 #define CHECK_REGION(r) \
190 (((r) == NULL) || ((r)->region_magic != REGION_MAGIC))
192 #define CHECK_ERASEQ(q) \
193 (((q) == NULL) || ((q)->eraseq_magic != ERASEQ_MAGIC))
195 #define EVENT(h, e, p) \
196 ((h)->event_handler((e), (p), &(h)->event_callback_args))
199 int cb_alloc(socket_info_t
*s
);
200 void cb_free(socket_info_t
*s
);
201 int cb_config(socket_info_t
*s
);
202 void cb_release(socket_info_t
*s
);
203 void cb_enable(socket_info_t
*s
);
204 void cb_disable(socket_info_t
*s
);
205 void read_cb_mem(socket_info_t
*s
, u_char fn
, int space
,
206 u_int addr
, u_int len
, void *ptr
);
207 void cb_release_cis_mem(socket_info_t
*s
);
210 void read_cis_mem(socket_info_t
*s
, int attr
,
211 u_int addr
, u_int len
, void *ptr
);
212 void write_cis_mem(socket_info_t
*s
, int attr
,
213 u_int addr
, u_int len
, void *ptr
);
214 void release_cis_mem(socket_info_t
*s
);
215 int verify_cis_cache(socket_info_t
*s
);
216 void preload_cis_cache(socket_info_t
*s
);
217 int get_first_tuple(client_handle_t handle
, tuple_t
*tuple
);
218 int get_next_tuple(client_handle_t handle
, tuple_t
*tuple
);
219 int get_tuple_data(client_handle_t handle
, tuple_t
*tuple
);
220 int parse_tuple(client_handle_t handle
, tuple_t
*tuple
, cisparse_t
*parse
);
221 int validate_cis(client_handle_t handle
, cisinfo_t
*info
);
222 int replace_cis(client_handle_t handle
, cisdump_t
*cis
);
223 int read_tuple(client_handle_t handle
, cisdata_t code
, void *parse
);
226 void retry_erase_list(struct erase_busy_t
*list
, u_int cause
);
227 int get_first_region(client_handle_t handle
, region_info_t
*rgn
);
228 int get_next_region(client_handle_t handle
, region_info_t
*rgn
);
229 int register_mtd(client_handle_t handle
, mtd_reg_t
*reg
);
230 int register_erase_queue(client_handle_t
*handle
, eraseq_hdr_t
*header
);
231 int deregister_erase_queue(eraseq_handle_t eraseq
);
232 int check_erase_queue(eraseq_handle_t eraseq
);
233 int open_memory(client_handle_t
*handle
, open_mem_t
*open
);
234 int close_memory(memory_handle_t handle
);
235 int read_memory(memory_handle_t handle
, mem_op_t
*req
, caddr_t buf
);
236 int write_memory(memory_handle_t handle
, mem_op_t
*req
, caddr_t buf
);
237 int copy_memory(memory_handle_t handle
, copy_op_t
*req
);
240 void validate_mem(int (*is_valid
)(u_long
), int (*do_cksum
)(u_long
),
242 int find_io_region(ioaddr_t
*base
, ioaddr_t num
, ioaddr_t align
,
244 int find_mem_region(u_long
*base
, u_long num
, u_long align
,
245 int force_low
, char *name
);
246 int try_irq(u_int Attributes
, int irq
, int specific
);
247 void undo_irq(u_int Attributes
, int irq
);
248 int adjust_resource_info(client_handle_t handle
, adjust_t
*adj
);
249 void release_resource_db(void);
250 int proc_read_io(char *buf
, char **start
, off_t pos
,
251 int count
, int *eof
, void *data
);
252 int proc_read_mem(char *buf
, char **start
, off_t pos
,
253 int count
, int *eof
, void *data
);
256 extern socket_t sockets
;
257 extern socket_info_t
*socket_table
[MAX_SOCK
];
259 #ifdef CONFIG_PROC_FS
260 extern struct proc_dir_entry
*proc_pccard
;
265 #define DEBUG(n, args...) do { if (pc_debug>(n)) printk(KERN_DEBUG args); } while (0)
267 #define DEBUG(n, args...) do { } while (0)
270 #endif /* _LINUX_CS_INTERNAL_H */