2
* Purpose: Wrapper routines for Linux kernel services
4
* The functions and structures declared here are part of the osscore.c
5
* file that is compiled in the target system. This file must not be
6
* modified in the target system because the precompiled binaries included
7
* in the OSS installation package depend on it too.
11
* This file is part of Open Sound System.
13
* Copyright (C) 4Front Technologies 1996-2008.
15
* This this source file is released under GPL v2 license (no other versions).
16
* See the COPYING file included in the main directory of this source
17
* distribution for the license terms and conditions.
24
#if defined(__x86_64__)
25
typedef unsigned long long oss_native_word; /* Same as the address and status register size */
27
typedef unsigned long oss_native_word; /* Same as the address and status register size */
29
typedef long long oss_int64_t; /* Signed 64 bit integer */
30
typedef unsigned long long oss_uint64_t; /* Unsigned 64 bit integer */
32
extern char *oss_strcpy (char *s1, const char *s2);
33
extern void *oss_memcpy (void *t_, const void *f_, size_t l);
34
extern void *oss_memset (void *t, int val, size_t l);
35
extern int oss_strcmp (const char *s1, const char *s2);
36
extern size_t oss_strlen (const char *s);
37
extern char *oss_strncpy (char *s1, const char *s2, size_t l);
38
extern void oss_udelay (unsigned long d);
40
typedef struct _oss_mutex_t *oss_mutex_t;
41
typedef struct _poll_table_handle oss_poll_table_handle_t;
42
typedef struct _file_handle_t oss_file_handle_t;
44
struct _oss_poll_event_t
46
short events, revents;
47
oss_poll_table_handle_t *wait;
48
oss_file_handle_t *file;
50
typedef struct _oss_poll_event_t oss_poll_event_t;
52
extern oss_mutex_t oss_mutex_init (void);
53
extern void oss_mutex_cleanup (oss_mutex_t mutex);
54
extern void oss_spin_lock_irqsave (oss_mutex_t mutex,
55
oss_native_word * flags);
56
extern void oss_spin_unlock_irqrestore (oss_mutex_t mutex,
57
oss_native_word flags);
58
extern void oss_spin_lock (oss_mutex_t mutex);
59
extern void oss_spin_unlock (oss_mutex_t mutex);
60
extern unsigned long long oss_get_jiffies (void);
61
extern char *oss_get_procname (void);
62
extern int oss_get_pid (void);
63
extern int oss_get_uid (void);
65
struct oss_wait_queue;
70
typedef void *oss_dma_handle_t; /* Unused type */
73
* Sleep/wakeup/poll support. These definitions are duplicates from
74
* oss_config.h which is the official place. Both definitions must match.
77
extern struct oss_wait_queue *oss_create_wait_queue (oss_device_t * osdev,
79
extern void oss_reset_wait_queue (struct oss_wait_queue *wq);
80
extern void oss_remove_wait_queue (struct oss_wait_queue *wq);
81
extern int oss_sleep (struct oss_wait_queue *wq, oss_mutex_t * mutex,
82
int ticks, oss_native_word * flags,
83
unsigned int *status);
84
extern int oss_register_poll (struct oss_wait_queue *wq, oss_mutex_t * mutex,
85
oss_native_word * flags, oss_poll_event_t * ev);
86
extern void oss_wakeup (struct oss_wait_queue *wq, oss_mutex_t * mutex,
87
oss_native_word * flags, short events);
89
extern void oss_cmn_err (int level, const char *format, ...);
95
typedef int timeout_id_t;
96
extern timeout_id_t oss_timeout (void (*func) (void *), void *arg,
97
unsigned long long ticks);
98
extern void oss_untimeout (timeout_id_t id);
100
extern int sprintf (char *buf, const char *s, ...);
103
{ UIO_READ, UIO_WRITE } uio_rw_t;
108
int kernel_space; /* Set if this uio points to a kernel space buffer */
111
typedef struct uio uio_t;
113
extern int oss_uiomove (void *address, size_t nbytes, enum uio_rw rwflag,
115
extern int oss_create_uio (uio_t * uiop, char *buf, size_t count, uio_rw_t rw,
117
extern void *oss_kmem_alloc (size_t size);
118
extern void oss_kmem_free (void *addr);
119
extern void *oss_pmalloc (size_t sz);
120
extern oss_native_word oss_virt_to_bus (void *addr);
121
extern void oss_reserve_pages (oss_native_word start_addr,
122
oss_native_word end_addr);
123
extern void oss_unreserve_pages (oss_native_word start_addr,
124
oss_native_word end_addr);
125
extern void *oss_contig_malloc (oss_device_t * osdev, int sz,
126
oss_uint64_t memlimit,
127
oss_native_word * phaddr);
128
extern void oss_contig_free (oss_device_t * osdev, void *p, int sz);
130
extern time_t oss_get_time (void);
132
typedef struct _inode_handle_t oss_inode_handle_t;
133
typedef struct _vm_aread_handle oss_vm_area_handle_t;
135
extern int oss_vma_get_flags (oss_vm_area_handle_t *);
137
typedef struct oss_file_operation_handle
139
ssize_t (*read) (oss_file_handle_t *, char *, size_t, loff_t *);
140
ssize_t (*write) (oss_file_handle_t *, char *, size_t, loff_t *);
141
int (*readdir) (oss_inode_handle_t *, oss_file_handle_t *, void *, int);
142
unsigned int (*poll) (oss_file_handle_t *, oss_poll_table_handle_t *);
143
int (*ioctl) (oss_inode_handle_t *, oss_file_handle_t *, unsigned int,
145
int (*mmap) (oss_file_handle_t *, oss_vm_area_handle_t *);
146
int (*open) (oss_inode_handle_t *, oss_file_handle_t *);
147
int (*release) (oss_inode_handle_t *, oss_file_handle_t *);
148
long (*compat_ioctl) (oss_file_handle_t *, unsigned int, unsigned long);
149
long (*unlocked_ioctl) (oss_file_handle_t *, unsigned int, unsigned long);
150
int (*fsync) (oss_inode_handle_t *, oss_file_handle_t *);
151
int (*fasync) (oss_inode_handle_t *, oss_file_handle_t *, int);
153
oss_file_operation_handle_t;
155
extern int oss_do_mmap (oss_vm_area_handle_t * vma,
156
oss_native_word dmabuf_phys, int bytes_in_use);
157
extern int oss_register_chrdev (oss_device_t * osdev, unsigned int major,
159
oss_file_operation_handle_t * op);
160
extern void oss_register_minor (int major, int minor, char *name);
161
extern int oss_unregister_chrdev (unsigned int major, const char *name);
163
extern int oss_inode_get_minor (oss_inode_handle_t * inode);
164
extern int oss_file_get_flags (oss_file_handle_t * file);
165
extern void *oss_file_get_private (oss_file_handle_t * file);
166
extern void oss_file_set_private (oss_file_handle_t * file, void *v);
168
extern void oss_inc_refcounts (void);
169
extern void oss_dec_refcounts (void);
172
* Redefinitions of some routines defined in oss_config.h
173
* just to ensure they are defined in the same way in both places. The
174
* osscore/wrapper modules only include wrap.h so they can't see the "official"
175
* declarations in oss_config.h.
178
typedef struct _dev_info_t dev_info_t;
179
extern dev_info_t *oss_create_pcidip (struct pci_dev *pcidev);
180
extern oss_device_t *osdev_create (dev_info_t * dip, int dev_type,
181
int instance, const char *nick,
184
extern void osdev_delete (oss_device_t * osdev);
187
* PCI config space access (in osscore.c)
189
extern char *oss_pci_read_devpath (dev_info_t * dip);
190
extern int osscore_pci_read_config_byte (dev_info_t * dip, unsigned int where,
192
extern int osscore_pci_read_config_irq (dev_info_t * dip, unsigned int where,
194
extern int osscore_pci_read_config_word (dev_info_t * dip, unsigned int where,
195
unsigned short *val);
196
extern int osscore_pci_read_config_dword (dev_info_t * dip,
199
extern int osscore_pci_write_config_byte (dev_info_t * dip,
202
extern int osscore_pci_write_config_word (dev_info_t * dip,
205
extern int osscore_pci_write_config_dword (dev_info_t * dip,
209
extern int osscore_pci_enable_msi (dev_info_t * dip);
211
extern void *oss_map_pci_mem (oss_device_t * osdev, int size,
212
unsigned long offset);
214
extern void oss_unmap_pci_mem (void *addr);
216
extern int oss_copy_to_user (void *to, const void *from, unsigned long n);
217
extern int oss_copy_from_user (void *to, const void *from, unsigned long n);
219
extern void oss_register_module (struct module *mod);
220
extern void oss_unregister_module (struct module *mod);
223
extern char *oss_strcpy (char *s1, const char *s2);
225
#define strcpy oss_strcpy
227
extern void *oss_memcpy (void *t_, const void *f_, size_t l);
229
#define memcpy oss_memcpy
231
extern void *oss_memset (void *t, int val, size_t l);
233
#define memset oss_memset
235
extern int oss_strcmp (const char *s1, const char *s2);
237
#define strcmp oss_strcmp
238
extern int oss_strncmp (const char *s1, const char *s2, size_t len);
240
#define strncmp oss_strncmp
243
#define strlen oss_strlen
246
#define strncpy oss_strncpy
250
#define timeout oss_timeout
253
#define untimeout oss_untimeout
255
#define drv_usecwait oss_udelay
257
#define uiomove oss_uiomove
259
#define cmn_err oss_cmn_err
263
int mode; /* Open mode */
266
#define ISSET_FILE_FLAG(fileinfo, flag) (fileinfo->acc_flags & (flag) ? 1:0)
269
* USB related definitions
271
typedef struct udi_usb_devc udi_usb_devc;
274
* Functions exported by os.c
276
extern int oss_init_osscore (oss_device_t * osdev);
277
extern void oss_uninit_osscore (oss_device_t * osdev);
278
extern void osdev_set_owner (oss_device_t * osdev, struct module *owner);
279
extern void osdev_set_major (oss_device_t * osdev, int major);
280
extern void osdev_set_irqparms (oss_device_t * osdev, void *irqparms);
281
extern void *osdev_get_irqparms (oss_device_t * osdev);
282
extern void oss_inc_intrcount(oss_device_t *osdev, int claimed);
283
extern struct module *osdev_get_owner (oss_device_t * osdev);
284
extern char *osdev_get_nick (oss_device_t * osdev);
285
extern int osdev_get_instance (oss_device_t * osdev);
286
extern int oss_request_major (oss_device_t * osdev, int major, char *module);
287
extern int oss_register_device (oss_device_t * osdev, const char *name); /* from oss_config.h */