5
* Purpose: OS specific definitions for Linux
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.
16
* This file is part of Open Sound System.
18
* Copyright (C) 4Front Technologies 1996-2008.
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.
26
#define OS_VERSION "2.6.x"
28
#define OSS_MAINLINE_BUILD
31
* Debugging and misc settings
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
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.
48
#undef APPLIST_SUPPORT
49
#define USE_DEVICE_SUBDIRS
52
#define __invalid_size_argument_for_IOC 0 /* Dummy define to cure some broken ioctl.h versions */
54
#include <sys/types.h>
55
#include <sys/param.h>
56
#include <sys/signal.h>
57
#include <oss_errno.h>
61
#include <sys/fcntl.h>
63
#include "kernel/OS/Linux/wrapper/wrap.h"
69
/* The soundcard.h could be in a nonstandard place so include it here. */
70
#include "soundcard.h"
83
int num_audio_engines;
84
int num_audioplay, num_audiorec, num_audioduplex;
88
int first_mixer; /* This must be set to -1 by osdev_create() */
90
struct module *owner; /* Pointer to THISMODULE (needed by osscore.c) */
94
volatile int refcount; /* Nonzero means that the device is needed by some other (virtual) driver. */
98
ddi_iblock_cookie_t iblock_cookie; /* Dummy field under Linux */
100
int intrcount, ackcount;
102
/* PCI related fields */
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 */
111
#define ALLOW_BUFFER_MAPPING
115
#define SEL_EX 0xffffffff
117
/* Busy wait routine */
118
#define oss_udelay drv_usecwait
119
/* System wall timer access */
120
#define GET_JIFFIES() oss_get_jiffies()
122
extern inline unsigned int
123
__inb (unsigned short port)
126
__asm__ __volatile__ ("in" "b" " %" "w" "1,%" "b" "0":"=a" (_v):"d" (port),
130
extern inline unsigned int
131
__inw (unsigned short port)
134
__asm__ __volatile__ ("in" "w" " %" "w" "1,%" "w" "0":"=a" (_v):"d" (port),
138
extern inline unsigned int
139
__inl (unsigned short port)
142
__asm__ __volatile__ ("in" "l" " %" "w" "1,%" "" "0":"=a" (_v):"d" (port));
147
__outb (unsigned char value, unsigned short port)
149
__asm__ __volatile__ ("out" "b" " %" "b" "0,%" "w" "1"::"a" (value),
153
__outw (unsigned short value, unsigned short port)
155
__asm__ __volatile__ ("out" "w" " %" "w" "0,%" "w" "1"::"a" (value),
159
__outl (unsigned int value, unsigned short port)
161
__asm__ __volatile__ ("out" "l" " %" "0,%" "w" "1"::"a" (value),
165
#define INB(osdev,a) __inb(a)
166
#define INW(osdev,a) __inw(a)
167
#define INL(osdev,a) __inl(a)
169
#define OUTB(osdev, d, a) __outb(d, a)
171
#define OUTW(osdev, d, a) __outw(d, a)
172
#define OUTL(osdev, d, a) __outl(d, a)
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))
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).
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,
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)
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)
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).
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)
225
#define OSS_OS "Linux"
226
#define OSS_OS_LONGNAME "Linux"
228
#undef DMA_TRY_PSEUDOINIT
230
int get_dma_residue (int chn);
231
void disable_dma (int chn);
232
void enable_dma (int chn);
234
typedef void (*softintr_func_t) (int);
239
softintr_func_t func;
240
volatile int armed, running;
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)++
250
extern int detect_trace;
251
#define DDB(x) if (detect_trace) x
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) {}
258
#define GET_PROCESS_PID(x) oss_get_pid()
259
#define GET_PROCESS_UID(x) oss_get_uid()
261
#define GET_PROCESS_NAME(x) oss_get_procname()
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
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)