x86/amd-iommu: Add function to complete a tlb flush
[linux/fpc-iii.git] / drivers / isdn / hardware / eicon / platform.h
blob15d4942de53bae5badbab4bcac2c254a31628e36
1 /* $Id: platform.h,v 1.37.4.6 2005/01/31 12:22:20 armin Exp $
3 * platform.h
4 *
6 * Copyright 2000-2003 by Armin Schindler (mac@melware.de)
7 * Copyright 2000 Eicon Networks
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
14 #ifndef __PLATFORM_H__
15 #define __PLATFORM_H__
17 #if !defined(DIVA_BUILD)
18 #define DIVA_BUILD "local"
19 #endif
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/sched.h>
25 #include <linux/skbuff.h>
26 #include <linux/vmalloc.h>
27 #include <linux/proc_fs.h>
28 #include <linux/interrupt.h>
29 #include <linux/delay.h>
30 #include <linux/list.h>
31 #include <asm/types.h>
32 #include <asm/io.h>
34 #include "cardtype.h"
36 /* activate debuglib for modules only */
37 #ifndef MODULE
38 #define DIVA_NO_DEBUGLIB
39 #endif
41 #define DIVA_INIT_FUNCTION __init
42 #define DIVA_EXIT_FUNCTION __exit
44 #define DIVA_USER_MODE_CARD_CONFIG 1
45 #define USE_EXTENDED_DEBUGS 1
47 #define MAX_ADAPTER 32
49 #define DIVA_ISTREAM 1
51 #define MEMORY_SPACE_TYPE 0
52 #define PORT_SPACE_TYPE 1
55 #include <linux/string.h>
57 #ifndef byte
58 #define byte u8
59 #endif
61 #ifndef word
62 #define word u16
63 #endif
65 #ifndef dword
66 #define dword u32
67 #endif
69 #ifndef qword
70 #define qword u64
71 #endif
73 #ifndef NULL
74 #define NULL ((void *) 0)
75 #endif
77 #ifndef far
78 #define far
79 #endif
81 #ifndef _pascal
82 #define _pascal
83 #endif
85 #ifndef _loadds
86 #define _loadds
87 #endif
89 #ifndef _cdecl
90 #define _cdecl
91 #endif
93 #define MEM_TYPE_RAM 0
94 #define MEM_TYPE_PORT 1
95 #define MEM_TYPE_PROM 2
96 #define MEM_TYPE_CTLREG 3
97 #define MEM_TYPE_RESET 4
98 #define MEM_TYPE_CFG 5
99 #define MEM_TYPE_ADDRESS 6
100 #define MEM_TYPE_CONFIG 7
101 #define MEM_TYPE_CONTROL 8
103 #define MAX_MEM_TYPE 10
105 #define DIVA_OS_MEM_ATTACH_RAM(a) ((a)->ram)
106 #define DIVA_OS_MEM_ATTACH_PORT(a) ((a)->port)
107 #define DIVA_OS_MEM_ATTACH_PROM(a) ((a)->prom)
108 #define DIVA_OS_MEM_ATTACH_CTLREG(a) ((a)->ctlReg)
109 #define DIVA_OS_MEM_ATTACH_RESET(a) ((a)->reset)
110 #define DIVA_OS_MEM_ATTACH_CFG(a) ((a)->cfg)
111 #define DIVA_OS_MEM_ATTACH_ADDRESS(a) ((a)->Address)
112 #define DIVA_OS_MEM_ATTACH_CONFIG(a) ((a)->Config)
113 #define DIVA_OS_MEM_ATTACH_CONTROL(a) ((a)->Control)
115 #define DIVA_OS_MEM_DETACH_RAM(a, x) do { } while(0)
116 #define DIVA_OS_MEM_DETACH_PORT(a, x) do { } while(0)
117 #define DIVA_OS_MEM_DETACH_PROM(a, x) do { } while(0)
118 #define DIVA_OS_MEM_DETACH_CTLREG(a, x) do { } while(0)
119 #define DIVA_OS_MEM_DETACH_RESET(a, x) do { } while(0)
120 #define DIVA_OS_MEM_DETACH_CFG(a, x) do { } while(0)
121 #define DIVA_OS_MEM_DETACH_ADDRESS(a, x) do { } while(0)
122 #define DIVA_OS_MEM_DETACH_CONFIG(a, x) do { } while(0)
123 #define DIVA_OS_MEM_DETACH_CONTROL(a, x) do { } while(0)
125 #define DIVA_INVALID_FILE_HANDLE ((dword)(-1))
127 #define DIVAS_CONTAINING_RECORD(address, type, field) \
128 ((type *)((char*)(address) - (char*)(&((type *)0)->field)))
130 extern int sprintf(char *, const char*, ...);
132 typedef void* LIST_ENTRY;
134 typedef char DEVICE_NAME[64];
135 typedef struct _ISDN_ADAPTER ISDN_ADAPTER;
136 typedef struct _ISDN_ADAPTER* PISDN_ADAPTER;
138 typedef void (* DIVA_DI_PRINTF) (unsigned char *, ...);
139 #include "debuglib.h"
141 #define dtrc(p) DBG_PRV0(p)
142 #define dbug(a,p) DBG_PRV1(p)
145 typedef struct e_info_s E_INFO ;
147 typedef char diva_os_dependent_devica_name_t[64];
148 typedef void* PDEVICE_OBJECT;
150 struct _diva_os_soft_isr;
151 struct _diva_os_timer;
152 struct _ISDN_ADAPTER;
154 void diva_log_info(unsigned char *, ...);
157 ** XDI DIDD Interface
159 void diva_xdi_didd_register_adapter (int card);
160 void diva_xdi_didd_remove_adapter (int card);
163 ** memory allocation
165 static __inline__ void* diva_os_malloc (unsigned long flags, unsigned long size)
167 void *ret = NULL;
169 if (size) {
170 ret = (void *) vmalloc((unsigned int) size);
172 return (ret);
174 static __inline__ void diva_os_free (unsigned long flags, void* ptr)
176 vfree(ptr);
180 ** use skbuffs for message buffer
182 typedef struct sk_buff diva_os_message_buffer_s;
183 diva_os_message_buffer_s *diva_os_alloc_message_buffer(unsigned long size, void **data_buf);
184 void diva_os_free_message_buffer(diva_os_message_buffer_s *dmb);
185 #define DIVA_MESSAGE_BUFFER_LEN(x) x->len
186 #define DIVA_MESSAGE_BUFFER_DATA(x) x->data
189 ** mSeconds waiting
191 static __inline__ void diva_os_sleep(dword mSec)
193 msleep(mSec);
195 static __inline__ void diva_os_wait(dword mSec)
197 mdelay(mSec);
201 ** PCI Configuration space access
203 void PCIwrite (byte bus, byte func, int offset, void* data, int length, void* pci_dev_handle);
204 void PCIread (byte bus, byte func, int offset, void* data, int length, void* pci_dev_handle);
207 ** I/O Port utilities
209 int diva_os_register_io_port (void *adapter, int register, unsigned long port,
210 unsigned long length, const char* name, int id);
212 ** I/O port access abstraction
214 byte inpp (void __iomem *);
215 word inppw (void __iomem *);
216 void inppw_buffer (void __iomem *, void*, int);
217 void outppw (void __iomem *, word);
218 void outppw_buffer (void __iomem * , void*, int);
219 void outpp (void __iomem *, word);
222 ** IRQ
224 typedef struct _diva_os_adapter_irq_info {
225 byte irq_nr;
226 int registered;
227 char irq_name[24];
228 } diva_os_adapter_irq_info_t;
229 int diva_os_register_irq (void* context, byte irq, const char* name);
230 void diva_os_remove_irq (void* context, byte irq);
232 #define diva_os_in_irq() in_irq()
235 ** Spin Lock framework
237 typedef long diva_os_spin_lock_magic_t;
238 typedef spinlock_t diva_os_spin_lock_t;
239 static __inline__ int diva_os_initialize_spin_lock (spinlock_t *lock, void * unused) { \
240 spin_lock_init (lock); return(0); }
241 static __inline__ void diva_os_enter_spin_lock (diva_os_spin_lock_t* a, \
242 diva_os_spin_lock_magic_t* old_irql, \
243 void* dbg) { spin_lock_bh(a); }
244 static __inline__ void diva_os_leave_spin_lock (diva_os_spin_lock_t* a, \
245 diva_os_spin_lock_magic_t* old_irql, \
246 void* dbg) { spin_unlock_bh(a); }
248 #define diva_os_destroy_spin_lock(a,b) do { } while(0)
251 ** Deffered processing framework
253 typedef int (*diva_os_isr_callback_t)(struct _ISDN_ADAPTER*);
254 typedef void (*diva_os_soft_isr_callback_t)(struct _diva_os_soft_isr* psoft_isr, void* context);
256 typedef struct _diva_os_soft_isr {
257 void* object;
258 diva_os_soft_isr_callback_t callback;
259 void* callback_context;
260 char dpc_thread_name[24];
261 } diva_os_soft_isr_t;
263 int diva_os_initialize_soft_isr (diva_os_soft_isr_t* psoft_isr, diva_os_soft_isr_callback_t callback, void* callback_context);
264 int diva_os_schedule_soft_isr (diva_os_soft_isr_t* psoft_isr);
265 int diva_os_cancel_soft_isr (diva_os_soft_isr_t* psoft_isr);
266 void diva_os_remove_soft_isr (diva_os_soft_isr_t* psoft_isr);
269 Get time service
271 void diva_os_get_time (dword* sec, dword* usec);
274 ** atomic operation, fake because we use threads
276 typedef int diva_os_atomic_t;
277 static diva_os_atomic_t __inline__
278 diva_os_atomic_increment(diva_os_atomic_t* pv)
280 *pv += 1;
281 return (*pv);
283 static diva_os_atomic_t __inline__
284 diva_os_atomic_decrement(diva_os_atomic_t* pv)
286 *pv -= 1;
287 return (*pv);
291 ** CAPI SECTION
293 #define NO_CORNETN
294 #define IMPLEMENT_DTMF 1
295 #define IMPLEMENT_ECHO_CANCELLER 1
296 #define IMPLEMENT_RTP 1
297 #define IMPLEMENT_T38 1
298 #define IMPLEMENT_FAX_SUB_SEP_PWD 1
299 #define IMPLEMENT_V18 1
300 #define IMPLEMENT_DTMF_TONE 1
301 #define IMPLEMENT_PIAFS 1
302 #define IMPLEMENT_FAX_PAPER_FORMATS 1
303 #define IMPLEMENT_VOWN 1
304 #define IMPLEMENT_CAPIDTMF 1
305 #define IMPLEMENT_FAX_NONSTANDARD 1
306 #define VSWITCH_SUPPORT 1
308 #define IMPLEMENT_MARKED_OK_AFTER_FC 1
310 #define DIVA_IDI_RX_DMA 1
313 ** endian macros
315 ** If only... In some cases we did use them for endianness conversion;
316 ** unfortunately, other uses were real iomem accesses.
318 #define READ_BYTE(addr) readb(addr)
319 #define READ_WORD(addr) readw(addr)
320 #define READ_DWORD(addr) readl(addr)
322 #define WRITE_BYTE(addr,v) writeb(v,addr)
323 #define WRITE_WORD(addr,v) writew(v,addr)
324 #define WRITE_DWORD(addr,v) writel(v,addr)
326 static inline __u16 GET_WORD(void *addr)
328 return le16_to_cpu(*(__le16 *)addr);
330 static inline __u32 GET_DWORD(void *addr)
332 return le32_to_cpu(*(__le32 *)addr);
334 static inline void PUT_WORD(void *addr, __u16 v)
336 *(__le16 *)addr = cpu_to_le16(v);
338 static inline void PUT_DWORD(void *addr, __u32 v)
340 *(__le32 *)addr = cpu_to_le32(v);
344 ** 32/64 bit macors
346 #ifdef BITS_PER_LONG
347 #if BITS_PER_LONG > 32
348 #define PLATFORM_GT_32BIT
349 #define ULongToPtr(x) (void *)(unsigned long)(x)
350 #endif
351 #endif
354 ** undef os definitions of macros we use
356 #undef ID_MASK
357 #undef N_DATA
358 #undef ADDR
361 ** dump file
363 #define diva_os_dump_file_t char
364 #define diva_os_board_trace_t char
365 #define diva_os_dump_file(__x__) do { } while(0)
368 ** size of internal arrays
370 #define MAX_DESCRIPTORS 64
372 #endif /* __PLATFORM_H__ */