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
|
/**************************************************************************
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
* All Rights Reserved.
* Copyright 2009 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
/*
* Authors:
* Thomas Hellström <thomas-at-tungstengraphics-dot-com>
*/
#ifndef _WSBM_DRIVER_H
#define _WSBM_DRIVER_H
#include <stdint.h>
#include "wsbm_util.h"
#define WSBM_MUTEX_SPACE 16
#define WSBM_COND_SPACE 16
struct _WsbmMutex
{
struct _WsbmThreadFuncs *func;
unsigned long storage[WSBM_MUTEX_SPACE];
};
struct _WsbmCond
{
struct _WsbmThreadFuncs *func;
unsigned long storage[WSBM_COND_SPACE];
};
struct _WsbmThreadFuncs
{
int (*mutexInit) (struct _WsbmMutex *, struct _WsbmThreadFuncs *);
void (*mutexFree) (struct _WsbmMutex *);
void (*mutexLock) (struct _WsbmMutex *);
void (*mutexUnlock) (struct _WsbmMutex *);
int (*condInit) (struct _WsbmCond *, struct _WsbmThreadFuncs *);
void (*condFree) (struct _WsbmCond *);
void (*condWait) (struct _WsbmCond *, struct _WsbmMutex *);
void (*condBroadcast) (struct _WsbmCond *);
};
extern struct _WsbmThreadFuncs *wsbmCurThreadFunc;
#define WSBM_MUTEX_INIT(_mutex) \
wsbmThreadFuncs()->mutexInit(_mutex,wsbmThreadFuncs())
#define WSBM_MUTEX_FREE(_mutex) \
{ \
(_mutex)->func->mutexFree(_mutex); \
}
#define WSBM_MUTEX_LOCK(_mutex) \
(_mutex)->func->mutexLock(_mutex);
#define WSBM_MUTEX_UNLOCK(_mutex) \
(_mutex)->func->mutexUnlock(_mutex);
#define WSBM_COND_INIT(_mutex) \
wsbmThreadFuncs()->condInit(_mutex, wsbmThreadFuncs())
#define WSBM_COND_FREE(_cond) \
{ \
(_cond)->func->condFree(_cond); \
}
#define WSBM_COND_WAIT(_cond, _mutex) \
(_cond)->func->condWait(_cond, _mutex);
#define WSBM_COND_BROADCAST(_cond) \
(_cond)->func->condBroadcast(_cond);
struct _WsbmVNodeFuncs
{
struct _ValidateNode *(*alloc) (struct _WsbmVNodeFuncs *, int);
void (*free) (struct _ValidateNode *);
void (*clear) (struct _ValidateNode *);
};
extern struct _WsbmVNodeFuncs *wsbmCurVNodeFunc;
struct _WsbmBufStorage;
struct _WsbmKernelBuf;
struct _ValidateNode
{
uint32_t hash;
int type_id;
struct _WsbmListHead head;
struct _WsbmListHead hashHead;
int listItem;
uint64_t set_flags;
uint64_t clr_flags;
void *buf;
struct _WsbmVNodeFuncs *func;
};
static inline struct _WsbmVNodeFuncs *
wsbmVNodeFuncs(void)
{
return wsbmCurVNodeFunc;
}
static inline struct _WsbmThreadFuncs *
wsbmThreadFuncs(void)
{
return wsbmCurThreadFunc;
}
extern struct _WsbmThreadFuncs *wsbmNullThreadFuncs(void);
extern struct _WsbmThreadFuncs *wsbmPThreadFuncs(void);
#endif
|