source: drsdaq/VME/struck/sis1100/V2.02/dev/pci/compat_netbsd.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: 5.1 KB
Line 
1/* $ZEL: compat_netbsd.h,v 1.4 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_netbsd_h_
30#define _compat_netbsd_h_
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/conf.h>
35#include <sys/kernel.h>
36#include <sys/device.h>
37#include <sys/ioctl.h>
38#include <sys/fcntl.h>
39#include <sys/select.h>
40#include <sys/poll.h>
41#include <sys/proc.h>
42#include <sys/kthread.h>
43#include <sys/signalvar.h>
44#include <sys/malloc.h>
45#include <sys/buf.h>
46#include <sys/types.h>
47#include <machine/db_machdep.h>
48#include <machine/bus.h>
49#include <machine/intr.h>
50#include <uvm/uvm.h>
51#include <uvm/uvm_extern.h>
52#include <dev/pci/pcivar.h>
53#include <dev/pci/pcidevs.h>
54#include <dev/pci/pcireg.h>
55
56#define ofs(what, elem) ((off_t)&(((what *)0)->elem))
57
58#define _plxreadreg_4(sc, offset) \
59 bus_space_read_4(sc->plx_t, sc->plx_h, offset)
60#define _plxwritereg_4(sc, offset, val) \
61 bus_space_write_4(sc->plx_t, sc->plx_h, offset, val)
62
63#define _plxreadreg_1(sc, offset) \
64 bus_space_read_1(sc->plx_t, sc->plx_h, offset)
65#define _plxwritereg_1(sc, offset, val) \
66 bus_space_write_1(sc->plx_t, sc->plx_h, offset, val)
67
68#define _plxreadlocal0_4(sc, offset) \
69 bus_space_read_4(sc->reg_t, sc->reg_h, offset)
70#define _plxwritelocal0_4(sc, offset, val) \
71 bus_space_write_4(sc->reg_t, sc->reg_h, offset, val)
72
73#define _plxreadlocal1_4(sc, offset) \
74 bus_space_read_4(sc->rem_t, sc->rem_h, offset)
75#define _plxwritelocal1_4(sc, offset, val) \
76 bus_space_write_4(sc->rem_t, sc->rem_h, offset, val)
77#define _plxreadlocal1_2(sc, offset) \
78 bus_space_read_2(sc->rem_t, sc->rem_h, offset)
79#define _plxwritelocal1_2(sc, offset, val) \
80 bus_space_write_2(sc->rem_t, sc->rem_h, offset, val)
81
82#define pINFOsc(fmt, arg...) \
83 printf("sis1100: " fmt "\n" , ## arg)
84#define pINFO(sc, fmt, arg...) \
85 printf("%s: " fmt "\n", sc->sc_dev.dv_xname , ## arg)
86#define pERROR(sc, fmt, arg...) \
87 printf("%s: " fmt "\n", sc->sc_dev.dv_xname , ## arg)
88
89#if _BYTE_ORDER == _LITTLE_ENDIAN
90# undef __BIG_ENDIAN
91# define __LITTLE_ENDIAN
92#elif _BYTE_ORDER == _BIG_ENDIAN
93# undef __LITTLE_ENDIAN
94# define __BIG_ENDIAN
95#else
96# error UNKNOWN ENDIAN (bsd)
97#endif
98
99#define DECLARE_SPINLOCKFLAGS(s) int s;
100#define SPIN_LOCK_IRQSAVE(lock, s) do { \
101 s=splbio(); \
102 simple_lock(&lock); \
103 } while (0)
104#define SPIN_UNLOCK_IRQRESTORE(lock, s) do { \
105 simple_unlock(&lock); \
106 splx(s); \
107 } while (0)
108
109#define SEM_LOCK(sem) lockmgr(&(sem), LK_EXCLUSIVE, 0)
110#define SEM_UNLOCK(sem) lockmgr(&(sem), LK_RELEASE, 0)
111
112#define ACCESS_OK(buf, count, write) \
113 uvm_useracc(buf, count, write?B_READ:B_WRITE)
114
115/*
116 * copied from linux/include/linux/list.h
117 */
118struct list_head {
119 struct list_head *next, *prev;
120};
121
122#define INIT_LIST_HEAD(ptr) do { \
123 (ptr)->next = (ptr); (ptr)->prev = (ptr); \
124} while (0)
125
126static inline void __list_add(struct list_head *new,
127 struct list_head *prev,
128 struct list_head *next)
129{
130 next->prev = new;
131 new->next = next;
132 new->prev = prev;
133 prev->next = new;
134}
135
136static inline void
137list_add(struct list_head *new, struct list_head *head)
138{
139 __list_add(new, head, head->next);
140}
141
142static inline void __list_del(struct list_head * prev, struct list_head * next)
143{
144 next->prev = prev;
145 prev->next = next;
146}
147
148static inline void list_del(struct list_head *entry)
149{
150 __list_del(entry->prev, entry->next);
151}
152
153#define container_of(ptr, type, member) ({ \
154 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
155 (type *)( (char *)__mptr - offsetof(type,member) );})
156
157#define list_for_each(pos, head) \
158 for (pos = (head)->next; pos != (head); pos = pos->next)
159
160#define list_entry(ptr, type, member) container_of(ptr, type, member)
161
162typedef int irqreturn_t;
163#define IRQ_NONE 0
164#define IRQ_HANDLED 1
165
166#define LINUX_RETURN(x) return (x)
167
168#endif
Note: See TracBrowser for help on using the repository browser.