summaryrefslogtreecommitdiff
path: root/kernel/OS/VxWorks/os_vxworks.h
blob: 275aa34a6c0defaac7642f60f42374ee71cc6f5a (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#ifndef _OS_H_
#define _OS_H_

/*
 * Purpose: OS specific definitions for VxWorks
 *
 */
/*
 *
 * This file is part of Open Sound System.
 *
 * Copyright (C) 4Front Technologies 1996-2008.
 *
 * This this source file is released under GPL v2 license (no other versions).
 * See the COPYING file included in the main directory of this source
 * distribution for the license terms and conditions.
 *
 */

#define OS_VERSION "5.5"

#if (!defined(i386) && !defined(x86_64)) || defined(CONFIG_OSS_FIXDEPOINT)
// Floating point is not supported or it's disabled
#undef CONFIG_OSS_VMIX_FLOAT
#endif

#define VDEV_SUPPORT
#undef  USE_DEVICE_SUBDIRS

#define __inline__ inline
#define __inline inline
#define EXTERN_C extern "C"

/*
 * Disable support for per-application features such as /dev/dsp device
 * selection based on command name. Requires working GET_PROCESS_NAME
 * macro implementation.
 */
#undef  APPLIST_SUPPORT

#undef  ALLOW_BUFFER_MAPPING

/*
 * Some integer types
 */
#if defined(amd64) || defined(sparc)
typedef unsigned long long oss_native_word;	/* Same as the address and status register size */
#else
typedef unsigned long oss_native_word;	/* Same as the address and status register size */
#endif

typedef long long oss_int64_t;			/* Signed 64 bit integer */
typedef unsigned long long oss_uint64_t;	/* Unsigned 64 bit integer */

#include <stdarg.h>
#include <sys/types.h>
#include "vxWorks.h"
#include "iv.h"
#include "ioLib.h"
#include "fioLib.h"
#include "iosLib.h"
#include "wdLib.h"
#include "intLib.h"
#include "tickLib.h"
#include "errnoLib.h"
#include "sysLib.h"
#include "objLib.h"
#include "vmLib.h"
#include "semLib.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include <oss_errno.h>
/*
 * Mutexes
 */
typedef int oss_mutex_t;
#define MUTEX_INIT(osdev, mutex, hier)
#define MUTEX_CLEANUP(mutex)
#define MUTEX_ENTER_IRQDISABLE(mutex, flags)	{flags=0;mutex=0;}
#define MUTEX_ENTER(mutex, flags)	{flags=0;mutex=0;}
#define MUTEX_EXIT_IRQRESTORE(mutex, flags)	(flags)++
#define MUTEX_EXIT(mutex, flags)	(flags)++

/*
 * Fileinfo structure
 */
struct fileinfo
{
  int mode;			/* Open mode */
  int acc_flags;
};
#define ISSET_FILE_FLAG(fileinfo, flag)  (fileinfo->acc_flags & (flag) ? 1:0)

/*
 * Misc types
 */
typedef int oss_dma_handle_t;
typedef int oss_poll_event_t;
typedef int offset_t;

/*
 * uio_/uiomove()
 */
typedef enum uio_rw uio_rw_t;
typedef struct oss_uio
{
  char *ptr;
  int resid;
  int kernel_space;		/* Set if this uio points to a kernel space buffer */
  uio_rw_t rw;
} uio_t;
extern int oss_uiomove (void *address, size_t nbytes, enum uio_rw rwflag,
			uio_t * uio_p);
extern int oss_create_uio (uio_t * uiop, char *buf, size_t count, uio_rw_t rw,
			   int is_kernel);
#define uiomove oss_uiomove

/*
 * Error handling
 */
#define cmn_err oss_cmn_err
extern int detect_trace;
#define DDB(x) if (detect_trace) x
extern void oss_cmn_err (int level, const char *format, ...);
#define CE_CONT		0
#define CE_NOTE		1
#define CE_WARN		2
#define CE_PANIC	3

/* Busy wait routine */
extern void oss_udelay(unsigned long ticks);
/* System wall timer access */
#define GET_JIFFIES()	tickGet()
extern inline unsigned int
__inb (unsigned short port)
{
  unsigned int _v;
  __asm__ __volatile__ ("in" "b" " %" "w" "1,%" "b" "0":"=a" (_v):"d" (port),
			"0" (0));
  return _v;
}
extern inline unsigned int
__inw (unsigned short port)
{
  unsigned int _v;
  __asm__ __volatile__ ("in" "w" " %" "w" "1,%" "w" "0":"=a" (_v):"d" (port),
			"0" (0));
  return _v;
}
extern inline unsigned int
__inl (unsigned short port)
{
  unsigned int _v;
  __asm__ __volatile__ ("in" "l" " %" "w" "1,%" "" "0":"=a" (_v):"d" (port));
  return _v;
}

extern inline void
__outb (unsigned char value, unsigned short port)
{
  __asm__ __volatile__ ("out" "b" " %" "b" "0,%" "w" "1"::"a" (value),
			"d" (port));
}
extern inline void
__outw (unsigned short value, unsigned short port)
{
  __asm__ __volatile__ ("out" "w" " %" "w" "0,%" "w" "1"::"a" (value),
			"d" (port));
}
extern inline void
__outl (unsigned int value, unsigned short port)
{
  __asm__ __volatile__ ("out" "l" " %" "0,%" "w" "1"::"a" (value),
			"d" (port));
}

#define INB(osdev,a)	__inb(a)
#define INW(osdev,a)	__inw(a)
#define INL(osdev,a)	__inl(a)

#define OUTB(osdev, d, a) __outb(d, a)

#define OUTW(osdev, d, a)	__outw(d, a)
#define OUTL(osdev, d, a)	__outl(d, a)

#define PCI_READL(osdev, p)  (*(volatile unsigned int *) (p))
#define PCI_WRITEL(osdev, addr, data) (*(volatile unsigned int *) (addr) = (data))
#define PCI_READW(osdev, p)  (*(volatile unsigned short *) (p))
#define PCI_WRITEW(osdev, addr, data) (*(volatile unsigned short *) (addr) = (data))
#define PCI_READB(osdev, p)  (*(volatile unsigned char *) (p))
#define PCI_WRITEB(osdev, addr, data) (*(volatile unsigned char *) (addr) = (data))

#define MAP_PCI_IOADDR(osdev, nr, io) (oss_native_word)io
#define MAP_PCI_MEM(osdev, ix, phaddr, size) 	(oss_native_word)phaddr
#define UNMAP_PCI_MEM(osdev, ix, ph, virt, size)	{}
#define UNMAP_PCI_IOADDR(osdev, ix)	{}
/*
 * Memory allocation and mapping
 */
extern void *oss_contig_malloc (oss_device_t * osdev, int sz,
				oss_uint64_t memlimit,
				oss_native_word * phaddr);
extern void oss_contig_free (oss_device_t * osdev, void *p, int sz);
extern void oss_reserve_pages (oss_native_word start_addr,
			       oss_native_word end_addr);
extern void oss_unreserve_pages (oss_native_word start_addr,
				 oss_native_word end_addr);

#define KERNEL_MALLOC(nbytes)	malloc(nbytes)
#define KERNEL_FREE(addr)	free(addr)
#define CONTIG_MALLOC(osdev, sz, memlimit, phaddr, handle)	oss_contig_malloc(osdev, sz, memlimit, phaddr)
#define CONTIG_FREE(osdev, p, sz, handle)	oss_contig_free(osdev, p, sz)

typedef void dev_info_t;

struct _oss_device_t
{
  int cardnum;
  int dev_type;
  int available;
  int instance;
  dev_info_t *dip;
  void *devc;
  char *name;
  char nick[16];
  char handle[32];
  int num_audio_engines;
  int num_audioplay, num_audiorec, num_audioduplex;
  int num_mididevs;
  int num_mixerdevs;
  int num_loopdevs;
  int first_mixer;	/* This must be set to -1 by osdev_create() */
  int major;
  struct module *owner;		/* Pointer to THISMODULE (needed by osscore.c) */
  char modname[32];
  char *hw_info;

  volatile int refcount;	/* Nonzero means that the device is needed by some other (virtual) driver. */

/* Interrupts */

  int iblock_cookie;	/* Dummy field under Linux */
  void *irqparms;
  int intrcount, ackcount;
};

typedef struct
{
	int bus, dev, func;
} oss_pci_device_t;

typedef int timeout_id_t;
extern timeout_id_t oss_timeout (void (*func) (void *), void *arg,
				 unsigned long long ticks);
extern void oss_untimeout (timeout_id_t id);
#define timeout oss_timeout
#define untimeout oss_untimeout

extern int oss_hz;
#define HZ	oss_hz
#define OSS_HZ	HZ

/*
 * Dummy defines for poll()
 */
#define POLLIN		0
#define POLLOUT		0
#define POLLRDNORM	0
#define POLLWRNORM	0

/*
 * Process info macros
 */
#define GET_PROCESS_PID(x)  -1
#define GET_PROCESS_UID(x)  0
#define GET_PROCESS_NAME(x) NULL

/*
 * Floating point save/restore support for vmix
 */
#define FP_SUPPORT

#ifdef FP_SUPPORT
typedef short fp_env_t[512];
typedef unsigned int fp_flags_t[4];
extern int oss_fp_check (void);
extern void oss_fp_save (short *envbuf, fp_flags_t flags);
extern void oss_fp_restore (short *envbuf, fp_flags_t flags);
#undef FP_SAVE
#undef FP_RESTORE
#   define FP_SAVE(envbuf, flags)		oss_fp_save(envbuf, flags)
#   define FP_RESTORE(envbuf, flags)		oss_fp_restore(envbuf, flags)
#endif

#endif