1 /* $Id: platform.h,v 1.37.4.6 2005/01/31 12:22:20 armin Exp $
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"
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>
36 /* activate debuglib for modules only */
38 #define DIVA_NO_DEBUGLIB
41 #define DIVA_USER_MODE_CARD_CONFIG 1
42 #define USE_EXTENDED_DEBUGS 1
44 #define MAX_ADAPTER 32
46 #define DIVA_ISTREAM 1
48 #define MEMORY_SPACE_TYPE 0
49 #define PORT_SPACE_TYPE 1
52 #include <linux/string.h>
71 #define NULL ((void *) 0)
90 #define MEM_TYPE_RAM 0
91 #define MEM_TYPE_PORT 1
92 #define MEM_TYPE_PROM 2
93 #define MEM_TYPE_CTLREG 3
94 #define MEM_TYPE_RESET 4
95 #define MEM_TYPE_CFG 5
96 #define MEM_TYPE_ADDRESS 6
97 #define MEM_TYPE_CONFIG 7
98 #define MEM_TYPE_CONTROL 8
100 #define MAX_MEM_TYPE 10
102 #define DIVA_OS_MEM_ATTACH_RAM(a) ((a)->ram)
103 #define DIVA_OS_MEM_ATTACH_PORT(a) ((a)->port)
104 #define DIVA_OS_MEM_ATTACH_PROM(a) ((a)->prom)
105 #define DIVA_OS_MEM_ATTACH_CTLREG(a) ((a)->ctlReg)
106 #define DIVA_OS_MEM_ATTACH_RESET(a) ((a)->reset)
107 #define DIVA_OS_MEM_ATTACH_CFG(a) ((a)->cfg)
108 #define DIVA_OS_MEM_ATTACH_ADDRESS(a) ((a)->Address)
109 #define DIVA_OS_MEM_ATTACH_CONFIG(a) ((a)->Config)
110 #define DIVA_OS_MEM_ATTACH_CONTROL(a) ((a)->Control)
112 #define DIVA_OS_MEM_DETACH_RAM(a, x) do { } while (0)
113 #define DIVA_OS_MEM_DETACH_PORT(a, x) do { } while (0)
114 #define DIVA_OS_MEM_DETACH_PROM(a, x) do { } while (0)
115 #define DIVA_OS_MEM_DETACH_CTLREG(a, x) do { } while (0)
116 #define DIVA_OS_MEM_DETACH_RESET(a, x) do { } while (0)
117 #define DIVA_OS_MEM_DETACH_CFG(a, x) do { } while (0)
118 #define DIVA_OS_MEM_DETACH_ADDRESS(a, x) do { } while (0)
119 #define DIVA_OS_MEM_DETACH_CONFIG(a, x) do { } while (0)
120 #define DIVA_OS_MEM_DETACH_CONTROL(a, x) do { } while (0)
122 #define DIVA_INVALID_FILE_HANDLE ((dword)(-1))
124 #define DIVAS_CONTAINING_RECORD(address, type, field) \
125 ((type *)((char *)(address) - (char *)(&((type *)0)->field)))
127 extern int sprintf(char *, const char *, ...);
129 typedef void *LIST_ENTRY
;
131 typedef char DEVICE_NAME
[64];
132 typedef struct _ISDN_ADAPTER ISDN_ADAPTER
;
133 typedef struct _ISDN_ADAPTER
*PISDN_ADAPTER
;
135 typedef void (*DIVA_DI_PRINTF
)(unsigned char *, ...);
136 #include "debuglib.h"
138 #define dtrc(p) DBG_PRV0(p)
139 #define dbug(a, p) DBG_PRV1(p)
142 typedef struct e_info_s E_INFO
;
144 typedef char diva_os_dependent_devica_name_t
[64];
145 typedef void *PDEVICE_OBJECT
;
147 struct _diva_os_soft_isr
;
148 struct _diva_os_timer
;
149 struct _ISDN_ADAPTER
;
151 void diva_log_info(unsigned char *, ...);
154 ** XDI DIDD Interface
156 void diva_xdi_didd_register_adapter(int card
);
157 void diva_xdi_didd_remove_adapter(int card
);
162 static __inline__
void *diva_os_malloc(unsigned long flags
, unsigned long size
)
167 ret
= (void *) vmalloc((unsigned int) size
);
171 static __inline__
void diva_os_free(unsigned long flags
, void *ptr
)
177 ** use skbuffs for message buffer
179 typedef struct sk_buff diva_os_message_buffer_s
;
180 diva_os_message_buffer_s
*diva_os_alloc_message_buffer(unsigned long size
, void **data_buf
);
181 void diva_os_free_message_buffer(diva_os_message_buffer_s
*dmb
);
182 #define DIVA_MESSAGE_BUFFER_LEN(x) x->len
183 #define DIVA_MESSAGE_BUFFER_DATA(x) x->data
188 static __inline__
void diva_os_sleep(dword mSec
)
192 static __inline__
void diva_os_wait(dword mSec
)
198 ** PCI Configuration space access
200 void PCIwrite(byte bus
, byte func
, int offset
, void *data
, int length
, void *pci_dev_handle
);
201 void PCIread(byte bus
, byte func
, int offset
, void *data
, int length
, void *pci_dev_handle
);
204 ** I/O Port utilities
206 int diva_os_register_io_port(void *adapter
, int reg
, unsigned long port
,
207 unsigned long length
, const char *name
, int id
);
209 ** I/O port access abstraction
211 byte
inpp(void __iomem
*);
212 word
inppw(void __iomem
*);
213 void inppw_buffer(void __iomem
*, void *, int);
214 void outppw(void __iomem
*, word
);
215 void outppw_buffer(void __iomem
* , void*, int);
216 void outpp(void __iomem
*, word
);
221 typedef struct _diva_os_adapter_irq_info
{
225 } diva_os_adapter_irq_info_t
;
226 int diva_os_register_irq(void *context
, byte irq
, const char *name
);
227 void diva_os_remove_irq(void *context
, byte irq
);
229 #define diva_os_in_irq() in_irq()
232 ** Spin Lock framework
234 typedef long diva_os_spin_lock_magic_t
;
235 typedef spinlock_t diva_os_spin_lock_t
;
236 static __inline__
int diva_os_initialize_spin_lock(spinlock_t
*lock
, void *unused
) { \
237 spin_lock_init(lock
); return (0); }
238 static __inline__
void diva_os_enter_spin_lock(diva_os_spin_lock_t
*a
, \
239 diva_os_spin_lock_magic_t
*old_irql
, \
240 void *dbg
) { spin_lock_bh(a
); }
241 static __inline__
void diva_os_leave_spin_lock(diva_os_spin_lock_t
*a
, \
242 diva_os_spin_lock_magic_t
*old_irql
, \
243 void *dbg
) { spin_unlock_bh(a
); }
245 #define diva_os_destroy_spin_lock(a, b) do { } while (0)
248 ** Deffered processing framework
250 typedef int (*diva_os_isr_callback_t
)(struct _ISDN_ADAPTER
*);
251 typedef void (*diva_os_soft_isr_callback_t
)(struct _diva_os_soft_isr
*psoft_isr
, void *context
);
253 typedef struct _diva_os_soft_isr
{
255 diva_os_soft_isr_callback_t callback
;
256 void *callback_context
;
257 char dpc_thread_name
[24];
258 } diva_os_soft_isr_t
;
260 int diva_os_initialize_soft_isr(diva_os_soft_isr_t
*psoft_isr
, diva_os_soft_isr_callback_t callback
, void *callback_context
);
261 int diva_os_schedule_soft_isr(diva_os_soft_isr_t
*psoft_isr
);
262 int diva_os_cancel_soft_isr(diva_os_soft_isr_t
*psoft_isr
);
263 void diva_os_remove_soft_isr(diva_os_soft_isr_t
*psoft_isr
);
268 void diva_os_get_time(dword
*sec
, dword
*usec
);
271 ** atomic operation, fake because we use threads
273 typedef int diva_os_atomic_t
;
274 static inline diva_os_atomic_t
275 diva_os_atomic_increment(diva_os_atomic_t
*pv
)
280 static inline diva_os_atomic_t
281 diva_os_atomic_decrement(diva_os_atomic_t
*pv
)
291 #define IMPLEMENT_DTMF 1
292 #define IMPLEMENT_ECHO_CANCELLER 1
293 #define IMPLEMENT_RTP 1
294 #define IMPLEMENT_T38 1
295 #define IMPLEMENT_FAX_SUB_SEP_PWD 1
296 #define IMPLEMENT_V18 1
297 #define IMPLEMENT_DTMF_TONE 1
298 #define IMPLEMENT_PIAFS 1
299 #define IMPLEMENT_FAX_PAPER_FORMATS 1
300 #define IMPLEMENT_VOWN 1
301 #define IMPLEMENT_CAPIDTMF 1
302 #define IMPLEMENT_FAX_NONSTANDARD 1
303 #define VSWITCH_SUPPORT 1
305 #define IMPLEMENT_MARKED_OK_AFTER_FC 1
307 #define DIVA_IDI_RX_DMA 1
312 ** If only... In some cases we did use them for endianness conversion;
313 ** unfortunately, other uses were real iomem accesses.
315 #define READ_BYTE(addr) readb(addr)
316 #define READ_WORD(addr) readw(addr)
317 #define READ_DWORD(addr) readl(addr)
319 #define WRITE_BYTE(addr, v) writeb(v, addr)
320 #define WRITE_WORD(addr, v) writew(v, addr)
321 #define WRITE_DWORD(addr, v) writel(v, addr)
323 static inline __u16
GET_WORD(void *addr
)
325 return le16_to_cpu(*(__le16
*)addr
);
327 static inline __u32
GET_DWORD(void *addr
)
329 return le32_to_cpu(*(__le32
*)addr
);
331 static inline void PUT_WORD(void *addr
, __u16 v
)
333 *(__le16
*)addr
= cpu_to_le16(v
);
335 static inline void PUT_DWORD(void *addr
, __u32 v
)
337 *(__le32
*)addr
= cpu_to_le32(v
);
344 #if BITS_PER_LONG > 32
345 #define PLATFORM_GT_32BIT
346 #define ULongToPtr(x) (void *)(unsigned long)(x)
351 ** undef os definitions of macros we use
360 #define diva_os_dump_file_t char
361 #define diva_os_board_trace_t char
362 #define diva_os_dump_file(__x__) do { } while (0)
365 ** size of internal arrays
367 #define MAX_DESCRIPTORS 64
369 #endif /* __PLATFORM_H__ */