source: drsdaq/VME/struck/sis1100/V2.02/dev/pci/compat_linux.h@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 4.1 KB
Line 
1/* $ZEL: compat_linux.h,v 1.5 2004/05/27 23:10:12 wuestner Exp $ */
2
3/*
4 * Copyright (c) 2003-2004
5 * Peter Wuestner. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _compat_linux_h_
30#define _compat_linux_h_
31
32#include <linux/config.h>
33#include <linux/version.h>
34#include <linux/init.h>
35#include <linux/types.h>
36#include <linux/pci.h>
37#include <linux/module.h>
38#include <linux/interrupt.h>
39#include <linux/mm.h>
40#include <linux/poll.h>
41#include <asm/poll.h>
42#include <asm/uaccess.h>
43
44#define ofs(what, elem) ((off_t)&(((what *)0)->elem))
45
46#define _plxreadreg_4(sc, offset) readl((sc)->plxmembase+(offset))
47#define _plxwritereg_4(sc, offset, val) writel(val, (sc)->plxmembase+(offset))
48#define _plxreadreg_1(sc, offset) readb((sc)->plxmembase+(offset))
49#define _plxwritereg_1(sc, offset, val) writeb(val, (sc)->plxmembase+(offset))
50
51#define _plxreadlocal0_4(sc, offset) readl((sc)->reg_base+(offset))
52#define _plxwritelocal0_4(sc, offset, val) writel(val, (sc)->reg_base+(offset))
53#define _plxrawreadlocal0_4(sc, offset) __raw_readl((sc)->reg_base+(offset))
54#define _plxrawwritelocal0_4(sc, offset, val) __raw_writel(val, (sc)->reg_base+(offset))
55
56#define _plxreadlocal1_4(sc, offset) readl((sc)->rem_base+(offset))
57#define _plxwritelocal1_4(sc, offset, val) writel(val, (sc)->rem_base+(offset))
58#define _plxreadlocal1_2(sc, offset) readw((sc)->rem_base+(offset))
59#define _plxwritelocal1_2(sc, offset, val) writew(val, (sc)->rem_base+(offset))
60
61#define pINFOsc(fmt, arg...) \
62 printk(KERN_INFO "sis1100: " fmt "\n" , ## arg)
63#define pINFO(sc, fmt, arg...) \
64 printk(KERN_INFO "sis1100[%d]: " fmt "\n", sc->unit , ## arg)
65#define pERROR(sc, fmt, arg...) \
66 printk(KERN_ERR "sis1100[%d]: " fmt "\n", sc->unit , ## arg)
67
68#define DECLARE_SPINLOCKFLAGS(flags) unsigned long flags;
69#define SPIN_LOCK_IRQSAVE(lock, flags) spin_lock_irqsave(&(lock), flags)
70#define SPIN_UNLOCK_IRQRESTORE(lock, flags) spin_unlock_irqrestore(&(lock), flags)
71
72#define SEM_LOCK(sem) down(&(sem))
73#define SEM_UNLOCK(sem) up(&(sem))
74
75#define ACCESS_OK(buf, count, write) \
76 access_ok(write?VERIFY_READ:VERIFY_WRITE, buf, count)
77
78#define RMB(t, h, o, l) rmb()
79#define WMB(t, h, o, l) wmb()
80#define MB(t, h, o, l) mb()
81
82#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23)
83typedef void irqreturn_t;
84#define IRQ_NONE
85#define IRQ_HANDLED
86#endif
87
88#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
89#define SIGMASK_LOCK sigmask_lock
90#else
91#define SIGMASK_LOCK sighand->siglock
92#endif
93
94#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
95static inline unsigned iminor(struct inode *inode)
96{
97 return MINOR(inode->i_rdev);
98}
99#endif
100
101#define LINUX_RETURN(x) return -(x)
102
103int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
104 const char* uaddr, size_t count, int rw);
105int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages,
106 int dirtied);
107void dump_sgl(struct scatterlist *sgl, int nr_pages);
108
109#endif
Note: See TracBrowser for help on using the repository browser.