~ubuntu-branches/ubuntu/oneiric/oss4/oneiric-proposed

« back to all changes in this revision

Viewing changes to kernel/OS/Linux/os_linux.h

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera
  • Date: 2011-06-16 20:37:48 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110616203748-jbrxik6ql33z54co
Tags: 4.2-build2004-1ubuntu1
* Merge from Debian unstable.
  - Supports our current kernel (LP: #746048)
  Remaining changes:
  - debian/oss4-dkms.dkms.in: s/source/build/ in Kernel headers paths.
* ld-as-needed.patch: Re-order CC arguments to enable building with ld
  --as-needed (LP: #770972)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _OS_H_
 
2
#define _OS_H_
 
3
 
 
4
/*
 
5
 * Purpose: OS specific definitions for Linux
 
6
 *
 
7
 * Under Linux os.h (this file) defines just the macros, functions and
 
8
 * structures used by the code compiled in the development system. However
 
9
 * there are other Linux specific definitions contained in {!nlink Linux/wrap.h}
 
10
 * that are used both by the code compiled in the devlopment and target systems.
 
11
 * This means that some definitions found in os.h under some other operating
 
12
 * systems may be in wrap.h under Linux.
 
13
 */
 
14
/*
 
15
 *
 
16
 * This file is part of Open Sound System.
 
17
 *
 
18
 * Copyright (C) 4Front Technologies 1996-2008.
 
19
 *
 
20
 * This this source file is released under GPL v2 license (no other versions).
 
21
 * See the COPYING file included in the main directory of this source
 
22
 * distribution for the license terms and conditions.
 
23
 *
 
24
 */
 
25
 
 
26
#define OS_VERSION "2.6.x"
 
27
#define __EXTENDED__
 
28
#define OSS_MAINLINE_BUILD
 
29
 
 
30
/*
 
31
 * Debugging and misc settings
 
32
 */
 
33
#undef  MUTEX_CHECKS
 
34
#undef  MEMDEBUG
 
35
#define VDEV_SUPPORT
 
36
 
 
37
#if (!defined(__i386__) && !defined(__x86_64__)) || defined(CONFIG_OSS_FIXDEPOINT)
 
38
// Floating point is not supported or it's disabled
 
39
#undef CONFIG_OSS_VMIX_FLOAT
 
40
#endif
 
41
 
 
42
/*
 
43
 * Disable support for per-application features such as /dev/dsp device
 
44
 * selection based on command name. Requires working GET_PROCESS_NAME
 
45
 * macro implementation.
 
46
 */
 
47
 
 
48
#undef  APPLIST_SUPPORT
 
49
#define USE_DEVICE_SUBDIRS
 
50
#define EXTERN_C
 
51
 
 
52
#define __invalid_size_argument_for_IOC 0       /* Dummy define to cure some broken ioctl.h versions */
 
53
 
 
54
#include <sys/types.h>
 
55
#include <sys/param.h>
 
56
#include <sys/signal.h>
 
57
#include <oss_errno.h>
 
58
#include <sys/file.h>
 
59
#include "oss_ddi.h"
 
60
#include <sys/stat.h>
 
61
#include <sys/fcntl.h>
 
62
#include <asm/poll.h>
 
63
#include "kernel/OS/Linux/wrapper/wrap.h"
 
64
 
 
65
#undef HZ
 
66
extern int oss_hz;
 
67
#define OSS_HZ oss_hz
 
68
 
 
69
/* The soundcard.h could be in a nonstandard place so include it here. */
 
70
#include "soundcard.h"
 
71
 
 
72
struct _oss_device_t
 
73
{
 
74
  int cardnum;
 
75
  int dev_type;
 
76
  int available;
 
77
  int instance;
 
78
  dev_info_t *dip;
 
79
  void *devc;
 
80
  char *name;
 
81
  char nick[16];
 
82
  char handle[32];
 
83
  int num_audio_engines;
 
84
  int num_audioplay, num_audiorec, num_audioduplex;
 
85
  int num_mididevs;
 
86
  int num_mixerdevs;
 
87
  int num_loopdevs;
 
88
  int first_mixer;      /* This must be set to -1 by osdev_create() */
 
89
  int major;
 
90
  struct module *owner;         /* Pointer to THISMODULE (needed by osscore.c) */
 
91
  char modname[32];
 
92
  char *hw_info;
 
93
 
 
94
  volatile int refcount;        /* Nonzero means that the device is needed by some other (virtual) driver. */
 
95
 
 
96
/* Interrupts */
 
97
 
 
98
  ddi_iblock_cookie_t iblock_cookie;    /* Dummy field under Linux */
 
99
  void *irqparms;
 
100
  int intrcount, ackcount;
 
101
 
 
102
/* PCI related fields */
 
103
 
 
104
#ifdef _KERNEL
 
105
  ddi_acc_handle_t pci_config_handle;
 
106
  ddi_acc_handle_t acc_handle;
 
107
  int swap_mode;                /* 0=DDI_STRUCTURE_NEVERSWAP_ACC, 1=DDI_STRUCTURE_LE_ACC */
 
108
#endif
 
109
};
 
110
 
 
111
#define ALLOW_BUFFER_MAPPING
 
112
#define ALLOW_SELECT
 
113
#define SEL_IN          0
 
114
#define SEL_OUT         1
 
115
#define SEL_EX          0xffffffff
 
116
 
 
117
/* Busy wait routine */
 
118
#define oss_udelay drv_usecwait
 
119
/* System wall timer access */
 
120
#define GET_JIFFIES()   oss_get_jiffies()
 
121
 
 
122
extern inline unsigned int
 
123
__inb (unsigned short port)
 
124
{
 
125
  unsigned int _v;
 
126
  __asm__ __volatile__ ("in" "b" " %" "w" "1,%" "b" "0":"=a" (_v):"d" (port),
 
127
                        "0" (0));
 
128
  return _v;
 
129
}
 
130
extern inline unsigned int
 
131
__inw (unsigned short port)
 
132
{
 
133
  unsigned int _v;
 
134
  __asm__ __volatile__ ("in" "w" " %" "w" "1,%" "w" "0":"=a" (_v):"d" (port),
 
135
                        "0" (0));
 
136
  return _v;
 
137
}
 
138
extern inline unsigned int
 
139
__inl (unsigned short port)
 
140
{
 
141
  unsigned int _v;
 
142
  __asm__ __volatile__ ("in" "l" " %" "w" "1,%" "" "0":"=a" (_v):"d" (port));
 
143
  return _v;
 
144
}
 
145
 
 
146
extern inline void
 
147
__outb (unsigned char value, unsigned short port)
 
148
{
 
149
  __asm__ __volatile__ ("out" "b" " %" "b" "0,%" "w" "1"::"a" (value),
 
150
                        "d" (port));
 
151
}
 
152
extern inline void
 
153
__outw (unsigned short value, unsigned short port)
 
154
{
 
155
  __asm__ __volatile__ ("out" "w" " %" "w" "0,%" "w" "1"::"a" (value),
 
156
                        "d" (port));
 
157
}
 
158
extern inline void
 
159
__outl (unsigned int value, unsigned short port)
 
160
{
 
161
  __asm__ __volatile__ ("out" "l" " %" "0,%" "w" "1"::"a" (value),
 
162
                        "d" (port));
 
163
}
 
164
 
 
165
#define INB(osdev,a)    __inb(a)
 
166
#define INW(osdev,a)    __inw(a)
 
167
#define INL(osdev,a)    __inl(a)
 
168
 
 
169
#define OUTB(osdev, d, a) __outb(d, a)
 
170
 
 
171
#define OUTW(osdev, d, a)       __outw(d, a)
 
172
#define OUTL(osdev, d, a)       __outl(d, a)
 
173
 
 
174
#define PCI_READL(osdev, p)  (*(volatile unsigned int *) (p))
 
175
#define PCI_WRITEL(osdev, addr, data) (*(volatile unsigned int *) (addr) = (data))
 
176
#define PCI_READW(osdev, p)  (*(volatile unsigned short *) (p))
 
177
#define PCI_WRITEW(osdev, addr, data) (*(volatile unsigned short *) (addr) = (data))
 
178
#define PCI_READB(osdev, p)  (*(volatile unsigned char *) (p))
 
179
#define PCI_WRITEB(osdev, addr, data) (*(volatile unsigned char *) (addr) = (data))
 
180
 
 
181
/* 
 
182
   KERNEL_MALLOC() allocates requested number of memory  and 
 
183
   KERNEL_FREE is used to free it. 
 
184
   These macros are never called from interrupt, in addition the
 
185
   nbytes will never be more than 4096 bytes. Generally the driver
 
186
   will allocate memory in blocks of 4k. If the kernel has just a
 
187
   page level memory allocation, 4K can be safely used as the size
 
188
   (the nbytes parameter can be ignored).
 
189
*/
 
190
#ifdef MEMDEBUG
 
191
extern void *oss_kmem_alloc (size_t size, char *file, int line);
 
192
extern void oss_kmem_free (void *addr);
 
193
#define KERNEL_MALLOC(nbytes)   oss_kmem_alloc(nbytes, __FILE__, __LINE__)
 
194
#define KERNEL_FREE(addr)       oss_kmem_free(addr)
 
195
extern void *oss_contig_malloc (oss_device_t * osdev, int sz,
 
196
                                oss_uint64_t memlimit,
 
197
                                oss_native_word * phaddr, char *file,
 
198
                                int line);
 
199
extern void oss_contig_free (oss_device_t * osdev, void *p, int sz);
 
200
extern oss_native_word oss_virt_to_bus (void *addr);
 
201
#define CONTIG_MALLOC(osdev, sz, memlimit, phaddr, handle)      oss_contig_malloc(osdev, sz, memlimit, phaddr, __FILE__, __LINE__)
 
202
#define CONTIG_FREE(osdev, p, sz, handle)       oss_contig_free(osdev, p, sz)
 
203
#else
 
204
#define KERNEL_MALLOC(nbytes)   oss_kmem_alloc(nbytes)
 
205
#define KERNEL_FREE(addr)       oss_kmem_free(addr)
 
206
#define CONTIG_MALLOC(osdev, sz, memlimit, phaddr, handle)      oss_contig_malloc(osdev, sz, memlimit, phaddr)
 
207
#define CONTIG_FREE(osdev, p, sz, handle)       oss_contig_free(osdev, p, sz)
 
208
#endif
 
209
 
 
210
/*
 
211
 * Timer macros
 
212
 *
 
213
 * These macros are obsolete and should not be used in any new code.
 
214
 * Use the timeout mechanism (see the timeout(9F) Solaris man page).
 
215
 */
 
216
#define DEFINE_TIMER(name, proc)        static timeout_id_t name = 0
 
217
#define REMOVE_TIMER(name, proc)        {if (name != 0) oss_untimeout(name);}
 
218
#define INIT_TIMER(name,proc)
 
219
typedef void (*timeout_func_t) (void *);
 
220
#define ACTIVATE_TIMER(name, proc, time) \
 
221
        name=oss_timeout((timeout_func_t)proc, (void*)&name, time)
 
222
 
 
223
#endif
 
224
 
 
225
#define OSS_OS "Linux"
 
226
#define OSS_OS_LONGNAME "Linux"
 
227
 
 
228
#undef DMA_TRY_PSEUDOINIT
 
229
 
 
230
int get_dma_residue (int chn);
 
231
void disable_dma (int chn);
 
232
void enable_dma (int chn);
 
233
 
 
234
typedef void (*softintr_func_t) (int);
 
235
 
 
236
struct oss_softintr
 
237
{
 
238
  int id;
 
239
  softintr_func_t func;
 
240
  volatile int armed, running;
 
241
};
 
242
 
 
243
#define MUTEX_INIT(osdev, mutex, hier) mutex=oss_mutex_init()
 
244
#define MUTEX_CLEANUP(mutex) {oss_mutex_cleanup(mutex);mutex=NULL;}
 
245
#define MUTEX_ENTER_IRQDISABLE(mutex, flags) flags=0;oss_spin_lock_irqsave(mutex, &flags)
 
246
#define MUTEX_EXIT_IRQRESTORE(mutex, flags) oss_spin_unlock_irqrestore(mutex, flags);(flags)++
 
247
#define MUTEX_ENTER(mutex, flags) flags=0;oss_spin_lock(mutex)
 
248
#define MUTEX_EXIT(mutex, flags) oss_spin_unlock(mutex);(flags)++
 
249
 
 
250
extern int detect_trace;
 
251
#define DDB(x) if (detect_trace) x
 
252
 
 
253
#define MAP_PCI_IOADDR(osdev, nr, io) (oss_native_word)io
 
254
#define MAP_PCI_MEM(osdev, ix, phaddr, size)    oss_map_pci_mem(osdev, size, phaddr)
 
255
#define UNMAP_PCI_MEM(osdev, ix, ph, virt, size)        oss_unmap_pci_mem(virt)
 
256
#define UNMAP_PCI_IOADDR(osdev, ix)     {}
 
257
 
 
258
#define GET_PROCESS_PID(x)  oss_get_pid()
 
259
#define GET_PROCESS_UID(x)  oss_get_uid()
 
260
 
 
261
#define GET_PROCESS_NAME(x) oss_get_procname()
 
262
 
 
263
#define pci_read_config_irq oss_pci_read_config_irq
 
264
#define pci_read_config_byte oss_pci_read_config_byte
 
265
#define pci_read_config_word oss_pci_read_config_word
 
266
#define pci_read_config_dword oss_pci_read_config_dword
 
267
#define pci_write_config_byte oss_pci_write_config_byte
 
268
#define pci_write_config_word oss_pci_write_config_word
 
269
#define pci_write_config_dword oss_pci_write_config_dword
 
270
#define pci_enable_msi oss_pci_enable_msi
 
271
 
 
272
#define VM_READ         0x1
 
273
#define VM_WRITE        0x2
 
274
 
 
275
#define FP_SUPPORT
 
276
 
 
277
#ifdef FP_SUPPORT
 
278
typedef short fp_env_t[512];
 
279
typedef unsigned int fp_flags_t[4];
 
280
extern int oss_fp_check (void);
 
281
extern void oss_fp_save (short *envbuf, fp_flags_t flags);
 
282
extern void oss_fp_restore (short *envbuf, fp_flags_t flags);
 
283
#   define FP_SAVE(envbuf, flags)               oss_fp_save(envbuf, flags)
 
284
#   define FP_RESTORE(envbuf, flags)            oss_fp_restore(envbuf, flags)
 
285
#endif
 
286
 
 
287
#include "oss_pci.h"