1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #define ALLOW_SELECT
30
31 #include <linux/param.h>
32 #include <linux/types.h>
33 #include <linux/errno.h>
34 #include <linux/signal.h>
35 #include <linux/fcntl.h>
36 #include <linux/sched.h>
37 #include <linux/timer.h>
38 #include <linux/tty.h>
39 #include <linux/ctype.h>
40 #include <asm/io.h>
41 #include <asm/segment.h>
42 #include <asm/system.h>
43 #include <asm/dma.h>
44 #include <sys/kd.h>
45 #include <linux/wait.h>
46 #include <linux/malloc.h>
47 #include <linux/soundcard.h>
48
49 typedef char snd_rw_buf;
50
51 #define FALSE 0
52 #define TRUE 1
53
54 #define COPY_FROM_USER(d, s, o, c) memcpy_fromfs((d), &((s)[o]), (c))
55 #define COPY_TO_USER(d, o, s, c) memcpy_tofs(&((d)[o]), (s), (c))
56 #define IOCTL_FROM_USER(d, s, o, c) memcpy_fromfs((d), &((s)[o]), (c))
57 #define IOCTL_TO_USER(d, o, s, c) memcpy_tofs(&((d)[o]), (s), (c))
58
59 #define GET_BYTE_FROM_USER(target, addr, offs) target = get_fs_byte(&((addr)[offs]))
60 #define GET_SHORT_FROM_USER(target, addr, offs) target = get_fs_word(&((addr)[offs]))
61 #define GET_WORD_FROM_USER(target, addr, offs) target = get_fs_long((long*)&((addr)[offs]))
62 #define PUT_WORD_TO_USER(addr, offs, data) put_fs_long(data, (long*)&((addr)[offs]))
63 #define IOCTL_IN(arg) get_fs_long((long *)(arg))
64 #define IOCTL_OUT(arg, ret) snd_ioctl_return((int *)arg, ret)
65
66 struct snd_wait {
67 int mode; int aborting;
68 };
69
70 #define DEFINE_WAIT_QUEUE(name, flag) static struct wait_queue *name = NULL; \
71 static volatile struct snd_wait flag = {0}
72 #define DEFINE_WAIT_QUEUES(name, flag) static struct wait_queue *name = {NULL}; \
73 static volatile struct snd_wait flag = {{0}}
74 #define RESET_WAIT_QUEUE(q, f) {f.aborting = 0;f.mode = WK_NONE;}
75 #define PROCESS_ABORTING(q, f) (f.aborting | (current->signal & ~current->blocked))
76 #define SET_ABORT_FLAG(q, f) f.aborting = 1
77 #define TIMED_OUT(q, f) (f.mode & WK_TIMEOUT)
78 #define DO_SLEEP(q, f, time_limit) \
79 { unsigned long tl;\
80 if (time_limit) tl = current->timeout = jiffies + (time_limit); \
81 else tl = 0xffffffff; \
82 f.mode = WK_SLEEP;interruptible_sleep_on(&q); \
83 if (!(f.mode & WK_WAKEUP)) \
84 { \
85 if (current->signal & ~current->blocked) \
86 f.aborting = 1; \
87 else \
88 if (jiffies >= tl) f.mode |= WK_TIMEOUT; \
89 } \
90 f.mode &= ~WK_SLEEP; \
91 }
92 #define SOMEONE_WAITING(q, f) (f.mode & WK_SLEEP)
93 #define WAKE_UP(q, f) {f.mode = WK_WAKEUP;wake_up(&q);}
94
95 #define ALLOC_DMA_CHN(chn) request_dma(chn)
96 #define RELEASE_DMA_CHN(chn) free_dma(chn)
97
98 #define GET_TIME() jiffies
99 #define RELEASE_IRQ free_irq
100 #define RET_ERROR(err) -err
101
102
103
104
105
106
107 #define DISABLE_INTR(flags) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=r" (flags));
108 #define RESTORE_INTR(flags) __asm__ __volatile__("pushl %0 ; popfl": \
109 :"r" (flags));
110
111
112
113
114
115
116
117
118
119 #define KERNEL_MALLOC(nbytes) kmalloc(nbytes, GFP_KERNEL)
120 #define KERNEL_FREE(addr) kfree(addr)
121
122
123
124
125
126
127
128
129
130
131 #define PERMANENT_MALLOC(typecast, mem_ptr, size, linux_ptr) \
132 {mem_ptr = (typecast)linux_ptr; \
133 linux_ptr += (size);}
134
135
136
137
138
139
140
141 #define DEFINE_TIMER(name, proc) \
142 static struct timer_list name = \
143 {NULL, NULL, 0, 0, proc}
144
145
146
147
148
149 #define ACTIVATE_TIMER(name, proc, time) \
150 {name.expires = time; \
151 add_timer (&name);}
152
153 #define INB inb
154 #define OUTB outb