import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / drivers / isdn / eicon / uxio.h
1 /*
2  * Interface to Unix specific code for performing card I/O
3  *
4  * Copyright (C) Eicon Technology Corporation, 2000.
5  *
6  * Eicon File Revision :    1.6  
7  *
8  * This software may be used and distributed according to the terms
9  * of the GNU General Public License, incorporated herein by reference.
10  *
11  */
12
13 #if !defined(UXIO_H)
14 #define UXIO_H
15
16 #include "sys.h"
17 #include "adapter.h"
18
19
20 struct pt_regs;
21
22 /* user callback, returns zero if interrupt was from this card */
23 typedef void            isr_fn_t(void *);
24 struct ux_diva_card_s
25 {
26         word    in_use;
27         int             io_base;
28         int             reset_base;
29         int             card_type;
30         byte            *mapped;
31         int             bus_num;
32         int             func_num;
33         int             slot;
34         int             irq;
35         byte            *pDRAM;
36         byte            *pDEVICES;
37         byte            *pCONFIG;
38         byte            *pSHARED;
39         byte            *pCONTROL;
40         word            features;
41         void            *user_isr_arg;
42         isr_fn_t        *user_isr;
43 };
44
45 /*
46  * Get a card handle to enable card to be accessed
47  */
48
49 int             UxCardHandleGet(        ux_diva_card_t  **card,
50                                                         dia_card_t              *cfg);
51
52 /*
53  * Free a card handle as no longer needed
54  */
55
56 void    UxCardHandleFree(ux_diva_card_t *card);
57
58 /*
59  * Lock and unlock access to a card
60  */
61
62 long            UxCardLock(ux_diva_card_t *card);
63 void    UxCardUnlock(ux_diva_card_t *card, long ipl);
64
65 /*
66  * Set the mapping address for PCI cards
67  */
68
69 int             UxCardAddrMappingSet(ux_diva_card_t     *card,
70                                                         int                             id,
71                                                         void                    *address,
72                                                         int                             size);
73
74 /*
75  * Attach card to memory to enable it to be accessed
76  * Returns the mapped address
77  */
78
79 void    *UxCardMemAttach(ux_diva_card_t *card, int id);
80
81 /*
82  * map card out of memory after completion of access
83  */
84
85 void    UxCardMemDetach(ux_diva_card_t *card, void *address);
86
87 /*
88  * input functions for memory-mapped cards
89  */
90
91 byte    UxCardMemIn(ux_diva_card_t *card, void *address);
92
93 word    UxCardMemInW(ux_diva_card_t *card, void *address);
94
95 dword   UxCardMemInD(ux_diva_card_t *card, void *address);
96
97 void    UxCardMemInBuffer(      ux_diva_card_t *card,
98                                                         void                    *address,
99                                                         void                    *buffer,
100                                                         int                             length);
101
102 /*
103  * output functions for memory-mapped cards
104  */
105
106 void UxCardMemOut(ux_diva_card_t *card, void *address, byte data);
107
108 void UxCardMemOutW(ux_diva_card_t *card, void *address, word data);
109
110 void UxCardMemOutD(ux_diva_card_t *card, void *address, dword data);
111
112 void UxCardMemOutBuffer(        ux_diva_card_t  *card,
113                                                         void                    *address,
114                                                         void                    *buffer,
115                                                         int                             length);
116
117 /*
118  * input functions for I/O-mapped cards
119  */
120
121 byte    UxCardIoIn(ux_diva_card_t *card, void *, void *address);
122
123 word    UxCardIoInW(ux_diva_card_t *card, void *, void *address);
124
125 dword   UxCardIoInD(ux_diva_card_t *card, void *, void *address);
126
127 void    UxCardIoInBuffer(       ux_diva_card_t *card,
128                                                         void *, void                    *address,
129                                                         void                    *buffer,
130                                                         int                             length);
131
132 /*
133  * output functions for I/O-mapped cards
134  */
135
136 void UxCardIoOut(ux_diva_card_t *card, void *, void *address, byte data);
137
138 void UxCardIoOutW(ux_diva_card_t *card, void *, void *address, word data);
139
140 void UxCardIoOutD(ux_diva_card_t *card, void *, void *address, dword data);
141
142 void UxCardIoOutBuffer( ux_diva_card_t  *card,
143                                                         void *, void                    *address,
144                                                         void                    *buffer,
145                                                         int                             length);
146
147 /*
148  * Get specified PCI config
149  */
150
151 void    UxPciConfigRead(ux_diva_card_t  *card, 
152                                                 int                             size,
153                                                 int                             offset,
154                                                 void                    *value);
155
156 /*
157  * Set specified PCI config
158  */
159
160 void    UxPciConfigWrite(ux_diva_card_t *card, 
161                                                 int                             size,
162                                                 int                             offset,
163                                                 void                    *value);
164
165 /* allocate memory, returning NULL if none available */
166
167 void    *UxAlloc(unsigned int size);
168
169 void    UxFree(void *);
170
171 /*
172  * Pause for specified number of milli-seconds 
173  */
174
175 void    UxPause(long ms);
176
177 /*
178  * Install an ISR for the specified card
179  */
180
181 int             UxIsrInstall(ux_diva_card_t *card, isr_fn_t *isr_fn, void *isr_arg);
182
183 /*
184  * Remove an ISR for the specified card
185  */
186 void    UxIsrRemove(ux_diva_card_t *card, void *);
187
188 /*
189  * DEBUG function to turn logging ON or OFF
190  */
191
192 void    UxCardLog(int turn_on);
193
194 long    UxInterlockedIncrement(ux_diva_card_t *card, long *dst);
195 long    UxInterlockedDecrement(ux_diva_card_t *card, long *dst);
196
197 #endif /* of UXIO_H */