1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
5 * Copyright 2009 VMware, Inc., Palo Alto, CA., USA
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
23 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
24 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26 * USE OR OTHER DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
31 * Thomas Hellström <thomas-at-tungstengraphics-dot-com>
34 #ifndef _WSBM_DRIVER_H
35 #define _WSBM_DRIVER_H
37 #include "wsbm_util.h"
39 #define WSBM_MUTEX_SPACE 16
40 #define WSBM_COND_SPACE 16
44 struct _WsbmThreadFuncs *func;
45 unsigned long storage[WSBM_MUTEX_SPACE];
50 struct _WsbmThreadFuncs *func;
51 unsigned long storage[WSBM_COND_SPACE];
54 struct _WsbmThreadFuncs
56 int (*mutexInit) (struct _WsbmMutex *, struct _WsbmThreadFuncs *);
57 void (*mutexFree) (struct _WsbmMutex *);
58 void (*mutexLock) (struct _WsbmMutex *);
59 void (*mutexUnlock) (struct _WsbmMutex *);
60 int (*condInit) (struct _WsbmCond *, struct _WsbmThreadFuncs *);
61 void (*condFree) (struct _WsbmCond *);
62 void (*condWait) (struct _WsbmCond *, struct _WsbmMutex *);
63 void (*condBroadcast) (struct _WsbmCond *);
66 extern struct _WsbmThreadFuncs *wsbmCurThreadFunc;
68 #define WSBM_MUTEX_INIT(_mutex) \
69 wsbmThreadFuncs()->mutexInit(_mutex,wsbmThreadFuncs())
70 #define WSBM_MUTEX_FREE(_mutex) \
72 (_mutex)->func->mutexFree(_mutex); \
74 #define WSBM_MUTEX_LOCK(_mutex) \
75 (_mutex)->func->mutexLock(_mutex);
76 #define WSBM_MUTEX_UNLOCK(_mutex) \
77 (_mutex)->func->mutexUnlock(_mutex);
79 #define WSBM_COND_INIT(_mutex) \
80 wsbmThreadFuncs()->condInit(_mutex, wsbmThreadFuncs())
81 #define WSBM_COND_FREE(_cond) \
83 (_cond)->func->condFree(_cond); \
85 #define WSBM_COND_WAIT(_cond, _mutex) \
86 (_cond)->func->condWait(_cond, _mutex);
87 #define WSBM_COND_BROADCAST(_cond) \
88 (_cond)->func->condBroadcast(_cond);
90 struct _WsbmVNodeFuncs
92 struct _ValidateNode *(*alloc) (struct _WsbmVNodeFuncs *, int);
93 void (*free) (struct _ValidateNode *);
94 void (*clear) (struct _ValidateNode *);
97 extern struct _WsbmVNodeFuncs *wsbmCurVNodeFunc;
99 struct _WsbmBufStorage;
100 struct _WsbmKernelBuf;
106 struct _WsbmListHead head;
107 struct _WsbmListHead hashHead;
112 struct _WsbmVNodeFuncs *func;
115 static inline struct _WsbmVNodeFuncs *
118 return wsbmCurVNodeFunc;
121 static inline struct _WsbmThreadFuncs *
122 wsbmThreadFuncs(void)
124 return wsbmCurThreadFunc;
127 extern struct _WsbmThreadFuncs *wsbmNullThreadFuncs(void);
129 extern struct _WsbmThreadFuncs *wsbmPThreadFuncs(void);