2005-04-17 06:20:36 +08:00
|
|
|
/* $Id: platform.h,v 1.37.4.6 2005/01/31 12:22:20 armin Exp $
|
|
|
|
*
|
|
|
|
* platform.h
|
2012-02-20 11:52:38 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Copyright 2000-2003 by Armin Schindler (mac@melware.de)
|
2012-02-20 11:52:38 +08:00
|
|
|
* Copyright 2000 Eicon Networks
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __PLATFORM_H__
|
|
|
|
#define __PLATFORM_H__
|
|
|
|
|
|
|
|
#if !defined(DIVA_BUILD)
|
|
|
|
#define DIVA_BUILD "local"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <asm/types.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include "cardtype.h"
|
|
|
|
|
|
|
|
/* activate debuglib for modules only */
|
|
|
|
#ifndef MODULE
|
|
|
|
#define DIVA_NO_DEBUGLIB
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DIVA_USER_MODE_CARD_CONFIG 1
|
|
|
|
#define USE_EXTENDED_DEBUGS 1
|
|
|
|
|
|
|
|
#define MAX_ADAPTER 32
|
|
|
|
|
|
|
|
#define DIVA_ISTREAM 1
|
|
|
|
|
|
|
|
#define MEMORY_SPACE_TYPE 0
|
|
|
|
#define PORT_SPACE_TYPE 1
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
|
|
|
#ifndef byte
|
|
|
|
#define byte u8
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef word
|
|
|
|
#define word u16
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef dword
|
|
|
|
#define dword u32
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef qword
|
|
|
|
#define qword u64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL ((void *) 0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef far
|
|
|
|
#define far
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _pascal
|
|
|
|
#define _pascal
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _loadds
|
|
|
|
#define _loadds
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _cdecl
|
|
|
|
#define _cdecl
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MEM_TYPE_RAM 0
|
|
|
|
#define MEM_TYPE_PORT 1
|
|
|
|
#define MEM_TYPE_PROM 2
|
|
|
|
#define MEM_TYPE_CTLREG 3
|
|
|
|
#define MEM_TYPE_RESET 4
|
|
|
|
#define MEM_TYPE_CFG 5
|
|
|
|
#define MEM_TYPE_ADDRESS 6
|
|
|
|
#define MEM_TYPE_CONFIG 7
|
|
|
|
#define MEM_TYPE_CONTROL 8
|
|
|
|
|
|
|
|
#define MAX_MEM_TYPE 10
|
|
|
|
|
|
|
|
#define DIVA_OS_MEM_ATTACH_RAM(a) ((a)->ram)
|
|
|
|
#define DIVA_OS_MEM_ATTACH_PORT(a) ((a)->port)
|
|
|
|
#define DIVA_OS_MEM_ATTACH_PROM(a) ((a)->prom)
|
|
|
|
#define DIVA_OS_MEM_ATTACH_CTLREG(a) ((a)->ctlReg)
|
|
|
|
#define DIVA_OS_MEM_ATTACH_RESET(a) ((a)->reset)
|
|
|
|
#define DIVA_OS_MEM_ATTACH_CFG(a) ((a)->cfg)
|
|
|
|
#define DIVA_OS_MEM_ATTACH_ADDRESS(a) ((a)->Address)
|
|
|
|
#define DIVA_OS_MEM_ATTACH_CONFIG(a) ((a)->Config)
|
|
|
|
#define DIVA_OS_MEM_ATTACH_CONTROL(a) ((a)->Control)
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
#define DIVA_OS_MEM_DETACH_RAM(a, x) do { } while (0)
|
|
|
|
#define DIVA_OS_MEM_DETACH_PORT(a, x) do { } while (0)
|
|
|
|
#define DIVA_OS_MEM_DETACH_PROM(a, x) do { } while (0)
|
|
|
|
#define DIVA_OS_MEM_DETACH_CTLREG(a, x) do { } while (0)
|
|
|
|
#define DIVA_OS_MEM_DETACH_RESET(a, x) do { } while (0)
|
|
|
|
#define DIVA_OS_MEM_DETACH_CFG(a, x) do { } while (0)
|
|
|
|
#define DIVA_OS_MEM_DETACH_ADDRESS(a, x) do { } while (0)
|
|
|
|
#define DIVA_OS_MEM_DETACH_CONFIG(a, x) do { } while (0)
|
|
|
|
#define DIVA_OS_MEM_DETACH_CONTROL(a, x) do { } while (0)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define DIVA_INVALID_FILE_HANDLE ((dword)(-1))
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
#define DIVAS_CONTAINING_RECORD(address, type, field) \
|
|
|
|
((type *)((char *)(address) - (char *)(&((type *)0)->field)))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
extern int sprintf(char *, const char *, ...);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
typedef void *LIST_ENTRY;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
typedef char DEVICE_NAME[64];
|
|
|
|
typedef struct _ISDN_ADAPTER ISDN_ADAPTER;
|
|
|
|
typedef struct _ISDN_ADAPTER *PISDN_ADAPTER;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
typedef void (*DIVA_DI_PRINTF)(unsigned char *, ...);
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "debuglib.h"
|
|
|
|
|
|
|
|
#define dtrc(p) DBG_PRV0(p)
|
2012-02-20 11:52:38 +08:00
|
|
|
#define dbug(a, p) DBG_PRV1(p)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
typedef struct e_info_s E_INFO;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
typedef char diva_os_dependent_devica_name_t[64];
|
2012-02-20 11:52:38 +08:00
|
|
|
typedef void *PDEVICE_OBJECT;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct _diva_os_soft_isr;
|
|
|
|
struct _diva_os_timer;
|
|
|
|
struct _ISDN_ADAPTER;
|
|
|
|
|
|
|
|
void diva_log_info(unsigned char *, ...);
|
|
|
|
|
|
|
|
/*
|
|
|
|
** XDI DIDD Interface
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
void diva_xdi_didd_register_adapter(int card);
|
|
|
|
void diva_xdi_didd_remove_adapter(int card);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** memory allocation
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
static __inline__ void *diva_os_malloc(unsigned long flags, unsigned long size)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
void *ret = NULL;
|
|
|
|
|
|
|
|
if (size) {
|
|
|
|
ret = (void *) vmalloc((unsigned int) size);
|
|
|
|
}
|
|
|
|
return (ret);
|
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
static __inline__ void diva_os_free(unsigned long flags, void *ptr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
vfree(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** use skbuffs for message buffer
|
|
|
|
*/
|
|
|
|
typedef struct sk_buff diva_os_message_buffer_s;
|
|
|
|
diva_os_message_buffer_s *diva_os_alloc_message_buffer(unsigned long size, void **data_buf);
|
|
|
|
void diva_os_free_message_buffer(diva_os_message_buffer_s *dmb);
|
|
|
|
#define DIVA_MESSAGE_BUFFER_LEN(x) x->len
|
|
|
|
#define DIVA_MESSAGE_BUFFER_DATA(x) x->data
|
|
|
|
|
|
|
|
/*
|
|
|
|
** mSeconds waiting
|
|
|
|
*/
|
|
|
|
static __inline__ void diva_os_sleep(dword mSec)
|
|
|
|
{
|
|
|
|
msleep(mSec);
|
|
|
|
}
|
|
|
|
static __inline__ void diva_os_wait(dword mSec)
|
|
|
|
{
|
|
|
|
mdelay(mSec);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** PCI Configuration space access
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
void PCIwrite(byte bus, byte func, int offset, void *data, int length, void *pci_dev_handle);
|
|
|
|
void PCIread(byte bus, byte func, int offset, void *data, int length, void *pci_dev_handle);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** I/O Port utilities
|
|
|
|
*/
|
2016-06-16 21:52:12 +08:00
|
|
|
int diva_os_register_io_port(void *adapter, int reg, unsigned long port,
|
2012-02-20 11:52:38 +08:00
|
|
|
unsigned long length, const char *name, int id);
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
** I/O port access abstraction
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
byte inpp(void __iomem *);
|
|
|
|
word inppw(void __iomem *);
|
|
|
|
void inppw_buffer(void __iomem *, void *, int);
|
|
|
|
void outppw(void __iomem *, word);
|
|
|
|
void outppw_buffer(void __iomem * , void*, int);
|
|
|
|
void outpp(void __iomem *, word);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
** IRQ
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
typedef struct _diva_os_adapter_irq_info {
|
2012-02-20 11:52:38 +08:00
|
|
|
byte irq_nr;
|
|
|
|
int registered;
|
|
|
|
char irq_name[24];
|
2005-04-17 06:20:36 +08:00
|
|
|
} diva_os_adapter_irq_info_t;
|
2012-02-20 11:52:38 +08:00
|
|
|
int diva_os_register_irq(void *context, byte irq, const char *name);
|
|
|
|
void diva_os_remove_irq(void *context, byte irq);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define diva_os_in_irq() in_irq()
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Spin Lock framework
|
|
|
|
*/
|
|
|
|
typedef long diva_os_spin_lock_magic_t;
|
|
|
|
typedef spinlock_t diva_os_spin_lock_t;
|
2012-02-20 11:52:38 +08:00
|
|
|
static __inline__ int diva_os_initialize_spin_lock(spinlock_t *lock, void *unused) { \
|
|
|
|
spin_lock_init(lock); return (0); }
|
|
|
|
static __inline__ void diva_os_enter_spin_lock(diva_os_spin_lock_t *a, \
|
|
|
|
diva_os_spin_lock_magic_t *old_irql, \
|
|
|
|
void *dbg) { spin_lock_bh(a); }
|
|
|
|
static __inline__ void diva_os_leave_spin_lock(diva_os_spin_lock_t *a, \
|
|
|
|
diva_os_spin_lock_magic_t *old_irql, \
|
|
|
|
void *dbg) { spin_unlock_bh(a); }
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
#define diva_os_destroy_spin_lock(a, b) do { } while (0)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Deffered processing framework
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
typedef int (*diva_os_isr_callback_t)(struct _ISDN_ADAPTER *);
|
|
|
|
typedef void (*diva_os_soft_isr_callback_t)(struct _diva_os_soft_isr *psoft_isr, void *context);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
typedef struct _diva_os_soft_isr {
|
2012-02-20 11:52:38 +08:00
|
|
|
void *object;
|
|
|
|
diva_os_soft_isr_callback_t callback;
|
|
|
|
void *callback_context;
|
|
|
|
char dpc_thread_name[24];
|
2005-04-17 06:20:36 +08:00
|
|
|
} diva_os_soft_isr_t;
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
int diva_os_initialize_soft_isr(diva_os_soft_isr_t *psoft_isr, diva_os_soft_isr_callback_t callback, void *callback_context);
|
|
|
|
int diva_os_schedule_soft_isr(diva_os_soft_isr_t *psoft_isr);
|
|
|
|
int diva_os_cancel_soft_isr(diva_os_soft_isr_t *psoft_isr);
|
|
|
|
void diva_os_remove_soft_isr(diva_os_soft_isr_t *psoft_isr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
Get time service
|
2012-02-20 11:52:38 +08:00
|
|
|
*/
|
|
|
|
void diva_os_get_time(dword *sec, dword *usec);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** atomic operation, fake because we use threads
|
|
|
|
*/
|
|
|
|
typedef int diva_os_atomic_t;
|
2016-06-16 21:52:12 +08:00
|
|
|
static inline diva_os_atomic_t
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_os_atomic_increment(diva_os_atomic_t *pv)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-02-20 11:52:38 +08:00
|
|
|
*pv += 1;
|
|
|
|
return (*pv);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2016-06-16 21:52:12 +08:00
|
|
|
static inline diva_os_atomic_t
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_os_atomic_decrement(diva_os_atomic_t *pv)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-02-20 11:52:38 +08:00
|
|
|
*pv -= 1;
|
|
|
|
return (*pv);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
/*
|
2005-04-17 06:20:36 +08:00
|
|
|
** CAPI SECTION
|
|
|
|
*/
|
|
|
|
#define NO_CORNETN
|
|
|
|
#define IMPLEMENT_DTMF 1
|
|
|
|
#define IMPLEMENT_ECHO_CANCELLER 1
|
|
|
|
#define IMPLEMENT_RTP 1
|
|
|
|
#define IMPLEMENT_T38 1
|
|
|
|
#define IMPLEMENT_FAX_SUB_SEP_PWD 1
|
|
|
|
#define IMPLEMENT_V18 1
|
|
|
|
#define IMPLEMENT_DTMF_TONE 1
|
|
|
|
#define IMPLEMENT_PIAFS 1
|
|
|
|
#define IMPLEMENT_FAX_PAPER_FORMATS 1
|
|
|
|
#define IMPLEMENT_VOWN 1
|
|
|
|
#define IMPLEMENT_CAPIDTMF 1
|
|
|
|
#define IMPLEMENT_FAX_NONSTANDARD 1
|
|
|
|
#define VSWITCH_SUPPORT 1
|
|
|
|
|
|
|
|
#define IMPLEMENT_MARKED_OK_AFTER_FC 1
|
|
|
|
|
|
|
|
#define DIVA_IDI_RX_DMA 1
|
|
|
|
|
|
|
|
/*
|
|
|
|
** endian macros
|
|
|
|
**
|
|
|
|
** If only... In some cases we did use them for endianness conversion;
|
|
|
|
** unfortunately, other uses were real iomem accesses.
|
|
|
|
*/
|
|
|
|
#define READ_BYTE(addr) readb(addr)
|
|
|
|
#define READ_WORD(addr) readw(addr)
|
|
|
|
#define READ_DWORD(addr) readl(addr)
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
#define WRITE_BYTE(addr, v) writeb(v, addr)
|
|
|
|
#define WRITE_WORD(addr, v) writew(v, addr)
|
|
|
|
#define WRITE_DWORD(addr, v) writel(v, addr)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static inline __u16 GET_WORD(void *addr)
|
|
|
|
{
|
|
|
|
return le16_to_cpu(*(__le16 *)addr);
|
|
|
|
}
|
|
|
|
static inline __u32 GET_DWORD(void *addr)
|
|
|
|
{
|
|
|
|
return le32_to_cpu(*(__le32 *)addr);
|
|
|
|
}
|
|
|
|
static inline void PUT_WORD(void *addr, __u16 v)
|
|
|
|
{
|
|
|
|
*(__le16 *)addr = cpu_to_le16(v);
|
|
|
|
}
|
|
|
|
static inline void PUT_DWORD(void *addr, __u32 v)
|
|
|
|
{
|
|
|
|
*(__le32 *)addr = cpu_to_le32(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** 32/64 bit macors
|
|
|
|
*/
|
|
|
|
#ifdef BITS_PER_LONG
|
2012-02-20 11:52:38 +08:00
|
|
|
#if BITS_PER_LONG > 32
|
|
|
|
#define PLATFORM_GT_32BIT
|
|
|
|
#define ULongToPtr(x) (void *)(unsigned long)(x)
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
** undef os definitions of macros we use
|
|
|
|
*/
|
|
|
|
#undef ID_MASK
|
|
|
|
#undef N_DATA
|
|
|
|
#undef ADDR
|
|
|
|
|
|
|
|
/*
|
|
|
|
** dump file
|
|
|
|
*/
|
|
|
|
#define diva_os_dump_file_t char
|
|
|
|
#define diva_os_board_trace_t char
|
2012-02-20 11:52:38 +08:00
|
|
|
#define diva_os_dump_file(__x__) do { } while (0)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** size of internal arrays
|
|
|
|
*/
|
|
|
|
#define MAX_DESCRIPTORS 64
|
|
|
|
|
|
|
|
#endif /* __PLATFORM_H__ */
|